1 ///////////////////////////////////////////////////////////////////////////////
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
9 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
10 // Vaclav Slavik <vaclav@wxwindows.org>
11 // Licence: wxWindows licence
12 ///////////////////////////////////////////////////////////////////////////////
14 #ifndef _WX_TOPLEVEL_BASE_H_
15 #define _WX_TOPLEVEL_BASE_H_
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
22 #pragma interface "toplevelbase.h"
25 #include "wx/window.h"
28 // the default names for various classs
29 WXDLLEXPORT_DATA(extern const wxChar
*) wxFrameNameStr
;
31 class WXDLLEXPORT wxTopLevelWindowBase
;
33 // Dialogs are created in a special way
34 #define wxTOPLEVEL_EX_DIALOG 0x00000008
36 // Styles for ShowFullScreen
37 // (note that wxTopLevelWindow only handles wxFULLSCREEN_NOBORDER and
38 // wxFULLSCREEN_NOCAPTION; the rest is handled by wxTopLevelWindow)
39 #define wxFULLSCREEN_NOMENUBAR 0x01
40 #define wxFULLSCREEN_NOTOOLBAR 0x02
41 #define wxFULLSCREEN_NOSTATUSBAR 0x04
42 #define wxFULLSCREEN_NOBORDER 0x08
43 #define wxFULLSCREEN_NOCAPTION 0x10
44 #define wxFULLSCREEN_ALL (wxFULLSCREEN_NOMENUBAR | wxFULLSCREEN_NOTOOLBAR | wxFULLSCREEN_NOSTATUSBAR | wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION)
46 // ----------------------------------------------------------------------------
47 // wxTopLevelWindow: a top level (as opposed to child) window
48 // ----------------------------------------------------------------------------
50 class WXDLLEXPORT wxTopLevelWindowBase
: public wxWindow
54 wxTopLevelWindowBase();
56 // top level wnd state
57 // --------------------
59 // maximize = TRUE => maximize, otherwise - restore
60 virtual void Maximize(bool maximize
= TRUE
) = 0;
62 // undo Maximize() or Iconize()
63 virtual void Restore() = 0;
65 // iconize = TRUE => iconize, otherwise - restore
66 virtual void Iconize(bool iconize
= TRUE
) = 0;
68 // return TRUE if the frame is maximized
69 virtual bool IsMaximized() const = 0;
71 // return TRUE if the frame is iconized
72 virtual bool IsIconized() const = 0;
75 const wxIcon
& GetIcon() const { return m_icon
; }
78 virtual void SetIcon(const wxIcon
& icon
) { m_icon
= icon
; }
80 // maximize the window to cover entire screen
81 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
) = 0;
83 // return TRUE if the frame is in fullscreen mode
84 virtual bool IsFullScreen() const = 0;
87 for now we already have them in wxWindow, but this is wrong: these
88 methods really only make sense for wxTopLevelWindow!
90 virtual void SetTitle(const wxString& title) = 0;
91 virtual wxString GetTitle() const = 0;
94 // old functions, use the new ones instead!
95 #if WXWIN_COMPATIBILITY_2
96 bool Iconized() const { return IsIconized(); }
97 #endif // WXWIN_COMPATIBILITY_2
99 // implementation only from now on
100 // -------------------------------
102 // override some base class virtuals
103 virtual bool Destroy();
104 virtual bool IsTopLevel() const { return TRUE
; }
107 void OnCloseWindow(wxCloseEvent
& event
);
108 void OnSize(wxSizeEvent
& event
);
110 // this should go away, but for now it's called from docview.cpp,
111 // so should be there for all platforms
112 void OnActivate(wxActivateEvent
&WXUNUSED(event
)) { }
115 virtual ~wxTopLevelWindowBase() {}
119 // the frame client to screen translation should take account of the
120 // toolbar which may shift the origin of the client area
121 virtual void DoClientToScreen(int *x
, int *y
) const;
122 virtual void DoScreenToClient(int *x
, int *y
) const;
124 // send the iconize event, return TRUE if processed
125 bool SendIconizeEvent(bool iconized
= TRUE
);
130 // test whether this window makes part of the frame
131 // (menubar, toolbar and statusbar are excluded from automatic layout)
132 virtual bool IsOneOfBars(const wxWindow
*WXUNUSED(win
)) const { return FALSE
; }
134 DECLARE_EVENT_TABLE()
138 // include the real class declaration
139 #if defined(__WXMSW__)
140 #include "wx/msw/toplevel.h"
141 #define wxTopLevelWindowNative wxTopLevelWindowMSW
142 #elif defined(__WXGTK__)
143 #include "wx/gtk/toplevel.h"
144 #define wxTopLevelWindowNative wxTopLevelWindowGTK
145 #elif defined(__WXMGL__)
146 #include "wx/mgl/toplevel.h"
147 #define wxTopLevelWindowNative wxTopLevelWindowMGL
148 #elif defined(__WXMAC__)
149 #include "wx/mac/toplevel.h"
150 #define wxTopLevelWindowNative wxTopLevelWindowMac
153 #ifdef __WXUNIVERSAL__
154 #include "wx/univ/toplevel.h"
155 #else // !__WXUNIVERSAL__
156 #ifdef wxTopLevelWindowNative
157 class WXDLLEXPORT wxTopLevelWindow
: public wxTopLevelWindowNative
161 wxTopLevelWindow() { Init(); }
162 wxTopLevelWindow(wxWindow
*parent
,
164 const wxString
& title
,
165 const wxPoint
& pos
= wxDefaultPosition
,
166 const wxSize
& size
= wxDefaultSize
,
167 long style
= wxDEFAULT_FRAME_STYLE
,
168 const wxString
& name
= wxFrameNameStr
)
171 Create(parent
, id
, title
, pos
, size
, style
, name
);
174 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow
)
176 #endif // wxTopLevelWindowNative
177 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
180 #endif // _WX_TOPLEVEL_BASE_H_