TweetFollow Us on Twitter

OD Container Interface
Volume Number:12
Issue Number:5
Column Tag:Opendoc

Rethinking the Interface

Getting the look and feel of a container application

By Tantek Çelik and David Curbow

Many OpenDoc parts are being created, and much has been written about how to do so; but very little has appeared about how to “host” OpenDoc parts - that is, how to be a container application. Indeed, as of this writing, only five container applications are even known to exist. Issues both of Human Interface and of programming technique are at last being worked out; and here, two leading authorities in the field expound for the first time what an existing application needs to do in order to become a container application.

Adding OpenDoc support to your application requires rethinking your application’s human interface design a bit. In many ways, adding OpenDoc embedding is no more intrusive than adding QuickTime movie embedding. However, because of OpenDoc’s generality, it relies on sharing various application-owned structures. In short, these are: document files, menus, windows and events, clipboard, drag and drop, and, of course, the application heap. Most of these affect the human interface of your application.

OpenDoc part editors assume there is a document shell which provides certain functions, such as default menus and a document model. Parts also assume that either they are the root part of a document or they are embedded into a containing part. In the latter case, they will interact with this containing part in certain ways, for example through frame negotiation. It is also important that the containing part provide access to the Part Info dialog for all the parts it contains. We did our best to strike a good balance between ease of development for the part editor, on the one hand, and minimal change for the container application, on the other. This article both delineates the practical minimum of what an application must do to adapt its human interface to support OpenDoc embedding, and explores what an application could do to be as seamlessly integrated as possible into the OpenDoc user experience.

Document Files

Your application can keep its current document format, as long as it has the ability to store an object of arbitrary length at some application-determined offset at save time. Alternatively, your application can make use of OpenDoc’s structured storage model, and encapsulate your current document format inside an OpenDoc stream. This latter approach makes your documents more forward compatible - you will be able to write part editors to read and write the exact same format. The MacTech Magazine 12.1 (January 1996) article titled “OpenDoc: Contain Yourself”, by Eric Soldan, does a great job of illustrating how container application support affects your document storage model at the implementation level; no need to repeat here.

If you make changes to your file format, you may be wondering if you should also modify your suite of icons, perhaps to convey the idea that your application supports OpenDoc. We recommend against that. You probably didn’t change your icons when you added support for QuickTime, so you shouldn’t make any changes now.

Menus

There are a few differences between your application’s menus and those of OpenDoc. There are very few changes you’ll need to make and we’ll discuss them in detail. Here are OpenDoc’s default menus:

Figure 1. OpenDoc default menus

The Document Menu

The first difference people notice between OpenDoc and today’s applications is that OpenDoc’s default first menu is called Document instead of File. We believe that “File” is overused today. It often refers to documents, control panels, network browsers, utilities that have nothing to do with files, etc. In OpenDoc, we use a “Document” menu name for documents, and we will use other menu names in the future.

For now, we recommend that you continue to use File as your first menu. That way, Document is a clue to users that they are working with an OpenDoc document being handled by a part editor, as opposed to an application.

The second difference people notice is that there isn’t a Quit command in the first menu. We got rid of the Quit command in OpenDoc for a very important reason - orphan menubars. When the user closes the last document in most applications today, the menubar remains behind, and this often causes users to be confused. We chose to fix this problem by using a single process per OpenDoc document and closing that process when the user closes the document. Of course, to use this solution, the time needed to open each document must be considerably smaller than what it takes to launch a full-blown application. (Yes, we know opening a document isn’t fast enough yet in version 1.0, and that’s a focus for our upcoming releases.) Most of today’s applications cannot use this solution, so we recommend keeping the Quit command.

Notice also that OpenDoc uses Save A Copy instead of Save As . Whatever you are using now is fine; don’t change it. At this time, Drafts are not supported for Container Applications. If your application already has a sense of providing access to the Document’s name, create/mod dates, comments and info, it is appropriate for your application to provide a Document Info menu item. Otherwise, omit this command from your File menu.

OpenDoc’s Close menu item by default applies to the frontmost content window, which is not always the window containing the document. You may need to change the behavior of your application to match.

You may not be aware of the following “power user feature”. If the user holds down the Option key and chooses Close, or types Apple-option-W, your application should close all the windows of the document to which the frontmost content window belongs. We recommend adding this behavior, but it is not required.

The Edit Menu

The Edit menu also has a few changes from today. Today the Undo and Redo functions are usually handled by one menu command - Undo. OpenDoc supports multiple levels of Undo and Redo, so it is necessary to have two commands. It is likely that your application only has the Undo command, but when an embedded part is active it will have Undo and Redo commands. This means that there can be some confusion, unless you change your application to also have both. Be aware that OpenDoc reserves AppleR for Redo and we recommend that your application not use this command-key equivalent for any other operation.

Your application can support Undo in a couple of ways, but to get the best user experience, it should support multiple levels of undo. It is perfectly acceptable, however, to support only one level.

Given that your container application probably does support only one level of undo, there are three points we need to cover. First, it is important that your application not purge the undo stack every time the container is activated. Instead, purge the stack after the user does some undoable action in your contents. You should use your existing undo mechanism.

Second, you need to enable either the Undo or Redo commands, but not both. When the user invokes Undo, your application should disable Undo and enable Redo, and if the user then invokes Redo you should get back to the state things were in before Undo was invoked. This is essentially the same as what many apps do today, except that here, Undo and Redo are different menu items.

Third, you need to clear the Redo command whenever a new undoable action is to be recorded. Suppose that an action has been undone and the user then selects some content and invokes Cut. At this time, your application should purge the redo action, disable Redo, record the new undo action, and enable Undo.

On the other hand, if your application supports multiple levels of undo, you must use the OpenDoc undo stack in conjunction with the above. When the user does some undoable action in your container, put that action on the OpenDoc undo stack (as described in OPG). If the user activates an embedded part and then reactivates your container, your application needs to decide whether to enable the Undo and/or Redo commands; to do this, you look at the status of the OpenDoc undo stack (check out the PeekUndoHistory method of the ODUndo class).

Now we’ll talk about the Paste As command. This command allows the user control over whether pasted content is to be embedded as a new part, or merged into the currently active part. It also allows control over which kinds to paste and which editor to associate with new parts. This command can also be used to create links, which are based on Publish & Subscribe. We recommend that you leave this command out of your Edit menu.

The Info command applies to the current selection, and provides information about the selection. To make it more obvious what kind of info will be given to the user, the menu command changes its name according to the selection. For example, when a part is selected, the menu name is Part Info, and when a link is selected, the menu name is Link Info. The intent is that users can find info about any content via an Info command. To make it easier for users to find this functionality, we recommend that editors and container applications reuse this menu command whenever possible. For example, when a sprite within an animation is selected, the menu command might be Sprite Info.

Not all applications provide this kind of information, so if no info can be given about the selected content, the menu command would be disabled. When the user selects an embedded part, your container application should change the menu name to Part Info.

If your application already supports an Info command, simply change that menu item to Part Info when a part is selected; there is no need to add a new menu item. Also, if your application already has a command-key equivalent for this Info command, don’t change it. If not, and you have not already made use of AppleL, then go ahead and make it the command-key equivalent for your Info command. If you don’t currently use AppleL in your application, please avoid adding it in the future - keep it reserved for the Info feature.

Most applications don’t allow new views of their content to be created. Therefore, we recommend that you omit the View In Window command from your Edit menu.

Previously, we’ve recommended that your application have a Preferences menu command in the Edit menu. OpenDoc follows that earlier guideline, but we recommend that you add the name of your application - just to make it clear which set of preferences will be presented. For example, the command might be SurfWriter Preferences .

In your application, you may have menu items that are not in the OpenDoc Edit menu. You may be able to easily rearrange your menu items so that you follow the guidelines on p. 543 of the OpenDoc Programmer’s Guide (hereinafter, OPG). Obviously you need to consider the impact on your documentation.

Your Application’s Menus

Your application’s current menus are probably fine as is. However, there are a couple of things to watch out for. We’ve already mentioned the Undo/Redo split and the two newly reserved command-keys, AppleR and AppleL.

In addition, command-key equivalents that you’ve assigned to operations in the File or Edit menus will be usurped by an embedded part. For example, suppose your application uses AppleI for some command, such as Get Info. Now suppose that an embedded text part uses AppleI for “Italics”. When this part is active and the user types AppleI, the Italics command will be executed instead of Get Info.

Menus for Embedded Parts

Now that we’ve discussed the new commands that OpenDoc adds to the menubar, it’s time to talk about implementing a menubar for embedded parts. As stated above, embedded parts expect to reuse the document shell’s menubar as a starting point. Therefore your application must fulfill this function. It needs to provide a “base menubar” which the part editors running inside your documents will use as a starting point for their menus. This consists of the “standard” Macintosh File and Edit menus, with a few more menu items as specified by OpenDoc Human Interface specification.

Part editors expect access to at least the following set of menus.

Standard Macintosh:

File: Close, Page Setup..., Print

Edit: Cut, Copy, Paste, Clear, Select All

OpenDoc additions:

File: Open Selection, Insert...

Edit: Undo and Redo as separate items, Paste As...,
Part Info, View in Window, Editor
Preferences

Once you have provided the base menubar for parts to use, you may add all your application- and content-specific menu items for your application’s menubar. You may also remove menu items which your application does not support. Some of the menu items introduced by OpenDoc your application will need to keep, however.

Embedding New Parts

Many of today’s applications already support some sort of embedding, even if it is only embedding of PICTs or QuickTime movies. In our examples, we’ll concentrate on these kinds of applications, since they already have some sort of model for embedding objects in their content. Most such applications support embedding via the Copy and Paste commands. Some applications have tool palettes for creating new embedded objects (such as drawings). A few applications have recently added support for drag and drop. We recommend reusing these same mechanisms to add embedded OpenDoc parts. This was discussed in some detail in the May 1995 Apple Directions article, “How to Add Content to OpenDoc”. You should also see p. 593 of the OPG.

Your application must support at least one and potentially all three standard mechanisms for embedding content (insert, copy/paste, drag and drop). The first is the easiest, and thus is the best place to start implementing OpenDoc embedding. Many applications have an Import or similar command. In OpenDoc we decided that Insert was easier to understand. However, your application may continue to use any existing Import command.

If you are considering converting your application to a container application, you may be worried that you must now support drag and drop. This isn’t true. Users like drag and drop because it provides an immediate sense of control, and supporting it may make your application stand out, but there is no requirement to support drag and drop just because you want your application to be a container application. We’ll talk about implementing drag and drop a bit later in this article.

Windows

The most visible aspect of embedding OpenDoc parts is that your application gives the embedded parts some real estate within its document windows. To do this, you have to register each of your document windows with OpenDoc.

Events

When the user clicks in your application’s content, your content (and application for that matter) are said to become “active”. Your application needs to request the user input focus and install its menubar as the current one.

Parts do the same thing in response to clicks in their content. Menu and keyboard events automatically route to whatever part is active (has the user interface focus). If the part does not handle a menu event, the document shell gets a chance to handle it. Your application is the document shell from an embedded part’s perspective, so you will still need to handle some menu events when embedded parts are active.

Selecting Parts

Users shouldn’t be able to tell where the part boundaries are until absolutely necessary. Thus, selecting one or more embedded parts should be as easy as selecting other content within your application. However, it is more important to be able to easily activate a part than select it. So, a click on a part will always activate it instead of select it. All other selection mechanisms, such as selection by dragging, should apply to parts as well as other content. Selection of parts is covered in detail pp. 562-568 of OPG.

Clipboard

Typically applications have a local scrap which they use exclusively until a suspend or resume event occurs, at which time they synch with the system scrap. Because of OpenDoc, you must synch with the system scrap more frequently, so that you may properly exchange clipboard data with embedded parts. Whenever your application loses the user interface focus, you must export to the system scrap. Whenever your application acquires the user interface focus, either via the user clicking in your content area or by an OpenDoc part relinquishing the user interface focus (notification here also), you must import from the system scrap, or at least note that your local scrap is old and update it later when needed.

Drag & Drop

If you application does not support drag and drop, users may be a little surprised to see that dragging and dropping into already embedded parts works, but that in your application’s content it doesn’t. Supporting drag and drop is optional, but your users will thank you if you do.

If you implement drag and drop, you need to support files being dragged in from the Finder as well as dragging content to the Finder. When content is dragged to the desktop, you should create a new document on the desktop which is the same data format as the current document. This way, the user deals with only one document format, instead of having to also deal with clippings. OpenDoc introduces this simplification to the drag and drop model.

The Application Heap

OpenDoc’s shared libraries plus the structures for one simple open OpenDoc document occupy about 100K of application heap. OpenDoc’s shared libraries get loaded into temp mem, not the app heap, so the code size (i.e. PowerPC vs. 68K) does not affect this 100K. It is recommended that you raise your application’s recommended minimum heap size by 100K accordingly. You may keep the current required minimum heap size for your application, as long as it is capable of disabling features (such as OpenDoc embedding) when low memory conditions result. If you want all features to be always available, then you should also raise the required minimum heap size for your application by 100K.

Conclusion

From this discussion it is pretty clear that OpenDoc support involves touching quite a few places in your code. However, it should also be noted that most of these changes are as simple as one or two additional lines of code. There certainly is some freedom with respect to how much you want to change your application’s human interface to support OpenDoc embedding. Hopefully this article has conveyed an idea of what the range of freedom is, and has provided some help with what each of the human interface changes means for your application in particular. So go out there and figure out how you want your container application to look and feel.

6prime Corporation

http://www.6prime.com

OpenDoc

http://www.opendoc.apple.com

CALib and PartMaker

http://www.opendoc.apple.com/dload/developer.html

OpenDoc Human Interface FAQ

http://dev.info.apple.com/appledirections/mar96/opendocfaqs.html

OpenDoc QT demos

http://www.opendoc.apple.com/demos/HIdemos.html

MacOS

http://www.macos.apple.com

Further information on Container App development

http://www.6prime.com/containerapp.html

Apple Directions article

http://dev.info.apple.com/appledirections/may95/techopendoc.html

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Dropbox 193.4.5594 - Cloud backup and sy...
Dropbox is a file hosting service that provides cloud storage, file synchronization, personal cloud, and client software. It is a modern workspace that allows you to get to all of your files, manage... Read more
Google Chrome 122.0.6261.57 - Modern and...
Google Chrome is a Web browser by Google, created to be a modern platform for Web pages and applications. It utilizes very fast loading of Web pages and has a V8 engine, which is a custom built... Read more
Skype 8.113.0.210 - Voice-over-internet...
Skype is a telecommunications app that provides HD video calls, instant messaging, calling to any phone number or landline, and Skype for Business for productive cooperation on the projects. This... Read more
Tor Browser 13.0.10 - Anonymize Web brow...
Using Tor Browser you can protect yourself against tracking, surveillance, and censorship. Tor was originally designed, implemented, and deployed as a third-generation onion-routing project of the U.... Read more
Deeper 3.0.4 - Enable hidden features in...
Deeper is a personalization utility for macOS which allows you to enable and disable the hidden functions of the Finder, Dock, QuickTime, Safari, iTunes, login window, Spotlight, and many of Apple's... Read more
OnyX 4.5.5 - Maintenance and optimizatio...
OnyX is a multifunction utility that you can use to verify the startup disk and the structure of its system files, to run miscellaneous maintenance and cleaning tasks, to configure parameters in the... Read more
Hopper Disassembler 5.14.1 - Binary disa...
Hopper Disassembler is a binary disassembler, decompiler, and debugger for 32- and 64-bit executables. It will let you disassemble any binary you want, and provide you all the information about its... Read more

Latest Forum Discussions

See All

Zenless Zone Zero opens entries for its...
miHoYo, aka HoYoverse, has become such a big name in mobile gaming that it's hard to believe that arguably their flagship title, Genshin Impact, is only three and a half years old. Now, they continue the road to the next title in their world, with... | Read more »
Live, Playdate, Live! – The TouchArcade...
In this week’s episode of The TouchArcade Show we kick things off by talking about all the games I splurged on during the recent Playdate Catalog one-year anniversary sale, including the new Lucas Pope jam Mars After Midnight. We haven’t played any... | Read more »
TouchArcade Game of the Week: ‘Vroomies’
So here’s a thing: Vroomies from developer Alex Taber aka Unordered Games is the Game of the Week! Except… Vroomies came out an entire month ago. It wasn’t on my radar until this week, which is why I included it in our weekly new games round-up, but... | Read more »
SwitchArcade Round-Up: ‘MLB The Show 24’...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for March 15th, 2024. We’re closing out the week with a bunch of new games, with Sony’s baseball franchise MLB The Show up to bat yet again. There are several other interesting games to... | Read more »
Steam Deck Weekly: WWE 2K24 and Summerho...
Welcome to this week’s edition of the Steam Deck Weekly. The busy season has begun with games we’ve been looking forward to playing including Dragon’s Dogma 2, Horizon Forbidden West Complete Edition, and also console exclusives like Rise of the... | Read more »
Steam Spring Sale 2024 – The 10 Best Ste...
The Steam Spring Sale 2024 began last night, and while it isn’t as big of a deal as say the Steam Winter Sale, you may as well take advantage of it to save money on some games you were planning to buy. I obviously recommend checking out your own... | Read more »
New ‘SaGa Emerald Beyond’ Gameplay Showc...
Last month, Square Enix posted a Let’s Play video featuring SaGa Localization Director Neil Broadley who showcased the worlds, companions, and more from the upcoming and highly-anticipated RPG SaGa Emerald Beyond. | Read more »
Choose Your Side in the Latest ‘Marvel S...
Last month, Marvel Snap (Free) held its very first “imbalance" event in honor of Valentine’s Day. For a limited time, certain well-known couples were given special boosts when conditions were right. It must have gone over well, because we’ve got a... | Read more »
Warframe welcomes the arrival of a new s...
As a Warframe player one of the best things about it launching on iOS, despite it being arguably the best way to play the game if you have a controller, is that I can now be paid to talk about it. To whit, we are gearing up to receive the first... | Read more »
Apple Arcade Weekly Round-Up: Updates an...
Following the new releases earlier in the month and April 2024’s games being revealed by Apple, this week has seen some notable game updates and events go live for Apple Arcade. What The Golf? has an April Fool’s Day celebration event going live “... | Read more »

Price Scanner via MacPrices.net

Apple Education is offering $100 discounts on...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take $100 off the price of a new M3 MacBook Air.... Read more
Apple Watch Ultra 2 with Blood Oxygen feature...
Best Buy is offering Apple Watch Ultra 2 models for $50 off MSRP on their online store this week. Sale prices available for online orders only, in-store prices may vary. Order online, and choose... Read more
New promo at Sams Club: Apple HomePods for $2...
Sams Club has Apple HomePods on sale for $259 through March 31, 2024. Their price is $40 off Apple’s MSRP, and both Space Gray and White colors are available. Sale price is for online orders only, in... Read more
Get Apple’s 2nd generation Apple Pencil for $...
Apple’s Pencil (2nd generation) works with the 12″ iPad Pro (3rd, 4th, 5th, and 6th generation), 11″ iPad Pro (1st, 2nd, 3rd, and 4th generation), iPad Air (4th and 5th generation), and iPad mini (... Read more
10th generation Apple iPads on sale for $100...
Best Buy has Apple’s 10th-generation WiFi iPads back on sale for $100 off MSRP on their online store, starting at only $349. With the discount, Best Buy’s prices are the lowest currently available... Read more
iPad Airs on sale again starting at $449 on B...
Best Buy has 10.9″ M1 WiFi iPad Airs on record-low sale prices again for $150 off Apple’s MSRP, starting at $449. Sale prices for online orders only, in-store price may vary. Order online, and choose... Read more
Best Buy is blowing out clearance 13-inch M1...
Best Buy is blowing out clearance Apple 13″ M1 MacBook Airs this weekend for only $649.99, or $350 off Apple’s original MSRP. Sale prices for online orders only, in-store prices may vary. Order... Read more
Low price alert! You can now get a 13-inch M1...
Walmart has, for the first time, begun offering new Apple MacBooks for sale on their online store, albeit clearance previous-generation models. They now have the 13″ M1 MacBook Air (8GB RAM, 256GB... Read more
Best Apple MacBook deal this weekend: Get the...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New 15-inch M3 MacBook Air (Midnight) on sale...
Amazon has the new 15″ M3 MacBook Air (8GB RAM/256GB SSD/Midnight) in stock and on sale today for $1249.99 including free shipping. Their price is $50 off MSRP, and it’s the lowest price currently... Read more

Jobs Board

Early Preschool Teacher - Glenda Drive/ *Appl...
Early Preschool Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Read more
Senior Software Engineer - *Apple* Fundamen...
…center of Microsoft's efforts to empower our users to do more. The Apple Fundamentals team focused on defining and improving the end-to-end developer experience in Read more
Relationship Banker *Apple* Valley Main - W...
…Alcohol Policy to learn more. **Company:** WELLS FARGO BANK **Req Number:** R-350696 **Updated:** Mon Mar 11 00:00:00 UTC 2024 **Location:** APPLE VALLEY,California Read more
Medical Assistant - Surgical Oncology- *Apple...
Medical Assistant - Surgical Oncology- Apple Hill WellSpan Medical Group, York, PA | Nursing | Nursing Support | FTE: 1 | Regular | Tracking Code: 200555 Apply Now Read more
Early Preschool Teacher - Glenda Drive/ *Appl...
Early Preschool Teacher - Glenda Drive/ Apple ValleyTeacher Share by Email Share on LinkedIn Share on Twitter Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.