]>
Commit | Line | Data |
---|---|---|
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 | ||
46 | #ifndef ICON_BIG | |
47 | #define ICON_BIG 1 | |
48 | #endif | |
49 | ||
50 | #ifndef ICON_SMALL | |
51 | #define ICON_SMALL 0 | |
52 | #endif | |
53 | ||
54 | ||
55 | // ---------------------------------------------------------------------------- | |
56 | // globals | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
59 | // the name of the default wxWidgets class | |
60 | extern const wxChar *wxCanvasClassName; | |
61 | ||
62 | // Pointer to the currently active frame for the form event handler. | |
63 | wxFrame* ActiveParentFrame; | |
64 | ||
65 | // ============================================================================ | |
66 | // wxTopLevelWindowPalm implementation | |
67 | // ============================================================================ | |
68 | ||
69 | BEGIN_EVENT_TABLE(wxTopLevelWindowPalm, wxTopLevelWindowBase) | |
70 | EVT_ACTIVATE(wxTopLevelWindowPalm::OnActivate) | |
71 | END_EVENT_TABLE() | |
72 | ||
73 | // ---------------------------------------------------------------------------- | |
74 | // wxTopLevelWindowPalm creation | |
75 | // ---------------------------------------------------------------------------- | |
76 | ||
77 | void wxTopLevelWindowPalm::Init() | |
78 | { | |
79 | } | |
80 | ||
81 | WXDWORD wxTopLevelWindowPalm::PalmGetStyle(long style, WXDWORD *exflags) const | |
82 | { | |
83 | return 0; | |
84 | } | |
85 | ||
86 | WXHWND wxTopLevelWindowPalm::PalmGetParent() const | |
87 | { | |
88 | return NULL; | |
89 | } | |
90 | ||
91 | bool wxTopLevelWindowPalm::CreateDialog(const void *dlgTemplate, | |
92 | const wxString& title, | |
93 | const wxPoint& pos, | |
94 | const wxSize& size) | |
95 | { | |
96 | return false; | |
97 | } | |
98 | ||
99 | bool wxTopLevelWindowPalm::CreateFrame(const wxString& title, | |
100 | const wxPoint& pos, | |
101 | const wxSize& size) | |
102 | { | |
103 | return false; | |
104 | } | |
105 | ||
106 | bool wxTopLevelWindowPalm::Create(wxWindow *parent, | |
e9c52a40 WS |
107 | wxWindowID id, |
108 | const wxString& title, | |
109 | const wxPoint& pos, | |
110 | const wxSize& size, | |
111 | long style, | |
112 | const wxString& name) | |
ffecfa5a JS |
113 | { |
114 | ActiveParentFrame=NULL; | |
e9c52a40 | 115 | |
ffecfa5a JS |
116 | wxTopLevelWindows.Append(this); |
117 | ||
118 | if ( parent ) | |
119 | parent->AddChild(this); | |
120 | ||
e9c52a40 WS |
121 | m_windowId = id == wxID_ANY ? NewControlId() : id; |
122 | ||
123 | wxCoord x = ( ( pos.x == wxDefaultCoord ) ? 0 : pos.x ) ; | |
124 | wxCoord y = ( ( pos.y == wxDefaultCoord ) ? 0 : pos.y ) ; | |
125 | wxCoord w = ( ( size.x == wxDefaultCoord ) ? 160 : size.x ) ; | |
126 | wxCoord h = ( ( size.y == wxDefaultCoord ) ? 160 : size.y ) ; | |
127 | ||
128 | FrameForm = FrmNewForm( m_windowId, | |
129 | title, | |
130 | x, y, | |
131 | w, h, | |
132 | false, | |
133 | 0, | |
134 | NULL, | |
135 | 0, | |
136 | NULL, | |
137 | 0); | |
ffecfa5a JS |
138 | if(FrameForm==0) |
139 | return false; | |
140 | ||
141 | FrmSetEventHandler(FrameForm,FrameFormHandleEvent); | |
e9c52a40 | 142 | |
ffecfa5a JS |
143 | return true; |
144 | } | |
145 | ||
146 | bool wxTopLevelWindowPalm::Create(wxWindow *parent, | |
e9c52a40 WS |
147 | wxWindowID id, |
148 | const wxString& title, | |
149 | const wxPoint& pos, | |
150 | const wxSize& size, | |
151 | long style, | |
152 | const wxString& name, | |
153 | wxFrame* PFrame) | |
ffecfa5a JS |
154 | { |
155 | wxTopLevelWindows.Append(this); | |
156 | ||
157 | if ( parent ) | |
158 | parent->AddChild(this); | |
159 | ||
160 | m_windowId = id == -1 ? NewControlId() : id; | |
161 | ||
162 | FrameForm=FrmNewForm(m_windowId,title,0,0,160,160,false,0,NULL,0,NULL,0); | |
163 | if(FrameForm==0) | |
164 | return false; | |
165 | ||
166 | FrmSetEventHandler(FrameForm,FrameFormHandleEvent); | |
e9c52a40 | 167 | |
ffecfa5a | 168 | FrmSetActiveForm(FrameForm); |
e9c52a40 | 169 | |
ffecfa5a | 170 | ActiveParentFrame=PFrame; |
e9c52a40 | 171 | |
ffecfa5a JS |
172 | return true; |
173 | } | |
174 | ||
175 | wxTopLevelWindowPalm::~wxTopLevelWindowPalm() | |
176 | { | |
177 | } | |
178 | ||
179 | // ---------------------------------------------------------------------------- | |
180 | // wxTopLevelWindowPalm showing | |
181 | // ---------------------------------------------------------------------------- | |
182 | ||
183 | void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd) | |
184 | { | |
185 | } | |
186 | ||
187 | bool wxTopLevelWindowPalm::Show(bool show) | |
188 | { | |
189 | FrmDrawForm(FrameForm); | |
e9c52a40 | 190 | |
ffecfa5a JS |
191 | wxPaintEvent event(m_windowId); |
192 | event.SetEventObject(this); | |
e9c52a40 WS |
193 | GetEventHandler()->ProcessEvent(event); |
194 | ||
ffecfa5a JS |
195 | return true; |
196 | } | |
197 | ||
198 | // ---------------------------------------------------------------------------- | |
199 | // wxTopLevelWindowPalm maximize/minimize | |
200 | // ---------------------------------------------------------------------------- | |
201 | ||
202 | void wxTopLevelWindowPalm::Maximize(bool maximize) | |
203 | { | |
204 | } | |
205 | ||
206 | bool wxTopLevelWindowPalm::IsMaximized() const | |
207 | { | |
208 | return false; | |
209 | } | |
210 | ||
211 | void wxTopLevelWindowPalm::Iconize(bool iconize) | |
212 | { | |
213 | } | |
214 | ||
215 | bool wxTopLevelWindowPalm::IsIconized() const | |
216 | { | |
217 | return false; | |
218 | } | |
219 | ||
220 | void wxTopLevelWindowPalm::Restore() | |
221 | { | |
222 | } | |
223 | ||
224 | // ---------------------------------------------------------------------------- | |
225 | // wxTopLevelWindowPalm fullscreen | |
226 | // ---------------------------------------------------------------------------- | |
227 | ||
228 | bool wxTopLevelWindowPalm::ShowFullScreen(bool show, long style) | |
229 | { | |
230 | return false; | |
231 | } | |
232 | ||
233 | // ---------------------------------------------------------------------------- | |
234 | // wxTopLevelWindowPalm misc | |
235 | // ---------------------------------------------------------------------------- | |
236 | ||
237 | void wxTopLevelWindowPalm::SetIcon(const wxIcon& icon) | |
238 | { | |
239 | } | |
240 | ||
241 | void wxTopLevelWindowPalm::SetIcons(const wxIconBundle& icons) | |
242 | { | |
243 | } | |
244 | ||
245 | bool wxTopLevelWindowPalm::EnableCloseButton(bool enable) | |
246 | { | |
247 | return false; | |
248 | } | |
249 | ||
250 | #ifndef __WXWINCE__ | |
251 | ||
252 | bool wxTopLevelWindowPalm::SetShape(const wxRegion& region) | |
253 | { | |
254 | return false; | |
255 | } | |
256 | ||
257 | #endif // !__WXWINCE__ | |
258 | ||
259 | // ---------------------------------------------------------------------------- | |
260 | // wxTopLevelWindow event handling | |
261 | // ---------------------------------------------------------------------------- | |
262 | ||
263 | void wxTopLevelWindowPalm::OnActivate(wxActivateEvent& event) | |
264 | { | |
265 | } | |
266 | ||
267 | /* Palm OS Event handler for the window | |
e9c52a40 WS |
268 | * |
269 | * This function *must* be located outside of the wxTopLevelWindow class because | |
ffecfa5a JS |
270 | * the Palm OS API expects a standalone C function as a callback. You cannot |
271 | * pass a pointer to a member function of a C++ class as a callback because the | |
272 | * prototypes don't match. (A member function has a hidden "this" pointer as | |
273 | * its first parameter). | |
274 | * | |
275 | * This event handler uses a global pointer to the current wxFrame to process | |
276 | * the events generated by the Palm OS form API. I know this is ugly, but right | |
277 | * now I can't think of any other way to deal with this problem. If someone | |
278 | * finds a better solution, please let me know. My email address is | |
279 | * wbo@freeshell.org | |
280 | */ | |
281 | static Boolean FrameFormHandleEvent(EventType* pEvent) | |
282 | { | |
283 | Boolean fHandled = false; | |
284 | FormType* pForm; | |
285 | WinHandle hWindow; | |
286 | int ItemID=0; | |
287 | ||
288 | switch (pEvent->eType) { | |
289 | case ctlSelectEvent: | |
290 | break; | |
291 | #if wxUSE_MENUS_NATIVE | |
292 | case menuOpenEvent: | |
293 | fHandled=ActiveParentFrame->HandleMenuOpen(); | |
294 | break; | |
295 | case menuEvent: | |
296 | ItemID=pEvent->data.menu.itemID; | |
297 | fHandled=ActiveParentFrame->HandleMenuSelect(ItemID); | |
298 | break; | |
299 | #endif | |
300 | default: | |
301 | break; | |
302 | } | |
303 | ||
304 | return fHandled; | |
305 | } |