]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/toplevel.h
XRC: make wxSplitterWindow's sashpos and minpanesize dimensions.
[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 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_MSW_TOPLEVEL_H_
12 #define _WX_MSW_TOPLEVEL_H_
13
14 // ----------------------------------------------------------------------------
15 // wxTopLevelWindowMSW
16 // ----------------------------------------------------------------------------
17
18 class WXDLLIMPEXP_CORE wxTopLevelWindowMSW : public wxTopLevelWindowBase
19 {
20 public:
21 // constructors and such
22 wxTopLevelWindowMSW() { Init(); }
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,
30 const wxString& name = wxFrameNameStr)
31 {
32 Init();
33
34 (void)Create(parent, id, title, pos, size, style, name);
35 }
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
48 virtual void SetTitle( const wxString& title);
49 virtual wxString GetTitle() const;
50 virtual void Maximize(bool maximize = true);
51 virtual bool IsMaximized() const;
52 virtual void Iconize(bool iconize = true);
53 virtual bool IsIconized() const;
54 virtual void SetIcons(const wxIconBundle& icons );
55 virtual void Restore();
56
57 virtual void SetLayoutDirection(wxLayoutDirection dir);
58
59 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
60
61 virtual bool Show(bool show = true);
62 virtual void Raise();
63
64 virtual void ShowWithoutActivating();
65 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
66 virtual bool IsFullScreen() const { return m_fsIsShowing; }
67
68 // wxMSW only: EnableCloseButton(false) may be used to remove the "Close"
69 // button from the title bar
70 virtual bool EnableCloseButton(bool enable = true);
71
72 // Set window transparency if the platform supports it
73 virtual bool SetTransparent(wxByte alpha);
74 virtual bool CanSetTransparent();
75
76
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
90 // implementation from now on
91 // --------------------------
92
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
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);
103 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
104 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
105 #endif // __SMARTPHONE__ && __WXWINCE__
106
107 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
108 // Soft Input Panel (SIP) change notification
109 virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam);
110 #endif
111
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
121 // returns true if the platform should explicitly apply a theme border
122 virtual bool CanApplyThemeBorder() const { return false; }
123
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
140 protected:
141 // common part of all ctors
142 void Init();
143
144 // create a new frame, return false if it couldn't be created
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,
150 // return false if it couldn't be created
151 bool CreateDialog(const void *dlgTemplate,
152 const wxString& title,
153 const wxPoint& pos,
154 const wxSize& size);
155
156 // common part of Iconize(), Maximize() and Restore()
157 void DoShowWindow(int nShowCmd);
158
159 // override those to return the normal window coordinates even when the
160 // window is minimized
161 #ifndef __WXWINCE__
162 virtual void DoGetPosition(int *x, int *y) const;
163 virtual void DoGetSize(int *width, int *height) const;
164 #endif // __WXWINCE__
165
166 // Top level windows have different freeze semantics on Windows
167 virtual void DoFreeze();
168 virtual void DoThaw();
169
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
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);
175
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
182
183 // is the window currently iconized?
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;
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;
196
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).
207 wxWindow *m_winLastFocused;
208
209 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
210 class ButtonMenu
211 {
212 public:
213 ButtonMenu();
214 ~ButtonMenu();
215
216 void SetButton(int id = wxID_ANY,
217 const wxString& label = wxEmptyString,
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();
242 #endif // __SMARTPHONE__ && __WXWINCE__
243
244 private:
245
246 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
247 void* m_activateInfo;
248 #endif
249
250 // The system menu: initially NULL but can be set (once) by
251 // MSWGetSystemMenu(). Owned by this window.
252 wxMenu *m_menuSystem;
253
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
258 DECLARE_EVENT_TABLE()
259 wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW);
260 };
261
262 #endif // _WX_MSW_TOPLEVEL_H_