news download themes documentation links










FbWindow.hh

00001 // FbWindow.hh for FbTk - fluxbox toolkit
00002 // Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 //
00004 // Permission is hereby granted, free of charge, to any person obtaining a
00005 // copy of this software and associated documentation files (the "Software"),
00006 // to deal in the Software without restriction, including without limitation
00007 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008 // and/or sell copies of the Software, and to permit persons to whom the
00009 // Software is furnished to do so, subject to the following conditions:
00010 //
00011 // The above copyright notice and this permission notice shall be included in
00012 // all copies or substantial portions of the Software.
00013 //
00014 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00019 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00020 // DEALINGS IN THE SOFTWARE.
00021 
00022 // $Id: FbWindow.hh,v 1.27 2003/12/30 17:17:05 fluxgen Exp $
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 } // end namespace FbTk
00211 
00212 #endif // FBTK_FBWINDOW_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA