wxTOPLEVEL_EX_DIALOG is a better name than wxTLW_EX_DIALOG
[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 // Dialogs are created in a special way
34 #define wxTOPLEVEL_EX_DIALOG 0x00000008
35
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)
45
46 // ----------------------------------------------------------------------------
47 // wxTopLevelWindow: a top level (as opposed to child) window
48 // ----------------------------------------------------------------------------
49
50 class WXDLLEXPORT wxTopLevelWindowBase : public wxWindow
51 {
52 public:
53 // construction
54 wxTopLevelWindowBase();
55 #ifdef __DARWIN__
56 virtual ~wxTopLevelWindowBase() {}
57 #endif
58
59 // top level wnd state
60 // --------------------
61
62 // maximize = TRUE => maximize, otherwise - restore
63 virtual void Maximize(bool maximize = TRUE) = 0;
64
65 // undo Maximize() or Iconize()
66 virtual void Restore() = 0;
67
68 // iconize = TRUE => iconize, otherwise - restore
69 virtual void Iconize(bool iconize = TRUE) = 0;
70
71 // return TRUE if the frame is maximized
72 virtual bool IsMaximized() const = 0;
73
74 // return TRUE if the frame is iconized
75 virtual bool IsIconized() const = 0;
76
77 // get the frame icon
78 const wxIcon& GetIcon() const { return m_icon; }
79
80 // set the frame icon
81 virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
82
83 /*
84 for now we already have them in wxWindow, but this is wrong: these
85 methods really only make sense for wxTopLevelWindow!
86
87 virtual void SetTitle(const wxString& title) = 0;
88 virtual wxString GetTitle() const = 0;
89 */
90
91 // old functions, use the new ones instead!
92 #if WXWIN_COMPATIBILITY_2
93 bool Iconized() const { return IsIconized(); }
94 #endif // WXWIN_COMPATIBILITY_2
95
96 // implementation only from now on
97 // -------------------------------
98
99 // override some base class virtuals
100 virtual bool Destroy();
101 virtual bool IsTopLevel() const { return TRUE; }
102
103 // event handlers
104 void OnCloseWindow(wxCloseEvent& event);
105 void OnSize(wxSizeEvent& event);
106
107 // this should go away, but for now it's called from docview.cpp,
108 // so should be there for all platforms
109 void OnActivate(wxActivateEvent &WXUNUSED(event)) { }
110
111 protected:
112 // the frame client to screen translation should take account of the
113 // toolbar which may shift the origin of the client area
114 virtual void DoClientToScreen(int *x, int *y) const;
115 virtual void DoScreenToClient(int *x, int *y) const;
116
117 // send the iconize event, return TRUE if processed
118 bool SendIconizeEvent(bool iconized = TRUE);
119
120 // the frame icon
121 wxIcon m_icon;
122
123 // test whether this window makes part of the frame
124 // (menubar, toolbar and statusbar are excluded from automatic layout)
125 virtual bool IsOneOfBars(const wxWindow *WXUNUSED(win)) const { return FALSE; }
126
127 DECLARE_EVENT_TABLE()
128 };
129
130
131 // include the real class declaration
132 #if defined(__WXGTK__)
133 #include "wx/gtk/toplevel.h"
134 #define wxTopLevelWindowNative wxTopLevelWindowGTK
135 #elif defined(__WXMGL__)
136 #include "wx/mgl/toplevel.h"
137 #define wxTopLevelWindowNative wxTopLevelWindowMGL
138 #endif
139
140 #ifdef __WXUNIVERSAL__
141 #include "wx/univ/toplevel.h"
142 #else // !__WXUNIVERSAL__
143 #ifdef wxTopLevelWindowNative
144 class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative
145 {
146 public:
147 // construction
148 wxTopLevelWindow() { Init(); }
149 wxTopLevelWindow(wxWindow *parent,
150 wxWindowID id,
151 const wxString& title,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 long style = wxDEFAULT_FRAME_STYLE,
155 const wxString& name = wxFrameNameStr)
156 {
157 Init();
158 Create(parent, id, title, pos, size, style, name);
159 }
160
161 DECLARE_DYNAMIC_CLASS(wxTopLevelWindow)
162 };
163 #endif // wxTopLevelWindowNative
164 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
165
166
167 #endif // _WX_TOPLEVEL_BASE_H_