]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/frame.cpp
Implement support for gradient stops for OS X.
[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
ffecfa5a
JS
44#ifdef __WXUNIVERSAL__
45 #include "wx/univ/theme.h"
46 #include "wx/univ/colschem.h"
47#endif // __WXUNIVERSAL__
48
20bc5ad8
WS
49#include <Event.h>
50#include <Form.h>
51
ffecfa5a
JS
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
64BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
9b5d7dfc 65 EVT_PAINT(wxFrame::OnPaint)
ffecfa5a
JS
66END_EVENT_TABLE()
67
68#if wxUSE_EXTENDED_RTTI
69WX_DEFINE_FLAGS( wxFrameStyle )
70
71wxBEGIN_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)
9b5d7dfc 80
ffecfa5a
JS
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)
1c067fe3 102#if WXWIN_COMPATIBILITY_2_6
ffecfa5a 103 wxFLAGS_MEMBER(wxTHICK_FRAME)
1c067fe3 104#endif // WXWIN_COMPATIBILITY_2_6
ffecfa5a
JS
105 wxFLAGS_MEMBER(wxSYSTEM_MENU)
106 wxFLAGS_MEMBER(wxRESIZE_BORDER)
1c067fe3 107#if WXWIN_COMPATIBILITY_2_6
ffecfa5a 108 wxFLAGS_MEMBER(wxRESIZE_BOX)
1c067fe3 109#endif // WXWIN_COMPATIBILITY_2_6
ffecfa5a
JS
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
119wxEND_FLAGS( wxFrameStyle )
120
121IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow,"wx/frame.h")
122
123wxBEGIN_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"))
129wxEND_PROPERTIES_TABLE()
130
131wxBEGIN_HANDLERS_TABLE(wxFrame)
132wxEND_HANDLERS_TABLE()
133
9b5d7dfc 134wxCONSTRUCTOR_6( wxFrame , wxWindow* , Parent , wxWindowID , Id , wxString , Title , wxPoint , Position , wxSize , Size , long , WindowStyle)
ffecfa5a
JS
135
136#else
137IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
138#endif
139
140// ============================================================================
141// implementation
142// ============================================================================
143
ffecfa5a
JS
144// ----------------------------------------------------------------------------
145// creation/destruction
146// ----------------------------------------------------------------------------
147
148void wxFrame::Init()
149{
ffecfa5a
JS
150}
151
152bool 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{
db101bd3 160 if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) )
ffecfa5a 161 return false;
9b5d7dfc 162
ffecfa5a
JS
163 return true;
164}
165
166wxFrame::~wxFrame()
167{
168}
169
170// ----------------------------------------------------------------------------
171// wxFrame client size calculations
172// ----------------------------------------------------------------------------
173
174void wxFrame::DoSetClientSize(int width, int height)
175{
176}
177
178// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
179void wxFrame::DoGetClientSize(int *x, int *y) const
180{
be4e4e27
WS
181 wxSize size = GetSize();
182 wxPoint pos = GetClientAreaOrigin();
183 *x = size.x - pos.x - 1;
184 *y = size.y - pos.y - 1;
ffecfa5a
JS
185}
186
187// ----------------------------------------------------------------------------
188// wxFrame: various geometry-related functions
189// ----------------------------------------------------------------------------
190
191void wxFrame::Raise()
192{
193}
194
ffecfa5a
JS
195#if wxUSE_MENUS_NATIVE
196
ffecfa5a
JS
197void wxFrame::InternalSetMenuBar()
198{
199}
200
201bool wxFrame::HandleMenuOpen()
202{
203 if(!m_frameMenuBar)
204 return false;
9b5d7dfc 205
ffecfa5a
JS
206 m_frameMenuBar->LoadMenu();
207 return true;
208}
209
20bc5ad8 210bool wxFrame::HandleMenuSelect(WXEVENTPTR event)
ffecfa5a 211{
20bc5ad8
WS
212 const EventType *palmEvent = (EventType *)event;
213 const int ItemID = palmEvent->data.menu.itemID;
a152561c 214
ffecfa5a
JS
215 if (!m_frameMenuBar)
216 return false;
217
20bc5ad8
WS
218 const int item = m_frameMenuBar->ProcessCommand(ItemID);
219 if (item==-1)
ffecfa5a
JS
220 return false;
221
222 wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item);
223 commandEvent.SetEventObject(this);
9b5d7dfc 224
937013e0 225 HandleWindowEvent(commandEvent);
9b5d7dfc 226 return true;
ffecfa5a
JS
227}
228
229#endif // wxUSE_MENUS_NATIVE
230
ffecfa5a
JS
231void wxFrame::OnPaint(wxPaintEvent& event)
232{
9b5d7dfc
VZ
233#if wxUSE_STATUSBAR
234 if( m_frameStatusBar )
235 m_frameStatusBar->DrawStatusBar();
236#endif // wxUSE_STATUSBAR
ffecfa5a 237}
9b5d7dfc 238
db101bd3 239// Pass true to show full screen, false to restore.
ffecfa5a
JS
240bool 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
251wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
252{
253 return NULL;
254}
255
256void 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
269void wxFrame::IconizeChildFrames(bool bIconize)
270{
271}
272
ffecfa5a
JS
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
280wxPoint wxFrame::GetClientAreaOrigin() const
281{
f241653c
WS
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 {
20bc5ad8 289 if(!FrmPointInTitle((FormType*)GetForm(),X,Y))
f241653c
WS
290 return wxPoint(X,Y+1);
291 Y++;
292 }
293
294 return wxPoint(X,0);
ffecfa5a 295}