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