]> icculus.org git repositories - dana/openbox.git/blob - src/frame.hh
add an OBBackgroundWidget and use it for setting colors so far.
[dana/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 "otk/strut.hh"
15 #include "otk/rect.hh"
16 #include "otk/screeninfo.hh"
17 #include "otk/style.hh"
18 #include "otk/widget.hh"
19 #include "otk/button.hh"
20 #include "otk/focuswidget.hh"
21 #include "otk/focuslabel.hh"
22
23 #include <string>
24
25 namespace ob {
26
27 //! Holds and decorates a frame around an OBClient (client window)
28 /*!
29   The frame is responsible for calling XSelectInput on the client window's new
30   parent with the SubstructureRedirectMask so that structure events for the
31   client are sent to the window manager.
32 */
33 class OBFrame : public otk::OtkWidget {
34 public:
35
36   //! The event mask to grab on frame windows
37   static const long event_mask = EnterWindowMask | LeaveWindowMask;
38
39 private:
40   OBClient *_client;
41   const otk::ScreenInfo *_screen;
42
43   //! The style to use for size and display the decorations
44   otk::Style *_style;
45
46   //! The size of the frame on each side of the client window
47   otk::Strut _size;
48
49   //! The size of the frame on each side of the client window inside the border
50   otk::Strut _innersize;
51
52   // decoration windows
53   OBBackgroundWidget  _plate;   // sits entirely under the client window
54   OBBackgroundWidget  _titlebar;
55   otk::OtkButton      _button_close;
56   otk::OtkButton      _button_iconify;
57   otk::OtkButton      _button_max;
58   otk::OtkButton      _button_stick;
59   otk::OtkFocusLabel  _label;
60   OBBackgroundWidget  _handle;
61   otk::OtkButton      _grip_left;
62   otk::OtkButton      _grip_right;
63
64   //! The decorations to display on the window.
65   /*!
66     This is by default the same value as in the OBClient::decorations, but it
67     is duplicated here so that it can be overridden per-window by the user.
68   */
69   OBClient::DecorationFlags _decorations;
70
71   //! Reparents the client window from the root window onto the frame
72   void grabClient();
73   //! Reparents the client window back to the root window
74   /*!
75     @param remap Re-map the client window when we're done reparenting?
76   */
77   void releaseClient(bool remap);
78
79   //! Shape the frame window to the client window
80   void adjustShape();
81
82 public:
83   //! Constructs an OBFrame object, and reparents the client to itself
84   /*!
85     @param client The client window which will be decorated by the new OBFrame
86     @param style The style to use to decorate the frame
87   */
88   OBFrame(OBClient *client, otk::Style *style);
89   //! Destroys the OBFrame object
90   virtual ~OBFrame();
91
92   //! Set the style to decorate the frame with
93   virtual void setStyle(otk::Style *style);
94
95   //! Update the frame's size to match the client
96   void adjustSize();
97   //! Update the frame's position to match the client
98   void adjustPosition();
99
100   //! Applies gravity to the client's position to find where the frame should
101   //! be positioned.
102   /*!
103     @return The proper coordinates for the frame, based on the client.
104   */
105   void clientGravity(int &x, int &y);
106
107   //! Reversly applies gravity to the frame's position to find where the client
108   //! should be positioned.
109   /*!
110     @return The proper coordinates for the client, based on the frame.
111   */
112   void frameGravity(int &x, int &y);
113
114 };
115
116 }
117
118 #endif // __frame_hh