]> git.saurik.com Git - wxWidgets.git/blob - include/wx/toplevel.h
fix for scrollbar's thumb update bug in wxUniv
[wxWidgets.git] / include / wx / toplevel.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/toplevel.h
3 // Purpose: declares wxTopLevelWindow class, the base class for all
4 // top level windows (such as frames and dialogs)
5 // Author: Vadim Zeitlin, Vaclav Slavik
6 // Modified by:
7 // Created: 06.08.01
8 // RCS-ID: $Id$
9 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Vaclav Slavik <vaclav@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
13
14 #ifndef _WX_TOPLEVEL_BASE_H_
15 #define _WX_TOPLEVEL_BASE_H_
16
17 // ----------------------------------------------------------------------------
18 // headers
19 // ----------------------------------------------------------------------------
20
21 #ifdef __GNUG__
22 #pragma interface "toplevelbase.h"
23 #endif
24
25 #include "wx/window.h"
26 #include "wx/icon.h"
27
28 // the default names for various classs
29 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
30
31 class WXDLLEXPORT wxTopLevelWindowBase;
32
33 // ----------------------------------------------------------------------------
34 // constants
35 // ----------------------------------------------------------------------------
36
37 // Dialogs are created in a special way
38 #define wxTOPLEVEL_EX_DIALOG 0x00000008
39
40 // Styles for ShowFullScreen
41 // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
42 // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
43 enum
44 {
45 wxFULLSCREEN_NOMENUBAR = 0x0001,
46 wxFULLSCREEN_NOTOOLBAR = 0x0002,
47 wxFULLSCREEN_NOSTATUSBAR = 0x0004,
48 wxFULLSCREEN_NOBORDER = 0x0008,
49 wxFULLSCREEN_NOCAPTION = 0x0010,
50
51 wxFULLSCREEN_ALL = wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR |
52 wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER |
53 wxFULLSCREEN_NOCAPTION
54 };
55
56 // ----------------------------------------------------------------------------
57 // wxTopLevelWindow: a top level (as opposed to child) window
58 // ----------------------------------------------------------------------------
59
60 class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
61 {
62 public:
63 // construction
64 wxTopLevelWindowBase();
65 virtual ~wxTopLevelWindowBase();
66
67 // top level wnd state
68 // --------------------
69
70 // maximize = TRUE => maximize, otherwise - restore
71 virtual void Maximize(bool maximize = TRUE) = 0;
72
73 // undo Maximize() or Iconize()
74 virtual void Restore() = 0;
75
76 // iconize = TRUE => iconize, otherwise - restore
77 virtual void Iconize(bool iconize = TRUE) = 0;
78
79 // return TRUE if the frame is maximized
80 virtual bool IsMaximized() const = 0;
81
82 // return TRUE if the frame is iconized
83 virtual bool IsIconized() const = 0;
84
85 // get the frame icon
86 const wxIcon& GetIcon() const { return m_icon; }
87
88 // set the frame icon
89 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
90
91 // maximize the window to cover entire screen
92 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
93
94 // return TRUE if the frame is in fullscreen mode
95 virtual bool IsFullScreen() const = 0;
96
97 /*
98 for now we already have them in wxWindow, but this is wrong: these
99 methods really only make sense for wxTopLevelWindow!
100
101 virtual void SetTitle(const wxString& title) = 0;
102 virtual wxString GetTitle() const = 0;
103 */
104
105 // old functions, use the new ones instead!
106 #if WXWIN_COMPATIBILITY_2
107 bool Iconized() const { return IsIconized(); }
108 #endif // WXWIN_COMPATIBILITY_2
109
110 // implementation only from now on
111 // -------------------------------
112
113 // override some base class virtuals
114 virtual bool Destroy();
115 virtual bool IsTopLevel() const { return TRUE; }
116
117 // event handlers
118 void OnCloseWindow(wxCloseEvent& event);
119 void OnSize(wxSizeEvent& event);
120
121 // this should go away, but for now it's called from docview.cpp,
122 // so should be there for all platforms
123 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
124
125 // Override in derived, platfrom specific, class if your OS coordinate
126 // system uses anything other than the top left as 0,0. The second
127 // method updates any internal sizing parameters such as OS/2's SWP struct
128 inline virtual void AlterChildPos(void) { }
129 inline virtual void UpdateInternalSize( wxWindow* WXUNUSED(pChild)
130 ,int WXUNUSED(nWidth)
131 ,int WXUNUSED(nHeight)
132 ) { }
133
134 protected:
135 // the frame client to screen translation should take account of the
136 // toolbar which may shift the origin of the client area
137 virtual void DoClientToScreen(int *x, int *y) const;
138 virtual void DoScreenToClient(int *x, int *y) const;
139
140 // send the iconize event, return TRUE if processed
141 bool SendIconizeEvent(bool iconized = TRUE);
142
143 // the frame icon
144 wxIcon m_icon;
145
146 // test whether this window makes part of the frame
147 // (menubar, toolbar and statusbar are excluded from automatic layout)
148 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const { return FALSE; }
149
150 DECLARE_EVENT_TABLE()
151 };
152
153
154 // include the real class declaration
155 #if defined(__WXMSW__)
156 #include "wx/msw/toplevel.h"
157 #define wxTopLevelWindowNative wxTopLevelWindowMSW
158 #elif defined(__WXGTK__)
159 #include "wx/gtk/toplevel.h"
160 #define wxTopLevelWindowNative wxTopLevelWindowGTK
161 #elif defined(__WXX11__)
162 #include "wx/x11/toplevel.h"
163 #define wxTopLevelWindowNative wxTopLevelWindowX11
164 #elif defined(__WXMGL__)
165 #include "wx/mgl/toplevel.h"
166 #define wxTopLevelWindowNative wxTopLevelWindowMGL
167 #elif defined(__WXMAC__)
168 #include "wx/mac/toplevel.h"
169 #define wxTopLevelWindowNative wxTopLevelWindowMac
170 #elif defined(__WXPM__)
171 #include "wx/os2/toplevel.h"
172 #define wxTopLevelWindowNative wxTopLevelWindowOS2
173 #endif
174
175 #ifdef __WXUNIVERSAL__
176 #include "wx/univ/toplevel.h"
177 #else // !__WXUNIVERSAL__
178 #ifdef wxTopLevelWindowNative
179 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
180 {
181 public:
182 // construction
183 wxTopLevelWindow() { Init(); }
184 wxTopLevelWindow(wxWindow *parent,
185 wxWindowID id,
186 const wxString& title,
187 const wxPoint& pos = wxDefaultPosition,
188 const wxSize& size = wxDefaultSize,
189 long style = wxDEFAULT_FRAME_STYLE,
190 const wxString& name = wxFrameNameStr)
191 {
192 Init();
193 Create(parent, id, title, pos, size, style, name);
194 }
195
196 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
197 };
198 #endif // wxTopLevelWindowNative
199 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
200
201
202 #endif // _WX_TOPLEVEL_BASE_H_