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