aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbWindow.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/FbWindow.hh')
-rw-r--r--src/FbTk/FbWindow.hh182
1 files changed, 182 insertions, 0 deletions
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh
new file mode 100644
index 0000000..88a00d8
--- /dev/null
+++ b/src/FbTk/FbWindow.hh
@@ -0,0 +1,182 @@
1// FbWindow.hh for FbTk - fluxbox toolkit
2// Copyright (c) 2002 - 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: FbWindow.hh,v 1.19 2003/07/02 05:17:30 fluxgen Exp $
23
24#ifndef FBTK_FBWINDOW_HH
25#define FBTK_FBWINDOW_HH
26
27#include "FbDrawable.hh"
28
29#include <X11/Xlib.h>
30
31namespace FbTk {
32
33class Color;
34
35/// Wrapper for X window
36/**
37 * Example:
38 * FbWindow window(0, 10, 10, 100, 100, ExposeMask | ButtonPressMask); \n
39 * this will create a window on screen 0, position 10 10, size 100 100 \n
40 * and with eventmask Expose and ButtonPress. \n
41 * You need to register it to some eventhandler so you can catch events: \n
42 * EventManager::instance()->add(your_eventhandler, window); \n
43 * @see EventHandler
44 * @see EventManager
45 */
46class FbWindow: public FbDrawable {
47public:
48 FbWindow();
49
50 FbWindow(const FbWindow &win_copy);
51
52 FbWindow(int screen_num,
53 int x, int y, unsigned int width, unsigned int height, long eventmask,
54 bool overrride_redirect = false,
55 int depth = CopyFromParent,
56 int class_type = InputOutput);
57
58 FbWindow(const FbWindow &parent,
59 int x, int y,
60 unsigned int width, unsigned int height,
61 long eventmask,
62 bool overrride_redirect = false,
63 int depth = CopyFromParent,
64 int class_type = InputOutput);
65
66 virtual ~FbWindow();
67 void setBackgroundColor(const FbTk::Color &bg_color);
68 void setBackgroundPixmap(Pixmap bg_pixmap);
69 void setBorderColor(const FbTk::Color &border_color);
70 void setBorderWidth(unsigned int size);
71 /// set window name (title)
72 void setName(const char *name);
73 void setEventMask(long mask);
74 /// clear window with background pixmap or color
75 virtual void clear();
76 /// @param exposures wheter Expose event should be generated
77 virtual void clearArea(int x, int y,
78 unsigned int width, unsigned int height,
79 bool exposures = false);
80 /// assign a new X window to this
81 virtual FbWindow &operator = (Window win);
82 virtual void hide();
83 virtual void show();
84 virtual void showSubwindows();
85
86 virtual void move(int x, int y);
87 virtual void resize(unsigned int width, unsigned int height);
88 virtual void moveResize(int x, int y, unsigned int width, unsigned int height);
89 virtual void lower();
90 virtual void raise();
91 void setInputFocus(int revert_to, int time);
92 /// defines a cursor for this window
93 void setCursor(Cursor cur);
94 /// uses the parents cursor instead
95 void unsetCursor();
96
97 bool property(Atom property,
98 long long_offset, long long_length,
99 bool do_delete,
100 Atom req_type,
101 Atom *actual_type_return,
102 int *actual_format_return,
103 unsigned long *nitems_return,
104 unsigned long *bytes_after_return,
105 unsigned char **prop_return) const;
106
107 void changeProperty(Atom property, Atom type,
108 int format,
109 int mode,
110 unsigned char *data,
111 int nelements);
112
113 /// @return parent FbWindow
114 const FbWindow *parent() const { return m_parent; }
115 /// @return real X window
116 inline Window window() const { return m_window; }
117 /// @return drawable (the X window)
118 inline Drawable drawable() const { return window(); }
119 int x() const { return m_x; }
120 int y() const { return m_y; }
121 unsigned int width() const { return m_width; }
122 unsigned int height() const { return m_height; }
123 unsigned int borderWidth() const { return m_border_width; }
124 int depth() const { return m_depth; }
125 int screenNumber() const;
126 /// compare X window
127 bool operator == (Window win) const { return m_window == win; }
128 bool operator != (Window win) const { return m_window != win; }
129 /// compare two windows
130 bool operator == (const FbWindow &win) const { return m_window == win.m_window; }
131 bool operator != (const FbWindow &win) const { return m_window != win.m_window; }
132
133protected:
134 /// creates a window with x window client (m_window = client)
135 explicit FbWindow(Window client);
136 /// updates x,y, width, height and screen num from X window
137 void updateGeometry();
138private:
139 /// sets new X window and destroys old
140 void setNew(Window win);
141 /// creates a new X window
142 void create(Window parent, int x, int y, unsigned int width, unsigned int height,
143 long eventmask,
144 bool override_redirect,
145 int depth,
146 int class_type);
147 static Display *s_display; ///< display connection
148 const FbWindow *m_parent; ///< parent FbWindow
149 int m_screen_num; ///< screen num on which this window exist
150 Window m_window; ///< the X window
151 int m_x, m_y; ///< position of window
152 unsigned int m_width, m_height; ///< size of window
153 unsigned int m_border_width; ///< border size
154 int m_depth; ///< bit depth
155 bool m_destroy; ///< wheter the x window was created before
156};
157
158bool operator == (Window win, const FbWindow &fbwin);
159
160/// helper class for some STL routines
161class ChangeProperty {
162public:
163 ChangeProperty(Display *disp, Atom prop, int mode,
164 unsigned char *state, int num):m_disp(disp),
165 m_prop(prop), m_state(state), m_num(num), m_mode(mode){
166
167 }
168 void operator () (FbTk::FbWindow *win) {
169 XChangeProperty(m_disp, win->window(), m_prop, m_prop, 32, m_mode,
170 m_state, m_num);
171 }
172private:
173 Display *m_disp;
174 Atom m_prop;
175 unsigned char *m_state;
176 int m_num;
177 int m_mode;
178};
179
180}; // end namespace FbTk
181
182#endif // FBTK_FBWINDOW_HH