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"
42 #include "wx/statusbr.h"
43 #include "wx/generic/statusbr.h"
44 #endif // wxUSE_STATUSBAR
47 #include "wx/toolbar.h"
48 #endif // wxUSE_TOOLBAR
50 #include "wx/menuitem.h"
52 #ifdef __WXUNIVERSAL__
53 #include "wx/univ/theme.h"
54 #include "wx/univ/colschem.h"
55 #endif // __WXUNIVERSAL__
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 #if wxUSE_MENUS_NATIVE
65 extern wxMenu
*wxCurrentPopupMenu
;
66 #endif // wxUSE_MENUS_NATIVE
68 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
73 EVT_PAINT(wxFrame::OnPaint
)
76 #if wxUSE_EXTENDED_RTTI
77 WX_DEFINE_FLAGS( wxFrameStyle
)
79 wxBEGIN_FLAGS( wxFrameStyle
)
80 // new style border flags, we put them first to
81 // use them for streaming out
82 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
83 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
84 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
85 wxFLAGS_MEMBER(wxBORDER_RAISED
)
86 wxFLAGS_MEMBER(wxBORDER_STATIC
)
87 wxFLAGS_MEMBER(wxBORDER_NONE
)
89 // old style border flags
90 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
91 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
92 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
93 wxFLAGS_MEMBER(wxRAISED_BORDER
)
94 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
95 wxFLAGS_MEMBER(wxBORDER
)
97 // standard window styles
98 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
99 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
100 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
101 wxFLAGS_MEMBER(wxWANTS_CHARS
)
102 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
103 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
104 wxFLAGS_MEMBER(wxVSCROLL
)
105 wxFLAGS_MEMBER(wxHSCROLL
)
108 wxFLAGS_MEMBER(wxSTAY_ON_TOP
)
109 wxFLAGS_MEMBER(wxCAPTION
)
110 #if WXWIN_COMPATIBILITY_2_6
111 wxFLAGS_MEMBER(wxTHICK_FRAME
)
112 #endif // WXWIN_COMPATIBILITY_2_6
113 wxFLAGS_MEMBER(wxSYSTEM_MENU
)
114 wxFLAGS_MEMBER(wxRESIZE_BORDER
)
115 #if WXWIN_COMPATIBILITY_2_6
116 wxFLAGS_MEMBER(wxRESIZE_BOX
)
117 #endif // WXWIN_COMPATIBILITY_2_6
118 wxFLAGS_MEMBER(wxCLOSE_BOX
)
119 wxFLAGS_MEMBER(wxMAXIMIZE_BOX
)
120 wxFLAGS_MEMBER(wxMINIMIZE_BOX
)
122 wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
)
123 wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
)
125 wxFLAGS_MEMBER(wxFRAME_SHAPED
)
127 wxEND_FLAGS( wxFrameStyle
)
129 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h")
131 wxBEGIN_PROPERTIES_TABLE(wxFrame
)
132 wxEVENT_PROPERTY( Menu
, wxEVT_COMMAND_MENU_SELECTED
, wxCommandEvent
)
134 wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
135 wxPROPERTY_FLAGS( WindowStyle
, wxFrameStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
136 wxPROPERTY( MenuBar
, wxMenuBar
* , SetMenuBar
, GetMenuBar
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
137 wxEND_PROPERTIES_TABLE()
139 wxBEGIN_HANDLERS_TABLE(wxFrame
)
140 wxEND_HANDLERS_TABLE()
142 wxCONSTRUCTOR_6( wxFrame
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Title
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
145 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
148 // ============================================================================
150 // ============================================================================
152 // ----------------------------------------------------------------------------
153 // creation/destruction
154 // ----------------------------------------------------------------------------
160 bool wxFrame::Create(wxWindow
*parent
,
162 const wxString
& title
,
166 const wxString
& name
)
168 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
178 // ----------------------------------------------------------------------------
179 // wxFrame client size calculations
180 // ----------------------------------------------------------------------------
182 void wxFrame::DoSetClientSize(int width
, int height
)
186 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
187 void wxFrame::DoGetClientSize(int *x
, int *y
) const
189 wxSize size
= GetSize();
190 wxPoint pos
= GetClientAreaOrigin();
191 *x
= size
.x
- pos
.x
- 1;
192 *y
= size
.y
- pos
.y
- 1;
195 // ----------------------------------------------------------------------------
196 // wxFrame: various geometry-related functions
197 // ----------------------------------------------------------------------------
199 void wxFrame::Raise()
203 #if wxUSE_MENUS_NATIVE
205 void wxFrame::InternalSetMenuBar()
209 bool wxFrame::HandleMenuOpen()
214 m_frameMenuBar
->LoadMenu();
218 bool wxFrame::HandleMenuSelect(WXEVENTPTR event
)
220 const EventType
*palmEvent
= (EventType
*)event
;
221 const int ItemID
= palmEvent
->data
.menu
.itemID
;
226 const int item
= m_frameMenuBar
->ProcessCommand(ItemID
);
230 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, item
);
231 commandEvent
.SetEventObject(this);
233 GetEventHandler()->ProcessEvent(commandEvent
);
237 #endif // wxUSE_MENUS_NATIVE
239 void wxFrame::OnPaint(wxPaintEvent
& event
)
242 if( m_frameStatusBar
)
243 m_frameStatusBar
->DrawStatusBar();
244 #endif // wxUSE_STATUSBAR
247 // Pass true to show full screen, false to restore.
248 bool wxFrame::ShowFullScreen(bool show
, long style
)
253 // ----------------------------------------------------------------------------
254 // tool/status bar stuff
255 // ----------------------------------------------------------------------------
259 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
264 void wxFrame::PositionToolBar()
268 #endif // wxUSE_TOOLBAR
270 // ----------------------------------------------------------------------------
271 // frame state (iconized/maximized/...)
272 // ----------------------------------------------------------------------------
274 // propagate our state change to all child frames: this allows us to emulate X
275 // Windows behaviour where child frames float independently of the parent one
276 // on the desktop, but are iconized/restored with it
277 void wxFrame::IconizeChildFrames(bool bIconize
)
281 // ----------------------------------------------------------------------------
282 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
283 // from the client area, so the client area is what's really available for the
285 // ----------------------------------------------------------------------------
287 // get the origin of the client area in the client coordinates
288 wxPoint
wxFrame::GetClientAreaOrigin() const
290 // there is no API to get client area but we know
291 // it starts after titlebar and 1 pixel of form border
292 Coord maxY
= wxSystemSettings::GetMetric(wxSYS_SCREEN_Y
),
297 if(!FrmPointInTitle((FormType
*)GetForm(),X
,Y
))
298 return wxPoint(X
,Y
+1);