1 /********************************************************************************
2 *                                                                               *
3 *                           T a b  B a r   W i d g e t                          *
4 *                                                                               *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or                 *
9 * modify it under the terms of the GNU Lesser General Public                    *
10 * License as published by the Free Software Foundation; either                  *
11 * version 2.1 of the License, or (at your option) any later version.            *
12 *                                                                               *
13 * This library is distributed in the hope that it will be useful,               *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
16 * Lesser General Public License for more details.                               *
17 *                                                                               *
18 * You should have received a copy of the GNU Lesser General Public              *
19 * License along with this library; if not, write to the Free Software           *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
21 *********************************************************************************
22 * $Id: FXTabBar.h,v 1.15 2006/01/22 17:58:10 fox Exp $                          *
23 ********************************************************************************/
24 #ifndef FXTABBAR_H
25 #define FXTABBAR_H
26 
27 #ifndef FXPACKER_H
28 #include "FXPacker.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Tab Book options
35 enum {
36   TABBOOK_TOPTABS    = 0,                                   /// Tabs on top (default)
37   TABBOOK_BOTTOMTABS = 0x00020000,                          /// Tabs on bottom
38   TABBOOK_SIDEWAYS   = 0x00040000,                          /// Tabs on left
39   TABBOOK_LEFTTABS   = TABBOOK_SIDEWAYS|TABBOOK_TOPTABS,    /// Tabs on left
40   TABBOOK_RIGHTTABS  = TABBOOK_SIDEWAYS|TABBOOK_BOTTOMTABS, /// Tabs on right
41   TABBOOK_NORMAL     = TABBOOK_TOPTABS                      /// Normal tabs
42   };
43 
44 
45 
46 /**
47 * The tab bar layout manager arranges tab items side by side,
48 * and raises the active tab item above the neighboring tab items.
49 * In a the horizontal arrangement, the tab bar can have the tab
50 * items on the top or on the bottom.  In the vertical arrangement,
51 * the tabs can be on the left or on the right.
52 * When one of the tab items is pressed, the tab bar's setCurrent()
53 * is called with notify=TRUE.  Thus causes the tab bar to send a
54 * SEL_COMMAND message to its target.
55 */
56 class FXAPI FXTabBar : public FXPacker {
57   FXDECLARE(FXTabBar)
58 protected:
59   FXint current;        // Current tab index
60   FXint shift;          // Shift amount
61 protected:
FXTabBar()62   FXTabBar(){}
63 private:
64   FXTabBar(const FXTabBar&);
65   FXTabBar& operator=(const FXTabBar&);
66 public:
67   long onPaint(FXObject*,FXSelector,void*);
68   long onFocusNext(FXObject*,FXSelector,void*);
69   long onFocusPrev(FXObject*,FXSelector,void*);
70   long onFocusUp(FXObject*,FXSelector,void*);
71   long onFocusDown(FXObject*,FXSelector,void*);
72   long onFocusLeft(FXObject*,FXSelector,void*);
73   long onFocusRight(FXObject*,FXSelector,void*);
74   long onCmdOpenItem(FXObject*,FXSelector,void*);
75   long onCmdSetValue(FXObject*,FXSelector,void*);
76   long onCmdSetIntValue(FXObject*,FXSelector,void*);
77   long onCmdGetIntValue(FXObject*,FXSelector,void*);
78   long onCmdOpen(FXObject*,FXSelector,void*);
79   long onUpdOpen(FXObject*,FXSelector,void*);
80 public:
81   enum {
82     ID_OPEN_ITEM=FXPacker::ID_LAST,   /// Sent from one of the FXTabItems
83     ID_OPEN_FIRST,                    /// Switch to panel ID_OPEN_FIRST+i
84     ID_OPEN_SECOND,
85     ID_OPEN_THIRD,
86     ID_OPEN_FOURTH,
87     ID_OPEN_FIFTH,
88     ID_OPEN_SIXTH,
89     ID_OPEN_SEVENTH,
90     ID_OPEN_EIGHTH,
91     ID_OPEN_NINETH,
92     ID_OPEN_TENTH,
93     ID_OPEN_LAST=ID_OPEN_FIRST+100,
94     ID_LAST
95     };
96 public:
97 
98   /// Construct a tab bar
99   FXTabBar(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=TABBOOK_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_SPACING,FXint pr=DEFAULT_SPACING,FXint pt=DEFAULT_SPACING,FXint pb=DEFAULT_SPACING);
100 
101   /// Return default width
102   virtual FXint getDefaultWidth();
103 
104   /// Return default height
105   virtual FXint getDefaultHeight();
106 
107   /// Perform layout
108   virtual void layout();
109 
110   /**
111   * Change currently active tab item; this raises the active tab item
112   * slightly above the neighboring tab items.  If notify=TRUE then the
113   * tab bar will also send a SEL_COMMAND message to its target.
114   */
115   virtual void setCurrent(FXint panel,FXbool notify=FALSE);
116 
117   /// Return the currently active tab item
getCurrent()118   FXint getCurrent() const { return current; }
119 
120   /// Return tab bar style
121   FXuint getTabStyle() const;
122 
123   /// Change tab tab style
124   void setTabStyle(FXuint style);
125 
126   /// Save to stream
127   virtual void save(FXStream& store) const;
128 
129   /// Load from stream
130   virtual void load(FXStream& store);
131   };
132 
133 }
134 
135 #endif
136