Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/src/frame.hh

Go to the documentation of this file.
00001 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
00002 #ifndef   __frame_hh
00003 #define   __frame_hh
00004 
00005 /*! @file frame.hh
00006 */
00007 
00008 extern "C" {
00009 #include <X11/Xlib.h>
00010 }
00011 
00012 #include "client.hh"
00013 #include "backgroundwidget.hh"
00014 #include "labelwidget.hh"
00015 #include "buttonwidget.hh"
00016 #include "otk/strut.hh"
00017 #include "otk/rect.hh"
00018 #include "otk/screeninfo.hh"
00019 #include "otk/renderstyle.hh"
00020 #include "otk/widget.hh"
00021 #include "otk/ustring.hh"
00022 
00023 #include <string>
00024 
00025 namespace ob {
00026 
00027 //! Holds and decorates a frame around an Client (client window)
00028 /*!
00029   The frame is responsible for calling XSelectInput on the client window's new
00030   parent with the SubstructureRedirectMask so that structure events for the
00031   client are sent to the window manager.
00032 */
00033 class Frame : public otk::Widget, public WidgetBase {
00034 public:
00035 
00036   //! The event mask to grab on frame windows
00037   static const long event_mask = EnterWindowMask | LeaveWindowMask;
00038    
00039 private:
00040   Client *_client;
00041   const otk::ScreenInfo *_screen;
00042 
00043   //! The size of the frame on each side of the client window
00044   otk::Strut _size;
00045 
00046   //! The size of the frame on each side of the client window inside the border
00047   otk::Strut _innersize;
00048 
00049   // decoration windows
00050   BackgroundWidget  _plate;   // sits entirely under the client window
00051   BackgroundWidget  _titlebar;
00052   ButtonWidget      _button_close;
00053   ButtonWidget      _button_iconify;
00054   ButtonWidget      _button_max;
00055   ButtonWidget      _button_alldesk;
00056   LabelWidget       _label;
00057   BackgroundWidget  _handle;
00058   ButtonWidget      _grip_left;
00059   ButtonWidget      _grip_right;
00060 
00061   //! The decorations to display on the window.
00062   /*!
00063     This is by default the same value as in the Client::decorations, but it
00064     is duplicated here so that it can be overridden per-window by the user.
00065   */
00066   Client::DecorationFlags _decorations;
00067 
00068 public:
00069   //! Constructs an Frame object, and reparents the client to itself
00070   /*!
00071     @param client The client window which will be decorated by the new Frame
00072     @param style The style to use to decorate the frame
00073   */
00074   Frame(Client *client, otk::RenderStyle *style);
00075   //! Destroys the Frame object
00076   virtual ~Frame();
00077 
00078   //! Returns the size of the frame on each side of the client
00079   const otk::Strut& size() const { return _size; }
00080   
00081   //! Set the style to decorate the frame with
00082   virtual void setStyle(otk::RenderStyle *style);
00083 
00084   //! Empty overridden method to prevent automatic alignment of children
00085   virtual void adjust();
00086   
00087   //! Displays focused decorations
00088   virtual void focus();
00089   //! Displays unfocused decorations
00090   virtual void unfocus();
00091 
00092   void setTitle(const otk::ustring &text);
00093  
00094   //! Reparents the client window from the root window onto the frame
00095   void grabClient();
00096   //! Reparents the client window back to the root window
00097   void releaseClient();
00098 
00099   //! Update the frame's size to match the client
00100   void adjustSize();
00101   //! Update the frame's position to match the client
00102   void adjustPosition();
00103   //! Shape the frame window to the client window
00104   void adjustShape();
00105   //! Update the frame to match the client's new state (for things like toggle
00106   //! buttons)
00107   void adjustState();
00108 
00109   //! Applies gravity to the client's position to find where the frame should
00110   //! be positioned.
00111   /*!
00112     @return The proper coordinates for the frame, based on the client.
00113   */
00114   void clientGravity(int &x, int &y);
00115 
00116   //! Reversly applies gravity to the frame's position to find where the client
00117   //! should be positioned.
00118   /*!
00119     @return The proper coordinates for the client, based on the frame.
00120   */
00121   void frameGravity(int &x, int &y);
00122 
00123   //! Gets the window id of the frame's "plate" subelement
00124   inline Window plate() const { return _plate.window(); }
00125   //! Gets the window id of the frame's "titlebar" subelement
00126   inline Window titlebar() const { return _titlebar.window(); }
00127   //! Gets the window id of the frame's "label" subelement
00128   inline Window label() const { return _label.window(); }
00129   //! Gets the window id of the frame's "close button" subelement
00130   inline Window button_close() const { return _button_close.window(); }
00131   //! Gets the window id of the frame's "iconify button" subelement
00132   inline Window button_iconify() const { return _button_iconify.window(); }
00133   //! Gets the window id of the frame's "maximize button" subelement
00134   inline Window button_max() const { return _button_max.window(); }
00135   //! Gets the window id of the frame's "all desktops button" subelement
00136   inline Window button_alldesk() const { return _button_alldesk.window(); }
00137   //! Gets the window id of the frame's "handle" subelement
00138   inline Window handle() const { return _handle.window(); }
00139   //! Gets the window id of the frame's "left grip" subelement
00140   inline Window grip_left() const { return _grip_left.window(); }
00141   //! Gets the window id of the frame's "right grip" subelement
00142   inline Window grip_right() const { return _grip_right.window(); }
00143 
00144 };
00145 
00146 }
00147 
00148 #endif // __frame_hh

Generated on Tue Feb 4 22:58:58 2003 for Openbox by doxygen1.3-rc2