wxframea frame is a window whose size and position can (usually) be changed by the user. it usually has thick borders and a title bar, and can optionally contain a menu bar, toolbar and status bar. a frame can contain any window that is not a frame or dialog. a frame that has a status bar and toolbar created via the createstatusbar/createtoolbar functions manages these windows, and adjusts the value returned by getclientsize to reflect the remaining size available to application windows. derived from
wxtoplevelwindow include files <wx/frame.h> window styles
the default frame style is for normal, resizeable frames. to create a frame which can not be resized by user, you may use the following combination of styles: wxdefault_frame_style & ~ (wxresize_border | wxresize_box | wxmaximize_box). see also window styles overview. default event processing wxframe processes the following events:
remarks an application should normally define an wxcloseevent handler for the frame to respond to system close events, for example so that related data and subwindows can be cleaned up. see also wxmdiparentframe, wxmdichildframe, wxminiframe, wxdialog members
wxframe::wxframe
wxframe::wxframewxframe() default constructor. wxframe(wxwindow* parent, wxwindowid id, const wxstring& title, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxdefault_frame_style, const wxstring& name = "frame") constructor, creating the window. parameters parent
id
title
pos
size
style
name
remarks for motif, mwm (the motif window manager) should be running for any window styles to work (otherwise all styles take effect). see also
wxframe::~wxframevoid ~wxframe() destructor. destroys all child windows and menu bar if present.
wxframe::centrevoid centre(int direction = wxboth) centres the frame on the display. parameters direction
wxframe::createbool create(wxwindow* parent, wxwindowid id, const wxstring& title, const wxpoint& pos = wxdefaultposition, const wxsize& size = wxdefaultsize, long style = wxdefault_frame_style, const wxstring& name = "frame") used in two-step frame construction. see wxframe::wxframe for further details.
wxframe::createstatusbarvirtual wxstatusbar* createstatusbar(int number = 1, long style = 0, wxwindowid id = -1, const wxstring& name = "statusbar") creates a status bar at the bottom of the frame. parameters number
style
id
name
return value a pointer to the status bar if it was created successfully, null otherwise. remarks the width of the status bar is the whole width of the frame (adjusted automatically when resizing), and the height and text size are chosen by the host windowing system. by default, the status bar is an instance of wxstatusbar. to use a different class, override wxframe::oncreatestatusbar. note that you can put controls and other windows on the status bar if you wish. see also wxframe::setstatustext, wxframe::oncreatestatusbar, wxframe::getstatusbar
wxframe::createtoolbarvirtual wxtoolbar* createtoolbar(long style = wxno_border | wxtb_horizontal, wxwindowid id = -1, const wxstring& name = "toolbar") creates a toolbar at the top or left of the frame. parameters style
id
name
return value a pointer to the toolbar if it was created successfully, null otherwise. remarks by default, the toolbar is an instance of wxtoolbar (which is defined to be a suitable toolbar class on each platform, such as wxtoolbar95). to use a different class, override wxframe::oncreatetoolbar. when a toolbar has been created with this function, or made known to the frame with wxframe::settoolbar, the frame will manage the toolbar position and adjust the return value from wxwindow::getclientsize to reflect the available space for application windows. under pocket pc, you should always use this function for creating the toolbar to be managed by the frame, so that wxwidgets can use a combined menubar and toolbar. where you manage your own toolbars, create a wxtoolbar as usual. see also wxframe::createstatusbar, wxframe::oncreatetoolbar, wxframe::settoolbar, wxframe::gettoolbar
wxframe::getclientareaoriginwxpoint getclientareaorigin() const returns the origin of the frame client area (in client coordinates). it may be different from (0, 0) if the frame has a toolbar.
wxframe::getmenubarwxmenubar* getmenubar() const returns a pointer to the menubar currently associated with the frame (if any). see also wxframe::setmenubar, wxmenubar, wxmenu
wxframe::getstatusbarwxstatusbar* getstatusbar() const returns a pointer to the status bar currently associated with the frame (if any). see also wxframe::createstatusbar, wxstatusbar
wxframe::getstatusbarpaneint getstatusbarpane() returns the status bar pane used to display menu and toolbar help. see also
wxframe::gettoolbarwxtoolbar* gettoolbar() const returns a pointer to the toolbar currently associated with the frame (if any). see also wxframe::createtoolbar, wxtoolbar, wxframe::settoolbar
wxframe::oncreatestatusbarvirtual wxstatusbar* oncreatestatusbar(int number, long style, wxwindowid id, const wxstring& name) virtual function called when a status bar is requested by wxframe::createstatusbar. parameters number
style
id
name
return value a status bar object. remarks an application can override this function to return a different kind of status bar. the default implementation returns an instance of wxstatusbar. see also wxframe::createstatusbar, wxstatusbar.
wxframe::oncreatetoolbarvirtual wxtoolbar* oncreatetoolbar(long style, wxwindowid id, const wxstring& name) virtual function called when a toolbar is requested by wxframe::createtoolbar. parameters style
id
name
return value a toolbar object. remarks an application can override this function to return a different kind of toolbar. the default implementation returns an instance of wxtoolbar. see also wxframe::createtoolbar, wxtoolbar.
wxframe::processcommandvoid processcommand(int id) simulate a menu command. parameters id
wxframe::sendsizeeventvoid sendsizeevent() this function sends a dummy size event to the frame forcing it to reevaluate its children positions. it is sometimes useful to call this function after adding or deleting a children after the frame creation or if a child size changes. note that if the frame is using either sizers or constraints for the children layout, it is enough to call layout() directly and this function should not be used in this case.
wxframe::setmenubarvoid setmenubar(wxmenubar* menubar) tells the frame to show the given menu bar. parameters menubar
remarks if the frame is destroyed, the menu bar and its menus will be destroyed also, so do not delete the menu bar explicitly (except by resetting the frame's menu bar to another frame or null). under windows, a size event is generated, so be sure to initialize data members properly before calling setmenubar. note that on some platforms, it is not possible to call this function twice for the same frame object. see also wxframe::getmenubar, wxmenubar, wxmenu.
wxframe::setstatusbarvoid setstatusbar(wxstatusbar* statusbar) associates a status bar with the frame. see also wxframe::createstatusbar, wxstatusbar, wxframe::getstatusbar
wxframe::setstatusbarpanevoid setstatusbarpane(int n) set the status bar pane used to display menu and toolbar help. using -1 disables help display.
wxframe::setstatustextvirtual void setstatustext(const wxstring& text, int number = 0) sets the status bar text and redraws the status bar. parameters text
number
remarks use an empty string to clear the status bar. see also wxframe::createstatusbar, wxstatusbar
wxframe::setstatuswidthsvirtual void setstatuswidths(int n, int *widths) sets the widths of the fields in the status bar. parameters n
widths
remarks the widths of the variable fields are calculated from the total width of all fields, minus the sum of widths of the non-variable fields, divided by the number of variable fields. wxpython note: only a single parameter is required, a python list of integers. wxperl note: in wxperl this method takes the field widths as parameters.
wxframe::settoolbarvoid settoolbar(wxtoolbar* toolbar) associates a toolbar with the frame. see also wxframe::createtoolbar, wxtoolbar, wxframe::gettoolbar
|