]>
Commit | Line | Data |
---|---|---|
ffecfa5a | 1 | ///////////////////////////////////////////////////////////////////////////// |
e2731512 | 2 | // Name: src/palmos/frame.cpp |
ffecfa5a | 3 | // Purpose: wxFrame |
e2731512 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
db101bd3 | 5 | // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality |
ffecfa5a | 6 | // Created: 10/13/04 |
e2731512 | 7 | // RCS-ID: $Id$ |
db101bd3 | 8 | // Copyright: (c) William Osborne, Wlodzimierz Skiba |
ffecfa5a JS |
9 | // Licence: wxWindows licence |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
ffecfa5a JS |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
24 | #pragma hdrstop | |
25 | #endif | |
26 | ||
e4db172a WS |
27 | #include "wx/frame.h" |
28 | ||
ffecfa5a | 29 | #ifndef WX_PRECOMP |
ffecfa5a JS |
30 | #include "wx/app.h" |
31 | #include "wx/menu.h" | |
32 | #include "wx/utils.h" | |
33 | #include "wx/dialog.h" | |
34 | #include "wx/settings.h" | |
35 | #include "wx/dcclient.h" | |
36 | #include "wx/mdi.h" | |
37 | #include "wx/panel.h" | |
e4db172a | 38 | #include "wx/log.h" |
4e3e485b | 39 | #include "wx/toolbar.h" |
3304646d | 40 | #include "wx/statusbr.h" |
ffecfa5a JS |
41 | #endif // WX_PRECOMP |
42 | ||
3304646d | 43 | #include "wx/generic/statusbr.h" |
ffecfa5a | 44 | |
ffecfa5a | 45 | #include "wx/menuitem.h" |
ffecfa5a JS |
46 | |
47 | #ifdef __WXUNIVERSAL__ | |
48 | #include "wx/univ/theme.h" | |
49 | #include "wx/univ/colschem.h" | |
50 | #endif // __WXUNIVERSAL__ | |
51 | ||
20bc5ad8 WS |
52 | #include <Event.h> |
53 | #include <Form.h> | |
54 | ||
ffecfa5a JS |
55 | // ---------------------------------------------------------------------------- |
56 | // globals | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
59 | #if wxUSE_MENUS_NATIVE | |
60 | extern wxMenu *wxCurrentPopupMenu; | |
61 | #endif // wxUSE_MENUS_NATIVE | |
62 | ||
63 | // ---------------------------------------------------------------------------- | |
64 | // event tables | |
65 | // ---------------------------------------------------------------------------- | |
66 | ||
67 | BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) | |
9b5d7dfc | 68 | EVT_PAINT(wxFrame::OnPaint) |
ffecfa5a JS |
69 | END_EVENT_TABLE() |
70 | ||
71 | #if wxUSE_EXTENDED_RTTI | |
72 | WX_DEFINE_FLAGS( wxFrameStyle ) | |
73 | ||
74 | wxBEGIN_FLAGS( wxFrameStyle ) | |
75 | // new style border flags, we put them first to | |
76 | // use them for streaming out | |
77 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) | |
78 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
79 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
80 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
81 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
82 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
9b5d7dfc | 83 | |
ffecfa5a JS |
84 | // old style border flags |
85 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) | |
86 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
87 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
88 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
89 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
90 | wxFLAGS_MEMBER(wxBORDER) | |
91 | ||
92 | // standard window styles | |
93 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) | |
94 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
95 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
96 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
97 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) | |
98 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
99 | wxFLAGS_MEMBER(wxVSCROLL) | |
100 | wxFLAGS_MEMBER(wxHSCROLL) | |
101 | ||
102 | // frame styles | |
103 | wxFLAGS_MEMBER(wxSTAY_ON_TOP) | |
104 | wxFLAGS_MEMBER(wxCAPTION) | |
1c067fe3 | 105 | #if WXWIN_COMPATIBILITY_2_6 |
ffecfa5a | 106 | wxFLAGS_MEMBER(wxTHICK_FRAME) |
1c067fe3 | 107 | #endif // WXWIN_COMPATIBILITY_2_6 |
ffecfa5a JS |
108 | wxFLAGS_MEMBER(wxSYSTEM_MENU) |
109 | wxFLAGS_MEMBER(wxRESIZE_BORDER) | |
1c067fe3 | 110 | #if WXWIN_COMPATIBILITY_2_6 |
ffecfa5a | 111 | wxFLAGS_MEMBER(wxRESIZE_BOX) |
1c067fe3 | 112 | #endif // WXWIN_COMPATIBILITY_2_6 |
ffecfa5a JS |
113 | wxFLAGS_MEMBER(wxCLOSE_BOX) |
114 | wxFLAGS_MEMBER(wxMAXIMIZE_BOX) | |
115 | wxFLAGS_MEMBER(wxMINIMIZE_BOX) | |
116 | ||
117 | wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW) | |
118 | wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT) | |
119 | ||
120 | wxFLAGS_MEMBER(wxFRAME_SHAPED) | |
121 | ||
122 | wxEND_FLAGS( wxFrameStyle ) | |
123 | ||
124 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h") | |
125 | ||
126 | wxBEGIN_PROPERTIES_TABLE(wxFrame) | |
127 | wxEVENT_PROPERTY( Menu , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent) | |
128 | ||
129 | wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
130 | wxPROPERTY_FLAGS( WindowStyle , wxFrameStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style | |
131 | wxPROPERTY( MenuBar , wxMenuBar * , SetMenuBar , GetMenuBar , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
132 | wxEND_PROPERTIES_TABLE() | |
133 | ||
134 | wxBEGIN_HANDLERS_TABLE(wxFrame) | |
135 | wxEND_HANDLERS_TABLE() | |
136 | ||
9b5d7dfc | 137 | wxCONSTRUCTOR_6( wxFrame , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle) |
ffecfa5a JS |
138 | |
139 | #else | |
140 | IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) | |
141 | #endif | |
142 | ||
143 | // ============================================================================ | |
144 | // implementation | |
145 | // ============================================================================ | |
146 | ||
ffecfa5a JS |
147 | // ---------------------------------------------------------------------------- |
148 | // creation/destruction | |
149 | // ---------------------------------------------------------------------------- | |
150 | ||
151 | void wxFrame::Init() | |
152 | { | |
ffecfa5a JS |
153 | } |
154 | ||
155 | bool wxFrame::Create(wxWindow *parent, | |
156 | wxWindowID id, | |
157 | const wxString& title, | |
158 | const wxPoint& pos, | |
159 | const wxSize& size, | |
160 | long style, | |
161 | const wxString& name) | |
162 | { | |
db101bd3 | 163 | if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) |
ffecfa5a | 164 | return false; |
9b5d7dfc | 165 | |
ffecfa5a JS |
166 | return true; |
167 | } | |
168 | ||
169 | wxFrame::~wxFrame() | |
170 | { | |
171 | } | |
172 | ||
173 | // ---------------------------------------------------------------------------- | |
174 | // wxFrame client size calculations | |
175 | // ---------------------------------------------------------------------------- | |
176 | ||
177 | void wxFrame::DoSetClientSize(int width, int height) | |
178 | { | |
179 | } | |
180 | ||
181 | // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. | |
182 | void wxFrame::DoGetClientSize(int *x, int *y) const | |
183 | { | |
be4e4e27 WS |
184 | wxSize size = GetSize(); |
185 | wxPoint pos = GetClientAreaOrigin(); | |
186 | *x = size.x - pos.x - 1; | |
187 | *y = size.y - pos.y - 1; | |
ffecfa5a JS |
188 | } |
189 | ||
190 | // ---------------------------------------------------------------------------- | |
191 | // wxFrame: various geometry-related functions | |
192 | // ---------------------------------------------------------------------------- | |
193 | ||
194 | void wxFrame::Raise() | |
195 | { | |
196 | } | |
197 | ||
ffecfa5a JS |
198 | #if wxUSE_MENUS_NATIVE |
199 | ||
ffecfa5a JS |
200 | void wxFrame::InternalSetMenuBar() |
201 | { | |
202 | } | |
203 | ||
204 | bool wxFrame::HandleMenuOpen() | |
205 | { | |
206 | if(!m_frameMenuBar) | |
207 | return false; | |
9b5d7dfc | 208 | |
ffecfa5a JS |
209 | m_frameMenuBar->LoadMenu(); |
210 | return true; | |
211 | } | |
212 | ||
20bc5ad8 | 213 | bool wxFrame::HandleMenuSelect(WXEVENTPTR event) |
ffecfa5a | 214 | { |
20bc5ad8 WS |
215 | const EventType *palmEvent = (EventType *)event; |
216 | const int ItemID = palmEvent->data.menu.itemID; | |
a152561c | 217 | |
ffecfa5a JS |
218 | if (!m_frameMenuBar) |
219 | return false; | |
220 | ||
20bc5ad8 WS |
221 | const int item = m_frameMenuBar->ProcessCommand(ItemID); |
222 | if (item==-1) | |
ffecfa5a JS |
223 | return false; |
224 | ||
225 | wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item); | |
226 | commandEvent.SetEventObject(this); | |
9b5d7dfc | 227 | |
ffecfa5a | 228 | GetEventHandler()->ProcessEvent(commandEvent); |
9b5d7dfc | 229 | return true; |
ffecfa5a JS |
230 | } |
231 | ||
232 | #endif // wxUSE_MENUS_NATIVE | |
233 | ||
ffecfa5a JS |
234 | void wxFrame::OnPaint(wxPaintEvent& event) |
235 | { | |
9b5d7dfc VZ |
236 | #if wxUSE_STATUSBAR |
237 | if( m_frameStatusBar ) | |
238 | m_frameStatusBar->DrawStatusBar(); | |
239 | #endif // wxUSE_STATUSBAR | |
ffecfa5a | 240 | } |
9b5d7dfc | 241 | |
db101bd3 | 242 | // Pass true to show full screen, false to restore. |
ffecfa5a JS |
243 | bool wxFrame::ShowFullScreen(bool show, long style) |
244 | { | |
245 | return false; | |
246 | } | |
247 | ||
248 | // ---------------------------------------------------------------------------- | |
249 | // tool/status bar stuff | |
250 | // ---------------------------------------------------------------------------- | |
251 | ||
252 | #if wxUSE_TOOLBAR | |
253 | ||
254 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) | |
255 | { | |
256 | return NULL; | |
257 | } | |
258 | ||
259 | void wxFrame::PositionToolBar() | |
260 | { | |
261 | } | |
262 | ||
263 | #endif // wxUSE_TOOLBAR | |
264 | ||
265 | // ---------------------------------------------------------------------------- | |
266 | // frame state (iconized/maximized/...) | |
267 | // ---------------------------------------------------------------------------- | |
268 | ||
269 | // propagate our state change to all child frames: this allows us to emulate X | |
270 | // Windows behaviour where child frames float independently of the parent one | |
271 | // on the desktop, but are iconized/restored with it | |
272 | void wxFrame::IconizeChildFrames(bool bIconize) | |
273 | { | |
274 | } | |
275 | ||
ffecfa5a JS |
276 | // ---------------------------------------------------------------------------- |
277 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
278 | // from the client area, so the client area is what's really available for the | |
279 | // frame contents | |
280 | // ---------------------------------------------------------------------------- | |
281 | ||
282 | // get the origin of the client area in the client coordinates | |
283 | wxPoint wxFrame::GetClientAreaOrigin() const | |
284 | { | |
f241653c WS |
285 | // there is no API to get client area but we know |
286 | // it starts after titlebar and 1 pixel of form border | |
287 | Coord maxY = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y), | |
288 | X = 1, | |
289 | Y = 0; | |
290 | while ( Y < maxY ) | |
291 | { | |
20bc5ad8 | 292 | if(!FrmPointInTitle((FormType*)GetForm(),X,Y)) |
f241653c WS |
293 | return wxPoint(X,Y+1); |
294 | Y++; | |
295 | } | |
296 | ||
297 | return wxPoint(X,0); | |
ffecfa5a | 298 | } |