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