1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/gtk/toplevel.h
3 // Purpose:
4 // Author:      Robert Roebling
5 // Copyright:   (c) 1998 Robert Roebling, Julian Smart
6 // Licence:     wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8 
9 #ifndef _WX_GTK_TOPLEVEL_H_
10 #define _WX_GTK_TOPLEVEL_H_
11 
12 class WXDLLIMPEXP_FWD_CORE wxGUIEventLoop;
13 
14 //-----------------------------------------------------------------------------
15 // wxTopLevelWindowGTK
16 //-----------------------------------------------------------------------------
17 
18 class WXDLLIMPEXP_CORE wxTopLevelWindowGTK : public wxTopLevelWindowBase
19 {
20     typedef wxTopLevelWindowBase base_type;
21 public:
22     // construction
wxTopLevelWindowGTK()23     wxTopLevelWindowGTK() { Init(); }
24     wxTopLevelWindowGTK(wxWindow *parent,
25                         wxWindowID id,
26                         const wxString& title,
27                         const wxPoint& pos = wxDefaultPosition,
28                         const wxSize& size = wxDefaultSize,
29                         long style = wxDEFAULT_FRAME_STYLE,
30                         const wxString& name = wxASCII_STR(wxFrameNameStr))
31     {
32         Init();
33 
34         Create(parent, id, title, pos, size, style, name);
35     }
36 
37     bool Create(wxWindow *parent,
38                 wxWindowID id,
39                 const wxString& title,
40                 const wxPoint& pos = wxDefaultPosition,
41                 const wxSize& size = wxDefaultSize,
42                 long style = wxDEFAULT_FRAME_STYLE,
43                 const wxString& name = wxASCII_STR(wxFrameNameStr));
44 
45     virtual ~wxTopLevelWindowGTK();
46 
47     // implement base class pure virtuals
48     virtual void Maximize(bool maximize = true) wxOVERRIDE;
49     virtual bool IsMaximized() const wxOVERRIDE;
50     virtual void Iconize(bool iconize = true) wxOVERRIDE;
51     virtual bool IsIconized() const wxOVERRIDE;
52     virtual void SetIcons(const wxIconBundle& icons) wxOVERRIDE;
53     virtual void Restore() wxOVERRIDE;
54 
55     virtual bool EnableCloseButton(bool enable = true) wxOVERRIDE;
56 
57     virtual void ShowWithoutActivating() wxOVERRIDE;
58     virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) wxOVERRIDE;
IsFullScreen()59     virtual bool IsFullScreen() const wxOVERRIDE { return m_fsIsShowing; }
60 
61     virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO) wxOVERRIDE;
62 
63     virtual void SetWindowStyleFlag( long style ) wxOVERRIDE;
64 
65     virtual bool Show(bool show = true) wxOVERRIDE;
66 
67     virtual void Raise() wxOVERRIDE;
68 
69     virtual bool IsActive() wxOVERRIDE;
70 
71     virtual void SetTitle( const wxString &title ) wxOVERRIDE;
GetTitle()72     virtual wxString GetTitle() const wxOVERRIDE { return m_title; }
73 
SetLabel(const wxString & label)74     virtual void SetLabel(const wxString& label) wxOVERRIDE { SetTitle( label ); }
GetLabel()75     virtual wxString GetLabel() const wxOVERRIDE            { return GetTitle(); }
76 
77     virtual wxVisualAttributes GetDefaultAttributes() const wxOVERRIDE;
78 
79     virtual bool SetTransparent(wxByte alpha) wxOVERRIDE;
80     virtual bool CanSetTransparent() wxOVERRIDE;
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;
87 
88 
89     virtual void Refresh( bool eraseBackground = true,
90                           const wxRect *rect = (const wxRect *) NULL ) wxOVERRIDE;
91 
92     // implementation from now on
93     // --------------------------
94 
95     // GTK callbacks
96     virtual void GTKHandleRealized() wxOVERRIDE;
97 
98     void GTKConfigureEvent(int x, int y);
99 
100     // do *not* call this to iconize the frame, this is a private function!
101     void SetIconizeState(bool iconic);
102 
103     GtkWidget    *m_mainWidget;
104 
105     bool          m_fsIsShowing;         /* full screen */
106     int           m_fsSaveGdkFunc, m_fsSaveGdkDecor;
107     wxRect        m_fsSaveFrame;
108 
109     // m_windowStyle translated to GDK's terms
110     int           m_gdkFunc,
111                   m_gdkDecor;
112 
113     // size of WM decorations
114     struct DecorSize
115     {
DecorSizeDecorSize116         DecorSize()
117         {
118             left =
119             right =
120             top =
121             bottom = 0;
122         }
123 
124         int left, right, top, bottom;
125     };
126     DecorSize m_decorSize;
127 
128     // private gtk_timeout_add result for mimicking wxUSER_ATTENTION_INFO and
129     // wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
130     int m_urgency_hint;
131     // timer for detecting WM with broken _NET_REQUEST_FRAME_EXTENTS handling
132     unsigned m_netFrameExtentsTimerId;
133 
134     // return the size of the window without WM decorations
135     void GTKDoGetSize(int *width, int *height) const;
136 
137     void GTKUpdateDecorSize(const DecorSize& decorSize);
138 
139     void GTKDoAfterShow();
140 
141 #ifdef __WXGTK3__
142     void GTKUpdateClientSizeIfNecessary();
143 
144     virtual void SetMinSize(const wxSize& minSize) wxOVERRIDE;
145 
146     virtual void WXSetInitialFittingClientSize(int flags) wxOVERRIDE;
147 
148 private:
149     // Flags to call WXSetInitialFittingClientSize() with if != 0.
150     int m_pendingFittingClientSizeFlags;
151 #endif // __WXGTK3__
152 
153 protected:
154     // give hints to the Window Manager for how the size
155     // of the TLW can be changed by dragging
156     virtual void DoSetSizeHints( int minW, int minH,
157                                  int maxW, int maxH,
158                                  int incW, int incH) wxOVERRIDE;
159     // move the window to the specified location and resize it
160     virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE;
161 
162     // take into account WM decorations here
163     virtual void DoSetSize(int x, int y,
164                            int width, int height,
165                            int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
166 
167     virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
168     virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
169 
170     // string shown in the title bar
171     wxString m_title;
172 
173     bool m_deferShow;
174 
175 private:
176     void Init();
177     DecorSize& GetCachedDecorSize();
178 
179     // size hint increments
180     int m_incWidth, m_incHeight;
181 
182     // position before it last changed
183     wxPoint m_lastPos;
184 
185     // is the frame currently iconized?
186     bool m_isIconized;
187 
188     // is the frame currently grabbed explicitly by the application?
189     wxGUIEventLoop* m_grabbedEventLoop;
190 
191     bool m_updateDecorSize;
192     bool m_deferShowAllowed;
193 };
194 
195 #endif // _WX_GTK_TOPLEVEL_H_
196