Added wxFrame::MakeModal for MSW, (it's already there for GTK)
[wxWidgets.git] / include / wx / msw / frame.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: frame.h
3 // Purpose: wxFrame class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FRAME_H_
13 #define _WX_FRAME_H_
14
15 #ifdef __GNUG__
16 #pragma interface "frame.h"
17 #endif
18
19 #include "wx/window.h"
20 #include "wx/toolbar.h"
21 #include "wx/msw/accel.h"
22 #include "wx/icon.h"
23
24 WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
25 WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
26 WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
27
28 class WXDLLEXPORT wxMenuBar;
29 class WXDLLEXPORT wxStatusBar;
30
31 class WXDLLEXPORT wxFrame : public wxWindow
32 {
33 DECLARE_DYNAMIC_CLASS(wxFrame)
34
35 public:
36 wxFrame();
37 wxFrame(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 Create(parent, id, title, pos, size, style, name);
46 }
47
48 ~wxFrame();
49
50 bool Create(wxWindow *parent,
51 wxWindowID id,
52 const wxString& title,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = wxDEFAULT_FRAME_STYLE,
56 const wxString& name = wxFrameNameStr);
57
58 virtual bool Destroy();
59
60 virtual void ClientToScreen(int *x, int *y) const;
61 virtual void ScreenToClient(int *x, int *y) const;
62
63 void OnSize(wxSizeEvent& event);
64 void OnMenuHighlight(wxMenuEvent& event);
65 void OnActivate(wxActivateEvent& event);
66 void OnIdle(wxIdleEvent& event);
67 void OnCloseWindow(wxCloseEvent& event);
68
69 bool Show(bool show);
70
71 // Set menu bar
72 void SetMenuBar(wxMenuBar *menu_bar);
73 virtual wxMenuBar *GetMenuBar() const;
74
75 // Call this to simulate a menu command
76 bool Command(int id) { return ProcessCommand(id); }
77
78 // process menu command: returns TRUE if processed
79 bool ProcessCommand(int id);
80
81 // make the window modal (all other windows unresponsive)
82 virtual void MakeModal(bool modal = TRUE);
83
84 // Set icon
85 virtual void SetIcon(const wxIcon& icon);
86
87 // Toolbar
88 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
89 wxWindowID id = -1,
90 const wxString& name = wxToolBarNameStr);
91
92 virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
93
94 virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
95 virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
96
97 virtual void PositionToolBar();
98
99 // Status bar
100 virtual wxStatusBar* CreateStatusBar(int number = 1,
101 long style = wxST_SIZEGRIP,
102 wxWindowID id = 0,
103 const wxString& name = wxStatusLineNameStr);
104
105 wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
106 void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; }
107
108 virtual void PositionStatusBar();
109 virtual wxStatusBar *OnCreateStatusBar(int number,
110 long style,
111 wxWindowID id,
112 const wxString& name);
113
114 // Set status line text
115 virtual void SetStatusText(const wxString& text, int number = 0);
116
117 // Set status line widths
118 virtual void SetStatusWidths(int n, const int widths_field[]);
119
120 // Hint to tell framework which status bar to use
121 // TODO: should this go into a wxFrameworkSettings class perhaps?
122 static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
123 static bool UsesNativeStatusBar() { return m_useNativeStatusBar; };
124
125 // Iconize
126 virtual void Iconize(bool iconize);
127
128 virtual bool IsIconized() const;
129
130 // Is it maximized?
131 virtual bool IsMaximized() const;
132
133 // Compatibility
134 bool Iconized() const { return IsIconized(); }
135
136 virtual void Maximize(bool maximize);
137 // virtual bool LoadAccelerators(const wxString& table);
138
139 // Responds to colour changes
140 void OnSysColourChanged(wxSysColourChangedEvent& event);
141
142 // Query app for menu item updates (called from OnIdle)
143 void DoMenuUpdates();
144 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
145
146 WXHMENU GetWinMenu() const { return m_hMenu; }
147
148 // Returns the origin of client area (may be different from (0,0) if the
149 // frame has a toolbar)
150 virtual wxPoint GetClientAreaOrigin() const;
151
152 // Implementation only from here
153 // event handlers
154 bool HandlePaint();
155 bool HandleSize(int x, int y, WXUINT flag);
156 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
157 bool HandleMenuSelect(WXWORD nItem, WXWORD nFlags, WXHMENU hMenu);
158
159 bool MSWCreate(int id, wxWindow *parent, const char *wclass,
160 wxWindow *wx_win, const char *title,
161 int x, int y, int width, int height, long style);
162
163 // tooltip management
164 #if wxUSE_TOOLTIPS
165 WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
166 void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
167 #endif // tooltips
168
169 protected:
170 // override base class virtuals
171 virtual void DoGetClientSize(int *width, int *height) const;
172 virtual void DoGetSize(int *width, int *height) const;
173 virtual void DoGetPosition(int *x, int *y) const;
174
175 virtual void DoSetSize(int x, int y,
176 int width, int height,
177 int sizeFlags = wxSIZE_AUTO);
178 virtual void DoSetClientSize(int width, int height);
179
180 // a plug in for MDI frame classes which need to do something special when
181 // the menubar is set
182 virtual void InternalSetMenuBar();
183
184 // propagate our state change to all child frames
185 void IconizeChildFrames(bool bIconize);
186
187 // we add menu bar accel processing
188 bool MSWTranslateMessage(WXMSG* pMsg);
189
190 // window proc for the frames
191 long MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
192
193 wxMenuBar * m_frameMenuBar;
194 wxStatusBar * m_frameStatusBar;
195 wxIcon m_icon;
196 bool m_iconized;
197 WXHICON m_defaultIcon;
198 wxToolBar * m_frameToolBar;
199
200 static bool m_useNativeStatusBar;
201
202 private:
203 #if wxUSE_TOOLTIPS
204 WXHWND m_hwndToolTip;
205 #endif // tooltips
206
207 DECLARE_EVENT_TABLE()
208 };
209
210 #endif
211 // _WX_FRAME_H_