Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Programmer's Guide to MacApp / Part 2 - Working With MacApp
Chapter 18 - Working With Windows


Overview

In MacApp, each window that your program displays on the screen is represented by an object based on the TWindow class. The TWindow class is a subclass of TView that draws the frame and the blank white background of a window. TWindow handles most window operations, including opening, moving, resizing, updating, activating, and deactivating the window; drawing the window frame and grow box; and responding to mouse clicks in the window frame. Because window behavior is fairly standard, you can often create TWindow objects without defining a custom subclass.

A window object in MacApp is usually the root view of a view hierarchy. A window must have at least one subview if you wish to allow drawing in the content area. Your view draws the content area of the window and responds to mouse clicks in that area.

Floating Windows

A floating window is a window that "floats" above all other application windows (except possibly for other floating windows) and is typically hidden when the application is in the background. Floating windows are used for tool palettes and other items that should always be visible (except when they are put away). They are sometimes referred to as windoids or miniwindows.

MacApp provides a number of facilities to help support floating windows:

Using Window Manager Routines

Every TWindow object contains a field, fWMgrWindow, that references a Toolbox Window Manager window record. You normally work with windows in MacApp as objects in the object-oriented world, and MacApp maps your operations into Window Manager calls. But if you are familiar with the Window Manager, you can use the fWMgrWindow field to manipulate the window directly with Toolbox routines. The volume Inside Macintosh: Macintosh Toolbox Essentials describes Window Manager operations in detail.

Defining a Window With a 'View' Resource

MacApp defines view resource templates for all its view classes in the file ViewTypes.r. Using these view templates, you can create resource definitions that describe complex window and view hierarchies. Although you can use a text editor to create a text version of a view resource definition, it is far easier to define most views with a graphical resource editor. The Ad Lib view editor, available from Apple Computer, provides a graphical environment that lets you quickly define your application's user interface. Creating view resources and working with graphical resource editors are described in "Working With View Resource Templates," beginning on page 425.

Creating Windows

MacApp provides the TViewServer class to manage the creation of views and windows. MacApp automatically creates a TViewServer object for your application and keeps a reference to it in the global variable gViewServer.

The TViewServer class has two methods that create a window by passing a 'WIND' resource identifier to one of the Macintosh Toolbox routines GetNewCWindow or GetNewWindow:

The TViewServer class also has one method that creates a window from a 'View' resource definition:


Previous Book Contents Book Index Next

© Apple Computer, Inc.
25 JUL 1996