]> git.saurik.com Git - wxWidgets.git/blame - src/palmos/toplevel.cpp
added a few more UTF-[78] tests
[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
808e3bce
WS
189void wxTopLevelWindowPalm::DoGetSize( int *width, int *height ) const
190{
191 RectangleType rect;
192 FrmGetFormBounds( GetForm() , &rect );
193 if(width)
194 *width = rect.extent.x;
195 if(height)
196 *height = rect.extent.y;
197}
198
ffecfa5a
JS
199// ----------------------------------------------------------------------------
200// wxTopLevelWindowPalm fullscreen
201// ----------------------------------------------------------------------------
202
203bool wxTopLevelWindowPalm::ShowFullScreen(bool show, long style)
204{
205 return false;
206}
207
208// ----------------------------------------------------------------------------
209// wxTopLevelWindowPalm misc
210// ----------------------------------------------------------------------------
211
212void wxTopLevelWindowPalm::SetIcon(const wxIcon& icon)
213{
214}
215
216void wxTopLevelWindowPalm::SetIcons(const wxIconBundle& icons)
217{
218}
219
220bool wxTopLevelWindowPalm::EnableCloseButton(bool enable)
221{
222 return false;
223}
224
808e3bce 225FormType *wxTopLevelWindowPalm::GetForm() const
bdb54365 226{
808e3bce 227 return FrmGetActiveForm();
bdb54365
WS
228}
229
ffecfa5a
JS
230#ifndef __WXWINCE__
231
232bool wxTopLevelWindowPalm::SetShape(const wxRegion& region)
233{
234 return false;
235}
236
237#endif // !__WXWINCE__
238
239// ----------------------------------------------------------------------------
240// wxTopLevelWindow event handling
241// ----------------------------------------------------------------------------
242
243void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event)
244{
245}
246
247/* Palm OS Event handler for the window
e9c52a40
WS
248 *
249 * This function *must* be located outside of the wxTopLevelWindow class because
e2731512
WS
250 * the Palm OS API expects a standalone C function as a callback. You cannot
251 * pass a pointer to a member function of a C++ class as a callback because the
252 * prototypes don't match. (A member function has a hidden "this" pointer as
ffecfa5a 253 * its first parameter).
e2731512
WS
254 *
255 * This event handler uses a global pointer to the current wxFrame to process
256 * the events generated by the Palm OS form API. I know this is ugly, but right
257 * now I can't think of any other way to deal with this problem. If someone
258 * finds a better solution, please let me know. My email address is
ffecfa5a
JS
259 * wbo@freeshell.org
260 */
261static Boolean FrameFormHandleEvent(EventType* pEvent)
262{
db101bd3 263 wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame);
ffecfa5a 264 Boolean fHandled = false;
db101bd3
WS
265 FormType* pForm;
266 WinHandle hWindow;
267 int ItemID=0;
e2731512 268
ffecfa5a
JS
269 switch (pEvent->eType) {
270 case ctlSelectEvent:
271 break;
272#if wxUSE_MENUS_NATIVE
273 case menuOpenEvent:
db101bd3 274 fHandled = frame->HandleMenuOpen();
e2731512 275 break;
ffecfa5a 276 case menuEvent:
db101bd3
WS
277 ItemID = pEvent->data.menu.itemID;
278 fHandled = frame->HandleMenuSelect(ItemID);
ffecfa5a
JS
279 break;
280#endif
281 default:
282 break;
283 }
e2731512 284
ffecfa5a
JS
285 return fHandled;
286}