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