]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/palmos/toplevel.cpp
CoreGraphics dev
[wxWidgets.git] / src / palmos / toplevel.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/palmos/toplevel.cpp
3// Purpose: implements wxTopLevelWindow for Palm OS
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 <wbo@freeshell.org>, Wlodzimierz Skiba
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 "toplevel.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/app.h"
33 #include "wx/toplevel.h"
34 #include "wx/dialog.h"
35 #include "wx/string.h"
36 #include "wx/log.h"
37 #include "wx/intl.h"
38 #include "wx/frame.h"
39 #include "wx/containr.h" // wxSetFocusToChild()
40#endif //WX_PRECOMP
41
42#include "wx/module.h"
43
44#include "wx/display.h"
45
46// ----------------------------------------------------------------------------
47// globals
48// ----------------------------------------------------------------------------
49
50// the name of the default wxWidgets class
51extern const wxChar *wxCanvasClassName;
52
53// Pointer to the currently active frame for the form event handler.
54wxTopLevelWindowPalm* ActiveParentFrame;
55
56// ============================================================================
57// wxTopLevelWindowPalm implementation
58// ============================================================================
59
60BEGIN_EVENT_TABLE(wxTopLevelWindowPalm, wxTopLevelWindowBase)
61 EVT_ACTIVATE(wxTopLevelWindowPalm::OnActivate)
62END_EVENT_TABLE()
63
64// ----------------------------------------------------------------------------
65// wxTopLevelWindowPalm creation
66// ----------------------------------------------------------------------------
67
68void wxTopLevelWindowPalm::Init()
69{
70}
71
72WXDWORD wxTopLevelWindowPalm::PalmGetStyle(long style, WXDWORD *exflags) const
73{
74 return 0;
75}
76
77WXHWND wxTopLevelWindowPalm::PalmGetParent() const
78{
79 return NULL;
80}
81
82bool wxTopLevelWindowPalm::Create(wxWindow *parent,
83 wxWindowID id,
84 const wxString& title,
85 const wxPoint& pos,
86 const wxSize& size,
87 long style,
88 const wxString& name)
89{
90 // this is a check for limitation mentioned before FrameFormHandleEvent() code
91 if(wxTopLevelWindows.GetCount()>0)
92 return false;
93
94 ActiveParentFrame=NULL;
95
96 wxTopLevelWindows.Append(this);
97
98 if ( parent )
99 parent->AddChild(this);
100
101 SetId( id == wxID_ANY ? NewControlId() : id );
102
103 WinConstraintsType constraints;
104 memset(&constraints, 0, sizeof(WinConstraintsType));
105 // position
106 constraints.x_pos = ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x;
107 constraints.y_pos = ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y;
108 // size
109 constraints.x_min = winUndefConstraint;
110 constraints.x_max = winMaxConstraint;
111 constraints.x_pref = ( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x;
112 constraints.y_min = winUndefConstraint;
113 constraints.y_max = winMaxConstraint;
114 constraints.y_pref = ( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y;
115
116 FrameForm = FrmNewFormWithConstraints(
117 GetId(),
118 title.c_str(),
119 winFlagBackBuffer,
120 &constraints,
121 0,
122 NULL,
123 0,
124 NULL,
125 0
126 );
127
128 if(FrameForm==NULL)
129 return false;
130
131 FrmSetEventHandler(FrameForm,FrameFormHandleEvent);
132
133 FrmSetActiveForm(FrameForm);
134
135 ActiveParentFrame=this;
136
137 return true;
138}
139
140wxTopLevelWindowPalm::~wxTopLevelWindowPalm()
141{
142}
143
144// ----------------------------------------------------------------------------
145// wxTopLevelWindowPalm showing
146// ----------------------------------------------------------------------------
147
148void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd)
149{
150}
151
152bool wxTopLevelWindowPalm::Show(bool show)
153{
154 FrmDrawForm(FrameForm);
155
156 wxPaintEvent event(m_windowId);
157 event.SetEventObject(this);
158 GetEventHandler()->ProcessEvent(event);
159
160 return true;
161}
162
163// ----------------------------------------------------------------------------
164// wxTopLevelWindowPalm maximize/minimize
165// ----------------------------------------------------------------------------
166
167void wxTopLevelWindowPalm::Maximize(bool maximize)
168{
169}
170
171bool wxTopLevelWindowPalm::IsMaximized() const
172{
173 return false;
174}
175
176void wxTopLevelWindowPalm::Iconize(bool iconize)
177{
178}
179
180bool wxTopLevelWindowPalm::IsIconized() const
181{
182 return false;
183}
184
185void wxTopLevelWindowPalm::Restore()
186{
187}
188
189// ----------------------------------------------------------------------------
190// wxTopLevelWindowPalm fullscreen
191// ----------------------------------------------------------------------------
192
193bool wxTopLevelWindowPalm::ShowFullScreen(bool show, long style)
194{
195 return false;
196}
197
198// ----------------------------------------------------------------------------
199// wxTopLevelWindowPalm misc
200// ----------------------------------------------------------------------------
201
202void wxTopLevelWindowPalm::SetIcon(const wxIcon& icon)
203{
204}
205
206void wxTopLevelWindowPalm::SetIcons(const wxIconBundle& icons)
207{
208}
209
210bool wxTopLevelWindowPalm::EnableCloseButton(bool enable)
211{
212 return false;
213}
214
215FormType *wxTopLevelWindowPalm::GetForm()
216{
217 return FrmGetActiveForm ();
218}
219
220#ifndef __WXWINCE__
221
222bool wxTopLevelWindowPalm::SetShape(const wxRegion& region)
223{
224 return false;
225}
226
227#endif // !__WXWINCE__
228
229// ----------------------------------------------------------------------------
230// wxTopLevelWindow event handling
231// ----------------------------------------------------------------------------
232
233void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event)
234{
235}
236
237/* Palm OS Event handler for the window
238 *
239 * This function *must* be located outside of the wxTopLevelWindow class because
240 * the Palm OS API expects a standalone C function as a callback. You cannot
241 * pass a pointer to a member function of a C++ class as a callback because the
242 * prototypes don't match. (A member function has a hidden "this" pointer as
243 * its first parameter).
244 *
245 * This event handler uses a global pointer to the current wxFrame to process
246 * the events generated by the Palm OS form API. I know this is ugly, but right
247 * now I can't think of any other way to deal with this problem. If someone
248 * finds a better solution, please let me know. My email address is
249 * wbo@freeshell.org
250 */
251static Boolean FrameFormHandleEvent(EventType* pEvent)
252{
253 wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame);
254 Boolean fHandled = false;
255 FormType* pForm;
256 WinHandle hWindow;
257 int ItemID=0;
258
259 switch (pEvent->eType) {
260 case ctlSelectEvent:
261 break;
262#if wxUSE_MENUS_NATIVE
263 case menuOpenEvent:
264 fHandled = frame->HandleMenuOpen();
265 break;
266 case menuEvent:
267 ItemID = pEvent->data.menu.itemID;
268 fHandled = frame->HandleMenuSelect(ItemID);
269 break;
270#endif
271 default:
272 break;
273 }
274
275 return fHandled;
276}