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