]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/toplevel.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/toplevel.cpp
3 // Purpose: implements wxTopLevelWindow for Palm OS
4 // Author: William Osborne
8 // Copyright: (c) William Osborne <wbo@freeshell.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "toplevel.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #include "wx/toplevel.h"
34 #include "wx/dialog.h"
35 #include "wx/string.h"
39 #include "wx/containr.h" // wxSetFocusToChild()
42 #include "wx/module.h"
44 #include "wx/display.h"
55 // ----------------------------------------------------------------------------
57 // ----------------------------------------------------------------------------
59 // the name of the default wxWidgets class
60 extern const wxChar
*wxCanvasClassName
;
62 // Pointer to the currently active frame for the form event handler.
63 wxFrame
* ActiveParentFrame
;
65 // ============================================================================
66 // wxTopLevelWindowPalm implementation
67 // ============================================================================
69 BEGIN_EVENT_TABLE(wxTopLevelWindowPalm
, wxTopLevelWindowBase
)
70 EVT_ACTIVATE(wxTopLevelWindowPalm::OnActivate
)
73 // ----------------------------------------------------------------------------
74 // wxTopLevelWindowPalm creation
75 // ----------------------------------------------------------------------------
77 void wxTopLevelWindowPalm::Init()
81 WXDWORD
wxTopLevelWindowPalm::PalmGetStyle(long style
, WXDWORD
*exflags
) const
86 WXHWND
wxTopLevelWindowPalm::PalmGetParent() const
91 bool wxTopLevelWindowPalm::CreateDialog(const void *dlgTemplate
,
92 const wxString
& title
,
99 bool wxTopLevelWindowPalm::CreateFrame(const wxString
& title
,
106 bool wxTopLevelWindowPalm::Create(wxWindow
*parent
,
108 const wxString
& title
,
112 const wxString
& name
)
114 ActiveParentFrame
=NULL
;
116 wxTopLevelWindows
.Append(this);
119 parent
->AddChild(this);
121 m_windowId
= id
== -1 ? NewControlId() : id
;
123 FrameForm
=FrmNewForm(m_windowId
,title
,0,0,160,160,false,0,NULL
,0,NULL
,0);
127 FrmSetEventHandler(FrameForm
,FrameFormHandleEvent
);
132 bool wxTopLevelWindowPalm::Create(wxWindow
*parent
,
134 const wxString
& title
,
138 const wxString
& name
,
141 wxTopLevelWindows
.Append(this);
144 parent
->AddChild(this);
146 m_windowId
= id
== -1 ? NewControlId() : id
;
148 FrameForm
=FrmNewForm(m_windowId
,title
,0,0,160,160,false,0,NULL
,0,NULL
,0);
152 FrmSetEventHandler(FrameForm
,FrameFormHandleEvent
);
154 FrmSetActiveForm(FrameForm
);
156 ActiveParentFrame
=PFrame
;
161 wxTopLevelWindowPalm::~wxTopLevelWindowPalm()
165 // ----------------------------------------------------------------------------
166 // wxTopLevelWindowPalm showing
167 // ----------------------------------------------------------------------------
169 void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd
)
173 bool wxTopLevelWindowPalm::Show(bool show
)
175 FrmDrawForm(FrameForm
);
177 wxPaintEvent
event(m_windowId
);
178 event
.SetEventObject(this);
179 GetEventHandler()->ProcessEvent(event
);
184 // ----------------------------------------------------------------------------
185 // wxTopLevelWindowPalm maximize/minimize
186 // ----------------------------------------------------------------------------
188 void wxTopLevelWindowPalm::Maximize(bool maximize
)
192 bool wxTopLevelWindowPalm::IsMaximized() const
197 void wxTopLevelWindowPalm::Iconize(bool iconize
)
201 bool wxTopLevelWindowPalm::IsIconized() const
206 void wxTopLevelWindowPalm::Restore()
210 // ----------------------------------------------------------------------------
211 // wxTopLevelWindowPalm fullscreen
212 // ----------------------------------------------------------------------------
214 bool wxTopLevelWindowPalm::ShowFullScreen(bool show
, long style
)
219 // ----------------------------------------------------------------------------
220 // wxTopLevelWindowPalm misc
221 // ----------------------------------------------------------------------------
223 void wxTopLevelWindowPalm::SetIcon(const wxIcon
& icon
)
227 void wxTopLevelWindowPalm::SetIcons(const wxIconBundle
& icons
)
231 bool wxTopLevelWindowPalm::EnableCloseButton(bool enable
)
238 bool wxTopLevelWindowPalm::SetShape(const wxRegion
& region
)
243 #endif // !__WXWINCE__
245 // ----------------------------------------------------------------------------
246 // wxTopLevelWindow event handling
247 // ----------------------------------------------------------------------------
249 void wxTopLevelWindowPalm::OnActivate(wxActivateEvent
& event
)
253 /* Palm OS Event handler for the window
255 * This function *must* be located outside of the wxTopLevelWindow class because
256 * the Palm OS API expects a standalone C function as a callback. You cannot
257 * pass a pointer to a member function of a C++ class as a callback because the
258 * prototypes don't match. (A member function has a hidden "this" pointer as
259 * its first parameter).
261 * This event handler uses a global pointer to the current wxFrame to process
262 * the events generated by the Palm OS form API. I know this is ugly, but right
263 * now I can't think of any other way to deal with this problem. If someone
264 * finds a better solution, please let me know. My email address is
267 static Boolean
FrameFormHandleEvent(EventType
* pEvent
)
269 Boolean fHandled
= false;
274 switch (pEvent
->eType
) {
277 #if wxUSE_MENUS_NATIVE
279 fHandled
=ActiveParentFrame
->HandleMenuOpen();
282 ItemID
=pEvent
->data
.menu
.itemID
;
283 fHandled
=ActiveParentFrame
->HandleMenuSelect(ItemID
);