1 /*
2   FXiTe - The Free eXtensIble Text Editor
3   Copyright (c) 2009-2011 Jeffrey Pohlmeyer <yetanothergeek@gmail.com>
4 
5   This program is free software; you can redistribute it and/or modify it
6   under the terms of the GNU General Public License version 3 as
7   published by the Free Software Foundation.
8 
9   This software is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18 
19 
20 #include "shady_tabs.h"
21 
22 typedef enum {
23   DOCTAB_CLEAN,
24   DOCTAB_DIRTY,
25   DOCTAB_LOCKED,
26   DOCTAB_SAME,
27 } DocTabState;
28 
29 class DocTab: public FXTabItem {
30   private:
FXDECLARE(DocTab)31     FXDECLARE(DocTab)
32     DocTab(){}
33     bool dnd_accept;
34     FXCursor*defaultDragCursor;
35     DocTabState _state;
36   public:
37     long onDnd(FXObject* sender,FXSelector sel, void*p);
38     DocTab(FXTabBar*bar, const FXString&text);
setDefaultDragCursor(FXCursor * ddc)39     void setDefaultDragCursor(FXCursor*ddc) { defaultDragCursor=ddc; setDragCursor(ddc); }
40     void SetIcon(DocTabState state);
41     enum {
42       ID_DND=FXTabItem::ID_LAST,
43       ID_LAST
44     };
45 };
46 
47 
48 
49 typedef bool (*TabCallback) (FXint index, DocTab*tab, FXWindow*page, void*user_data);
50 
51 
52 class DocTabs: public ShadyTabs {
53   FXDECLARE(DocTabs);
54 private:
55   enum {MOVEUP,MOVEDOWN,MOVETOFIRST,MOVETOLAST};
56   FXMenuPane*tab_popup;
57 
DocTabs()58   DocTabs(){}
59   void MoveTab(FXint how);
60   FXint tab_width_max;
61   FXuchar tabs_compact;
62   bool dnd_accept;
63   static bool UpdateTabWidths(FXint index, DocTab*tab, FXWindow*page, void*user_data);
64 public:
65   long onTabPopupMenu ( FXObject* sender, FXSelector sel, void* p );
66   long onPopupClick   ( FXObject* sender, FXSelector sel, void* p );
67   DocTabs(FXComposite*p,FXObject*trg,FXSelector sel,FXuint opts);
68   ~DocTabs();
69 
70 #ifdef WIN32
71   virtual void create();
72 #else
73   long onDnd(FXObject* sender,FXSelector sel, void*p);
74 #endif
75   DocTab*NewTab(FXString text);
76   DocTab*ActiveTab();
77   FXWindow*ActivePage();
78   FXWindow*ActiveView();
79   FXWindow*PageAt(FXint n);
80 
81   virtual void setCurrent(FXint panel,FXbool notify=false);
82   virtual void show();
83 
84   bool ActivateTab(DocTab*tab);
85   bool ActivateTab(FXint n);
86 
MoveTabUp()87   void MoveTabUp()    { MoveTab(MOVEUP); }
MoveTabDown()88   void MoveTabDown()  { MoveTab(MOVEDOWN); }
MoveTabFirst()89   void MoveTabFirst() { MoveTab(MOVETOFIRST); }
MoveTabLast()90   void MoveTabLast()  { MoveTab(MOVETOLAST); }
91 
92   void setTabStyle(FXuint style);
93   void setTabStyleByChar(FXuchar c);
94   void setTabsCompact(FXuchar compact);
getTabsCompact()95   FXuchar getTabsCompact() { return tabs_compact; }
96   void FocusNextTab(bool forward);
97   void ForEachTab(TabCallback cb, void *user_data, bool hourglass=true);
98 
Count()99   FXint Count() { return numChildren()/2; }
MaxTabWidth()100   FXint MaxTabWidth() { return tab_width_max; }
101   void MaxTabWidth(FXint w);
102   enum {
103     ID_TAB_POPUP_MENU=FXTabBook::ID_LAST,
104     ID_POPUP_CLICK,
105     ID_LAST
106   };
107 };
108 
109