]>
git.saurik.com Git - wxWidgets.git/blob - 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
8 // Copyright: (c) William Osborne <wbo@freeshell.org>, Wlodzimierz Skiba
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
== wxID_ANY
? NewControlId() : id
;
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
) ;
128 FrameForm
= FrmNewForm( m_windowId
,
141 FrmSetEventHandler(FrameForm
,FrameFormHandleEvent
);
146 bool wxTopLevelWindowPalm::Create(wxWindow
*parent
,
148 const wxString
& title
,
152 const wxString
& name
,
155 wxTopLevelWindows
.Append(this);
158 parent
->AddChild(this);
160 m_windowId
= id
== -1 ? NewControlId() : id
;
162 FrameForm
=FrmNewForm(m_windowId
,title
,0,0,160,160,false,0,NULL
,0,NULL
,0);
166 FrmSetEventHandler(FrameForm
,FrameFormHandleEvent
);
168 FrmSetActiveForm(FrameForm
);
170 ActiveParentFrame
=PFrame
;
175 wxTopLevelWindowPalm::~wxTopLevelWindowPalm()
179 // ----------------------------------------------------------------------------
180 // wxTopLevelWindowPalm showing
181 // ----------------------------------------------------------------------------
183 void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd
)
187 bool wxTopLevelWindowPalm::Show(bool show
)
189 FrmDrawForm(FrameForm
);
191 wxPaintEvent
event(m_windowId
);
192 event
.SetEventObject(this);
193 GetEventHandler()->ProcessEvent(event
);
198 // ----------------------------------------------------------------------------
199 // wxTopLevelWindowPalm maximize/minimize
200 // ----------------------------------------------------------------------------
202 void wxTopLevelWindowPalm::Maximize(bool maximize
)
206 bool wxTopLevelWindowPalm::IsMaximized() const
211 void wxTopLevelWindowPalm::Iconize(bool iconize
)
215 bool wxTopLevelWindowPalm::IsIconized() const
220 void wxTopLevelWindowPalm::Restore()
224 // ----------------------------------------------------------------------------
225 // wxTopLevelWindowPalm fullscreen
226 // ----------------------------------------------------------------------------
228 bool wxTopLevelWindowPalm::ShowFullScreen(bool show
, long style
)
233 // ----------------------------------------------------------------------------
234 // wxTopLevelWindowPalm misc
235 // ----------------------------------------------------------------------------
237 void wxTopLevelWindowPalm::SetIcon(const wxIcon
& icon
)
241 void wxTopLevelWindowPalm::SetIcons(const wxIconBundle
& icons
)
245 bool wxTopLevelWindowPalm::EnableCloseButton(bool enable
)
252 bool wxTopLevelWindowPalm::SetShape(const wxRegion
& region
)
257 #endif // !__WXWINCE__
259 // ----------------------------------------------------------------------------
260 // wxTopLevelWindow event handling
261 // ----------------------------------------------------------------------------
263 void wxTopLevelWindowPalm::OnActivate(wxActivateEvent
& event
)
267 /* Palm OS Event handler for the window
269 * This function *must* be located outside of the wxTopLevelWindow class because
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).
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
281 static Boolean
FrameFormHandleEvent(EventType
* pEvent
)
283 Boolean fHandled
= false;
288 switch (pEvent
->eType
) {
291 #if wxUSE_MENUS_NATIVE
293 fHandled
=ActiveParentFrame
->HandleMenuOpen();
296 ItemID
=pEvent
->data
.menu
.itemID
;
297 fHandled
=ActiveParentFrame
->HandleMenuSelect(ItemID
);