1 /////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/frame.cpp
4 // Author: William Osborne
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "frame.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
36 #include "wx/dialog.h"
37 #include "wx/settings.h"
38 #include "wx/dcclient.h"
44 #include "wx/statusbr.h"
45 #include "wx/generic/statusbr.h"
46 #endif // wxUSE_STATUSBAR
49 #include "wx/toolbar.h"
50 #endif // wxUSE_TOOLBAR
52 #include "wx/menuitem.h"
55 #ifdef __WXUNIVERSAL__
56 #include "wx/univ/theme.h"
57 #include "wx/univ/colschem.h"
58 #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_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
74 EVT_PAINT(wxFrame::OnPaint
)
77 #if wxUSE_EXTENDED_RTTI
78 WX_DEFINE_FLAGS( wxFrameStyle
)
80 wxBEGIN_FLAGS( wxFrameStyle
)
81 // new style border flags, we put them first to
82 // use them for streaming out
83 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
84 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
85 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
86 wxFLAGS_MEMBER(wxBORDER_RAISED
)
87 wxFLAGS_MEMBER(wxBORDER_STATIC
)
88 wxFLAGS_MEMBER(wxBORDER_NONE
)
90 // old style border flags
91 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
92 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
93 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
94 wxFLAGS_MEMBER(wxRAISED_BORDER
)
95 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
96 wxFLAGS_MEMBER(wxBORDER
)
98 // standard window styles
99 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
100 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
101 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
102 wxFLAGS_MEMBER(wxWANTS_CHARS
)
103 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
104 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
105 wxFLAGS_MEMBER(wxVSCROLL
)
106 wxFLAGS_MEMBER(wxHSCROLL
)
109 wxFLAGS_MEMBER(wxSTAY_ON_TOP
)
110 wxFLAGS_MEMBER(wxCAPTION
)
111 wxFLAGS_MEMBER(wxTHICK_FRAME
)
112 wxFLAGS_MEMBER(wxSYSTEM_MENU
)
113 wxFLAGS_MEMBER(wxRESIZE_BORDER
)
114 wxFLAGS_MEMBER(wxRESIZE_BOX
)
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
, this) )
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
188 // ----------------------------------------------------------------------------
189 // wxFrame: various geometry-related functions
190 // ----------------------------------------------------------------------------
192 void wxFrame::Raise()
196 // generate an artificial resize event
197 void wxFrame::SendSizeEvent()
201 #if wxUSE_MENUS_NATIVE
203 void wxFrame::AttachMenuBar(wxMenuBar
*menubar
)
205 wxFrameBase::AttachMenuBar(menubar
);
209 // actually remove the menu from the frame
210 m_hMenu
= (WXHMENU
)0;
214 void wxFrame::InternalSetMenuBar()
218 bool wxFrame::HandleMenuOpen()
223 m_frameMenuBar
->LoadMenu();
227 bool wxFrame::HandleMenuSelect(int ItemID
)
232 int item
=m_frameMenuBar
->ProcessCommand(ItemID
);
236 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, item
);
237 commandEvent
.SetEventObject(this);
239 GetEventHandler()->ProcessEvent(commandEvent
);
243 #endif // wxUSE_MENUS_NATIVE
245 // Responds to colour changes, and passes event on to children.
246 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
250 void wxFrame::OnPaint(wxPaintEvent
& event
)
253 if( m_frameStatusBar
)
254 m_frameStatusBar
->DrawStatusBar();
255 #endif // wxUSE_STATUSBAR
258 // Pass TRUE to show full screen, FALSE to restore.
259 bool wxFrame::ShowFullScreen(bool show
, long style
)
264 // ----------------------------------------------------------------------------
265 // tool/status bar stuff
266 // ----------------------------------------------------------------------------
270 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
275 void wxFrame::PositionToolBar()
279 #endif // wxUSE_TOOLBAR
281 // ----------------------------------------------------------------------------
282 // frame state (iconized/maximized/...)
283 // ----------------------------------------------------------------------------
285 // propagate our state change to all child frames: this allows us to emulate X
286 // Windows behaviour where child frames float independently of the parent one
287 // on the desktop, but are iconized/restored with it
288 void wxFrame::IconizeChildFrames(bool bIconize
)
292 WXHICON
wxFrame::GetDefaultIcon() const
294 // we don't have any standard icons (any more)
298 // ===========================================================================
299 // message processing
300 // ===========================================================================
302 // ---------------------------------------------------------------------------
304 // ---------------------------------------------------------------------------
306 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
311 // ---------------------------------------------------------------------------
312 // our private (non virtual) message handlers
313 // ---------------------------------------------------------------------------
315 bool wxFrame::HandlePaint()
320 bool wxFrame::HandleSize(int x
, int y
, WXUINT id
)
325 bool wxFrame::HandleCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
330 // ---------------------------------------------------------------------------
331 // the window proc for wxFrame
332 // ---------------------------------------------------------------------------
334 WXLRESULT
wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
339 // ----------------------------------------------------------------------------
340 // wxFrame size management: we exclude the areas taken by menu/status/toolbars
341 // from the client area, so the client area is what's really available for the
343 // ----------------------------------------------------------------------------
345 // get the origin of the client area in the client coordinates
346 wxPoint
wxFrame::GetClientAreaOrigin() const