Important: The information in this document is obsolete and should not be used for new development.
Overview
In MacApp, each window that your program displays on the screen is represented by an object based on theTWindow
class. TheTWindow
class is a subclass ofTView
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 createTWindow
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:
- MacApp defines the resource type '
fwnd'
, which allows you to specify a floating window in your'View'
resources. As a result, you can define a floating window with a view-editing application and create the window using thegViewServer->NewTemplateWindow
method.- The
TWindow
class includes fields for operating on floating windows:
- The fDoFirstClick field stores a Boolean value. If
FALSE
, the window becomes active when it receives a mouse-down event. IfTRUE
, the window both becomes active and responds to the event. A floating window is always visible but is not always the active window. By setting the fDoFirstClick field to TRUE, a floating window can function as though it is always active.- The
fFloats
field is a Boolean field that indicates whether a window is a floating window. When iterating through your application's windows, you can examinefFloats
to identify floating windows for special handling.- The
fGeneratesActivates
field is used to ensure proper activation of a floating window when the application is switched back in.- The
fHideOnSuspend
field is a Boolean field that indicates whether a window should be hidden, as floating windows normally are, when the application is suspended.- The
fWasHiddenOnSuspend
field is a Boolean field that indicates whether a window was hidden when the application was suspended, as floating windows normally are, and hence should be shown when the application is switched in.
- The window class
TFloatWindow
helps implement a floating window.
- Its constructor method,
TFloatWindow
, contains the following code to set the value of window fields used in floating:
fHideOnSuspend = TRUE;
fDoFirstClick = TRUE;
fFloats = TRUE;
fGenerateActivates = FALSE;- Its initialization method,
IFloatWindow
, marks its Window Manager window record as a floating window. (See the following section.)- Its
Close
method sets the application's target to another window, if possible.
Using Window Manager Routines
EveryTWindow
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 thefWMgrWindow
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 fileViewTypes.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 theTViewServer
class to manage the creation of views and windows. MacApp automatically creates aTViewServer
object for your application and keeps a reference to it in the global variablegViewServer
.The
TViewServer
class has two methods that create a window by passing a'WIND'
resource identifier to one of the Macintosh Toolbox routinesGetNewCWindow
orGetNewWindow
:
The
- The
NewPaletteWindow
method creates a MacDraw-like window with either a nonscrolling palette along the left edge or a nonscrolling status area at the top of the window. The window has a main view that may or may not scroll.- The
NewSimpleWindow
method creates a simple window that contains one view and may or may not scroll.
TViewServer
class also has one method that creates a window from a'View'
resource definition: