1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/toplevel.h
3 // Purpose: wxTopLevelWindowMSW is the MSW implementation of wxTLW
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_MSW_TOPLEVEL_H_
12 #define _WX_MSW_TOPLEVEL_H_
14 // ----------------------------------------------------------------------------
15 // wxTopLevelWindowMSW
16 // ----------------------------------------------------------------------------
18 class WXDLLIMPEXP_CORE wxTopLevelWindowMSW
: public wxTopLevelWindowBase
21 // constructors and such
22 wxTopLevelWindowMSW() { Init(); }
24 wxTopLevelWindowMSW(wxWindow
*parent
,
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
)
34 (void)Create(parent
, id
, title
, pos
, size
, style
, name
);
37 bool Create(wxWindow
*parent
,
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
);
45 virtual ~wxTopLevelWindowMSW();
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();
57 virtual void SetLayoutDirection(wxLayoutDirection dir
);
59 virtual void RequestUserAttention(int flags
= wxUSER_ATTENTION_INFO
);
61 virtual bool Show(bool show
= true);
64 virtual void ShowWithoutActivating();
65 virtual bool ShowFullScreen(bool show
, long style
= wxFULLSCREEN_ALL
);
66 virtual bool IsFullScreen() const { return m_fsIsShowing
; }
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);
72 // Set window transparency if the platform supports it
73 virtual bool SetTransparent(wxByte alpha
);
74 virtual bool CanSetTransparent();
77 // MSW-specific methods
78 // --------------------
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.
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;
90 // implementation from now on
91 // --------------------------
94 void OnActivate(wxActivateEvent
& event
);
96 // called by wxWindow whenever it gets focus
97 void SetLastFocus(wxWindow
*win
) { m_winLastFocused
= win
; }
98 wxWindow
*GetLastFocus() const { return m_winLastFocused
; }
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__
107 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
108 // Soft Input Panel (SIP) change notification
109 virtual bool HandleSettingChange(WXWPARAM wParam
, WXLPARAM lParam
);
112 // translate wxWidgets flags to Windows ones
113 virtual WXDWORD
MSWGetStyle(long flags
, WXDWORD
*exstyle
) const;
115 // choose the right parent to use with CreateWindow()
116 virtual WXHWND
MSWGetParent() const;
118 // window proc for the frames
119 WXLRESULT
MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
121 // returns true if the platform should explicitly apply a theme border
122 virtual bool CanApplyThemeBorder() const { return false; }
125 bool HandleMenuSelect(WXWORD nItem
, WXWORD nFlags
, WXHMENU hMenu
);
127 // handle WM_EXITMENULOOP message for Win95 only
128 bool HandleExitMenuLoop(WXWORD isPopup
);
130 // handle WM_(UN)INITMENUPOPUP message to generate wxEVT_MENU_OPEN/CLOSE
131 bool HandleMenuPopup(wxEventType evtType
, WXHMENU hMenu
);
133 // Command part of HandleMenuPopup() and HandleExitMenuLoop().
134 bool DoSendMenuOpenCloseEvent(wxEventType evtType
, wxMenu
* menu
, bool popup
);
136 // Find the menu corresponding to the given handle.
137 virtual wxMenu
* MSWFindMenuFromHMENU(WXHMENU hMenu
);
138 #endif // wxUSE_MENUS
141 // common part of all ctors
144 // create a new frame, return false if it couldn't be created
145 bool CreateFrame(const wxString
& title
,
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
,
156 // common part of Iconize(), Maximize() and Restore()
157 void DoShowWindow(int nShowCmd
);
159 // override those to return the normal window coordinates even when the
160 // window is minimized
162 virtual void DoGetPosition(int *x
, int *y
) const;
163 virtual void DoGetSize(int *width
, int *height
) const;
164 #endif // __WXWINCE__
166 // Top level windows have different freeze semantics on Windows
167 virtual void DoFreeze();
168 virtual void DoThaw();
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
);
176 // override wxWindow virtual method to use CW_USEDEFAULT if necessary
177 virtual void MSWGetCreateWindowCoords(const wxPoint
& pos
,
180 int& w
, int& h
) const;
183 // is the window currently iconized?
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
;
190 // Data to save/restore when calling ShowFullScreen
191 long m_fsStyle
; // Passed to ShowFullScreen
193 long m_fsOldWindowStyle
;
194 bool m_fsIsMaximized
;
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();
201 // Restore focus to m_winLastFocused if possible and needed.
202 void DoRestoreLastFocus();
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
;
209 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
216 void SetButton(int id
= wxID_ANY
,
217 const wxString
& label
= wxEmptyString
,
218 wxMenu
*subMenu
= NULL
);
220 bool IsAssigned() const {return m_assigned
;}
221 bool IsMenu() const {return m_menu
!=NULL
;}
223 int GetId() const {return m_id
;}
224 wxMenu
* GetMenu() const {return m_menu
;}
225 wxString
GetLabel() {return m_label
;}
227 static wxMenu
*DuplicateMenu(wxMenu
*menu
);
236 ButtonMenu m_LeftButton
;
237 ButtonMenu m_RightButton
;
240 void ReloadButton(ButtonMenu
& button
, UINT menuID
);
241 void ReloadAllButtons();
242 #endif // __SMARTPHONE__ && __WXWINCE__
246 #if defined(__SMARTPHONE__) || defined(__POCKETPC__)
247 void* m_activateInfo
;
250 // The system menu: initially NULL but can be set (once) by
251 // MSWGetSystemMenu(). Owned by this window.
252 wxMenu
*m_menuSystem
;
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.
258 DECLARE_EVENT_TABLE()
259 wxDECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW
);
262 #endif // _WX_MSW_TOPLEVEL_H_