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