| 1 | <HTML> |
| 2 | |
| 3 | <HEAD> |
| 4 | <TITLE>Motif Multi-Document Interface (MDI)</TITLE> |
| 5 | <LINK REV="made" HREF="mailto:ssadler@cisco.com"> |
| 6 | </HEAD> |
| 7 | |
| 8 | <CENTER> |
| 9 | <IMG SRC="pics/mdi.gif" ALT="[Class Structure]"> |
| 10 | <P><H2> |
| 11 | <B> |
| 12 | The Motif Multi-Document Interface |
| 13 | </B> |
| 14 | </H2> |
| 15 | </CENTER> |
| 16 | |
| 17 | <P> |
| 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. |
| 22 | |
| 23 | <P> |
| 24 | <HR SIZE = 4> |
| 25 | |
| 26 | <P> |
| 27 | <B> |
| 28 | C<FONT SIZE=-1>LASS</FONT> |
| 29 | S<FONT SIZE=-1>TRUCTURE:</FONT> |
| 30 | </B> |
| 31 | |
| 32 | <P> |
| 33 | <IMG SRC="pics/classes.gif" ALT="[Class Structure]"> |
| 34 | |
| 35 | <BR> |
| 36 | Figure 1. Inheritance Graph for MDI classes |
| 37 | |
| 38 | <P> |
| 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. |
| 43 | |
| 44 | <P> |
| 45 | <HR SIZE = 4> |
| 46 | |
| 47 | <P> |
| 48 | <B> |
| 49 | E<FONT SIZE=-1>XAMPLE:</FONT> |
| 50 | </B> |
| 51 | |
| 52 | <P> |
| 53 | The process of building and displaying a Multi-Document Interface using MDI |
| 54 | consists of the following steps: |
| 55 | |
| 56 | <OL> |
| 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> |
| 60 | </OL> |
| 61 | |
| 62 | <PRE> |
| 63 | |
| 64 | #include "XsMDICanvas.h" |
| 65 | #include "XsMotifWindow.h" |
| 66 | |
| 67 | // Application document (derived from XsMotifWindow) |
| 68 | |
| 69 | class MyDocument : public XsMotifWindow { |
| 70 | public: |
| 71 | MyDocument (const char *name); |
| 72 | virtual ~MyDocument ( ); |
| 73 | protected: |
| 74 | virtual void _buildClientArea (Widget parent); |
| 75 | }; |
| 76 | |
| 77 | void createCanvas (Widget parent) { |
| 78 | |
| 79 | // Create documents |
| 80 | |
| 81 | MyDocument *doc1 = new MyDocument ("doc1"); |
| 82 | MyDocument *doc2 = new MyDocument ("doc2"); |
| 83 | |
| 84 | // Create the canvas |
| 85 | |
| 86 | XsMDICanvas *canvas = new XsMDICanvas ("canvas", parent); |
| 87 | |
| 88 | // Add documents to canvas |
| 89 | |
| 90 | canvas->add (doc1); |
| 91 | canvas->add (doc2); |
| 92 | |
| 93 | // Show the canvas |
| 94 | |
| 95 | canvas->show ( ); |
| 96 | } |
| 97 | |
| 98 | </PRE> |
| 99 | |
| 100 | <P> |
| 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>. |
| 104 | |
| 105 | <P> |
| 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. |
| 110 | |
| 111 | <P> |
| 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. |
| 118 | |
| 119 | <P> |
| 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. |
| 124 | |
| 125 | <P> |
| 126 | <HR SIZE = 4> |
| 127 | |
| 128 | <P> |
| 129 | <B> |
| 130 | C<FONT SIZE=-1>LASS</FONT> |
| 131 | R<FONT SIZE=-1>EFERENCES:</FONT> |
| 132 | </B> |
| 133 | |
| 134 | <P> |
| 135 | Of the classes in the MDI package, only the following should be of |
| 136 | interest to MDI library users: |
| 137 | |
| 138 | <UL> |
| 139 | <LI> <A HREF="canvas.html"> XsMDICanvas </A> </LI> |
| 140 | <LI> <A HREF="mwindow.html"> XsMotifWindow </A> </LI> |
| 141 | </UL> |
| 142 | |
| 143 | <P> |
| 144 | <HR SIZE = 4> |
| 145 | |
| 146 | <P> |
| 147 | <B> |
| 148 | E<FONT SIZE=-1>XPLORING</FONT> |
| 149 | R<FONT SIZE=-1>ESOURCES:</FONT> |
| 150 | </B> |
| 151 | |
| 152 | <P> |
| 153 | The MDI classes support a number of different X-resources (please refer |
| 154 | the 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: |
| 157 | |
| 158 | <DL> |
| 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> |
| 164 | </DL> |
| 165 | |
| 166 | <P> |
| 167 | <HR SIZE = 4> |
| 168 | |
| 169 | <P> |
| 170 | <B> |
| 171 | A<FONT SIZE=-1>DDITIONAL</FONT> |
| 172 | I<FONT SIZE=-1>INFORMATION:</FONT> |
| 173 | </B> |
| 174 | |
| 175 | <P> |
| 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. |
| 178 | |
| 179 | </BODY> |
| 180 | </HTML> |
| 181 | |
| 182 | |