00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FBTK_FBWINDOW_HH
00025 #define FBTK_FBWINDOW_HH
00026
00027 #include "FbDrawable.hh"
00028
00029 #include <X11/Xlib.h>
00030 #include <memory>
00031
00032
00033 namespace FbTk {
00034
00035 class Color;
00036 class Transparent;
00037
00039
00049 class FbWindow: public FbDrawable {
00050 public:
00051 FbWindow();
00052
00053 FbWindow(const FbWindow &win_copy);
00054
00055 FbWindow(int screen_num,
00056 int x, int y, unsigned int width, unsigned int height, long eventmask,
00057 bool overrride_redirect = false,
00058 int depth = CopyFromParent,
00059 int class_type = InputOutput);
00060
00061 FbWindow(const FbWindow &parent,
00062 int x, int y,
00063 unsigned int width, unsigned int height,
00064 long eventmask,
00065 bool overrride_redirect = false,
00066 int depth = CopyFromParent,
00067 int class_type = InputOutput);
00068
00069 virtual ~FbWindow();
00070 virtual void setBackgroundColor(const FbTk::Color &bg_color);
00071 virtual void setBackgroundPixmap(Pixmap bg_pixmap);
00072 virtual void setBorderColor(const FbTk::Color &border_color);
00073 virtual void setBorderWidth(unsigned int size);
00075 void setName(const char *name);
00076 void setEventMask(long mask);
00078 virtual void clear();
00080 virtual void clearArea(int x, int y,
00081 unsigned int width, unsigned int height,
00082 bool exposures = false);
00083 void updateTransparent(int x = -1, int y = -1, unsigned int width = 0, unsigned int height = 0);
00084
00085 void setAlpha(unsigned char alpha);
00086
00087 virtual FbWindow &operator = (const FbWindow &win);
00089 virtual FbWindow &operator = (Window win);
00090 virtual void hide();
00091 virtual void show();
00092 virtual void showSubwindows();
00093
00094 virtual inline void move(int x, int y) {
00095 XMoveWindow(s_display, m_window, x, y);
00096 m_x = x;
00097 m_y = y;
00098 }
00099
00100 virtual inline void resize(unsigned int width, unsigned int height) {
00101 XResizeWindow(s_display, m_window, width, height);
00102 m_width = width;
00103 m_height = height;
00104 }
00105
00106 virtual inline void moveResize(int x, int y, unsigned int width, unsigned int height) {
00107 XMoveResizeWindow(s_display, m_window, x, y, width, height);
00108 m_x = x;
00109 m_y = y;
00110 m_width = width;
00111 m_height = height;
00112 }
00113 virtual void lower();
00114 virtual void raise();
00115 void setInputFocus(int revert_to, int time);
00117 void setCursor(Cursor cur);
00119 void unsetCursor();
00120 void reparent(const FbWindow &parent, int x, int y);
00121
00122 bool property(Atom property,
00123 long long_offset, long long_length,
00124 bool do_delete,
00125 Atom req_type,
00126 Atom *actual_type_return,
00127 int *actual_format_return,
00128 unsigned long *nitems_return,
00129 unsigned long *bytes_after_return,
00130 unsigned char **prop_return) const;
00131
00132 void changeProperty(Atom property, Atom type,
00133 int format,
00134 int mode,
00135 unsigned char *data,
00136 int nelements);
00137
00139 const FbWindow *parent() const { return m_parent; }
00141 inline Window window() const { return m_window; }
00143 inline Drawable drawable() const { return window(); }
00144 int x() const { return m_x; }
00145 int y() const { return m_y; }
00146 unsigned int width() const { return m_width; }
00147 unsigned int height() const { return m_height; }
00148 unsigned int borderWidth() const { return m_border_width; }
00149 int depth() const { return m_depth; }
00150 int screenNumber() const;
00151 long eventMask() const;
00153 bool operator == (Window win) const { return m_window == win; }
00154 bool operator != (Window win) const { return m_window != win; }
00156 bool operator == (const FbWindow &win) const { return m_window == win.m_window; }
00157 bool operator != (const FbWindow &win) const { return m_window != win.m_window; }
00158
00159 protected:
00161 explicit FbWindow(Window client);
00162 void setBufferPixmap(Pixmap pm);
00164 void updateGeometry();
00165 private:
00167 void setNew(Window win);
00169 void create(Window parent, int x, int y, unsigned int width, unsigned int height,
00170 long eventmask,
00171 bool override_redirect,
00172 int depth,
00173 int class_type);
00174 static Display *s_display;
00175 const FbWindow *m_parent;
00176 int m_screen_num;
00177 mutable Window m_window;
00178 int m_x, m_y;
00179 unsigned int m_width, m_height;
00180 unsigned int m_border_width;
00181 int m_depth;
00182 bool m_destroy;
00183 std::auto_ptr<FbTk::Transparent> m_transparent;
00184 Pixmap m_buffer_pm;
00185 };
00186
00187 bool operator == (Window win, const FbWindow &fbwin);
00188
00190 class ChangeProperty {
00191 public:
00192 ChangeProperty(Display *disp, Atom prop, int mode,
00193 unsigned char *state, int num):m_disp(disp),
00194 m_prop(prop), m_state(state), m_num(num), m_mode(mode){
00195
00196 }
00197 void operator () (FbTk::FbWindow *win) {
00198 XChangeProperty(m_disp, win->window(), m_prop, m_prop, 32, m_mode,
00199 m_state, m_num);
00200 }
00201 private:
00202 Display *m_disp;
00203 Atom m_prop;
00204 unsigned char *m_state;
00205 int m_num;
00206 int m_mode;
00207
00208 };
00209
00210 }
00211
00212 #endif // FBTK_FBWINDOW_HH