]> icculus.org git repositories - mikachu/openbox.git/blob - src/frame.hh
setup the locale on the X server on start
[mikachu/openbox.git] / src / frame.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef   __frame_hh
3 #define   __frame_hh
4
5 /*! @file frame.hh
6 */
7
8 extern "C" {
9 #include <X11/Xlib.h>
10 }
11
12 #include "client.hh"
13 #include "backgroundwidget.hh"
14 #include "labelwidget.hh"
15 #include "buttonwidget.hh"
16 #include "otk/strut.hh"
17 #include "otk/rect.hh"
18 #include "otk/screeninfo.hh"
19 #include "otk/style.hh"
20 #include "otk/widget.hh"
21
22 #include <string>
23
24 namespace ob {
25
26 //! Holds and decorates a frame around an Client (client window)
27 /*!
28   The frame is responsible for calling XSelectInput on the client window's new
29   parent with the SubstructureRedirectMask so that structure events for the
30   client are sent to the window manager.
31 */
32 class Frame : public otk::Widget, public WidgetBase {
33 public:
34
35   //! The event mask to grab on frame windows
36   static const long event_mask = EnterWindowMask | LeaveWindowMask;
37    
38 private:
39   Client *_client;
40   const otk::ScreenInfo *_screen;
41
42   //! The style to use for size and display the decorations
43   otk::Style *_style;
44
45   //! The size of the frame on each side of the client window
46   otk::Strut _size;
47
48   //! The size of the frame on each side of the client window inside the border
49   otk::Strut _innersize;
50
51   // decoration windows
52   BackgroundWidget  _plate;   // sits entirely under the client window
53   BackgroundWidget  _titlebar;
54   ButtonWidget      _button_close;
55   ButtonWidget      _button_iconify;
56   ButtonWidget      _button_max;
57   ButtonWidget      _button_stick;
58   LabelWidget       _label;
59   BackgroundWidget  _handle;
60   ButtonWidget      _grip_left;
61   ButtonWidget      _grip_right;
62
63   //! The decorations to display on the window.
64   /*!
65     This is by default the same value as in the Client::decorations, but it
66     is duplicated here so that it can be overridden per-window by the user.
67   */
68   Client::DecorationFlags _decorations;
69
70 public:
71   //! Constructs an Frame object, and reparents the client to itself
72   /*!
73     @param client The client window which will be decorated by the new Frame
74     @param style The style to use to decorate the frame
75   */
76   Frame(Client *client, otk::Style *style);
77   //! Destroys the Frame object
78   virtual ~Frame();
79
80   //! Set the style to decorate the frame with
81   virtual void setStyle(otk::Style *style);
82
83   //! Empty overridden method to prevent automatic alignment of children
84   virtual void adjust();
85   
86   //! Displays focused decorations
87   virtual void focus();
88   //! Displays unfocused decorations
89   virtual void unfocus();
90
91   void setTitle(const std::string &text);
92  
93   //! Reparents the client window from the root window onto the frame
94   void grabClient();
95   //! Reparents the client window back to the root window
96   void releaseClient();
97
98   //! Update the frame's size to match the client
99   void adjustSize();
100   //! Update the frame's position to match the client
101   void adjustPosition();
102   //! Shape the frame window to the client window
103   void adjustShape();
104
105   //! Applies gravity to the client's position to find where the frame should
106   //! be positioned.
107   /*!
108     @return The proper coordinates for the frame, based on the client.
109   */
110   void clientGravity(int &x, int &y);
111
112   //! Reversly applies gravity to the frame's position to find where the client
113   //! should be positioned.
114   /*!
115     @return The proper coordinates for the client, based on the frame.
116   */
117   void frameGravity(int &x, int &y);
118
119   //! Gets the window id of the frame's "plate" subelement
120   inline Window plate() const { return _plate.window(); }
121   //! Gets the window id of the frame's "titlebar" subelement
122   inline Window titlebar() const { return _titlebar.window(); }
123   //! Gets the window id of the frame's "label" subelement
124   inline Window label() const { return _label.window(); }
125   //! Gets the window id of the frame's "close button" subelement
126   inline Window button_close() const { return _button_close.window(); }
127   //! Gets the window id of the frame's "iconify button" subelement
128   inline Window button_iconify() const { return _button_iconify.window(); }
129   //! Gets the window id of the frame's "maximize button" subelement
130   inline Window button_max() const { return _button_max.window(); }
131   //! Gets the window id of the frame's "sticky button" subelement
132   inline Window button_stick() const { return _button_stick.window(); }
133   //! Gets the window id of the frame's "handle" subelement
134   inline Window handle() const { return _handle.window(); }
135   //! Gets the window id of the frame's "left grip" subelement
136   inline Window grip_left() const { return _grip_left.window(); }
137   //! Gets the window id of the frame's "right grip" subelement
138   inline Window grip_right() const { return _grip_right.window(); }
139
140 };
141
142 }
143
144 #endif // __frame_hh