wxWindow split (MSW part of changes)
[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 // Set title
76 void SetTitle(const wxString& title);
77 wxString GetTitle() const ;
78
79 void Centre(int direction = wxBOTH);
80
81 // Call this to simulate a menu command
82 virtual void Command(int id);
83 virtual void ProcessCommand(int id);
84
85 // Set icon
86 virtual void SetIcon(const wxIcon& icon);
87
88 // Toolbar
89 virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT,
90 wxWindowID id = -1,
91 const wxString& name = wxToolBarNameStr);
92
93 virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name);
94
95 virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; }
96 virtual wxToolBar *GetToolBar() const { return m_frameToolBar; }
97
98 virtual void PositionToolBar();
99
100 // Status bar
101 virtual wxStatusBar* CreateStatusBar(int number = 1,
102 long style = wxST_SIZEGRIP,
103 wxWindowID id = 0,
104 const wxString& name = wxStatusLineNameStr);
105
106 wxStatusBar *GetStatusBar() const { return m_frameStatusBar; }
107 void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; }
108
109 virtual void PositionStatusBar();
110 virtual wxStatusBar *OnCreateStatusBar(int number,
111 long style,
112 wxWindowID id,
113 const wxString& name);
114
115 // Set status line text
116 virtual void SetStatusText(const wxString& text, int number = 0);
117
118 // Set status line widths
119 virtual void SetStatusWidths(int n, const int widths_field[]);
120
121 // Hint to tell framework which status bar to use
122 // TODO: should this go into a wxFrameworkSettings class perhaps?
123 static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; };
124 static bool UsesNativeStatusBar() { return m_useNativeStatusBar; };
125
126 // Fit frame around subwindows
127 virtual void Fit();
128
129 // Iconize
130 virtual void Iconize(bool iconize);
131
132 virtual bool IsIconized() const ;
133
134 // Is it maximized?
135 virtual bool IsMaximized() const ;
136
137 // Compatibility
138 bool Iconized() const { return IsIconized(); }
139
140 virtual void Maximize(bool maximize);
141 // virtual bool LoadAccelerators(const wxString& table);
142
143 // Responds to colour changes
144 void OnSysColourChanged(wxSysColourChangedEvent& event);
145
146 // Query app for menu item updates (called from OnIdle)
147 void DoMenuUpdates();
148 void DoMenuUpdates(wxMenu* menu, wxWindow* focusWin);
149
150 WXHMENU GetWinMenu() const ;
151
152 // Returns the origin of client area (may be different from (0,0) if the
153 // frame has a toolbar)
154 virtual wxPoint GetClientAreaOrigin() const;
155
156 // Implementation only from here
157 // event handlers
158 bool MSWOnPaint();
159 WXHICON MSWOnQueryDragIcon();
160 void MSWOnSize(int x, int y, WXUINT flag);
161 bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control);
162 bool MSWOnClose();
163 void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu);
164 bool MSWProcessMessage(WXMSG *msg);
165 bool MSWTranslateMessage(WXMSG *msg);
166 void MSWCreate(int id, wxWindow *parent, const char *wclass,
167 wxWindow *wx_win, const char *title,
168 int x, int y, int width, int height, long style);
169
170 // tooltip management
171 #if wxUSE_TOOLTIPS
172 WXHWND GetToolTipCtrl() const { return m_hwndToolTip; }
173 void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; }
174 #endif // tooltips
175
176 protected:
177 void DoGetClientSize(int *width, int *height) const;
178 void DoGetSize(int *width, int *height) const ;
179 void DoGetPosition(int *x, int *y) const ;
180
181 // propagate our state change to all child frames
182 void IconizeChildFrames(bool bIconize);
183
184 wxMenuBar * m_frameMenuBar;
185 wxStatusBar * m_frameStatusBar;
186 wxIcon m_icon;
187 bool m_iconized;
188 WXHICON m_defaultIcon;
189 wxToolBar * m_frameToolBar ;
190
191 static bool m_useNativeStatusBar;
192
193 #if wxUSE_TOOLTIPS
194 WXHWND m_hwndToolTip;
195 #endif // tooltips
196
197 virtual void DoSetSize(int x, int y,
198 int width, int height,
199 int sizeFlags = wxSIZE_AUTO);
200 virtual void DoSetClientSize(int width, int height);
201
202 private:
203 DECLARE_EVENT_TABLE()
204 };
205
206 #endif
207 // _WX_FRAME_H_