4 <TITLE>Motif Multi-Document Interface (MDI)
</TITLE> 
   5 <LINK REV=
"made" HREF=
"mailto:ssadler@cisco.com"> 
   9 <IMG SRC=
"pics/mdi.gif" ALT=
"[Class Structure]"> 
  12 The Motif Multi-Document Interface
 
  18 The Motif Multi-Document Interface (MDI) is a collection of C++ classes
 
  19 that emulates the behavior of the Multi-Document Interface in Microsoft
 
  20 Windows.  The MDI framework allows a user to view multiple documents (windows)
 
  21 constrained to a single parent window.
 
  28 C
<FONT SIZE=-
1>LASS
</FONT> 
  29 S
<FONT SIZE=-
1>TRUCTURE:
</FONT> 
  33 <IMG SRC=
"pics/classes.gif" ALT=
"[Class Structure]"> 
  36 Figure 
1.  Inheritance Graph for MDI classes
 
  39 The 
<I>XsMDICanvas
</I> is a self-contained component used to display and manage
 
  40 any number of child document windows.  All documents windows are derived from
 
  41 the abstract base-class 
<I>XsMDIWindow
</I>.  To get the Motif-like functionality,
 
  42 document windows should be derived from the 
<I>XsMotifWindow
</I> class.
 
  49 E
<FONT SIZE=-
1>XAMPLE:
</FONT>  
  53 The process of building and displaying a Multi-Document Interface using MDI
 
  54 consists of the following steps:
 
  57 <LI>Creating the application document(s)
</LI> 
  58 <LI>Creating the MDI canvas
</LI> 
  59 <LI>Adding the document(s) to the canvas
</LI> 
  64 #include "XsMDICanvas.h"
 
  65 #include "XsMotifWindow.h"
 
  67 // Application document (derived from XsMotifWindow)
 
  69 class MyDocument : public XsMotifWindow {
 
  71       MyDocument (const char *name);
 
  72       virtual ~MyDocument ( );
 
  74       virtual void _buildClientArea (Widget parent);
 
  77 void createCanvas (Widget parent) {
 
  81    MyDocument *doc1 = new MyDocument ("doc1");
 
  82    MyDocument *doc2 = new MyDocument ("doc2");
 
  86    XsMDICanvas *canvas = new XsMDICanvas ("canvas", parent);
 
  88 // Add documents to canvas
 
 101 In this example, the application document 
<I>MyDocument
</I> is derived
 
 102 from 
<I>XsMotifWindow
</I>.  This provides a Motif-like window suitable for
 
 103 use with the 
<I>XsMDICanvas
</I>.
 
 106 Next, two 
<I>MyDocument
</I> objects are created along with the 
<I>XsMDICanvas
</I>.
 
 107 The two documents are then added to the canvas using the 
<I>add
</I> 
 108 member-function of the canvas.  Lastly, the canvas is shown (managed)
 
 109 using the 
<I>show
</I> member-function.
 
 112 Creating the document 
<I>MyDocument
</I> does not automatically create any
 
 113 widgets.  Rather, it only initializes internal variables.  The widgets are
 
 114 not created until the document is added to the canvas.  The 
<I>XsMDICanvas
</I> 
 115 is responsible for calling 
<I>XsMotifWindow::_buildClientArea()
</I> at an
 
 116 appropriate time.  In this member-function, the application can create the
 
 117 actual contents of the document.
 
 120 The member-function 
<I>_buildClientArea
</I> is passed a widget to be used as
 
 121 the parent of the document contents.  This parent widget is an unmanaged
 
 122 <I>XmForm
</I> widget.  The application is free to create whatever contents
 
 123 it needs as a child of the 
<I>XmForm
</I> parent.
 
 130 C
<FONT SIZE=-
1>LASS
</FONT> 
 131 R
<FONT SIZE=-
1>EFERENCES:
</FONT> 
 135 Of the classes in the MDI package, only the following should be of
 
 136 interest to MDI library users:
 
 139 <LI> <A HREF=
"canvas.html"> XsMDICanvas 
</A> </LI> 
 140 <LI> <A HREF=
"mwindow.html"> XsMotifWindow 
</A> </LI> 
 148 E
<FONT SIZE=-
1>XPLORING
</FONT> 
 149 R
<FONT SIZE=-
1>ESOURCES:
</FONT> 
 153 The MDI classes support a number of different X-resources (please refer
 
 154 to the class manual pages for complete details).  In order to get a feel
 
 155 for the customization capabilities of the MDI library, try running the
 
 156 test program (
<I>MDItest
</I>) with the following command-line options:
 
 159 <DD>MDItest -xrm "*showBorder:false"
</DD> 
 160 <DD>MDItest -xrm "*showTitle:false" -xrm "*showResize:false"
</DD> 
 161 <DD>MDItest -xrm "*showMenu:false" -xrm "*showMaximize:false"
</DD> 
 162 <DD>MDItest -xrm "*borderSize:
4" -xrm "*buttonSize:
14"
</DD> 
 163 <DD>MDItest -xrm "*lowerOnIconify:true" -xrm "*title:Hello World"
</DD> 
 171 A
<FONT SIZE=-
1>DDITIONAL
</FONT> 
 172 I
<FONT SIZE=-
1>INFORMATION:
</FONT> 
 176 The test program 
<I>MDItest.C
</I> gives a complete example of an MDI
 
 177 application.  It should serve as a good reference/example of the MDI library.