]> git.saurik.com Git - wxWidgets.git/blob - src/palmos/toplevel.cpp
Use stock labels. Native wxRadioButton. Getting position and size for the controls...
[wxWidgets.git] / src / palmos / toplevel.cpp
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
51 extern const wxChar *wxCanvasClassName;
52
53 // Pointer to the currently active frame for the form event handler.
54 wxTopLevelWindowPalm* ActiveParentFrame;
55
56 // ============================================================================
57 // wxTopLevelWindowPalm implementation
58 // ============================================================================
59
60 BEGIN_EVENT_TABLE(wxTopLevelWindowPalm, wxTopLevelWindowBase)
61 EVT_ACTIVATE(wxTopLevelWindowPalm::OnActivate)
62 END_EVENT_TABLE()
63
64 // ----------------------------------------------------------------------------
65 // wxTopLevelWindowPalm creation
66 // ----------------------------------------------------------------------------
67
68 void wxTopLevelWindowPalm::Init()
69 {
70 }
71
72 WXDWORD wxTopLevelWindowPalm::PalmGetStyle(long style, WXDWORD *exflags) const
73 {
74 return 0;
75 }
76
77 WXHWND wxTopLevelWindowPalm::PalmGetParent() const
78 {
79 return NULL;
80 }
81
82 bool 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
140 wxTopLevelWindowPalm::~wxTopLevelWindowPalm()
141 {
142 }
143
144 // ----------------------------------------------------------------------------
145 // wxTopLevelWindowPalm showing
146 // ----------------------------------------------------------------------------
147
148 void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd)
149 {
150 }
151
152 bool 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
167 void wxTopLevelWindowPalm::Maximize(bool maximize)
168 {
169 }
170
171 bool wxTopLevelWindowPalm::IsMaximized() const
172 {
173 return false;
174 }
175
176 void wxTopLevelWindowPalm::Iconize(bool iconize)
177 {
178 }
179
180 bool wxTopLevelWindowPalm::IsIconized() const
181 {
182 return false;
183 }
184
185 void wxTopLevelWindowPalm::Restore()
186 {
187 }
188
189 void 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
199 // ----------------------------------------------------------------------------
200 // wxTopLevelWindowPalm fullscreen
201 // ----------------------------------------------------------------------------
202
203 bool wxTopLevelWindowPalm::ShowFullScreen(bool show, long style)
204 {
205 return false;
206 }
207
208 // ----------------------------------------------------------------------------
209 // wxTopLevelWindowPalm misc
210 // ----------------------------------------------------------------------------
211
212 void wxTopLevelWindowPalm::SetIcon(const wxIcon& icon)
213 {
214 }
215
216 void wxTopLevelWindowPalm::SetIcons(const wxIconBundle& icons)
217 {
218 }
219
220 bool wxTopLevelWindowPalm::EnableCloseButton(bool enable)
221 {
222 return false;
223 }
224
225 FormType *wxTopLevelWindowPalm::GetForm() const
226 {
227 return FrmGetActiveForm();
228 }
229
230 #ifndef __WXWINCE__
231
232 bool wxTopLevelWindowPalm::SetShape(const wxRegion& region)
233 {
234 return false;
235 }
236
237 #endif // !__WXWINCE__
238
239 // ----------------------------------------------------------------------------
240 // wxTopLevelWindow event handling
241 // ----------------------------------------------------------------------------
242
243 void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event)
244 {
245 }
246
247 /* Palm OS Event handler for the window
248 *
249 * This function *must* be located outside of the wxTopLevelWindow class because
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
253 * its first parameter).
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
259 * wbo@freeshell.org
260 */
261 static Boolean FrameFormHandleEvent(EventType* pEvent)
262 {
263 wxFrame* frame = wxDynamicCast(ActiveParentFrame,wxFrame);
264 Boolean fHandled = false;
265 FormType* pForm;
266 WinHandle hWindow;
267 int ItemID=0;
268
269 switch (pEvent->eType) {
270 case ctlSelectEvent:
271 break;
272 #if wxUSE_MENUS_NATIVE
273 case menuOpenEvent:
274 fHandled = frame->HandleMenuOpen();
275 break;
276 case menuEvent:
277 ItemID = pEvent->data.menu.itemID;
278 fHandled = frame->HandleMenuSelect(ItemID);
279 break;
280 #endif
281 default:
282 break;
283 }
284
285 return fHandled;
286 }