Contents Up Previous Next

wxMDIParentFrame

An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its own 'desktop'. It is a convenient way to avoid window clutter, and is used in many popular Windows applications, such as Microsoft Word(TM).

Derived from

wxFrame
wxWindow
wxEvtHandler
wxObject

Include files

<wx/mdi.h>

Remarks

There may be multiple MDI parent frames in a single application, but this probably only makes sense within programming development environments.

Child frames may be of class wxMDIChildFrame (contained within the parent frame) or wxFrame (shown as a top-level frame).

An MDI parent frame always has a wxMDIClientWindow associated with it, which is the parent for MDI client frames. This client window may be resized to accommodate non-MDI windows, as seen in Microsoft Visual C++ (TM) and Microsoft Publisher (TM), where a documentation window is placed to one side of the workspace.

MDI remains popular despite dire warnings from Microsoft itself that MDI is an obsolete user interface style.

The implementation is native in Windows, and simulated under Motif. Under Motif, the child window frames will often have a different appearance from other frames because the window decorations are simulated.

Window styles

wxCAPTION Puts a caption on the frame.
wxDEFAULT_FRAME_STYLE Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION.
wxHSCROLL Displays a horizontal scrollbar in the client window, allowing the user to view child frames that are off the current view.
wxICONIZE Display the frame iconized (minimized) (Windows only).
wxMAXIMIZE Displays the frame maximized (Windows only).
wxMAXIMIZE_BOX Displays a maximize box on the frame (Windows and Motif only).
wxMINIMIZE Identical to wxICONIZE.
wxMINIMIZE_BOX Displays a minimize box on the frame (Windows and Motif only).
wxRESIZE_BORDER Displays a resizeable border around the window (Motif only; for Windows, it is implicit in wxTHICK_FRAME).
wxSTAY_ON_TOP Stay on top of other windows (Windows only).
wxSYSTEM_MENU Displays a system menu (Windows and Motif only).
wxTHICK_FRAME Displays a thick frame around the window (Windows and Motif only).
wxVSCROLL Displays a vertical scrollbar in the client window, allowing the user to view child frames that are off the current view.
wxFRAME_NO_WINDOW_MENU Under Windows, removes the Window menu that is normally added automatically.

See also window styles overview.

See also

wxMDIChildFrame, wxMDIClientWindow, wxFrame, wxDialog

Members

wxMDIParentFrame::wxMDIParentFrame
wxMDIParentFrame::~wxMDIParentFrame
wxMDIParentFrame::ActivateNext
wxMDIParentFrame::ActivatePrevious
wxMDIParentFrame::ArrangeIcons
wxMDIParentFrame::Cascade
wxMDIParentFrame::Create
wxMDIParentFrame::GetClientSize
wxMDIParentFrame::GetActiveChild
wxMDIParentFrame::GetClientWindow
wxMDIParentFrame::GetToolBar
wxMDIParentFrame::GetWindowMenu
wxMDIParentFrame::OnCreateClient
wxMDIParentFrame::SetToolBar
wxMDIParentFrame::SetWindowMenu
wxMDIParentFrame::Tile


wxMDIParentFrame::wxMDIParentFrame

wxMDIParentFrame()

Default constructor.

wxMDIParentFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, const wxString& name = "frame")

Constructor, creating the window.

Parameters

parent

id

title

pos

size

style

name

Remarks

During the construction of the frame, the client window will be created. To use a different class from wxMDIClientWindow, override wxMDIParentFrame::OnCreateClient.

Under Windows 95, the client window will automatically have a sunken border style when the active child is not maximized, and no border style when a child is maximized.

See also

wxMDIParentFrame::Create, wxMDIParentFrame::OnCreateClient


wxMDIParentFrame::~wxMDIParentFrame

~wxMDIParentFrame()

Destructor. Destroys all child windows and menu bar if present.


wxMDIParentFrame::ActivateNext

void ActivateNext()

Activates the MDI child following the currently active one.

See also

wxMDIParentFrame::ActivatePrevious


wxMDIParentFrame::ActivatePrevious

void ActivatePrevious()

Activates the MDI child preceding the currently active one.

See also

wxMDIParentFrame::ActivateNext


wxMDIParentFrame::ArrangeIcons

void ArrangeIcons()

Arranges any iconized (minimized) MDI child windows.

See also

wxMDIParentFrame::Cascade, wxMDIParentFrame::Tile


wxMDIParentFrame::Cascade

void Cascade()

Arranges the MDI child windows in a cascade.

See also

wxMDIParentFrame::Tile, wxMDIParentFrame::ArrangeIcons


wxMDIParentFrame::Create

bool Create(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, const wxString& name = "frame")

Used in two-step frame construction. See wxMDIParentFrame::wxMDIParentFrame for further details.


wxMDIParentFrame::GetClientSize

virtual void GetClientSize(int* width, int* height) const

This gets the size of the frame 'client area' in pixels.

Parameters

width

height

Remarks

The client area is the area which may be drawn on by the programmer, excluding title bar, border, status bar, and toolbar if present.

If you wish to manage your own toolbar (or perhaps you have more than one), provide an OnSize event handler. Call GetClientSize to find how much space there is for your windows and don't forget to set the size and position of the MDI client window as well as your toolbar and other windows (but not the status bar).

If you have set a toolbar with wxMDIParentFrame::SetToolbar, the client size returned will have subtracted the toolbar height. However, the available positions for the client window and other windows of the frame do not start at zero - you must add the toolbar height.

The position and size of the status bar and toolbar (if known to the frame) are always managed by wxMDIParentFrame, regardless of what behaviour is defined in your OnSize event handler. However, the client window position and size are always set in OnSize, so if you override this event handler, make sure you deal with the client window.

You do not have to manage the size and position of MDI child windows, since they are managed automatically by the client window.

See also

wxMDIParentFrame::GetToolBar, wxMDIParentFrame::SetToolBar, wxMDIClientWindow

wxPython note: The wxPython version of this method takes no arguments and returns a tuple containing width and height.


wxMDIParentFrame::GetActiveChild

wxMDIChildFrame* GetActiveChild() const

Returns a pointer to the active MDI child, if there is one.


wxMDIParentFrame::GetClientWindow

wxMDIClientWindow* GetClientWindow() const

Returns a pointer to the client window.

See also

wxMDIParentFrame::OnCreateClient


wxMDIParentFrame::GetToolBar

virtual wxWindow* GetToolBar() const

Returns the window being used as the toolbar for this frame.

See also

wxMDIParentFrame::SetToolBar


wxMDIParentFrame::GetWindowMenu

wxMenu* GetWindowMenu() const

Returns the current Window menu (added by wxWidgets to the menubar). This function is available under Windows only.


wxMDIParentFrame::OnCreateClient

virtual wxMDIClientWindow* OnCreateClient()

Override this to return a different kind of client window. If you override this function, you must create your parent frame in two stages, or your function will never be called, due to the way C++ treats virtual functions called from constructors. For example:

  frame = new MyParentFrame;
  frame->Create(parent, myParentFrameId, wxT("My Parent Frame"));
Remarks

You might wish to derive from wxMDIClientWindow in order to implement different erase behaviour, for example, such as painting a bitmap on the background.

Note that it is probably impossible to have a client window that scrolls as well as painting a bitmap or pattern, since in OnScroll, the scrollbar positions always return zero. (Solutions to: julian.smart@btopenworld.com).

See also

wxMDIParentFrame::GetClientWindow, wxMDIClientWindow


wxMDIParentFrame::SetToolBar

virtual void SetToolBar(wxWindow* toolbar)

Sets the window to be used as a toolbar for this MDI parent window. It saves the application having to manage the positioning of the toolbar MDI client window.

Parameters

toolbar

Remarks

When the frame is resized, the toolbar is resized to be the width of the frame client area, and the toolbar height is kept the same.

The parent of the toolbar must be this frame.

If you wish to manage your own toolbar (or perhaps you have more than one), don't call this function, and instead manage your subwindows and the MDI client window by providing an OnSize event handler. Call wxMDIParentFrame::GetClientSize to find how much space there is for your windows.

Note that SDI (normal) frames and MDI child windows must always have their toolbars managed by the application.

See also

wxMDIParentFrame::GetToolBar, wxMDIParentFrame::GetClientSize


wxMDIParentFrame::SetWindowMenu

void SetWindowMenu(wxMenu* menu)

Call this to change the current Window menu. Ownership of the menu object passes to the frame when you call this function.

This call is available under Windows only.

To remove the window completely, use the wxFRAME_NO_WINDOW_MENU window style.


wxMDIParentFrame::Tile

void Tile(wxOrientation orient = wxHORIZONTAL)

Tiles the MDI child windows either horizontally or vertically depending on whether orient is wxHORIZONTAL or wxVERTICAL.

Currently only implemented for MSW, does nothing under the other platforms.

See also

wxMDIParentFrame::Cascade, wxMDIParentFrame::ArrangeIcons