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"
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
50 // the name of the default wxWidgets class
51 extern const wxChar
*wxCanvasClassName
;
53 // Pointer to the currently active frame for the form event handler.
54 wxTopLevelWindowPalm
* ActiveParentFrame
;
56 // ============================================================================
57 // wxTopLevelWindowPalm implementation
58 // ============================================================================
60 BEGIN_EVENT_TABLE(wxTopLevelWindowPalm
, wxTopLevelWindowBase
)
61 EVT_ACTIVATE(wxTopLevelWindowPalm::OnActivate
)
64 // ----------------------------------------------------------------------------
65 // wxTopLevelWindowPalm creation
66 // ----------------------------------------------------------------------------
68 void wxTopLevelWindowPalm::Init()
72 WXDWORD
wxTopLevelWindowPalm::PalmGetStyle(long style
, WXDWORD
*exflags
) const
77 WXHWND
wxTopLevelWindowPalm::PalmGetParent() const
82 bool wxTopLevelWindowPalm::Create(wxWindow
*parent
,
84 const wxString
& title
,
90 // this is a check for limitation mentioned before FrameFormHandleEvent() code
91 if(wxTopLevelWindows
.GetCount()>0)
94 ActiveParentFrame
=NULL
;
96 wxTopLevelWindows
.Append(this);
99 parent
->AddChild(this);
101 SetId( id
== wxID_ANY
? NewControlId() : id
);
103 WinConstraintsType constraints
;
104 memset(&constraints
, 0, sizeof(WinConstraintsType
));
106 constraints
.x_pos
= ( pos
.x
== wxDefaultCoord
) ? winUndefConstraint
: pos
.x
;
107 constraints
.y_pos
= ( pos
.y
== wxDefaultCoord
) ? winUndefConstraint
: pos
.y
;
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
;
116 FrameForm
= FrmNewFormWithConstraints(
131 FrmSetEventHandler(FrameForm
,FrameFormHandleEvent
);
133 FrmSetActiveForm(FrameForm
);
135 ActiveParentFrame
=this;
140 wxTopLevelWindowPalm::~wxTopLevelWindowPalm()
144 // ----------------------------------------------------------------------------
145 // wxTopLevelWindowPalm showing
146 // ----------------------------------------------------------------------------
148 void wxTopLevelWindowPalm::DoShowWindow(int nShowCmd
)
152 bool wxTopLevelWindowPalm::Show(bool show
)
154 FrmDrawForm(FrameForm
);
156 wxPaintEvent
event(m_windowId
);
157 event
.SetEventObject(this);
158 GetEventHandler()->ProcessEvent(event
);
163 // ----------------------------------------------------------------------------
164 // wxTopLevelWindowPalm maximize/minimize
165 // ----------------------------------------------------------------------------
167 void wxTopLevelWindowPalm::Maximize(bool maximize
)
171 bool wxTopLevelWindowPalm::IsMaximized() const
176 void wxTopLevelWindowPalm::Iconize(bool iconize
)
180 bool wxTopLevelWindowPalm::IsIconized() const
185 void wxTopLevelWindowPalm::Restore()
189 // ----------------------------------------------------------------------------
190 // wxTopLevelWindowPalm fullscreen
191 // ----------------------------------------------------------------------------
193 bool wxTopLevelWindowPalm::ShowFullScreen(bool show
, long style
)
198 // ----------------------------------------------------------------------------
199 // wxTopLevelWindowPalm misc
200 // ----------------------------------------------------------------------------
202 void wxTopLevelWindowPalm::SetIcon(const wxIcon
& icon
)
206 void wxTopLevelWindowPalm::SetIcons(const wxIconBundle
& icons
)
210 bool wxTopLevelWindowPalm::EnableCloseButton(bool enable
)
215 FormType
*wxTopLevelWindowPalm::GetForm()
217 return FrmGetActiveForm ();
222 bool wxTopLevelWindowPalm::SetShape(const wxRegion
& region
)
227 #endif // !__WXWINCE__
229 // ----------------------------------------------------------------------------
230 // wxTopLevelWindow event handling
231 // ----------------------------------------------------------------------------
233 void wxTopLevelWindowPalm::OnActivate(wxActivateEvent
& event
)
237 /* Palm OS Event handler for the window
239 * This function *must* be located outside of the wxTopLevelWindow class because
240 * the Palm OS API expects a standalone C function as a callback. You cannot
241 * pass a pointer to a member function of a C++ class as a callback because the
242 * prototypes don't match. (A member function has a hidden "this" pointer as
243 * its first parameter).
245 * This event handler uses a global pointer to the current wxFrame to process
246 * the events generated by the Palm OS form API. I know this is ugly, but right
247 * now I can't think of any other way to deal with this problem. If someone
248 * finds a better solution, please let me know. My email address is
251 static Boolean
FrameFormHandleEvent(EventType
* pEvent
)
253 wxFrame
* frame
= wxDynamicCast(ActiveParentFrame
,wxFrame
);
254 Boolean fHandled
= false;
259 switch (pEvent
->eType
) {
262 #if wxUSE_MENUS_NATIVE
264 fHandled
= frame
->HandleMenuOpen();
267 ItemID
= pEvent
->data
.menu
.itemID
;
268 fHandled
= frame
->HandleMenuSelect(ItemID
);