A 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
wxWindow
wxEvtHandler
wxObject
Include files
<wx/frame.h>
Window styles
wxDEFAULT_FRAME_STYLE | Defined as wxMINIMIZE_BOX || wxMAXIMIZE_BOX || wxRESIZE_BORDER || wxSYSTEM_MENU || wxCAPTION || wxCLOSE_BOX || wxCLIP_CHILDREN. |
---|---|
wxICONIZE | Display the frame iconized (minimized). Windows only. |
wxCAPTION | Puts a caption on the frame. |
wxMINIMIZE | Identical to wxICONIZE. Windows only. |
wxMINIMIZE_BOX | Displays a minimize box on the frame. |
wxMAXIMIZE | Displays the frame maximized. Windows only. |
wxMAXIMIZE_BOX | Displays a maximize box on the frame. |
wxCLOSE_BOX | Displays a close box on the frame. |
wxSTAY_ON_TOP | Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT. Windows only. |
wxSYSTEM_MENU | Displays a system menu. |
wxRESIZE_BORDER | Displays a resizeable border around the window. |
wxFRAME_TOOL_WINDOW | Causes a frame with a small titlebar to be created; the frame does not appear in the taskbar under Windows or GTK+. |
wxFRAME_NO_TASKBAR | Creates an otherwise normal
frame but it does not appear in the taskbar under Windows or GTK+ (note that it
will minimize to the desktop window under Windows which may seem strange to the
users and thus it might be better to use this style only without
wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if GTK+ is at
least version 2.2 and the window manager supports
_NET_WM_STATE_SKIP_TASKBAR (#2 ) hint.
Has no effect under other platforms. |
wxFRAME_FLOAT_ON_PARENT | The frame will always be on top of its parent (unlike wxSTAY_ON_TOP). A frame created with this style must have a non-NULL parent. |
wxFRAME_EX_CONTEXTHELP | Under Windows, puts a query button on the caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send a wxEVT_HELP event if the user clicked on an application window. Note that this is an extended style and must be set by calling SetExtraStyle before Create is called (two-step construction). You cannot use this style together with wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use wxDEFAULT_FRAME_STYLE & (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the frames having this style (the dialogs don't have a minimize or a maximize box by default) |
wxFRAME_SHAPED | Windows with this style are allowed to have their shape changed with the SetShape method. |
wxFRAME_EX_METAL | On Mac OS X, frames with this style will be shown with a metallic look. This is an extra style. |
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:
wxEVT_SIZE | If the frame has exactly one child window, not counting the status and toolbar, this child is resized to take the entire frame client area. If two or more windows are present, they should be laid out explicitly either by manually handling wxEVT_SIZE or using sizers |
---|---|
wxEVT_MENU_HIGHLIGHT | The default implementation displays the help string associated with the selected item in the first pane of the status bar, if there is one. |
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
Default constructor.
Constructor, creating the window.
Parameters
Remarks
For Motif, MWM (the Motif Window Manager) should be running for any window styles to work (otherwise all styles take effect).
See also
Destructor. Destroys all child windows and menu bar if present.
Centres the frame on the display.
Parameters
Used in two-step frame construction. See wxFrame::wxFrame for further details.
Creates a status bar at the bottom of the frame.
Parameters
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
Creates a toolbar at the top or left of the frame.
Parameters
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
wxPoint GetClientAreaOrigin(void) 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.
wxMenuBar* GetMenuBar(void) const
Returns a pointer to the menubar currently associated with the frame (if any).
See also
wxFrame::SetMenuBar, wxMenuBar, wxMenu
wxStatusBar* GetStatusBar(void) const
Returns a pointer to the status bar currently associated with the frame (if any).
See also
wxFrame::CreateStatusBar, wxStatusBar
Returns the status bar pane used to display menu and toolbar help.
See also
wxToolBar* GetToolBar(void) const
Returns a pointer to the toolbar currently associated with the frame (if any).
See also
wxFrame::CreateToolBar, wxToolBar, wxFrame::SetToolBar
Virtual function called when a status bar is requested by wxFrame::CreateStatusBar.
Parameters
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.
Virtual function called when a toolbar is requested by wxFrame::CreateToolBar.
Parameters
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.
Simulate a menu command.
Parameters
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.
Tells the frame to show the given menu bar.
Parameters
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.
Associates a status bar with the frame.
See also
wxFrame::CreateStatusBar, wxStatusBar, wxFrame::GetStatusBar
Set the status bar pane used to display menu and toolbar help. Using -1 disables help display.
Sets the status bar text and redraws the status bar.
Parameters
Remarks
Use an empty string to clear the status bar.
See also
wxFrame::CreateStatusBar, wxStatusBar
Sets the widths of the fields in the status bar.
Parameters
nThe number of fields in the status bar. It must be the same used in CreateStatusBar.
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 での注意点: Only a single parameter is required, a Python list of integers.
wxPerl での注意点: In wxPerl this method takes the field widths as parameters.
Associates a toolbar with the frame.
See also
wxFrame::CreateToolBar, wxToolBar, wxFrame::GetToolBar
ymasuda 平成17年11月19日