]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/toplevel.cpp
CoreGraphics dev
[wxWidgets.git] / src / palmos / toplevel.cpp
CommitLineData
ffecfa5a 1///////////////////////////////////////////////////////////////////////////////
e9c52a40 2// Name: src/palmos/toplevel.cpp
ffecfa5a 3// Purpose: implements wxTopLevelWindow for Palm OS
e9c52a40
WS
4// Author: William Osborne - minimal working wxPalmOS port
5// Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
ffecfa5a 6// Created: 10/13/04
e9c52a40
WS
7// RCS-ID: $Id$
8// Copyright: (c) William Osborne <wbo@freeshell.org>, 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 "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
ffecfa5a
JS
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.
db101bd3 54wxTopLevelWindowPalm* ActiveParentFrame;
ffecfa5a
JS
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
ffecfa5a 82bool wxTopLevelWindowPalm::Create(wxWindow *parent,
e9c52a40
WS
83 wxWindowID id,
84 const wxString& title,
85 const wxPoint& pos,
86 const wxSize& size,
87 long style,
88 const wxString& name)
ffecfa5a 89{
db101bd3
WS
90 // this is a check for limitation mentioned before FrameFormHandleEvent() code
91 if(wxTopLevelWindows.GetCount()>0)
ffecfa5a
JS
92 return false;
93
db101bd3 94 ActiveParentFrame=NULL;
ffecfa5a 95
ffecfa5a
JS
96 wxTopLevelWindows.Append(this);
97
98 if ( parent )
99 parent->AddChild(this);
100
ba889513 101 SetId( id == wxID_ANY ? NewControlId() : id );
ffecfa5a 102
db101bd3
WS
103 WinConstraintsType constraints;
104 memset(&constraints, 0, sizeof(WinConstraintsType));
ba889513 105 // position
db101bd3
WS
106 constraints.x_pos = ( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x;
107 constraints.y_pos = ( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y;
ba889513 108 // size
db101bd3
WS
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(
ba889513 117 GetId(),
db101bd3
WS
118 title.c_str(),
119 winFlagBackBuffer,
120 &constraints,
121 0,
122 NULL,
123 0,
124 NULL,
125 0
126 );
127
128 if(FrameForm==NULL)
ffecfa5a
JS
129 return false;
130
131 FrmSetEventHandler(FrameForm,FrameFormHandleEvent);
e9c52a40 132
ffecfa5a 133 FrmSetActiveForm(FrameForm);
e9c52a40 134
db101bd3 135 ActiveParentFrame=this;
e9c52a40 136
ffecfa5a
JS
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);
e9c52a40 155
ffecfa5a
JS
156 wxPaintEvent event(m_windowId);
157 event.SetEventObject(this);
e9c52a40
WS
158 GetEventHandler()->ProcessEvent(event);
159
ffecfa5a
JS
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
bdb54365
WS
215FormType *wxTopLevelWindowPalm::GetForm()
216{
217 return FrmGetActiveForm ();
218}
219
ffecfa5a
JS
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
e9c52a40
WS
238 *
239 * This function *must* be located outside of the wxTopLevelWindow class because
e2731512
WS
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
ffecfa5a 243 * its first parameter).
e2731512
WS
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
ffecfa5a
JS
249 * wbo@freeshell.org
250 */
251static Boolean FrameFormHandleEvent(EventType* pEvent)
252{
db101bd3 253 wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame);
ffecfa5a 254 Boolean fHandled = false;
db101bd3
WS
255 FormType* pForm;
256 WinHandle hWindow;
257 int ItemID=0;
e2731512 258
ffecfa5a
JS
259 switch (pEvent->eType) {
260 case ctlSelectEvent:
261 break;
262#if wxUSE_MENUS_NATIVE
263 case menuOpenEvent:
db101bd3 264 fHandled = frame->HandleMenuOpen();
e2731512 265 break;
ffecfa5a 266 case menuEvent:
db101bd3
WS
267 ItemID = pEvent->data.menu.itemID;
268 fHandled = frame->HandleMenuSelect(ItemID);
ffecfa5a
JS
269 break;
270#endif
271 default:
272 break;
273 }
e2731512 274
ffecfa5a
JS
275 return fHandled;
276}