The XsMDICanvas Class
This section describes how to build and manipulate an MDI using the XsMDICanvas class. Minimally, you must perform the following actions to build and display an MDI canvas:
- Create the XsMDICanvas object.
- Create the documents as instances of subclasses of XsMDIWindow.
- Add the documents to the canvas
- Show the canvas
Constructor and Destructor:
The XsMDICanvas accepts two arguments:
The name parameter specifies the name of the canvas and is used as the widget name for the underlying implementation. The parent parameter specifies the widget that is to be used as the parent of the canvas.
The XsMDICanvas destructor destroys the canvas, but it does not destroy any of the underlying documents. It is up to the application to destroy these.
Adding and removing documents:
After the documents are created, they must be added to the canvas. The XsMDICanvas::add() member-function adds documents to the canvas:
The behavior of adding the same document to the canvas more than once is undefined. Documents can be removed from the canvas by using:
Additionally, all documents can be removed from the canvas with:
The number of documents currently installed in the canvas can be retrieved with:
Showing the canvas:
In order to show (manage) the canvas call the show member function:
The current implementation of XsMDICanvas uses a very simple algorithm to place the documents on the canvas. In order to implement a more specific placement algorithm, derive a class from XsMDICanvas and override the member-function:
This member-function is called for each document in the canvas to compute the location of the document. Please refer to the code (XsMDICanvas.C) for more details.
The XsMDICanvas is implemented as an XmScrolledWindow with an XmDrawingArea work-window. The instance name for the work-window is canvas. Internal callbacks in the canvas class force the work-window to be at-least the size of the clip-window. This prevents documents from being clipped as they are moved around.
By default, the XmDrawingArea work-window has its XmNresizePolicy set to XmRESIZE_GROW. This will allow the work-area to grow to whatever size necessary, but it will not automatically shrink as windows are manipulated. If different behavior is desired, the XmNresizePolicy resource on the work-area can be set to XmRESIZE_ANY. This will force the work-window to recompute its size as windows are manipulated, and it will grow and shrink as necessary. However, the XsMDICanvas will still force the work-area to be at-least the size of the clip-window.
To change the default behavior, add the following resource: