The XsMDICanvas requires that all documents be a subclass of XsMDIWindow or a subclass of a class derived from it. By itself XsMDIWindow does not define any appearance or behavior for the documents. However, XsMotifWindow, derived from XsMDIWindow, defines a MWM-like look-and-feel to a document.
Documents in your application should be derived from XsMotifWindow. This class provides the look-and-feel of Motif window and supports the interaction with the XsMDICanvas. It is up to the application to define the contents of each document.
Constructor and Destructor:
The XsMotifWindow constructor accepts one argument:
The name parameter specifies the name of the document and is used as the widget name for the underlying implementation. The name parameter is also used as the default title and icon-name for the document.
Note: The XsMotifWindow constructor does not create any widgets. Rather it only initializes internal variables. The widgets are not created until the document is added to the canvas. The XsMDICanvas calls the member-function XsMotifWindow::_buildClientArea() when it needs to create the document widgets.
The XsMotifWindow destructor destroys the document widgets (if they have been created) and frees its internal storage. It is up to the application to free all documents. The XsMDICanvas will not destroy the documents for you.
Document Utilities:
Although rarely called from the application, the XsMotifWindow supports a number of utility functions to manipulate the document.
The close member-function does not destroy the document, it simply hides it from view. You can restore a closed document with XsMotifWindow::show().
The following member-functions are used to change/query the appearance of the document:
The setPixmap member-function accepts a pixmap which the document then uses as the decoration on the icon. Because the document does not make a copy of the pixmap, it is important that the application not free the pixmap until all documents that reference it are deleted. The document does, however, make a local copy of the title or icon-name string passed to it, so the application is free to do whatever it wants to the passed-in string. The icon member-function returns the widget that is used to implement the icon.
Creating Window Subclasses:
The application must derive its documents from XsMotifWindow in order to define the contents of the document. The XsMDICanvas calls the protected member-function _buildClientArea when it creates the document. Each class derived from XsMotifWindow must override this pure-virtual member-function.
The member-function _buildClientArea is called with a single argument:
As an example, consider the following:
// _buildClientArea (called to create document contents) void MyDocument::_buildClientArea (Widget parent) { assert (parent != 0); // Create a main window with some dummy menus Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); ... XtManageChild (mainW); }
In this case, an XmMainWindow is created as the child of the parent widget. The XmMainWindow is then attached to the 4 sides of the parent form. Note also that the main window is managed before returning from the function.
Resources:
The XsMotifWindow supports the following resources:
Name Class Type Default ------------------------------------------------------------------------------ borderSize BorderSize Dimension 6 buttonSize ButtonSize Dimension 23 title Title String dynamic titleFont TitleFont String -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1 iconSize IconSize Dimension 70 iconName IconName String dynamic iconFont IconFont String *-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1 XmNiconX XmCIconX Position dynamic XmNiconY XmCIconY Position dynamic saveUnder SaveUnder Boolean True restoreString RestoreString String "Restore" moveString MoveString String "Move" sizeString SizeString String "Size" minimizeString MinimizeString String "Minimize" maximizeString MaximizeString String "Maximize" raiseString RaiseString String "Raise" lowerString LowerString String "Lower" closeString CloseString String "Close" menuFont MenuFont String -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1 showBorder ShowBorder Boolean True showResize ShowResize Boolean True showTitle ShowTitle Boolean True showMenu ShowMenu Boolean True showMinimize ShowMinimize Boolean True showMaximize ShowMaximize Boolean True lowerOnIconify LowerOnIconify Boolean False XmNminWidth XmCMinWidth Dimension dynamic XmNmaxWidth XmCMaxWidth Dimension dynamic XmNminHeight XmCMinHeight Dimension dynamic XmNmaxHeight XmCMaxHeight Dimension dynamic
XsMotifWindow Implementation:
As a convenience to those who wish to modify the XsMotifWindow code, here is a diagram of the internal class structure: