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