]>
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 | ||
23 | WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; | |
24 | WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; | |
25 | WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr; | |
26 | ||
27 | class WXDLLEXPORT wxMenuBar; | |
28 | class WXDLLEXPORT wxStatusBar; | |
29 | ||
30 | class WXDLLEXPORT wxFrame : public wxWindow | |
31 | { | |
32 | DECLARE_DYNAMIC_CLASS(wxFrame) | |
33 | ||
34 | public: | |
35 | wxFrame(); | |
36 | wxFrame(wxWindow *parent, | |
37 | wxWindowID id, | |
38 | const wxString& title, | |
39 | const wxPoint& pos = wxDefaultPosition, | |
40 | const wxSize& size = wxDefaultSize, | |
41 | long style = wxDEFAULT_FRAME_STYLE, | |
42 | const wxString& name = wxFrameNameStr) | |
43 | { | |
44 | Create(parent, id, title, pos, size, style, name); | |
45 | } | |
46 | ||
47 | ~wxFrame(); | |
48 | ||
49 | bool Create(wxWindow *parent, | |
50 | wxWindowID id, | |
51 | const wxString& title, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = wxDEFAULT_FRAME_STYLE, | |
55 | const wxString& name = wxFrameNameStr); | |
56 | ||
57 | virtual bool Destroy(); | |
58 | ||
59 | void GetClientSize(int *width, int *height) const; | |
60 | void GetSize(int *width, int *height) const ; | |
61 | void GetPosition(int *x, int *y) const ; | |
62 | ||
63 | wxSize GetSize() const { return wxWindow::GetSize(); } | |
64 | wxPoint GetPosition() const { return wxWindow::GetPosition(); } | |
65 | wxSize GetClientSize() const { return wxWindow::GetClientSize(); } | |
66 | wxRect GetClientRect() const { return wxWindow::GetClientRect(); } | |
67 | ||
68 | virtual void ClientToScreen(int *x, int *y) const; | |
69 | virtual void ScreenToClient(int *x, int *y) const; | |
70 | ||
71 | void OnSize(wxSizeEvent& event); | |
72 | void OnMenuHighlight(wxMenuEvent& event); | |
73 | void OnActivate(wxActivateEvent& event); | |
74 | void OnIdle(wxIdleEvent& event); | |
75 | void OnCloseWindow(wxCloseEvent& event); | |
76 | ||
77 | bool Show(bool show); | |
78 | ||
79 | // Set menu bar | |
80 | void SetMenuBar(wxMenuBar *menu_bar); | |
81 | virtual wxMenuBar *GetMenuBar() const ; | |
82 | ||
83 | // Set title | |
84 | void SetTitle(const wxString& title); | |
85 | wxString GetTitle() const ; | |
86 | ||
87 | void Centre(int direction = wxBOTH); | |
88 | ||
89 | // Call this to simulate a menu command | |
90 | virtual void Command(int id); | |
91 | virtual void ProcessCommand(int id); | |
92 | ||
93 | // Set icon | |
94 | virtual void SetIcon(const wxIcon& icon); | |
95 | ||
96 | // Toolbar | |
97 | virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT, | |
98 | wxWindowID id = -1, | |
99 | const wxString& name = wxToolBarNameStr); | |
100 | ||
101 | virtual wxToolBar *OnCreateToolBar(long style, wxWindowID id, const wxString& name); | |
102 | ||
103 | virtual void SetToolBar(wxToolBar *toolbar) { m_frameToolBar = toolbar; } | |
104 | virtual wxToolBar *GetToolBar() const { return m_frameToolBar; } | |
105 | ||
106 | virtual void PositionToolBar(); | |
107 | ||
108 | // Status bar | |
109 | virtual wxStatusBar* CreateStatusBar(int number = 1, | |
110 | long style = wxST_SIZEGRIP, | |
111 | wxWindowID id = 0, | |
112 | const wxString& name = wxStatusLineNameStr); | |
113 | ||
114 | wxStatusBar *GetStatusBar() const { return m_frameStatusBar; } | |
115 | void SetStatusBar(wxStatusBar *statusBar) { m_frameStatusBar = statusBar; } | |
116 | ||
117 | virtual void PositionStatusBar(); | |
118 | virtual wxStatusBar *OnCreateStatusBar(int number, | |
119 | long style, | |
120 | wxWindowID id, | |
121 | const wxString& name); | |
122 | ||
123 | // Set status line text | |
124 | virtual void SetStatusText(const wxString& text, int number = 0); | |
125 | ||
126 | // Set status line widths | |
127 | virtual void SetStatusWidths(int n, const int widths_field[]); | |
128 | ||
129 | // Hint to tell framework which status bar to use | |
130 | // TODO: should this go into a wxFrameworkSettings class perhaps? | |
131 | static void UseNativeStatusBar(bool useNative) { m_useNativeStatusBar = useNative; }; | |
132 | static bool UsesNativeStatusBar() { return m_useNativeStatusBar; }; | |
133 | ||
134 | // Fit frame around subwindows | |
135 | virtual void Fit(); | |
136 | ||
137 | // Iconize | |
138 | virtual void Iconize(bool iconize); | |
139 | ||
140 | virtual bool IsIconized() const ; | |
141 | ||
142 | // Is it maximized? | |
143 | virtual bool IsMaximized() const ; | |
144 | ||
145 | // Compatibility | |
146 | bool Iconized() const { return IsIconized(); } | |
147 | ||
148 | virtual void Maximize(bool maximize); | |
149 | // virtual bool LoadAccelerators(const wxString& table); | |
150 | ||
151 | // Responds to colour changes | |
152 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
153 | ||
154 | // Query app for menu item updates (called from OnIdle) | |
155 | void DoMenuUpdates(); | |
156 | void DoMenuUpdates(wxMenu* menu); | |
157 | ||
158 | WXHMENU GetWinMenu() const ; | |
159 | ||
160 | // Returns the origin of client area (may be different from (0,0) if the | |
161 | // frame has a toolbar) | |
162 | virtual wxPoint GetClientAreaOrigin() const; | |
163 | ||
164 | // Implementation only from here | |
165 | // event handlers | |
166 | bool MSWOnPaint(); | |
167 | WXHICON MSWOnQueryDragIcon(); | |
168 | void MSWOnSize(int x, int y, WXUINT flag); | |
169 | bool MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control); | |
170 | bool MSWOnClose(); | |
171 | void MSWOnMenuHighlight(WXWORD item, WXWORD flags, WXHMENU sysmenu); | |
172 | bool MSWProcessMessage(WXMSG *msg); | |
173 | bool MSWTranslateMessage(WXMSG *msg); | |
174 | void MSWCreate(int id, wxWindow *parent, const char *wclass, | |
175 | wxWindow *wx_win, const char *title, | |
176 | int x, int y, int width, int height, long style); | |
177 | ||
178 | // tooltip management | |
179 | #if wxUSE_TOOLTIPS | |
180 | WXHWND GetToolTipCtrl() const { return m_hwndToolTip; } | |
181 | void SetToolTipCtrl(WXHWND hwndTT) { m_hwndToolTip = hwndTT; } | |
182 | #endif // tooltips | |
183 | ||
184 | protected: | |
185 | // propagate our state change to all child frames | |
186 | void IconizeChildFrames(bool bIconize); | |
187 | ||
188 | wxMenuBar * m_frameMenuBar; | |
189 | wxStatusBar * m_frameStatusBar; | |
190 | wxIcon m_icon; | |
191 | bool m_iconized; | |
192 | WXHICON m_defaultIcon; | |
193 | wxToolBar * m_frameToolBar ; | |
194 | ||
195 | static bool m_useNativeStatusBar; | |
196 | ||
197 | #if wxUSE_TOOLTIPS | |
198 | WXHWND m_hwndToolTip; | |
199 | #endif // tooltips | |
200 | ||
201 | virtual void DoSetSize(int x, int y, | |
202 | int width, int height, | |
203 | int sizeFlags = wxSIZE_AUTO); | |
204 | virtual void DoSetClientSize(int width, int height); | |
205 | ||
206 | private: | |
207 | DECLARE_EVENT_TABLE() | |
208 | }; | |
209 | ||
210 | #endif | |
211 | // _WX_FRAME_H_ |