Programming Guide


Controls

   

This section discusses what kinds of controls you can construct, and how to handle events within controls. It also discusses two specific issues for palettes: how to share them among instances of your part, and how to use them to embed parts within your part.

Design Issues for Controls

 

Controls in OpenDoc have the same function as in conventional applications: they are graphical objects that allow you to interact with and manipulate documents in a variety of ways. However, there are some differences:

   

Standard types of controls you might wish to include with your parts include:

                   

Rulers usually reflect some settings of the current selection context and contain controls that allow you to change these settings. Tool bars are like rulers but they often trigger actions instead of changing settings. Status bars display the progress of some long-running operation or suggest actions to users.

In conventional applications, rulers and tool bars commonly occupy the margins of the window. In an OpenDoc document, controls can be displayed at the margins of the window, in separate frames outside the embedded frame they apply to, or within the frame they apply to.

A ruler for a text part, for example, can be an additional frame associated with the part. Events in the ruler are handled by the part's editor. Alternatively, the ruler may be its own part with its own editor. In this case, the text part editor must maintain a reference to the ruler part and be able to communicate with it through semantic events or some other extension mechanism.

A ruler that is a separate part can have its own embedded parts, such as buttons. The ruler part must then be able to communicate with its embedded controls as well as with the part that it services.  

Palettes often contain editing tools but can also contain choices for object attributes like color or line width. Palettes commonly float freely beside or over the document, although they can also be fixed at the window margins. Palettes might also pop up, pull down, or be torn off of menus.

If all parts in a document can communicate with each other, they can coordinate the drawing and hiding of palettes or other controls to avoid irritating the user. For example, all parts in a document can share a single palette, within which the various parts negotiate for space and in which they draw only those tools that must change as the active part changes.

Handling Events in Controls

 

How you handle events in a control depends on how you design the control:

Sharing Palettes and Utility Windows

The user-interface guidelines state that you should hide any visible palettes, modeless dialog boxes, or other utility windows when your part becomes inactive or its document closes. When the part becomes active or the document reopens, you should restore them in the same positions. In addition, if your part editor maintains multiple parts in a document and the active state switches from one to another of them, any visible utility windows that apply to both parts should remain steadily visible, without any flicker caused by hiding and immediate restoring.

One way to implement this behavior for a utility window is to follow, in general, steps such as these:

Using a Tool Palette to Embed Parts

An example of an OpenDoc-specific use for controls is to allow you to embed parts by selecting items from a palette. Using a palette in this way, your part can create embedded parts from scratch, rather than through reading in existing part data.

Your part can provide a palette, menu, or dialog box from which you select an item that specifies a part kind. As in many conventional applications, your palette could display a set of tools to the user. These user tools are for drawing, painting, text and so forth. In this case, however, selecting an item from the palette actually means that a new part of that kind is to be embedded in your part.

The items could represent existing stationery documents in the user's system, or they could simply represent individual part kinds for which editors exist. If you are creating parts from scratch, follow steps such as these once your have made a selection from your palette:


[ Top | Previous | Next | Contents | Index | Documentation Homepage ]