diff options
Diffstat (limited to 'src/Tab.hh')
-rw-r--r-- | src/Tab.hh | 98 |
1 files changed, 62 insertions, 36 deletions
@@ -1,5 +1,5 @@ | |||
1 | // Tab.hh for Fluxbox | 1 | // Tab.hh for Fluxbox Window Manager |
2 | // Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) | 2 | // Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) |
3 | // | 3 | // |
4 | // Permission is hereby granted, free of charge, to any person obtaining a | 4 | // Permission is hereby granted, free of charge, to any person obtaining a |
5 | // copy of this software and associated documentation files (the "Software"), | 5 | // copy of this software and associated documentation files (the "Software"), |
@@ -19,67 +19,88 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | #ifndef _TAB_HH_ | 22 | // $Id: Tab.hh,v 1.15 2002/08/11 20:57:13 fluxgen Exp $ |
23 | #define _TAB_HH_ | 23 | |
24 | #ifndef TAB_HH | ||
25 | #define TAB_HH | ||
24 | 26 | ||
25 | #ifndef _IMAGE_HH_ | ||
26 | #include "Image.hh" | 27 | #include "Image.hh" |
27 | #endif | ||
28 | #ifndef _SCREEN_HH_ | ||
29 | #include "Screen.hh" | ||
30 | #endif | ||
31 | #ifndef _WINDOW_HH_ | ||
32 | #include "Window.hh" | 28 | #include "Window.hh" |
33 | #endif | 29 | |
34 | 30 | ||
35 | //Note: Tab is a friend of FluxboxWindow | 31 | //Note: Tab is a friend of FluxboxWindow |
36 | 32 | ||
37 | 33 | ||
38 | class Tab { | 34 | class Tab { |
39 | public: | 35 | public: |
36 | enum Placement{ PTOP = 0, PBOTTOM = 5, PLEFT = 10, PRIGHT = 15, PNONE = 20}; | ||
37 | enum Alignment{ ALEFT = 0, ACENTER, ARIGHT, ARELATIVE, ANONE }; | ||
38 | |||
40 | Tab(FluxboxWindow *win, Tab *prev=0, Tab *next=0); | 39 | Tab(FluxboxWindow *win, Tab *prev=0, Tab *next=0); |
41 | ~Tab(); | 40 | ~Tab(); |
42 | void draw(bool pressed); | 41 | |
43 | inline Tab *next() const { return m_next; } | 42 | void setConfigured(bool value) { m_configured = value; } |
44 | inline Tab *prev() const { return m_prev; } | 43 | Tab *next() { return m_next; } |
45 | inline FluxboxWindow *getWindow() const { return m_win; } | 44 | Tab *prev() { return m_prev; } |
46 | inline unsigned int getTabWidth() const { return m_size_w; } | 45 | Tab *last() { return getLast(this); } |
47 | inline unsigned int getTabHeight() const { return m_size_h; } | 46 | Tab *first() { return getFirst(this); } |
47 | FluxboxWindow *getWindow() { return m_win; } | ||
48 | |||
48 | void focus(); | 49 | void focus(); |
49 | void decorate(); | 50 | void decorate(); |
50 | void deiconify(); | 51 | void deiconify(); |
51 | void iconify(); | 52 | void iconify(); |
52 | void raise(); | 53 | void raise(); |
54 | void lower(); | ||
53 | void withdraw(); | 55 | void withdraw(); |
54 | void stick(); | 56 | void stick(); |
55 | void resize(); | 57 | void resize(); |
56 | void shade(); | 58 | void shade(); |
57 | //position tab to follow (FluxboxWindow *) m_win | 59 | void setPosition(); //position tab to follow (FluxboxWindow *) m_win |
58 | void setPosition(); | 60 | void moveNext(); |
61 | void movePrev(); | ||
62 | void insert(Tab *next); | ||
63 | |||
59 | //event handlers | 64 | //event handlers |
60 | void buttonReleaseEvent(XButtonEvent *be); | 65 | void buttonReleaseEvent(XButtonEvent *be); |
61 | void buttonPressEvent(XButtonEvent *be); | 66 | void buttonPressEvent(XButtonEvent *be); |
62 | void exposeEvent(XExposeEvent *ee); | 67 | void exposeEvent(XExposeEvent *ee); |
63 | void motionNotifyEvent(XMotionEvent *me); | 68 | void motionNotifyEvent(XMotionEvent *me); |
64 | static Tab *getFirst(Tab *current); | 69 | |
65 | void disconnect(); | 70 | void disconnect(); |
66 | 71 | ||
67 | enum { PTop = 0, PBottom = 5, PLeft = 10, PRight = 15, pnone = 20}; | 72 | //accessors |
68 | enum { ALeft = 0, ACenter, ARight, ARelative, anone }; | 73 | |
69 | 74 | static const char *getTabPlacementString(Tab::Placement placement); | |
70 | static const char *getTabPlacementString(int placement); | 75 | static Tab::Placement getTabPlacementNum(const char *string); |
71 | static int getTabPlacementNum(const char *string); | 76 | static const char *getTabAlignmentString(Tab::Alignment alignment); |
72 | static const char *getTabAlignmentString(int placement); | 77 | static Tab::Alignment getTabAlignmentNum(const char *string); |
73 | static int getTabAlignmentNum(const char *string); | 78 | |
74 | //TODO: do these have to be public? | 79 | const Tab *next() const { return m_next; } |
75 | void resizeGroup(void); // used when (un)shading windows | 80 | const Tab *prev() const { return m_prev; } |
76 | void calcIncrease(void); | 81 | const Tab *last() const { return getLast(const_cast<Tab *>(this)); } |
77 | inline bool configured() { return m_configured; } | 82 | const Tab *first() const { return getFirst(const_cast<Tab *>(this)); } |
78 | inline void setConfigured(bool value) { m_configured = value; } | 83 | |
84 | const FluxboxWindow *getWindow() const { return m_win; } | ||
85 | Window getTabWindow() const { return m_tabwin; } | ||
86 | unsigned int getTabWidth() const { return m_size_w; } | ||
87 | unsigned int getTabHeight() const { return m_size_h; } | ||
88 | |||
89 | void resizeGroup(); // used when (un)shading windows | ||
90 | void calcIncrease(); | ||
91 | bool configured() const { return m_configured; } | ||
92 | void draw(bool pressed) const; | ||
93 | |||
94 | bool addWindowToGroup(FluxboxWindow *window); | ||
95 | |||
96 | static Tab *getFirst(Tab *current); | ||
97 | static Tab *getLast(Tab *current); | ||
98 | |||
79 | private: | 99 | private: |
100 | |||
80 | bool m_configured; | 101 | bool m_configured; |
81 | 102 | ||
82 | void insert(Tab *next); | 103 | |
83 | //The size of the tab | 104 | //The size of the tab |
84 | unsigned int m_size_w; | 105 | unsigned int m_size_w; |
85 | unsigned int m_size_h; | 106 | unsigned int m_size_h; |
@@ -89,8 +110,13 @@ private: | |||
89 | static const int m_max_tabs; | 110 | static const int m_max_tabs; |
90 | bool m_focus, m_moving; // moving and focus | 111 | bool m_focus, m_moving; // moving and focus |
91 | void createTabWindow(); // creates the X win of tab | 112 | void createTabWindow(); // creates the X win of tab |
113 | void loadTheme(); // loads the textures with right width and height | ||
114 | int setPositionShadingHelper(bool shaded); | ||
115 | int setPositionTBAlignHelper(Alignment align); | ||
116 | int setPositionLRAlignHelper(Alignment align); | ||
92 | void setTabWidth(unsigned int w); | 117 | void setTabWidth(unsigned int w); |
93 | void setTabHeight(unsigned int h); | 118 | void setTabHeight(unsigned int h); |
119 | unsigned int numObjects(); | ||
94 | unsigned int calcRelativeWidth(); | 120 | unsigned int calcRelativeWidth(); |
95 | unsigned int calcRelativeHeight(); | 121 | unsigned int calcRelativeHeight(); |
96 | unsigned int calcCenterXPos(); | 122 | unsigned int calcCenterXPos(); |
@@ -112,7 +138,7 @@ private: | |||
112 | return (tp==p); | 138 | return (tp==p); |
113 | } | 139 | } |
114 | inline bool operator == (const char *str) { | 140 | inline bool operator == (const char *str) { |
115 | if (strcasecmp(string, str)==0) | 141 | if (strcasecmp(string, str) == 0) |
116 | return true; | 142 | return true; |
117 | return false; | 143 | return false; |
118 | } | 144 | } |
@@ -122,4 +148,4 @@ private: | |||
122 | 148 | ||
123 | }; | 149 | }; |
124 | 150 | ||
125 | #endif //_TAB_HH_ | 151 | #endif //TAB_HH |