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