# wxMDIParentFrame Class Reference
[Managed Windows]

`#include <wx/mdi.h>`

Inheritance diagram for wxMDIParentFrame:
[legend]

## Detailed Description

An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its client area which emulates the full desktop.

MDI is a user-interface model in which all the window reside inside the single parent window as opposed to being separate from each other. It remains popular despite dire warnings from Microsoft itself (which popularized this model in the first model) that MDI is obsolete.

An MDI parent frame always has a wxMDIClientWindow associated with it, which is the parent for MDI child frames. In the simplest case, the client window takes up the entire parent frame area but it is also possible to resize it to be smaller in order to have other windows in the frame, a typical example is using a sidebar along one of the window edges.

The appearance of MDI applications differs between different ports. The classic MDI model, with child windows which can be independently moved, resized etc, is only available under MSW, which provides native support for it. In Mac ports, multiple top level windows are used for the MDI children too and the MDI parent frame itself is invisible, to accommodate the native look and feel requirements. In all the other ports, a tab-based MDI implementation (sometimes called TDI) is used and so at most one MDI child is visible at any moment (child frames are always maximized).

Remarks:

Although it is possible to have multiple MDI parent frames, a typical MDI application has a single MDI parent frame window inside which multiple MDI child frames, i.e. objects of class wxMDIChildFrame, can be created.

## Styles

This class supports the following styles:

There are no special styles for this class, all wxFrame styles apply to it in the usual way. The only exception is that wxHSCROLL and wxVSCROLL styles apply not to the frame itself but to the client window, so that using them enables horizontal and vertical scrollbars for this window and not the frame.

##

Library: wxCore

Category: Managed Windows

See also:
  wxMDIChildFrame, wxMDIClientWindow, wxFrame, wxDialog

## Public Member Functions
| 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=wxFrameNameStr)
| Constructor, creating the window.
virtual | ~wxMDIParentFrame ()
| Destructor.
virtual void | ActivateNext ()
| Activates the MDI child following the currently active one.
virtual void | ActivatePrevious ()
| Activates the MDI child preceding the currently active one.
virtual void | ArrangeIcons ()
| Arranges any iconized (minimized) MDI child windows.
virtual void | Cascade ()
| Arranges the MDI child windows in a cascade.
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=wxFrameNameStr)
| Used in two-step frame construction.
virtual wxMDIChildFrame * | GetActiveChild () const
| Returns a pointer to the active MDI child, if there is one.
wxMDIClientWindowBase * | GetClientWindow () const
| Returns a pointer to the client window.
wxMenu * | GetWindowMenu () const
| Returns the current MDI Window menu.
virtual wxMDIClientWindow * | OnCreateClient ()
| Override this to return a different kind of client window.
virtual void | SetWindowMenu (wxMenu *menu)
| Replace the current MDI Window menu.
virtual void | Tile (wxOrientation orient=wxHORIZONTAL)
| Tiles the MDI child windows either horizontally or vertically depending on whether orient is `wxHORIZONTAL` or `wxVERTICAL`.
## Static Public Member Functions
static bool | IsTDI ()
| Returns whether the MDI implementation is tab-based.

List of all members.

## Constructor & Destructor Documentation

wxMDIParentFrame::wxMDIParentFrame | ( |  | ) |

Default constructor.

Use Create() for the objects created using this constructor.

wxMDIParentFrame::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 = `wxFrameNameStr` |
| ) |  |  |

Constructor, creating the window.

Notice that if you override virtual OnCreateClient() method you shouldn't be using this constructor but the default constructor and Create() as otherwise your overridden method is never going to be called because of the usual C++ virtual call resolution rules.

Parameters:

  | parent | The window parent. Usually is NULL.
  | id | The window identifier. It may take a value of `wxID_ANY` to indicate a default value.
  | title | The caption to be displayed on the frame's title bar.
  | pos | The window position. The value wxDefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform.
  | size | The window size. The value wxDefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform.
  | style | The window style. Default value includes wxHSCROLL and wxVSCROLL styles.
  | name | The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.

Remarks:

Under wxMSW, 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:
  Create(), OnCreateClient()

virtual wxMDIParentFrame::~wxMDIParentFrame | ( |  | ) | `[virtual]`

Destructor.

Destroys all child windows and menu bar if present.

## Member Function Documentation

virtual void wxMDIParentFrame::ActivateNext | ( |  | ) | `[virtual]`

Activates the MDI child following the currently active one.

The MDI children are maintained in an ordered list and this function switches to the next element in this list, wrapping around the end of it if the currently active child is the last one.

See also:
  ActivatePrevious()

virtual void wxMDIParentFrame::ActivatePrevious | ( |  | ) | `[virtual]`

Activates the MDI child preceding the currently active one.

See also:
  ActivateNext()

virtual void wxMDIParentFrame::ArrangeIcons | ( |  | ) | `[virtual]`

Arranges any iconized (minimized) MDI child windows.

This method is only implemented in MSW MDI implementation and does nothing under the other platforms.

See also:
  Cascade(), Tile()

virtual void wxMDIParentFrame::Cascade | ( |  | ) | `[virtual]`

Arranges the MDI child windows in a cascade.

This method is only implemented in MSW MDI implementation and does nothing under the other platforms.

See also:
  Tile(), ArrangeIcons()

bool wxMDIParentFrame::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 = `wxFrameNameStr` |
| ) |  |  |

Used in two-step frame construction.

See wxMDIParentFrame() for further details.

Reimplemented from wxFrame.

virtual wxMDIChildFrame* wxMDIParentFrame::GetActiveChild | ( |  | ) | const`[virtual]`

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

If there are any children at all this function returns a non-NULL pointer.

wxMDIClientWindowBase* wxMDIParentFrame::GetClientWindow | ( |  | ) | const

Returns a pointer to the client window.

See also:
  OnCreateClient()

wxMenu* wxMDIParentFrame::GetWindowMenu | ( |  | ) | const

Returns the current MDI Window menu.

Unless wxFRAME_NO_WINDOW_MENU style was used, a default menu listing all the currently active children and providing the usual operations (tile, cascade, ...) on them is created automatically by the library and this function can be used to retrieve it. Notice that the default menu can be replaced by calling SetWindowMenu().

This function is currently not available under OS X.

Returns:
  The current Window menu or NULL.

static bool wxMDIParentFrame::IsTDI | ( |  | ) | `[static]`

Returns whether the MDI implementation is tab-based.

Currently only the MSW port uses the real MDI. In Mac ports the usual SDI is used, as common under this platforms, and all the other ports use TDI implementation.

TDI-based MDI applications have different appearance and functionality (e.g. child frames can't be minimized and only one of them is visible at any given time) so the application may need to adapt its interface somewhat depending on the return value of this function.

virtual wxMDIClientWindow* wxMDIParentFrame::OnCreateClient | ( |  | ) | `[virtual]`

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, "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.

See also:
  GetClientWindow(), wxMDIClientWindow

virtual void wxMDIParentFrame::SetWindowMenu | ( | wxMenu * | menu | ) | `[virtual]`

Replace the current MDI Window menu.

Ownership of the menu object passes to the frame when you call this function, i.e. the menu will be deleted by it when it's no longer needed (usually when the frame itself is deleted or when SetWindowMenu() is called again).

To remove the window completely, you can use the wxFRAME_NO_WINDOW_MENU window style but this function also allows to do it by passing NULL pointer as menu.

The menu may include the items with the following standard identifiers (but may use arbitrary text and help strings and bitmaps for them):

- `wxID_MDI_WINDOW_CASCADE`
- `wxID_MDI_WINDOW_TILE_HORZ`
- `wxID_MDI_WINDOW_TILE_VERT`
- `wxID_MDI_WINDOW_ARRANGE_ICONS`
- `wxID_MDI_WINDOW_PREV`
- `wxID_MDI_WINDOW_NEXT` All of which are handled by wxMDIParentFrame itself. If any other commands are used in the menu, the derived frame should handle them.

This function is currently not available under OS X.

Parameters:

  | menu | The menu to be used instead of the standard MDI Window menu or NULL.

virtual void wxMDIParentFrame::Tile | ( | wxOrientation | orient = `wxHORIZONTAL` | ) | `[virtual]`

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

This method is only implemented in MSW MDI implementation and does nothing under the other platforms.

|  | [ top ]