workaround for broken window managers which claim to support _NET_REQUEST_FRAME_EXTEN...
[wxWidgets.git] / include / wx / gtk / toplevel.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/toplevel.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_TOPLEVEL_H_
11 #define _WX_GTK_TOPLEVEL_H_
12
13 //-----------------------------------------------------------------------------
14 // wxTopLevelWindowGTK
15 //-----------------------------------------------------------------------------
16
17 class WXDLLIMPEXP_CORE wxTopLevelWindowGTK : public wxTopLevelWindowBase
18 {
19 typedef wxTopLevelWindowBase base_type;
20 public:
21 // construction
22 wxTopLevelWindowGTK() { Init(); }
23 wxTopLevelWindowGTK(wxWindow *parent,
24 wxWindowID id,
25 const wxString& title,
26 const wxPoint& pos = wxDefaultPosition,
27 const wxSize& size = wxDefaultSize,
28 long style = wxDEFAULT_FRAME_STYLE,
29 const wxString& name = wxFrameNameStr)
30 {
31 Init();
32
33 Create(parent, id, title, pos, size, style, name);
34 }
35
36 bool Create(wxWindow *parent,
37 wxWindowID id,
38 const wxString& title,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = wxDEFAULT_FRAME_STYLE,
42 const wxString& name = wxFrameNameStr);
43
44 virtual ~wxTopLevelWindowGTK();
45
46 // implement base class pure virtuals
47 virtual void Maximize(bool maximize = true);
48 virtual bool IsMaximized() const;
49 virtual void Iconize(bool iconize = true);
50 virtual bool IsIconized() const;
51 virtual void SetIcons(const wxIconBundle& icons);
52 virtual void Restore();
53
54 virtual bool EnableCloseButton(bool enable = true);
55
56 virtual void ShowWithoutActivating();
57 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
58 virtual bool IsFullScreen() const { return m_fsIsShowing; };
59
60 virtual bool SetShape(const wxRegion& region);
61
62 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
63
64 virtual void SetWindowStyleFlag( long style );
65
66 virtual bool Show(bool show = true);
67
68 virtual void Raise();
69
70 virtual bool IsActive();
71
72 virtual void SetTitle( const wxString &title );
73 virtual wxString GetTitle() const { return m_title; }
74
75 virtual void SetLabel(const wxString& label) { SetTitle( label ); }
76 virtual wxString GetLabel() const { return GetTitle(); }
77
78
79 virtual bool SetTransparent(wxByte alpha);
80 virtual bool CanSetTransparent();
81
82 // Experimental, to allow help windows to be
83 // viewable from within modal dialogs
84 virtual void AddGrab();
85 virtual void RemoveGrab();
86 virtual bool IsGrabbed() const { return m_grabbed; }
87
88
89 virtual void Refresh( bool eraseBackground = true,
90 const wxRect *rect = (const wxRect *) NULL );
91
92 // implementation from now on
93 // --------------------------
94
95 // GTK callbacks
96 virtual void OnInternalIdle();
97
98 // do *not* call this to iconize the frame, this is a private function!
99 void SetIconizeState(bool iconic);
100
101 GtkWidget *m_mainWidget;
102
103 bool m_fsIsShowing; /* full screen */
104 int m_fsSaveGdkFunc, m_fsSaveGdkDecor;
105 wxRect m_fsSaveFrame;
106
107 // m_windowStyle translated to GDK's terms
108 int m_gdkFunc,
109 m_gdkDecor;
110
111 // size of WM decorations
112 wxSize m_decorSize;
113
114 // shape of the frame
115 wxRegion m_shape;
116
117 // private gtk_timeout_add result for mimicing wxUSER_ATTENTION_INFO and
118 // wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
119 int m_urgency_hint;
120 // timer for detecting WM with broken _NET_REQUEST_FRAME_EXTENTS handling
121 unsigned m_netFrameExtentsTimerId;
122
123 // return the size of the window without WM decorations
124 void GTKDoGetSize(int *width, int *height) const;
125
126 void GTKUpdateDecorSize(const wxSize& decorSize);
127
128 protected:
129 // give hints to the Window Manager for how the size
130 // of the TLW can be changed by dragging
131 virtual void DoSetSizeHints( int minW, int minH,
132 int maxW, int maxH,
133 int incW, int incH);
134 // common part of all ctors
135 void Init();
136
137 // move the window to the specified location and resize it
138 virtual void DoMoveWindow(int x, int y, int width, int height);
139
140 // take into account WM decorations here
141 virtual void DoSetSize(int x, int y,
142 int width, int height,
143 int sizeFlags = wxSIZE_AUTO);
144
145 virtual void DoSetClientSize(int width, int height);
146 virtual void DoGetClientSize(int *width, int *height) const;
147
148 // string shown in the title bar
149 wxString m_title;
150
151 bool m_deferShow;
152
153 private:
154 wxSize& GetCachedDecorSize();
155
156 // is the frame currently iconized?
157 bool m_isIconized;
158
159 // is the frame currently grabbed explicitly by the application?
160 bool m_grabbed;
161
162 bool m_updateDecorSize;
163 bool m_deferShowAllowed;
164 };
165
166 #endif // _WX_GTK_TOPLEVEL_H_