]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/toplevel.h
No real changes, just refactor wxControlContainer code a little.
[wxWidgets.git] / include / wx / msw / toplevel.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/toplevel.h
3 // Purpose: wxTopLevelWindowMSW is the MSW implementation of wxTLW
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 20.09.01
7 // RCS-ID: $Id$
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MSW_TOPLEVEL_H_
13 #define _WX_MSW_TOPLEVEL_H_
14
15 // ----------------------------------------------------------------------------
16 // wxTopLevelWindowMSW
17 // ----------------------------------------------------------------------------
18
19 class WXDLLIMPEXP_CORE wxTopLevelWindowMSW : public wxTopLevelWindowBase
20 {
21 public:
22 // constructors and such
23 wxTopLevelWindowMSW() { Init(); }
24
25 wxTopLevelWindowMSW(wxWindow *parent,
26 wxWindowID id,
27 const wxString& title,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = wxDEFAULT_FRAME_STYLE,
31 const wxString& name = wxFrameNameStr)
32 {
33 Init();
34
35 (void)Create(parent, id, title, pos, size, style, name);
36 }
37
38 bool Create(wxWindow *parent,
39 wxWindowID id,
40 const wxString& title,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize,
43 long style = wxDEFAULT_FRAME_STYLE,
44 const wxString& name = wxFrameNameStr);
45
46 virtual ~wxTopLevelWindowMSW();
47
48 // implement base class pure virtuals
49 virtual void SetTitle( const wxString& title);
50 virtual wxString GetTitle() const;
51 virtual void Maximize(bool maximize = true);
52 virtual bool IsMaximized() const;
53 virtual void Iconize(bool iconize = true);
54 virtual bool IsIconized() const;
55 virtual void SetIcons(const wxIconBundle& icons );
56 virtual void Restore();
57
58 virtual void SetLayoutDirection(wxLayoutDirection dir);
59
60 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
61
62 virtual bool Show(bool show = true);
63 virtual void Raise();
64
65 virtual void ShowWithoutActivating();
66 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
67 virtual bool IsFullScreen() const { return m_fsIsShowing; }
68
69 // wxMSW only: EnableCloseButton(false) may be used to remove the "Close"
70 // button from the title bar
71 virtual bool EnableCloseButton(bool enable = true);
72
73 // Set window transparency if the platform supports it
74 virtual bool SetTransparent(wxByte alpha);
75 virtual bool CanSetTransparent();
76
77
78 // MSW-specific methods
79 // --------------------
80
81 // Return the menu representing the "system" menu of the window. You can
82 // call wxMenu::AppendWhatever() methods on it but removing items from it
83 // is in general not a good idea.
84 //
85 // The pointer returned by this method belongs to the window and will be
86 // deleted when the window itself is, do not delete it yourself. May return
87 // NULL if getting the system menu failed.
88 wxMenu *MSWGetSystemMenu() const;
89
90
91 // implementation from now on
92 // --------------------------
93
94 // event handlers
95 void OnActivate(wxActivateEvent& event);
96
97 // called by wxWindow whenever it gets focus
98 void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
99 wxWindow *GetLastFocus() const { return m_winLastFocused; }
100
101 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
102 virtual void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
103 virtual void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
104 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
105 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
106 #endif // __SMARTPHONE__ && __WXWINCE__
107
108 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
109 // Soft Input Panel (SIP) change notification
110 virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam);
111 #endif
112
113 // translate wxWidgets flags to Windows ones
114 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const;
115
116 // choose the right parent to use with CreateWindow()
117 virtual WXHWND MSWGetParent() const;
118
119 // window proc for the frames
120 WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
121
122 // returns true if the platform should explicitly apply a theme border
123 virtual bool CanApplyThemeBorder() const { return false; }
124
125 #if wxUSE_MENUS
126 bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu);
127
128 // handle WM_EXITMENULOOP message for Win95 only
129 bool HandleExitMenuLoop(WXWORD isPopup);
130
131 // handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE
132 bool HandleMenuPopup(wxEventType evtType, WXHMENU hMenu);
133
134 // Command part of HandleMenuPopup() and HandleExitMenuLoop().
135 bool DoSendMenuOpenCloseEvent(wxEventType evtType, wxMenu* menu, bool popup);
136
137 // Find the menu corresponding to the given handle.
138 virtual wxMenu* MSWFindMenuFromHMENU(WXHMENU hMenu);
139 #endif // wxUSE_MENUS
140
141 protected:
142 // common part of all ctors
143 void Init();
144
145 // create a new frame, return false if it couldn't be created
146 bool CreateFrame(const wxString& title,
147 const wxPoint& pos,
148 const wxSize& size);
149
150 // create a new dialog using the given dialog template from resources,
151 // return false if it couldn't be created
152 bool CreateDialog(const void *dlgTemplate,
153 const wxString& title,
154 const wxPoint& pos,
155 const wxSize& size);
156
157 // common part of Iconize(), Maximize() and Restore()
158 void DoShowWindow(int nShowCmd);
159
160 // override those to return the normal window coordinates even when the
161 // window is minimized
162 #ifndef __WXWINCE__
163 virtual void DoGetPosition(int *x, int *y) const;
164 virtual void DoGetSize(int *width, int *height) const;
165 #endif // __WXWINCE__
166
167 // Top level windows have different freeze semantics on Windows
168 virtual void DoFreeze();
169 virtual void DoThaw();
170
171 // helper of SetIcons(): calls gets the icon with the size specified by the
172 // given system metrics (SM_C{X|Y}[SM]ICON) from the bundle and sets it
173 // using WM_SETICON with the specified wParam (ICOM_SMALL or ICON_BIG);
174 // returns true if the icon was set
175 bool DoSelectAndSetIcon(const wxIconBundle& icons, int smX, int smY, int i);
176
177 // override wxWindow virtual method to use CW_USEDEFAULT if necessary
178 virtual void MSWGetCreateWindowCoords(const wxPoint& pos,
179 const wxSize& size,
180 int& x, int& y,
181 int& w, int& h) const;
182
183
184 // is the window currently iconized?
185 bool m_iconized;
186
187 // should the frame be maximized when it will be shown? set by Maximize()
188 // when it is called while the frame is hidden
189 bool m_maximizeOnShow;
190
191 // Data to save/restore when calling ShowFullScreen
192 long m_fsStyle; // Passed to ShowFullScreen
193 wxRect m_fsOldSize;
194 long m_fsOldWindowStyle;
195 bool m_fsIsMaximized;
196 bool m_fsIsShowing;
197
198 // Save the current focus to m_winLastFocused if we're not iconized (the
199 // focus is always NULL when we're iconized).
200 void DoSaveLastFocus();
201
202 // Restore focus to m_winLastFocused if possible and needed.
203 void DoRestoreLastFocus();
204
205 // The last focused child: we remember it when we're deactivated and
206 // restore focus to it when we're activated (this is done here) or restored
207 // from iconic state (done by wxFrame).
208 wxWindow *m_winLastFocused;
209
210 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
211 class ButtonMenu
212 {
213 public:
214 ButtonMenu();
215 ~ButtonMenu();
216
217 void SetButton(int id = wxID_ANY,
218 const wxString& label = wxEmptyString,
219 wxMenu *subMenu = NULL);
220
221 bool IsAssigned() const {return m_assigned;}
222 bool IsMenu() const {return m_menu!=NULL;}
223
224 int GetId() const {return m_id;}
225 wxMenu* GetMenu() const {return m_menu;}
226 wxString GetLabel() {return m_label;}
227
228 static wxMenu *DuplicateMenu(wxMenu *menu);
229
230 protected:
231 int m_id;
232 wxString m_label;
233 wxMenu *m_menu;
234 bool m_assigned;
235 };
236
237 ButtonMenu m_LeftButton;
238 ButtonMenu m_RightButton;
239 HWND m_MenuBarHWND;
240
241 void ReloadButton(ButtonMenu& button, UINT menuID);
242 void ReloadAllButtons();
243 #endif // __SMARTPHONE__ && __WXWINCE__
244
245 private:
246
247 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
248 void* m_activateInfo;
249 #endif
250
251 // The system menu: initially NULL but can be set (once) by
252 // MSWGetSystemMenu(). Owned by this window.
253 wxMenu *m_menuSystem;
254
255 // The number of currently opened menus: 0 initially, 1 when a top level
256 // menu is opened, 2 when its submenu is opened and so on.
257 int m_menuDepth;
258
259 DECLARE_EVENT_TABLE()
260 wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW);
261 };
262
263 #endif // _WX_MSW_TOPLEVEL_H_