1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/frame.cpp
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Wlodzimierz ABX Skiba - more than minimal functionality
8 // Copyright: (c) William Osborne, Wlodzimierz Skiba
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/dialog.h"
34 #include "wx/settings.h"
35 #include "wx/dcclient.h"
39 #include "wx/toolbar.h"
43 #include "wx/statusbr.h"
44 #include "wx/generic/statusbr.h"
45 #endif // wxUSE_STATUSBAR
47 #include "wx/menuitem.h"
49 #ifdef __WXUNIVERSAL__
50 #include "wx/univ/theme.h"
51 #include "wx/univ/colschem.h"
52 #endif // __WXUNIVERSAL__
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 #if wxUSE_MENUS_NATIVE
62 extern wxMenu
*wxCurrentPopupMenu
;
63 #endif // wxUSE_MENUS_NATIVE
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
70 EVT_PAINT(wxFrame::OnPaint
)
73 #if wxUSE_EXTENDED_RTTI
74 WX_DEFINE_FLAGS( wxFrameStyle
)
76 wxBEGIN_FLAGS( wxFrameStyle
)
77 // new style border flags, we put them first to
78 // use them for streaming out
79 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
80 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
81 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
82 wxFLAGS_MEMBER(wxBORDER_RAISED
)
83 wxFLAGS_MEMBER(wxBORDER_STATIC
)
84 wxFLAGS_MEMBER(wxBORDER_NONE
)
86 // old style border flags
87 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
88 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
89 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
90 wxFLAGS_MEMBER(wxRAISED_BORDER
)
91 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
92 wxFLAGS_MEMBER(wxBORDER
)
94 // standard window styles
95 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
96 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
97 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
98 wxFLAGS_MEMBER(wxWANTS_CHARS
)
99 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
100 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
101 wxFLAGS_MEMBER(wxVSCROLL
)
102 wxFLAGS_MEMBER(wxHSCROLL
)
105 wxFLAGS_MEMBER(wxSTAY_ON_TOP
)
106 wxFLAGS_MEMBER(wxCAPTION
)
107 #if WXWIN_COMPATIBILITY_2_6
108 wxFLAGS_MEMBER(wxTHICK_FRAME
)
109 #endif // WXWIN_COMPATIBILITY_2_6
110 wxFLAGS_MEMBER(wxSYSTEM_MENU
)
111 wxFLAGS_MEMBER(wxRESIZE_BORDER
)
112 #if WXWIN_COMPATIBILITY_2_6
113 wxFLAGS_MEMBER(wxRESIZE_BOX
)
114 #endif // WXWIN_COMPATIBILITY_2_6
115 wxFLAGS_MEMBER(wxCLOSE_BOX
)
116 wxFLAGS_MEMBER(wxMAXIMIZE_BOX
)
117 wxFLAGS_MEMBER(wxMINIMIZE_BOX
)
119 wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
)
120 wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
)
122 wxFLAGS_MEMBER(wxFRAME_SHAPED
)
124 wxEND_FLAGS( wxFrameStyle
)
126 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h")
128 wxBEGIN_PROPERTIES_TABLE(wxFrame
)
129 wxEVENT_PROPERTY( Menu
, wxEVT_COMMAND_MENU_SELECTED
, wxCommandEvent
)
131 wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
132 wxPROPERTY_FLAGS( WindowStyle
, wxFrameStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
133 wxPROPERTY( MenuBar
, wxMenuBar
* , SetMenuBar
, GetMenuBar
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
134 wxEND_PROPERTIES_TABLE()
136 wxBEGIN_HANDLERS_TABLE(wxFrame
)
137 wxEND_HANDLERS_TABLE()
139 wxCONSTRUCTOR_6( wxFrame
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Title
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
142 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
145 // ============================================================================
147 // ============================================================================
149 // ----------------------------------------------------------------------------
150 // creation/destruction
151 // ----------------------------------------------------------------------------
157 bool wxFrame::Create(wxWindow
*parent
,
159 const wxString
& title
,
163 const wxString
& name
)
165 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
175 // ----------------------------------------------------------------------------
176 // wxFrame client size calculations
177 // ----------------------------------------------------------------------------
179 void wxFrame::DoSetClientSize(int width
, int height
)
183 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
184 void wxFrame::DoGetClientSize(int *x
, int *y
) const
186 wxSize size
= GetSize();
187 wxPoint pos
= GetClientAreaOrigin();
188 *x
= size
.x
- pos
.x
- 1;
189 *y
= size
.y
- pos
.y
- 1;
192 // ----------------------------------------------------------------------------
193 // wxFrame: various geometry-related functions
194 // ----------------------------------------------------------------------------
196 void wxFrame::Raise()
200 #if wxUSE_MENUS_NATIVE
202 void wxFrame::InternalSetMenuBar()
206 bool wxFrame::HandleMenuOpen()
211 m_frameMenuBar
->LoadMenu();
215 bool wxFrame::HandleMenuSelect(WXEVENTPTR event
)
217 const EventType
*palmEvent
= (EventType
*)event
;
218 const int ItemID
= palmEvent
->data
.menu
.itemID
;
223 const int item
= m_frameMenuBar
->ProcessCommand(ItemID
);
227 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, item
);
228 commandEvent
.SetEventObject(this);
230 GetEventHandler()->ProcessEvent(commandEvent
);
234 #endif // wxUSE_MENUS_NATIVE
236 void wxFrame::OnPaint(wxPaintEvent
& event
)
239 if( m_frameStatusBar
)
240 m_frameStatusBar
->DrawStatusBar();
241 #endif // wxUSE_STATUSBAR
244 // Pass true to show full screen, false to restore.
245 bool wxFrame::ShowFullScreen(bool show
, long style
)
250 // ----------------------------------------------------------------------------
251 // tool/status bar stuff
252 // ----------------------------------------------------------------------------
256 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
261 void wxFrame::PositionToolBar()
265 #endif // wxUSE_TOOLBAR
267 // ----------------------------------------------------------------------------
268 // frame state (iconized/maximized/...)
269 // ----------------------------------------------------------------------------
271 // propagate our state change to all child frames: this allows us to emulate X
272 // Windows behaviour where child frames float independently of the parent one
273 // on the desktop, but are iconized/restored with it
274 void wxFrame::IconizeChildFrames(bool bIconize
)
278 // ----------------------------------------------------------------------------
279 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
280 // from the client area, so the client area is what's really available for the
282 // ----------------------------------------------------------------------------
284 // get the origin of the client area in the client coordinates
285 wxPoint
wxFrame::GetClientAreaOrigin() const
287 // there is no API to get client area but we know
288 // it starts after titlebar and 1 pixel of form border
289 Coord maxY
= wxSystemSettings::GetMetric(wxSYS_SCREEN_Y
),
294 if(!FrmPointInTitle((FormType
*)GetForm(),X
,Y
))
295 return wxPoint(X
,Y
+1);