]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/toplevel.h
Applied patch [ 1263950 ] wxConnection fixes for Unicode
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "toplevel.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // wxTopLevelWindowMSW
21 // ----------------------------------------------------------------------------
22
23 class WXDLLEXPORT wxTopLevelWindowMSW : public wxTopLevelWindowBase
24 {
25 public:
26 // constructors and such
27 wxTopLevelWindowMSW() { Init(); }
28
29 wxTopLevelWindowMSW(wxWindow *parent,
30 wxWindowID id,
31 const wxString& title,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = wxDEFAULT_FRAME_STYLE,
35 const wxString& name = wxFrameNameStr)
36 {
37 Init();
38
39 (void)Create(parent, id, title, pos, size, style, name);
40 }
41
42 bool Create(wxWindow *parent,
43 wxWindowID id,
44 const wxString& title,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = wxDEFAULT_FRAME_STYLE,
48 const wxString& name = wxFrameNameStr);
49
50 virtual ~wxTopLevelWindowMSW();
51
52 // implement base class pure virtuals
53 virtual void Maximize(bool maximize = true);
54 virtual bool IsMaximized() const;
55 virtual void Iconize(bool iconize = true);
56 virtual bool IsIconized() const;
57 virtual void SetIcon(const wxIcon& icon);
58 virtual void SetIcons(const wxIconBundle& icons );
59 virtual void Restore();
60
61 #ifndef __WXWINCE__
62 virtual bool SetShape(const wxRegion& region);
63 #endif // __WXWINCE__
64 virtual void RequestUserAttention(int flags = wxUSER_ATTENTION_INFO);
65
66 virtual bool Show(bool show = true);
67
68 virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
69 virtual bool IsFullScreen() const { return m_fsIsShowing; }
70
71 // wxMSW only: EnableCloseButton(false) may be used to remove the "Close"
72 // button from the title bar
73 bool EnableCloseButton(bool enable = true);
74
75 // implementation from now on
76 // --------------------------
77
78 // event handlers
79 void OnActivate(wxActivateEvent& event);
80
81 // called by wxWindow whenever it gets focus
82 void SetLastFocus(wxWindow *win) { m_winLastFocused = win; }
83 wxWindow *GetLastFocus() const { return m_winLastFocused; }
84
85 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
86 virtual void SetLeftMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
87 virtual void SetRightMenu(int id = wxID_ANY, const wxString& label = wxEmptyString, wxMenu *subMenu = NULL);
88 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
89 #endif // __SMARTPHONE__ && __WXWINCE__
90
91 protected:
92 // common part of all ctors
93 void Init();
94
95 // create a new frame, return false if it couldn't be created
96 bool CreateFrame(const wxString& title,
97 const wxPoint& pos,
98 const wxSize& size);
99
100 // create a new dialog using the given dialog template from resources,
101 // return false if it couldn't be created
102 bool CreateDialog(const void *dlgTemplate,
103 const wxString& title,
104 const wxPoint& pos,
105 const wxSize& size);
106
107 // common part of Iconize(), Maximize() and Restore()
108 void DoShowWindow(int nShowCmd);
109
110 // translate wxWidgets flags to Windows ones
111 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle) const;
112
113 // choose the right parent to use with CreateWindow()
114 virtual WXHWND MSWGetParent() const;
115
116 // is the window currently iconized?
117 bool m_iconized;
118
119 // should the frame be maximized when it will be shown? set by Maximize()
120 // when it is called while the frame is hidden
121 bool m_maximizeOnShow;
122
123 // Data to save/restore when calling ShowFullScreen
124 long m_fsStyle; // Passed to ShowFullScreen
125 wxRect m_fsOldSize;
126 long m_fsOldWindowStyle;
127 bool m_fsIsMaximized;
128 bool m_fsIsShowing;
129
130 // the last focused child: we restore focus to it on activation
131 wxWindow *m_winLastFocused;
132
133 #if defined(__SMARTPHONE__) && defined(__WXWINCE__)
134 class ButtonMenu
135 {
136 public:
137 ButtonMenu();
138 ~ButtonMenu();
139
140 void SetButton(int id = wxID_ANY,
141 const wxString& label = wxEmptyString,
142 wxMenu *subMenu = NULL);
143
144 bool IsAssigned() const {return m_assigned;}
145 bool IsMenu() const {return m_menu!=NULL;}
146
147 int GetId() const {return m_id;}
148 wxMenu* GetMenu() const {return m_menu;}
149 wxString GetLabel() {return m_label;}
150
151 static wxMenu *DuplicateMenu(wxMenu *menu);
152
153 protected:
154 int m_id;
155 wxString m_label;
156 wxMenu *m_menu;
157 bool m_assigned;
158 };
159
160 ButtonMenu m_LeftButton;
161 ButtonMenu m_RightButton;
162 HWND m_MenuBarHWND;
163
164 void ReloadButton(ButtonMenu& button, UINT menuID);
165 void ReloadAllButtons();
166 #endif // __SMARTPHONE__ && __WXWINCE__
167
168 DECLARE_EVENT_TABLE()
169 DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW)
170 };
171
172 #endif // _WX_MSW_TOPLEVEL_H_
173