diff options
author | fluxgen <fluxgen> | 2003-01-05 22:14:10 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-01-05 22:14:10 (GMT) |
commit | 4484d326807c6e1cf4ec6b6beeb099eab979723e (patch) | |
tree | 1fd6409e60fab3c9b80b3720445af27f020d8107 /src/FbWinFrame.hh | |
parent | e3071d20356ddafea8cf7047bd0556fc4b74ba47 (diff) | |
download | fluxbox_pavel-4484d326807c6e1cf4ec6b6beeb099eab979723e.zip fluxbox_pavel-4484d326807c6e1cf4ec6b6beeb099eab979723e.tar.bz2 |
frame handling
Diffstat (limited to 'src/FbWinFrame.hh')
-rw-r--r-- | src/FbWinFrame.hh | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh new file mode 100644 index 0000000..c74b73c --- /dev/null +++ b/src/FbWinFrame.hh | |||
@@ -0,0 +1,221 @@ | |||
1 | // FbWinFrame.hh for Fluxbox Window Manager | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | // $Id: FbWinFrame.hh,v 1.1 2003/01/05 22:14:10 fluxgen Exp $ | ||
23 | |||
24 | #ifndef FBWINFRAME_HH | ||
25 | #define FBWINFRAME_HH | ||
26 | |||
27 | #include "FbWindow.hh" | ||
28 | #include "Button.hh" | ||
29 | #include "EventHandler.hh" | ||
30 | #include "Font.hh" | ||
31 | #include "Text.hh" | ||
32 | #include "FbWinFrameTheme.hh" | ||
33 | |||
34 | #include <vector> | ||
35 | #include <string> | ||
36 | |||
37 | class FbWinFrameTheme; | ||
38 | class BImageControl; | ||
39 | |||
40 | /// holds a window frame with a client window | ||
41 | class FbWinFrame:public FbTk::EventHandler { | ||
42 | public: | ||
43 | |||
44 | /// create a top level window | ||
45 | FbWinFrame(FbWinFrameTheme &theme, BImageControl &imgctrl, int screen_num, int x, int y, | ||
46 | unsigned int width, unsigned int height); | ||
47 | |||
48 | /// create a frame window inside another FbWindow, NOT IMPLEMENTED! | ||
49 | FbWinFrame(FbWinFrameTheme &theme, BImageControl &imgctrl, const FbTk::FbWindow &parent, | ||
50 | int x, int y, | ||
51 | unsigned int width, unsigned int height); | ||
52 | |||
53 | /// destroy frame | ||
54 | ~FbWinFrame(); | ||
55 | |||
56 | void hide(); | ||
57 | void show(); | ||
58 | /// shade frame (ie resize to titlebar size) | ||
59 | void shade(); | ||
60 | void move(int x, int y); | ||
61 | void resize(unsigned int width, unsigned int height); | ||
62 | /// resize client to specified size and resize frame to it | ||
63 | void resizeForClient(unsigned int width, unsigned int height); | ||
64 | void moveResize(int x, int y, unsigned int width, unsigned int height); | ||
65 | /// sets title on the titlebar label | ||
66 | void setTitle(const std::string &title); | ||
67 | /// set focus/unfocus style | ||
68 | void setFocus(bool newvalue); | ||
69 | void setBevel(int bevel); | ||
70 | /// add a button to the left of the label | ||
71 | void addLeftButton(FbTk::Button *btn); | ||
72 | /// add a button to the right of the label | ||
73 | void addRightButton(FbTk::Button *btn); | ||
74 | /// remove all buttons from titlebar | ||
75 | void removeAllButtons(); | ||
76 | /// attach a client window for client area | ||
77 | void setClientWindow(Window win); | ||
78 | /// same as above but with FbWindow, NOT IMPLEMENTED! | ||
79 | void setClientWindow(FbTk::FbWindow win); | ||
80 | /// remove attached client window | ||
81 | void removeClient(); | ||
82 | /// redirect events to another eventhandler | ||
83 | void setEventHandler(FbTk::EventHandler &evh); | ||
84 | /// remove any handler for the windows | ||
85 | void removeEventHandler(); | ||
86 | |||
87 | void hideTitlebar(); | ||
88 | void showTitlebar(); | ||
89 | void hideHandle(); | ||
90 | void showHandle(); | ||
91 | |||
92 | /** | ||
93 | @name Event handlers | ||
94 | */ | ||
95 | //@{ | ||
96 | void buttonPressEvent(XButtonEvent &event); | ||
97 | void exposeEvent(XExposeEvent &event); | ||
98 | void configureNotifyEvent(XConfigureEvent &event); | ||
99 | void handleEvent(XEvent &event); | ||
100 | //@} | ||
101 | |||
102 | void reconfigure(); | ||
103 | |||
104 | /** | ||
105 | @name accessors | ||
106 | */ | ||
107 | //@{ | ||
108 | inline int x() const { return m_window.x(); } | ||
109 | inline int y() const { return m_window.y(); } | ||
110 | inline unsigned int width() const { return m_window.width(); } | ||
111 | inline unsigned int height() const { return m_window.height(); } | ||
112 | inline const FbTk::FbWindow &window() const { return m_window; } | ||
113 | inline FbTk::FbWindow &window() { return m_window; } | ||
114 | /// @return titlebar window | ||
115 | inline const FbTk::FbWindow &titlebar() const { return m_titlebar; } | ||
116 | inline FbTk::FbWindow &titlebar() { return m_titlebar; } | ||
117 | inline const FbTk::FbWindow &label() const { return m_label; } | ||
118 | inline FbTk::FbWindow &label() { return m_label; } | ||
119 | /// @return clientarea window | ||
120 | inline const FbTk::FbWindow &clientArea() const { return m_clientarea; } | ||
121 | inline FbTk::FbWindow &clientArea() { return m_clientarea; } | ||
122 | /// @return handle window | ||
123 | inline const FbTk::FbWindow &handle() const { return m_handle; } | ||
124 | inline FbTk::FbWindow &handle() { return m_handle; } | ||
125 | inline const FbTk::FbWindow &gripLeft() const { return m_grip_left; } | ||
126 | inline FbTk::FbWindow &gripLeft() { return m_grip_left; } | ||
127 | inline const FbTk::FbWindow &gripRight() const { return m_grip_right; } | ||
128 | inline FbTk::FbWindow &gripRight() { return m_grip_right; } | ||
129 | inline bool focused() const { return m_focused; } | ||
130 | inline bool isShaded() const { return m_shaded; } | ||
131 | unsigned int titleHeight() const; | ||
132 | unsigned int buttonHeight() const; | ||
133 | |||
134 | //@} | ||
135 | |||
136 | private: | ||
137 | void redrawTitle(); | ||
138 | void redrawTitlebar(); | ||
139 | /// reposition titlebar items | ||
140 | void reconfigureTitlebar(); | ||
141 | /** | ||
142 | @name render helper functions | ||
143 | */ | ||
144 | //@{ | ||
145 | void renderTitlebar(); | ||
146 | void renderHandles(); | ||
147 | void renderButtons(); | ||
148 | void renderLabel(); | ||
149 | /// renders to pixmap or sets color | ||
150 | void render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm, | ||
151 | unsigned int width, unsigned int height); | ||
152 | //@} | ||
153 | |||
154 | /// initiate some commont variables | ||
155 | void init(); | ||
156 | /// initiate inserted buttons for current theme | ||
157 | void setupButton(FbTk::Button &btn); | ||
158 | |||
159 | FbWinFrameTheme &m_theme; ///< theme to be used | ||
160 | BImageControl &m_imagectrl; ///< Image control for rendering | ||
161 | /** | ||
162 | @name windows | ||
163 | */ | ||
164 | //@{ | ||
165 | FbTk::FbWindow m_window; ///< base window that holds each decorations (ie titlebar, handles) | ||
166 | FbTk::FbWindow m_titlebar; ///< titlebar window | ||
167 | FbTk::FbWindow m_label; ///< holds title | ||
168 | FbTk::FbWindow m_grip_right, ///< rightgrip | ||
169 | m_grip_left; ///< left grip | ||
170 | FbTk::FbWindow m_handle; ///< handle between grips | ||
171 | FbTk::FbWindow m_clientarea; ///< window that holds client window @see setClientWindow | ||
172 | Window m_clientwin; ///< client window in clientarea | ||
173 | //@} | ||
174 | typedef std::vector<FbTk::Button *> ButtonList; | ||
175 | ButtonList m_buttons_left, ///< buttons to the left | ||
176 | m_buttons_right; ///< buttons to the right | ||
177 | |||
178 | std::string m_titletext; ///< text to be displayed int m_label | ||
179 | int m_bevel; ///< bevel between titlebar items and titlebar | ||
180 | bool m_use_titlebar; ///< if we should use titlebar | ||
181 | bool m_use_handles; ///< if we should use handles | ||
182 | bool m_focused; ///< focused/unfocused mode | ||
183 | /** | ||
184 | @name pixmaps and colors for rendering | ||
185 | */ | ||
186 | //@{ | ||
187 | Pixmap m_title_focused_pm; ///< pixmap for focused title | ||
188 | FbTk::Color m_title_focused_color; ///< color for focused title | ||
189 | Pixmap m_title_unfocused_pm; ///< pixmap for unfocused title | ||
190 | FbTk::Color m_title_unfocused_color; ///< color for unfocued title | ||
191 | |||
192 | Pixmap m_label_focused_pm; ///< pixmap for focused label | ||
193 | FbTk::Color m_label_focused_color; ///< color for focused label | ||
194 | Pixmap m_label_unfocused_pm; ///< pixmap for unfocused label | ||
195 | FbTk::Color m_label_unfocused_color; ///< color for unfocued label | ||
196 | |||
197 | FbTk::Color m_handle_focused_color, m_handle_unfocused_color; | ||
198 | Pixmap m_handle_focused_pm, m_handle_unfocused_pm; | ||
199 | |||
200 | |||
201 | Pixmap m_button_pm; ///< normal button | ||
202 | FbTk::Color m_button_color; ///< normal color button | ||
203 | Pixmap m_button_unfocused_pm; ///< unfocused button | ||
204 | FbTk::Color m_button_unfocused_color; ///< unfocused color button | ||
205 | Pixmap m_button_pressed_pm; ///< pressed button | ||
206 | FbTk::Color m_button_pressed_color; ///< pressed button color | ||
207 | |||
208 | Pixmap m_grip_focused_pm; | ||
209 | FbTk::Color m_grip_focused_color; ///< if no pixmap is given for grip, use this color | ||
210 | Pixmap m_grip_unfocused_pm; ///< unfocused pixmap for grip | ||
211 | FbTk::Color m_grip_unfocused_color; ///< unfocused color for grip if no pixmap is given | ||
212 | //@} | ||
213 | |||
214 | int m_button_size; ///< size for all titlebar buttons | ||
215 | unsigned int m_width_before_shade, ///< width before shade, so we can restore it when we unshade | ||
216 | m_height_before_shade; ///< height before shade, so we can restore it when we unshade | ||
217 | bool m_shaded; ///< wheter we're shaded or not | ||
218 | |||
219 | }; | ||
220 | |||
221 | #endif // FBWINFRAME_HH | ||