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"
40 #include "wx/statusbr.h"
41 #include "wx/menuitem.h"
44 #ifdef __WXUNIVERSAL__
45 #include "wx/univ/theme.h"
46 #include "wx/univ/colschem.h"
47 #endif // __WXUNIVERSAL__
52 // ----------------------------------------------------------------------------
54 // ----------------------------------------------------------------------------
56 #if wxUSE_MENUS_NATIVE
57 extern wxMenu
*wxCurrentPopupMenu
;
58 #endif // wxUSE_MENUS_NATIVE
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
65 EVT_PAINT(wxFrame::OnPaint
)
68 #if wxUSE_EXTENDED_RTTI
69 WX_DEFINE_FLAGS( wxFrameStyle
)
71 wxBEGIN_FLAGS( wxFrameStyle
)
72 // new style border flags, we put them first to
73 // use them for streaming out
74 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
75 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
76 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
77 wxFLAGS_MEMBER(wxBORDER_RAISED
)
78 wxFLAGS_MEMBER(wxBORDER_STATIC
)
79 wxFLAGS_MEMBER(wxBORDER_NONE
)
81 // old style border flags
82 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
83 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
84 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
85 wxFLAGS_MEMBER(wxRAISED_BORDER
)
86 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
87 wxFLAGS_MEMBER(wxBORDER
)
89 // standard window styles
90 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
91 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
92 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
93 wxFLAGS_MEMBER(wxWANTS_CHARS
)
94 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
95 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
96 wxFLAGS_MEMBER(wxVSCROLL
)
97 wxFLAGS_MEMBER(wxHSCROLL
)
100 wxFLAGS_MEMBER(wxSTAY_ON_TOP
)
101 wxFLAGS_MEMBER(wxCAPTION
)
102 #if WXWIN_COMPATIBILITY_2_6
103 wxFLAGS_MEMBER(wxTHICK_FRAME
)
104 #endif // WXWIN_COMPATIBILITY_2_6
105 wxFLAGS_MEMBER(wxSYSTEM_MENU
)
106 wxFLAGS_MEMBER(wxRESIZE_BORDER
)
107 #if WXWIN_COMPATIBILITY_2_6
108 wxFLAGS_MEMBER(wxRESIZE_BOX
)
109 #endif // WXWIN_COMPATIBILITY_2_6
110 wxFLAGS_MEMBER(wxCLOSE_BOX
)
111 wxFLAGS_MEMBER(wxMAXIMIZE_BOX
)
112 wxFLAGS_MEMBER(wxMINIMIZE_BOX
)
114 wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW
)
115 wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT
)
117 wxFLAGS_MEMBER(wxFRAME_SHAPED
)
119 wxEND_FLAGS( wxFrameStyle
)
121 IMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame
, wxTopLevelWindow
,"wx/frame.h")
123 wxBEGIN_PROPERTIES_TABLE(wxFrame
)
124 wxEVENT_PROPERTY( Menu
, wxEVT_COMMAND_MENU_SELECTED
, wxCommandEvent
)
126 wxPROPERTY( Title
,wxString
, SetTitle
, GetTitle
, wxString() , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
127 wxPROPERTY_FLAGS( WindowStyle
, wxFrameStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
128 wxPROPERTY( MenuBar
, wxMenuBar
* , SetMenuBar
, GetMenuBar
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
129 wxEND_PROPERTIES_TABLE()
131 wxBEGIN_HANDLERS_TABLE(wxFrame
)
132 wxEND_HANDLERS_TABLE()
134 wxCONSTRUCTOR_6( wxFrame
, wxWindow
* , Parent
, wxWindowID
, Id
, wxString
, Title
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
137 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxTopLevelWindow
)
140 // ============================================================================
142 // ============================================================================
144 // ----------------------------------------------------------------------------
145 // creation/destruction
146 // ----------------------------------------------------------------------------
152 bool wxFrame::Create(wxWindow
*parent
,
154 const wxString
& title
,
158 const wxString
& name
)
160 if ( !wxTopLevelWindow::Create(parent
, id
, title
, pos
, size
, style
, name
) )
170 // ----------------------------------------------------------------------------
171 // wxFrame client size calculations
172 // ----------------------------------------------------------------------------
174 void wxFrame::DoSetClientSize(int width
, int height
)
178 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
179 void wxFrame::DoGetClientSize(int *x
, int *y
) const
181 wxSize size
= GetSize();
182 wxPoint pos
= GetClientAreaOrigin();
183 *x
= size
.x
- pos
.x
- 1;
184 *y
= size
.y
- pos
.y
- 1;
187 // ----------------------------------------------------------------------------
188 // wxFrame: various geometry-related functions
189 // ----------------------------------------------------------------------------
191 void wxFrame::Raise()
195 #if wxUSE_MENUS_NATIVE
197 void wxFrame::InternalSetMenuBar()
201 bool wxFrame::HandleMenuOpen()
206 m_frameMenuBar
->LoadMenu();
210 bool wxFrame::HandleMenuSelect(WXEVENTPTR event
)
212 const EventType
*palmEvent
= (EventType
*)event
;
213 const int ItemID
= palmEvent
->data
.menu
.itemID
;
218 const int item
= m_frameMenuBar
->ProcessCommand(ItemID
);
222 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, item
);
223 commandEvent
.SetEventObject(this);
225 HandleWindowEvent(commandEvent
);
229 #endif // wxUSE_MENUS_NATIVE
231 void wxFrame::OnPaint(wxPaintEvent
& event
)
234 if( m_frameStatusBar
)
235 m_frameStatusBar
->DrawStatusBar();
236 #endif // wxUSE_STATUSBAR
239 // Pass true to show full screen, false to restore.
240 bool wxFrame::ShowFullScreen(bool show
, long style
)
245 // ----------------------------------------------------------------------------
246 // tool/status bar stuff
247 // ----------------------------------------------------------------------------
251 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
256 void wxFrame::PositionToolBar()
260 #endif // wxUSE_TOOLBAR
262 // ----------------------------------------------------------------------------
263 // frame state (iconized/maximized/...)
264 // ----------------------------------------------------------------------------
266 // propagate our state change to all child frames: this allows us to emulate X
267 // Windows behaviour where child frames float independently of the parent one
268 // on the desktop, but are iconized/restored with it
269 void wxFrame::IconizeChildFrames(bool bIconize
)
273 // ----------------------------------------------------------------------------
274 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
275 // from the client area, so the client area is what's really available for the
277 // ----------------------------------------------------------------------------
279 // get the origin of the client area in the client coordinates
280 wxPoint
wxFrame::GetClientAreaOrigin() const
282 // there is no API to get client area but we know
283 // it starts after titlebar and 1 pixel of form border
284 Coord maxY
= wxSystemSettings::GetMetric(wxSYS_SCREEN_Y
),
289 if(!FrmPointInTitle((FormType
*)GetForm(),X
,Y
))
290 return wxPoint(X
,Y
+1);