TweetFollow Us on Twitter

Fancy Dialogs
Volume Number:7
Issue Number:6
Column Tag:MacOOPs!

Related Info: Dialog Manager Standard File

Fancy Modal Dialogs

By Thomas Engel, Loma Linda, CA

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

[Thomas Engel is a practicing anesthesiologist. He has been writing computer simulations in physics, biology and physiology since 1975 and programming the Macintosh since 1986.]

Introduction

Most Macintosh programs use modal dialogs to convey information and get user input. Whenever you pick an About , Open , Save As , Page Setup or Print menu item you see a modal dialog. Error alerts and status messages are also forms of modal dialogs. The Dialog Manager handles events for each dialog separately from the application’s main event loop. Because the events are handled separately, the programmer must duplicate event loop code or rely on the Dialog Manager’s default behavior. Dialogs also have several unique features that require special consideration.

The Dialog Manager’s default behavior is not complete and does not provide many standard Macintosh user interface features or subtle nuances. Many applications do not provide these either. Although printer drivers and Standard File take care of most details for their dialogs, you are on your own for any others. Object-oriented programming can provide these features in a consistent way, with a minimum of programming effort.

This article discusses some fine points of programming modal dialogs for the Macintosh and presents a complete modal dialog class, subclasses and resources for six useful dialogs and a short program to demonstrate each dialog. The dialog class is written in Object Pascal with THINK Pascal 3.0, and should be portable to other environments.

Dialog Basics

A dialog is a specialized window managed by the Dialog Manager. A dialog is accessed by a DialogPtr like a window is accessed with a WindowPtr. The corresponding DialogPeek is a pointer to a DialogRecord. To access the DialogRecord fields, typecast the DialogPtr variable to a DialogPeek like this:

{1}

var
 toolboxDialog: DialogPtr;
 editItem: Integer;

editItem := DialogPeek(toolboxDialog)^.editField
 + 1;

The dialog record contains a WindowRecord and additional fields, including a handle to the dialog’s item list. A dialog is usually created from a “DLOG” resource; its items are created from a “DITL” resource. These resources contain templates for the dialog and its items and are created with a resource editing program like ResEdit.

The item list handle contains data for the dialog items. Dialog items include controls like buttons, check boxes, and radio buttons; static and editable text fields; icons; QuickDraw pictures and user items. The item list keeps an Integer item type, item Rect and a Handle for each item. The contents of the handle depends on the item’s type. Control items have a ControlHandle, text items have a handle to the text characters, an icon item has a handle to its icon, a picture item has a PicHandle, and each user item has a ProcPtr stored in place of its item handle.

To use a modal dialog, first create it with the toolbox routine GetNewDialog and set up its user items and fill in default values for text fields if necessary. Then repeat calls to ModalDialog to handle update, activate and user generated events until ModalDialog returns with an acceptable item hit. Then call DisposDialog. Here is an example:

{2}

var
 toolboxDialog: DialogPtr;
 itemHit: Integer;

toolboxDialog:= GetNewDialog(DialogID, nil, WindowPtr(-1));
{ Set user items and fill in text items. }
ShowWindow(toolboxDialog);
InitCursor;
repeat
 ModalDialog(@Filter, itemHit);
until (itemHit = OK) or (itemHit = Cancel);
DisposDialog(toolboxDialog);

The dialog manager provides two ways to modify the behavior of Modal Dialogs: an event filter procedure can intercept events for special handling and a user item procedure can draw a special dialog item.

A filter procedure gets each event from the Dialog Manager along with the item hit. The filter procedure returns true if it handles the event or false for the Dialog Manager to handle it. The filter procedure can change the event or item hit before returning to the Dialog Manager. An event filter procedure looks like this:

{3}

function Filter( toolboxDialog: DialogPtr;
 var theEvent: EventRecord;
 var itemHit: Integer): Boolean;

A user item procedure draws the item. The dialog manager calls it automatically for update events. If you want something to happen when the user clicks in a user item, you must handle that with the event filter procedure. (See Tech Note 34, User Items in Dialogs.) A user item procedure looks like this:

{4}

procedure User(toolboxDialog: DialogPtr;
 var itemHit: Integer);

Use GetDItem, SetDItem and a typecast to store a pointer to the user procedure in the item list before calling ModalDialog.

{5}

var
 itemType: Integer;
 itemRect: Rect;
 itemHandle: Handle;

GetDItem(toolboxDialog, theItem, itemType,
 itemRect, itemHandle);
SetDItem(toolboxDialog, theItem, itemType,
 itemRect, Handle(@User));

Standard File uses special user items and an event filter procedure for its scrolling file list and folder hierarchy pop-up menu in Open (SFGetFile) and Save As (SFPutFile) dialogs.

Aesthetics

The Dialog Manager’s default behavior includes drawing the dialog items in response to update events, hit testing items, highlighting buttons and selecting the first item if the user presses the return key. Apple recommends additional standard behavior that the Dialog Manager doesn’t handle.

A dialog should be centered near the top of the main screen (the one with the menu bar). Because the Macintosh supports a variety of screens with different sizes, this feature requires calculation of the dialog’s position at run time.

The dialog should draw an outline 3 pixels wide around the default button to indicate which button is the default. Apple recommends making a user item to do this, but this makes changing the default button awkward. Alternatively, a filter procedure can take over update events to draw the outline and any other embellishments along with the dialog items.

When the user presses the return key or enter key the default button should be selected; when the user presses command-period the cancel button should be selected. The dialog should highlight the button for a fraction of a second to give the user feedback about the keyboard selection instead of just disappearing with no other indication of the action. Turn the button’s highlight off before dismissing the dialog. This is similar to the blinking of menu items with mouse selection.

Radio buttons are grouped in sets; when the user selects one, the others in the set should be deselected. This may be done in a filter procedure or the repeat until loop that calls ModalDialog.

The dialog should select all the text of the default edit text field when the dialog is first shown. This tells the user where any typing will go and lets the user quickly replace the entire item’s text by only typing. The dialog should support Cut, Copy, Paste and Clear command key equivalents for edit text. The dialog should select all of the text in the next edit text field when the user presses the tab key and all of the text in the previous field when the user presses shift-tab. The dialog should also show the I-beam cursor when the cursor is over the current edit text item.

Because each dialog has different items, each usually requires its own special event filter and user items. These procedures are usually specific to the dialog and cannot be reused easily. Object-oriented programming provides a way to organize these general dialog features in one place and create specialized dialogs without rewriting all the code.

Dialog Class

An object has a type called its class. Each object is allocated with the built-in procedure New and is referred to by a reference variable. Classes are similar to records and are declared as types with the keyword object. The class defines instance variables (data) and methods (procedures and functions). Instance variables are like fields in a record.

A class may be declared as a subclass of a previously defined class; the previously defined class is its superclass. A subclass inherits all the instance variables and methods of its superclass and can add more instance fields and methods. The subclass can also modify the action of a method by overriding it. The new subclass method can call the superclass method with the keyword inherited. This article presents a general modal dialog class called TDialog and subclasses for several specific dialogs.

The TDialog class handles almost all of the features common to modal dialogs. To use TDialog, write a subclass for a specific dialog. The subclass will inherit basic and fancy dialog behavior from TDialog.

TDialog defines instance variables for its DialogPtr, DialogPeek and item count; its default item, cancel item and default text item; and the set of items that dismiss the dialog. This is its declaration:

{6}

type
 DialogItemSet = set of 1..255;

 TDialog = object
 toolboxDialog: DialogPtr;
 toolboxDPeek: DialogPeek;
 itemCount: Integer;
 defaultItem, cancelItem, defaultText: Integer;
 dismissSet: DialogItemSet;
 procedure IDialog(dialogID: Integer;
 default, cancel, text: Integer;
 dismiss: DialogItemSet; centered: Boolean);
 procedure Free;
 procedure Center;
 function Show: Integer;
 procedure Hide;
 function EventFilter( var theEvent: EventRecord;
 var itemHit: Integer): Boolean;
 procedure FixCursor;
 procedure Command(ch: Char; var itemHit: Integer);
 procedure Hit(var itemHit: Integer);
 procedure Draw;
 procedure DrawDefault;
 procedure DrawBox(itemSet: DialogItemSet;
 margin, thickness: Integer);
 procedure DrawTitleBox( itemSet: DialogItemSet;
 margin, thickness: Integer; title: Str255);
 procedure FlashItem(item: Integer);
 function GetText(item: Integer): Str255;
 procedure SetText(item: Integer; text: Str255);
 function GetInteger(item: Integer): Longint;
 procedure SetInteger(item: Integer; value: Longint);
 function GetReal(item: Integer): Extended;
 procedure SetReal(item: Integer;
 value: Extended; places: Integer);
 function GetControlValue( item: Integer): Integer;
 procedure SetControlValue(item: Integer; value: Integer);
 function GetControlTitle( item: Integer): Str255;
 procedure SetControlTitle(item: Integer; title: Str255);
 function GetRadioItem(
 radioSet: DialogItemSet): Integer;
 procedure SetRadioItem( radioSet: DialogItemSet;
 itemSelected: Integer);
 procedure SetIcon(item: Integer; iconID: Integer);
 procedure SetPicture(item: Integer; pictureID: Integer);
 procedure SetUserItem(item: Integer; userProc: ProcPtr);
 end;

Methods

The methods for TDialog do almost all of the work of managing modal dialogs.

TDialog.IDialog initializes the dialog. It accepts parameters for the DLOG template ID, default item (enter key, return key), cancel item (command-period), default text item, and the set of items that dismiss the dialog. If centered is true, the dialog will be centered on the main screen, otherwise it will remain in the position specified in the DLOG template. Each subclass of TDialog should know all of these parameters and pass them to IDialog.

TDialog.Free calls DisposDialog to release the dialog resources and then DisposHandle(Handle(self)).

TDialog.Center centers the dialog on the main screen.

TDialog.Show shows the dialog on the screen and calls ModalDialog to get dialog events. TDialog.Show calls TDialog.Hit for each item hit; when the user hits an item in the dismiss set, TDialog.Show returns with the item number.

Override TDialog.Hit to handle special items. TDialog.Hit can call TDialog.SetRadioItem to select the appropriate radio button. The default TDialog.Hit does nothing.

TDialog.EventFilter handles events for the dialog. It is called by DialogFilter. DialogFilter is a global procedure passed to ModalDialog because methods may not be passed as parameters. TDialog.EventFilter handles default, cancel and tab keys and update events. It calls TDialog.FixCursor to change the cursor, TDialog.Command for keyboard commands and TDialog.Draw to draw the dialog. TDialog.EventFilter returns true if it handled the event, and false to let the dialog manager handle it.

TDialog.FixCursor changes the shape of the cursor based on its location. The default method checks to see if the cursor is over the current edit text item; if it is, the method changes the cursor to the I-beam, otherwise it calls InitCursor.

TDialog.GetText and TDialog.SetText get and set the item text by calling the toolbox routines GetIText and SetIText. TDialog.SetText will select all the text if it changes the current edit text item. TDialog.GetInteger, TDialog.SetInteger, TDialog.GetReal and TDialog.SetReal are based on these calls.

Override TDialog.Draw to draw anything not drawn by the Dialog Manager. The default version calls TDialog.DrawDefault to draw a three pixel wide outline around the default button. You can also call TDialog.DrawBox to draw a box around any set of items. TDialog.DrawTitleBox draws the box with a title. These methods work correctly even if you later change the position or size of the dialog items. TDialog.Draw is called for every update event the dialog receives.

TDialog.Command handles keyboard commands. The default version calls the toolbox routines DlgCut, DlgCopy, DlgPaste and DlgClear. Override this method to add other keyboard commands.

TDialog.GetControlTitle, TDialog.SetControlTitle, TDialog.GetControlValue and TDialog.SetControlValue manage control items. Use these methods to change button titles and values.

Radio groups are handled by item number in sets. TDialog.SetRadioItem highlights the selected radio button and sets the highlight of the other buttons in the set to off. TDialog.GetRadioItem gets the item number of the highlighted radio button. These methods call TDialog.GetControlValue and TDialog.SetControlValue.

TDialog.FlashItem highlights a button for a few ticks to provide user feedback on the item selected with the keyboard.

TDialog.SetIcon and TDialog.SetPicture set dialog icon and picture items from resources. Neither of these methods release the memory used by a replaced icon or picture.

The Specifics

The THINK Pascal project document is “Dialog Project” and resources are in “Dialogs.rsrc.” A SADerez version of the resources is in the file “Dialogs.r”. The dialog project consists of three source code files: global declarations and variables are in the file “DialogGlobals.p”, the methods for TDialog and its subclasses are in “TDialog.p” and a short main program to display each dialog is in the file “Test Dialogs.p”.See figure 1.

Figure 1

DialogGlobals.p defines six subclasses of TDialog. Each of them inherits most of its features from TDialog. These subclasses serve as examples of customizing TDialog and are useful by themselves. The six subclasses are TAboutDialog, TMessageDialog, TStringDialog, TYesNoDialog, TYesNoCancelDialog, TFontSizeDialog and TMarginsDialog.

TAboutDialog shows an About box with the free memory in K bytes. TMessageDialog shows a message string to the user. TYesNoDialog and TYesNoCancelDialog ask the user a question, and TStringDialog gets a string from the user. TFontSizeDialog lets the user enter a font size, and TMarginsDialog gets page margins from the user. TStringDialog, TFontSizeDialog and TMarginsDialog each have GetData and SetData methods to handle all the user data at one time.

TMarginsDialog is the most complicated class. It contains edit text fields for the top, bottom, left and right margins expressed as real numbers and a radio button set for the unit of measure. TMarginsDialog.Draw calls TDialog.DrawTitleBox to frame the radio button set. See figure 2.

Figure 2

Create a dialog object with the built-in procedure New, call its initialization method and then its Show method. When you are done with the dialog dispose of it by calling its Free method. Here is an example:

{7}

var
 theDialog: TMessageDialog;
 itemHit: Integer;

New(theDialog);
theDialog.IMessageDialog(‘Hi there!’, NoteIcon);
itemHit := theDialog.Show;
theDialog.Free;

Improvements

Make your own dialogs by defining subclasses to TDialog or one of its subclasses. Your subclass will use a different dialog template resource ID and may have new specialized methods.

You may improve your dialog class by adding routines to manage scrolling lists or pop-up menus (pop-up menus may be easier when Apple releases a standard Pop-up CDEF). Override TDialog.Filter to handle mouse down events for these items. The event filter method may be improved to handle cancel commands on international keyboards. (See Tech Note 263, International Canceling.)

You may add methods for entry validation. You may also override TDialog.Filter or TDialog.FixCursor to do animation in the dialog. These methods are called each time the dialog gets an event.

If you are already using a class hierarchy, you can make TDialog a subclass of a basic class like TObject. Change TDialog.Free to call inherited Free instead of DisposHandle(Handle(self)).

Further Reading

Apple Computer. Inside Macintosh, Volumes 1-5. Reading, Massachusetts, Addison-Wesley Publishing Company, Inc., 1986. The primary reference for Macintosh programming.

Apple Computer. ResEdit Reference. Reading, Massachusetts, Addison-Wesley Publishing Company, Inc., 1990. Information on editing DLOG and DITL resources.

Chernicoff, S. Macintosh Revealed, Volumes 1-4. Carmel, Indiana, Hayden Books, 1990. An excellent introduction to programming the Macintosh with Pascal.

Knaster, S. Macintosh Programming Secrets. Reading, Massachusetts, Addison-Wesley Publishing Company, Inc., 1988. Contains a discussion on customizing dialogs.

Symantec Corporation. THINK Pascal Object-oriented Programming Manual. Cupertino, California, Symantec Corporation, 1990. Contains an excellent explanation of object-oriented programming with Object Pascal.

Listing: DialogGlobals.p

{ Written by Thomas Engel, M.D. }
{ Copyright © 1991 MacTutor. }

unit Globals;

interface

const

 { Special Characters. }

 EnterCh = Chr(3);
 BackSpaceCh = Chr(8);
 TabCh = Chr(9);
 ReturnCh = Chr(13);

 { Dialog resource IDs. }

 AboutID = 128;
 MessageID = 129;
 StringID = 130;
 YesNoID = 131;
 YesNoCancelID = 132;
 FontSizeID = 133;
 PageMarginsID = 134;

 { Dialog item numbers. }

 OKButton = 1;
 CancelButton = 2;
 YesButton = 1;
 NoButton = 3;

 { Miscellaneous. }

 ControlOn = 1;
 ControlOff = 0;
 ControlActive = 0;
 ControlInactive = 255;
 FlashTicks = 10;
 AfterTicks = 2;
 IBeamID = 1;
 WatchID = 4;

type
 IntegerPtr = ^Integer;
 IntegerHandle = ^IntegerPtr;
 LongintPtr = ^Longint;
 LongintHandle = ^LongintPtr;

 MeasureOption = (inches, cm, points);

 MarginRecord = record
 left, top, right, bottom: Single;
 measure: MeasureOption;
 end;

 DialogItemSet = set of 0..255;

 TDialog = object
 toolboxDialog: DialogPtr;
 toolboxDPeek: DialogPeek;
 itemCount: Integer;
 defaultItem, cancelItem,
 defaultText: Integer;
 dismissSet: DialogItemSet;
 procedure IDialog(dialogID: Integer;
 default, cancel, text: Integer;
 dismiss: DialogItemSet; centered: Boolean);
 procedure Free;
 procedure Center;
 function Show: Integer;
 procedure Hide;
 function EventFilter(
 var theEvent: EventRecord;
 var itemHit: Integer): Boolean;
 procedure FixCursor;
 procedure Command(ch: Char;
 var itemHit: Integer);
 procedure Hit(var itemHit: Integer);
 procedure Draw;
 procedure DrawDefault;
 procedure DrawBox(itemSet: DialogItemSet;
 margin, thickness: Integer);
 procedure DrawTitleBox(
 itemSet: DialogItemSet;
 margin, thickness: Integer; title: Str255);
 procedure FlashItem(item: Integer);
 function GetText(item: Integer): Str255;
 procedure SetText(item: Integer;
 text: Str255);
 function GetInteger(item: Integer): Longint;
 procedure SetInteger(item: Integer;
 value: Longint);
 function GetReal(item: Integer): Extended;
 procedure SetReal(item: Integer;
 value: Extended; places: Integer);
 function GetControlValue(
 item: Integer): Integer;
 procedure SetControlValue(item: Integer;
 value: Integer);
 function GetControlTitle(
 item: Integer): Str255;
 procedure SetControlTitle(
 item: Integer; title: Str255);
 function GetRadioItem(
 radioSet: DialogItemSet): Integer;
 procedure SetRadioItem(
 radioSet: DialogItemSet;
 itemSelected: Integer);
 procedure SetIcon(item: Integer;
 iconID: Integer);
 procedure SetPicture(item: Integer;
 pictureID: Integer);
 procedure SetUserItem(item: Integer;
 userProc: ProcPtr);
 end;

 TAboutDialog = object(TDialog)
 procedure IAboutDialog;
 function Show: Integer;
 override;
 end;

 TMessageDialog = object(TDialog)
 procedure IMessageDialog(message: Str255;
 iconID: Integer);
 procedure SetMessage(message: Str255);
 end;

 TStringDialog = object(TDialog)
 procedure IStringDialog(
 prompt, default: Str255);
 procedure SetData(prompt, default: Str255);
 procedure GetData(var response: Str255);
 end;

 TYesNoDialog = object(TDialog)
 procedure IYesNoDialog(
 prompt: Str255; default: Integer);
 procedure SetPrompt(prompt: Str255);
 end;

 TYesNoCancelDialog = object(TDialog)
 procedure IYesNoCancelDialog(prompt: Str255;
 default: Integer);
 procedure SetPrompt(prompt: Str255);
 end;

 TMarginsDialog = object(TDialog)
 measureSet: DialogItemSet;
 procedure IMarginsDialog(
 defaultMargins: MarginRecord);
 procedure Draw;
 override;
 procedure Hit(var itemHit: Integer);
 override;
 procedure SetData(newMargins: MarginRecord);
 procedure GetData(
 var theMargins: MarginRecord);
 end;

 TFontSizeDialog = object(TDialog)
 procedure IFontSizeDialog(
 defaultSize: Integer);
 procedure SetData(fontSize: Integer);
 procedure GetData(var fontSize: Integer);
 end;

var
 IBeam, Watch: CursHandle;

procedure ShowAbout;
procedure ShowMessage(message: Str255);
function YesNoDialog(prompt: Str255;
 defaultButton: Integer): Integer;
function YesNoCancelDialog(prompt: Str255;
 defaultButton: Integer): Integer;
function StringDialog(prompt: Str255;
 var response: Str255): Boolean;
function FontSizeDialog(
 var fontSize: Integer): Boolean;
function MarginsDialog(
 var margins: MarginRecord): Boolean;

implementation

procedure ShowAbout;

{ Show the application About  dialog. }

 var
 theDialog: TAboutDialog;
 theItem: Integer;

begin
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IAboutDialog;
 theItem := theDialog.Show;
 theDialog.Free
 end
end;

 procedure ShowMessage(message: Str255);

{ Show the message dialog. }

 var
 theDialog: TMessageDialog;
 theItem: Integer;

begin
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IMessageDialog(message, 1);
 theItem := theDialog.Show;
 theDialog.Free
 end
end;

function YesNoDialog(prompt: Str255; defaultButton: Integer): Integer;

{ Ask a yes or no question. }

 var
 theDialog: TYesNoDialog;

begin
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IYesNoDialog(prompt,
 defaultButton);
 YesNoDialog := theDialog.Show;
 theDialog.Free
 end
end;

function YesNoCancelDialog(prompt: Str255; defaultButton: Integer): Integer;

{ Ask a yes, no or cancel question. }

 var
 theDialog: TYesNoCancelDialog;

begin
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IYesNoCancelDialog(prompt,
 defaultButton);
 YesNoCancelDialog := theDialog.Show;
 theDialog.Free
 end
end;

function StringDialog(prompt: Str255; var response: Str255): Boolean;

{ Get a string from the user. }

 var
 theDialog: TStringDialog;
 theItem: Integer;

begin
 StringDialog := false;
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IStringDialog(prompt, response);
 theItem := theDialog.Show;
 if theItem = OKButton then
 begin
 theDialog.GetData(response);
 StringDialog := true
 end;
 theDialog.Free
 end
end;

function FontSizeDialog(var fontSize: Integer): Boolean;

{ Get new font size. }

 var
 theDialog: TFontSizeDialog;
 theItem: Integer;

begin
 FontSizeDialog := false;
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IFontSizeDialog(fontSize);
 theItem := theDialog.Show;
 if theItem = OKButton then
 begin
 theDialog.GetData(fontSize);
 FontSizeDialog := true
 end;
 theDialog.Free
 end
end;

function MarginsDialog(var margins: MarginRecord): Boolean;

{ Get new page margins. }

 var
 theDialog: TMarginsDialog;
 theItem: Integer;

begin
 MarginsDialog := false;
 New(theDialog);
 if theDialog <> nil then
 begin
 theDialog.IMarginsDialog(margins);
 theItem := theDialog.Show;
 if theItem = OKButton then
 begin
 theDialog.GetData(margins);
 MarginsDialog := true
 end;
 theDialog.Free
 end;
end;

end.
Listing: TDialog.p

{ Written by Thomas Engel, M.D. }
{ Copyright © 1991 MacTutor. }

unit TDialog;

interface

uses
 SANE, Globals;

function DialogFilter(toolboxDialog: DialogPtr; var theEvent: EventRecord; 
var itemHit: Integer): Boolean;

implementation

function DialogFilter(toolboxDialog: DialogPtr; var theEvent: EventRecord; 
var itemHit: Integer): Boolean;

{ Dialog filter function. }

 var
 theDialog: TDialog;

begin
 theDialog := TDialog(
 DialogPeek(toolboxDialog)^.window.refCon);
 DialogFilter := theDialog.EventFilter(theEvent,
 itemHit)
end;

procedure TDialog.IDialog(dialogID: Integer;
 default, cancel, text: Integer;
 dismiss: DialogItemSet; centered: Boolean);

{ Initialize dialog. }

begin
 defaultItem := default;
 cancelItem := cancel;
 defaultText := text;
 dismissSet := dismiss;
 itemCount := 0;
 toolboxDialog := GetNewDialog(dialogID, nil,
 pointer(-1));
 toolboxDPeek := DialogPeek(toolboxDialog);
 if toolboxDialog <> nil then
 begin
 toolboxDPeek^.window.refCon :=
 Longint(self);
 itemCount :=
 IntegerHandle(toolboxDPeek^.items)^^ + 1
 end;
 if centered then
 Center
end;

procedure TDialog.Free;

{ Free memory used by this object. }

begin
 if toolboxDialog <> nil then
 DisposDialog(toolboxDialog);
 HUnlock(Handle(self));
 DisposHandle(Handle(self))
end;

procedure TDialog.Center;

{ Center the dialog on the main screen. }

 var
 width, height: Integer;

begin
 if toolboxDialog <> nil then
 begin
 with toolboxDialog^.portRect do
 begin
 width := right - left;
 height := bottom - top
 end;
 with ScreenBits.bounds do
 MoveWindow(toolboxDialog,
 left + (right - left - width) div 2,
 top + (bottom - top - height) div 3,
 false)
 end
end;

function TDialog.Show: Integer;

{ Show the dialog. }

 var
 itemHit: Integer;

begin
 Show := 0;
 if toolboxDialog <> nil then
 begin
 if defaultText > 0 then
 SelIText(toolboxDialog, defaultText, 0,
 32767);
 ShowWindow(toolboxDialog);
 InitCursor;
 repeat
 ModalDialog(@DialogFilter, itemHit);
 if itemHit > 0 then
 Hit(itemHit);
 until (itemHit > 0) and
 (itemHit in dismissSet);
 Show := itemHit
 end
end;

procedure TDialog.Hide;

{ Hide the dialog. }

begin
 if toolboxDialog <> nil then
 HideWindow(toolboxDialog);
end;

function TDialog.EventFilter(var theEvent: EventRecord; var itemHit: 
Integer): Boolean;

{ Dialog event filter. }

 var
 savePort: GrafPtr;
 ch: Char;
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;
 editItem: Integer;

begin

 { Save current port. }

 GetPort(savePort);
 SetPort(toolboxDialog);

 { Fix cursor. }

 FixCursor;

 { Check the event. }

 case theEvent.what of

 keyDown, autoKey: 
 begin
 ch := Chr(BitAnd(theEvent.message,
 CharCodeMask));

   { Handle default item. }

 if (ch in [ReturnCh, EnterCh]) and
 (defaultItem > 0) then
 begin
 FlashItem(defaultItem);
 itemHit := defaultItem;
 EventFilter := true
 end

 { Handle cancel item. }

 else if (BitAnd(theEvent.modifiers,
 CmdKey) <> 0) and (ch in ['.']) and
 (cancelItem > 0) then
 begin
 FlashItem(cancelItem);
 itemHit := cancelItem;
 EventFilter := true
 end

 { Handle tab key. }

 else if (ch in [TabCh]) and
 (toolboxDPeek^.editField <> -1) then
 begin
 if BitAnd(theEvent.modifiers,
 ShiftKey) <> 0 then
 begin

 { Find previous edit item. }

 editItem := toolboxDPeek^.editField
 + 1;
 repeat
 if editItem = 1 then
 editItem := itemCount
 else
 editItem := editItem - 1;
 GetDItem(toolboxDialog, editItem,
 itemType, itemHandle,
 itemRect);
 until itemType = editText;
 end
 else
 begin

 { Find next edit item. }

 editItem := toolboxDPeek^.editField
 + 1;
 repeat
 if editItem = itemCount then
 editItem := 1
 else
 editItem := editItem + 1;
 GetDItem(toolboxDialog, editItem,
 itemType, itemHandle,
 itemRect);
 until itemType = editText
 end;

 { Select the edit field. }

 SelIText(toolboxDialog, editItem, 0,
 32767);
 itemHit := editItem;
 EventFilter := true
 end

 { Handle keyboard commands. }

 else if BitAnd(theEvent.modifiers,
 CmdKey) <> 0 then
 begin
 Command(ch, itemHit);
 EventFilter := true
 end

 { Handle other typing. }

 else
 EventFilter := false
 end;

 updateEvt: 
 begin
 BeginUpdate(toolboxDialog);
 UpdtDialog(toolboxDialog,
 toolboxDialog^.visRgn);
 Draw;
 EndUpdate(toolboxDialog);
 EventFilter := true
 end;

 otherwise
 EventFilter := false
 end;

 { Restore port. }

 SetPort(savePort)
end;

procedure TDialog.FixCursor;

{ Fix the cursor. }

 var
 localMouse: Point;
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 if toolboxDPeek^.editField <> -1 then
 begin
 GetMouse(localMouse);
 GetDItem(toolboxDialog,
 toolboxDPeek^.editField + 1, itemType,
 itemHandle, itemRect);
 if PtInRect(localMouse, itemRect) then
 SetCursor(IBeam^^)
 else
 InitCursor
 end
end;

procedure TDialog.Command(ch: Char;
 var itemHit: Integer);

{ Handle keyboard command. }

begin
 if toolboxDPeek^.editField <> -1 then
 begin
 if ch in ['X', 'x'] then
 begin
 DlgCut(toolboxDialog);
 itemHit := toolboxDPeek^.editField + 1
 end
 else if ch in ['C', 'c'] then
 begin
 DlgCopy(toolboxDialog);
 itemHit := toolboxDPeek^.editField + 1
 end
 else if ch in ['V', 'v'] then
 begin
 DlgPaste(toolboxDialog);
 itemHit := toolboxDPeek^.editField + 1
 end
 else if ch in ['B', 'b'] then
 begin
 DlgDelete(toolboxDialog);
 itemHit := toolboxDPeek^.editField + 1
 end
 end
end;

procedure TDialog.Hit(var itemHit: Integer);

{ Special handling for item hit. }

begin
end;

procedure TDialog.Draw;

{ Draw extra dialog embellishments. }

begin
 DrawDefault;
end;

procedure TDialog.DrawDefault;

{ Outline the default button. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect, outlineRect: Rect;

begin
 if defaultItem > 0 then
 begin
 GetDItem(toolboxDialog, defaultItem,
 itemType, itemHandle, itemRect);
 outlineRect := itemRect;
 InsetRect(outlineRect, -4, -4);
 PenSize(3, 3);
 FrameRoundRect(outlineRect, 16, 16);
 PenNormal
 end
end;

procedure TDialog.DrawBox(itemSet: DialogItemSet; margin, thickness: 
Integer);

{ Draw a box around a set of dialog items. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect, boxRect: Rect;
 item: Integer;

begin

 { Get the enclosing rectangle. }

 SetRect(boxRect, 0, 0, 0, 0);
 for item := 1 to itemCount do
 if item in itemSet then
 begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if EmptyRect(boxRect) then
 boxRect := itemRect
 else
 UnionRect(boxRect, ItemRect, boxRect)
 end;

 { Draw the box. }

 if not EmptyRect(boxRect) then
 begin
 InsetRect(boxRect, -(margin + thickness),
 -(margin + thickness));
 PenSize(thickness, thickness);
 FrameRect(boxRect);
 PenNormal
 end
end;

procedure TDialog.DrawTitleBox(
 itemSet: DialogItemSet;
 margin, thickness: Integer; title: Str255);

{ Draws a box around a set of dialog items. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect, boxRect: Rect;
 item: Integer;
 theInfo: FontInfo;

begin

 { Get the enclosing rectangle. }

 SetRect(boxRect, 0, 0, 0, 0);
 for item := 1 to itemCount do
 if item in itemSet then
 begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if EmptyRect(boxRect) then
 boxRect := itemRect
 else
 UnionRect(boxRect, ItemRect, boxRect)
 end;

 { Draw the box and the title. }

 if not EmptyRect(boxRect) then
 begin
 GetFontInfo(theInfo);
 with boxRect, theInfo do
 begin
 left := left - margin - thickness;
 top := top - descent - margin -
 thickness;
 right := right + margin;
 bottom := bottom + margin;
 PenSize(thickness, thickness);
 MoveTo(left, top);
 Line(margin + 2, 0);
 Move(thickness + 1,
 (ascent + descent) div 2 - descent);
 DrawString(title);
 Move(1, -((ascent + descent) div 2 -
 descent));
 LineTo(right, top);
 LineTo(right, top);
 LineTo(right, bottom);
 LineTo(left, bottom);
 LineTo(left, top);
 PenNormal
 end
 end
end;

TDialog.FlashItem(item: Integer);

{ Hilight the dialog item for a few ticks. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;
 finalTicks: Longint;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, ctrlItem) <> 0 then
 begin
 HiliteControl(ControlHandle(itemHandle),
 ControlOn);
 Delay(FlashTicks, finalTicks);
 HiliteControl(ControlHandle(itemHandle),
 ControlOff);
 Delay(AfterTicks, finalTicks)
 end
end;

function TDialog.GetText(
 item: Integer): Str255;

{ Get the dialog item text string. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;
 text: Str255;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, statText + editText) <> 0
 then
 GetIText(itemHandle, text)
 else
 text := '';
 GetText := text
end;

procedure TDialog.SetText(item: Integer;
 text: Str255);

{ Set the dialog item text string. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, statText + editText) <> 0
 then
 begin
 SetIText(itemHandle, text);
 if toolboxDPeek^.editField + 1 = item then
 SelIText(toolboxDialog, item, 0, 32767);
 end
end;

function TDialog.GetInteger(
 item: Integer): Longint;

{ Get an integer value from the item text. }

 var
 text: Str255;
 value: Longint;

begin
 text := GetText(item);
 StringToNum(text, value);
 GetInteger := value
end;

procedure TDialog.SetInteger(item: Integer;
 value: Longint);

{ Set the item text string to represent an integer. }

 var
 text: Str255;

begin
 NumToString(value, text);
 SetText(item, text)
end;

function TDialog.GetReal(
 item: Integer): Extended;

{ Get a real value from the item text. }

 var
 text: Str255;
 value: Extended;

begin
 text := GetText(item);
 value := Str2Num(text);
 GetReal := value
end;

procedure TDialog.SetReal(item: Integer;
 value: Extended; places: Integer);

{ Set the item text string to represent a real number. }

 var
 format: DecForm;
 text: DecStr;

begin
 SetRound(ToNearest);
 format.style := FixedDecimal;
 format.digits := places;
 Num2Str(format, value, text);
 SetText(item, text)
end;

function TDialog.GetControlValue(
 item: Integer): Integer;

{ Get the control value. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;
 value: Integer;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, ctrlItem) <> 0 then
 value := GetCtlValue(
 ControlHandle(itemHandle))
 else
 value := 0;
 GetControlValue := value
end;

procedure TDialog.SetControlValue(
 item: Integer; value: Integer);

{ Set the control value. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, ctrlItem) <> 0 then
 SetCtlValue(ControlHandle(itemHandle), value)
end;

function TDialog.GetControlTitle(
 item: Integer): Str255;

{ Get the control title. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;
 title: Str255;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, ctrlItem) <> 0 then
 GetCTitle(ControlHandle(itemHandle), title)
 else
 title := '';
 GetControlTitle := title
end;

procedure TDialog.SetControlTitle(
 item: Integer; title: Str255);

{ Set the control title. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, ctrlItem) <> 0 then
 SetCTitle(ControlHandle(itemHandle), title)
end;

function TDialog.GetRadioItem(
 radioSet: DialogItemSet): Integer;

{ Get the selected radio button. }

 var
 item, value: Integer;
 itemSelected: Integer;

begin
 itemSelected := 0;
 item := 1;
 while (itemSelected = 0) and
 (item <= itemCount) do
 begin
 if item in radioSet then
 if GetControlValue(item) = ControlOn then
 itemSelected := item;
 item := item + 1
 end;
 GetRadioItem := itemSelected
end;

procedure TDialog.SetRadioItem(
 radioSet: DialogItemSet;
 itemSelected: Integer);

{ Set the selected radio button. }

 var
 item: Integer;

begin
 if itemSelected in radioSet then
 for item := 1 to itemCount do
 if item in radioSet then
 if item = itemSelected then
 SetControlValue(item, ControlOn)
 else
 SetControlValue(item, ControlOff)
end;

procedure TDialog.SetIcon(item: Integer;
 iconID: Integer);

{ Set icon item. }

 var
 theIcon: Handle;
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 theIcon := GetIcon(iconID);
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if (BitAnd(itemType, iconItem) <> 0) and
 (theIcon <> nil) then
 SetDItem(toolboxDialog, item, itemType,
 Handle(theIcon), itemRect)
end;

procedure TDialog.SetPicture(item: Integer;
 pictureID: Integer);

{ Set picture item. }

 var
 thePicture: PicHandle;
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 thePicture := GetPicture(pictureID);
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if (BitAnd(itemType, picItem) <> 0) and
 (thePicture <> nil) then
 SetDItem(toolboxDialog, item, itemType,
 Handle(thePicture), itemRect)
end;

procedure TDialog.SetUserItem(item: Integer;
 userProc: ProcPtr);

{ Set the dialog user item procedure. }

 var
 itemType: Integer;
 itemHandle: Handle;
 itemRect: Rect;

begin
 GetDItem(toolboxDialog, item, itemType,
 itemHandle, itemRect);
 if BitAnd(itemType, userItem) <> 0 then
 SetDItem(toolboxDialog, item, itemType,
 Handle(userProc), itemRect)
end;

procedure TAboutDialog.IAboutDialog;

{ Initialize about dialog. }

begin
 IDialog(AboutID, OKButton, 0, 0, [OKButton], true)
end;

function TAboutDialog.Show: Integer;

{ Show about dialog. }

 var
 s: Str255;

begin
 NumToString(MaxBlock div 1024, s);
 s := Concat(s, 'K ', GetText(3));
 SetText(3, s);
 Show := inherited Show
end;

procedure TMessageDialog.IMessageDialog(
 message: Str255; iconID: Integer);

{ Initialize message dialog. }

begin
 IDialog(MessageID, OKButton, 0, 0, [OKButton],true);
 SetIcon(2, iconID);
 SetMessage(message)
end;

procedure TMessageDialog.SetMessage(message: Str255);
{Set message text string. }
begin
 SetText(3, message)
end;

procedure TStringDialog.IStringDialog(
 prompt, default: Str255);
{ Initialize string dialog. }
begin
 IDialog(StringID, OKButton, CancelButton, 4,
 [OKButton, CancelButton], true);
 SetData(prompt, default)
end;

procedure TStringDialog.SetData(prompt,default: Str255);
{ Set prompt and default text strings. }
begin
 SetText(3, prompt);
 SetText(4, default)
end;

procedure TStringDialog.GetData(
 var response: Str255);
{ Get string. }
begin
 response := GetText(4)
end;

procedure TYesNoDialog.IYesNoDialog(
 prompt: Str255; default: Integer);

{ Initialize Yes/No dialog. }

begin
 IDialog(YesNoID, default, 0, 0,
 [YesButton, NoButton], true);
 SetPrompt(prompt)
end;

procedure TYesNoDialog.SetPrompt(
 prompt: Str255);

{ Set prompt text string. }

begin
 SetText(2, prompt)
end;

procedure TYesNoCancelDialog.IYesNoCancelDialog(
 prompt: Str255; default: Integer);

{ Initialize Yes/No/Cancel dialog. }

begin
 IDialog(YesNoCancelID, default, CancelButton,
 0, [YesButton, NoButton, CancelButton],
 true);
 SetPrompt(prompt)
end;

procedure TYesNoCancelDialog.SetPrompt(
 prompt: Str255);

{ Set prompt text string. }

begin
 SetText(4, prompt)
end;

procedure TMarginsDialog.IMarginsDialog(
 defaultMargins: MarginRecord);
{ Initialize page margins dialog. }
begin
 IDialog(PageMarginsID, OKButton, CancelButton,
 5, [OKButton, CancelButton], true);
 measureSet := [12, 13, 14];
 SetData(defaultMargins)
end;

procedure TMarginsDialog.Draw;
{ Draw. }
begin
 DrawTitleBox(measureSet, 3, 1, 'Measure');
 DrawDefault
end;

procedure TMarginsDialog.Hit(var itemHit: Integer);
{ Item hit. }
 var
 oldItem: Integer;
 factor: Extended;
 places: Integer;

begin
 if itemHit in measureSet then
 begin

 { Convert margin values to new units. }

 oldItem := GetRadioItem(measureSet);
 if oldItem <> itemHit then
 begin
 if (oldItem = 12) and
 (itemHit = 13) then
 begin

 { Inches to cm. }

 factor := 2.54;
 places := 2
 end
 else if (oldItem = 12) and
 (itemHit = 14) then
 begin

 { Inches to points. }

 factor := 72.0;
 places := 0
 end
 else if (oldItem = 13) and
 (itemHit = 12) then
 begin

 { Cm to inches. }

 factor := 1.0 / 2.54;
 places := 2
 end
 else if (oldItem = 13) and
 (itemHit = 14) then
 begin

 { cm to points. }

 factor := 1.0 / 2.54 * 72.0;
 places := 0
 end
 else if (oldItem = 14) and
 (itemHit = 12) then
 begin

 { Points to inches. }

 factor := 1.0 / 72.0;
 places := 2
 end
 else if (oldItem = 14) and
 (itemHit = 13) then
 begin

 { Points to cm. }
 factor := 1.0 / 72.0 * 2.54;
 places := 2
 end;

 SetReal(5, GetReal(5) * factor, places);
 SetReal(7, GetReal(7) * factor, places);
 SetReal(9, GetReal(9) * factor, places);
 SetReal(11, GetReal(11) * factor,
 places);
 end;
 SetRadioItem(measureSet, itemHit)
 end
end;

procedure TMarginsDialog.SetData(newMargins: MarginRecord);
{ Set the page margin values. }
 var
 places: Integer;

begin
 case newMargins.measure of

 inches: 
 begin
 SetRadioItem(measureSet, 12);
 places := 2
 end;

 cm: 
 begin
 SetRadioItem(measureSet, 13);
 places := 2
 end;

 points: 
 begin
 SetRadioItem(measureSet, 14);
 places := 0
 end;

 end;
 SetReal(5, newMargins.top, places);
 SetReal(7, newMargins.bottom, places);
 SetReal(9, newMargins.left, places);
 SetReal(11, newMargins.right, places)
end;

procedure TMarginsDialog.GetData(var theMargins: MarginRecord);
{ Get the page margin values. }
begin
 case GetRadioItem(measureSet) of
 12: 
 theMargins.measure := inches;
 13: 
 theMargins.measure := cm;
 14: 
 theMargins.measure := points;
 end;
 theMargins.top := GetReal(5);
 theMargins.bottom := GetReal(7);
 theMargins.left := GetReal(9);
 theMargins.right := GetReal(11)
end;

procedure TFontSizeDialog.IFontSizeDialog(defaultSize: Integer);
{ Initialize font size dialog. }
begin
 IDialog(FontSizeID, OKButton, CancelButton, 4,
 [OKButton, CancelButton], true);
 SetData(defaultSize)
end;

procedure TFontSizeDialog.SetData(fontSize: Integer);
{ Set the font size. }
begin
 SetInteger(4, fontSize)
end;

procedure TFontSizeDialog.GetData(var fontSize: Integer);
{ Get the font size. }
begin
 fontSize := GetInteger(4)
end;

end.
Listing: Test Dialogs.p

{ Written by Thomas Engel, M.D. }
{ Copyright © 1991 MacTutor. }
{$I-}
program TestDialogs;
uses
 Globals, TDialog;
var
 theButton: Integer;
 response: Str255;
 fontSize: Integer;
 margins: MarginRecord;
 confirmed: Boolean;

begin
 { Initialize system. }
 MaxApplZone;
 MoreMasters;
 InitGraf(@thePort);
 InitFonts;
 InitWindows;
 InitMenus;
 TEInit;
 InitDialogs(nil);
 InitCursor;
 FlushEvents(EveryEvent, 0);
 IBeam := GetCursor(IBeamID);
 Watch := GetCursor(WatchID);

 { Test each dialog. }
 ShowAbout;
 ShowMessage('This is a message.');

 theButton := YesNoDialog(
 'This is the prompt. (Yes)', YesButton);
 theButton := YesNoCancelDialog(
 'This is the prompt. (Cancel)',
 CancelButton);

 response := 'This is the default text.';
 confirmed := StringDialog('This is the prompt.', response);

 fontSize := 12;
 confirmed := FontSizeDialog(fontSize);

 margins.measure := inches;
 margins.top := 1.0;
 margins.bottom := 1.5;
 margins.left := 1.25;
 margins.right := 1.25;
 confirmed := MarginsDialog(margins);
end.
Listing: Dialogs.r

resource 'DITL' (128, "About", purgeable, preload) {
 { /* array DITLarray: 4 elements */
 /* [1] */
 {111, 201, 130, 266},
 Button {
 enabled,
 "OK"
 },
 /* [2] */
 {15, 15, 47, 265},
 StaticText {
 disabled,
 "Dialog Test Application\nVersion 1.0\n"
 },
 /* [3] */
 {113, 15, 129, 182},
 StaticText {
 disabled,
 "bytes free."
 },
 /* [4] */
 {52, 15, 97, 265},
 StaticText {
 disabled,
 "Copyright © 1991 MacTutor.\nAll rights re"
 "served."
 }
 }
};

resource 'DITL' (129, "Message", purgeable, preload) {
 { /* array DITLarray: 3 elements */
 /* [1] */
 {98, 311, 117, 376},
 Button {
 enabled,
 "OK"
 },
 /* [2] */
 {10, 10, 42, 42},
 Icon {
 disabled,
 1
 },
 /* [3] */
 {20, 52, 84, 375},
 StaticText {
 disabled,
 "^0\n^1\n^2\n^3"
 }
 }
};

resource 'DITL' (130, "Get String", purgeable, preload) {
 { /* array DITLarray: 4 elements */
 /* [1] */
 {74, 206, 93, 271},
 Button {
 enabled,
 "OK"
 },
 /* [2] */
 {74, 281, 93, 346},
 Button {
 enabled,
 "Cancel"
 },
 /* [3] */
 {15, 15, 31, 345},
 StaticText {
 disabled,
 "Prompt?"
 },
 /* [4] */
 {38, 18, 54, 342},
 EditText {
 enabled,
 "Default"
 }
 }
};

resource 'DITL' (131, "Yes/No", purgeable, preload) {
 { /* array DITLarray: 3 elements */
 /* [1] */
 {77, 206, 96, 271},
 Button {
 enabled,
 "Yes"
 },
 /* [2] */
 {15, 15, 63, 345},
 StaticText {
 disabled,
 "^0"
 },
 /* [3] */
 {77, 281, 96, 346},
 Button {
 enabled,
 "No"
 }
 }
};

resource 'DITL' (132, "Yes/No/Cancel", purgeable, preload) {
 { /* array DITLarray: 4 elements */
 /* [1] */
 {77, 131, 96, 196},
 Button {
 enabled,
 "Yes"
 },
 /* [2] */
 {77, 281, 96, 346},
 Button {
 enabled,
 "Cancel"
 },
 /* [3] */
 {77, 206, 96, 271},
 Button {
 enabled,
 "No"
 },
 /* [4] */
 {15, 15, 63, 345},
 StaticText {
 disabled,
 "^0"
 }
 }
};

resource 'DITL' (133, "Font Size", purgeable, preload) {
 { /* array DITLarray: 4 elements */
 /* [1] */
 {74, 66, 93, 131},
 Button {
 enabled,
 "OK"
 },
 /* [2] */
 {74, 141, 93, 206},
 Button {
 enabled,
 "Cancel"
 },
 /* [3] */
 {35, 21, 51, 121},
 StaticText {
 disabled,
 "New font size:"
 },
 /* [4] */
 {35, 138, 51, 173},
 EditText {
 enabled,
 "12"
 }
 }
};

resource 'DITL' (134, "Page Margins", purgeable, preload) {
 { /* array DITLarray: 14 elements */
 /* [1] */
 {171, 186, 190, 251},
 Button {
 enabled,
 "OK"
 },
 /* [2] */
 {171, 261, 190, 326},
 Button {
 enabled,
 "Cancel"
 },
 /* [3] */
 {15, 15, 31, 325},
 StaticText {
 disabled,
 "New page margins:"
 },
 /* [4] */
 {40, 16, 56, 72},
 StaticText {
 disabled,
 "Top"
 },
 /* [5] */
 {40, 80, 56, 120},
 EditText {
 enabled,
 "1.25"
 },
 /* [6] */
 {64, 16, 80, 72},
 StaticText {
 disabled,
 "Bottom"
 },
 /* [7] */
 {64, 80, 80, 120},
 EditText {
 enabled,
 "1.25"
 },
 /* [8] */
 {40, 168, 56, 224},
 StaticText {
 disabled,
 "Left"
 },
 /* [9] */
 {40, 232, 56, 272},
 EditText {
 enabled,
 "1.25"
 },
 /* [10] */
 {64, 168, 80, 224},
 StaticText {
 disabled,
 "Right"
 },
 /* [11] */
 {64, 232, 80, 272},
 EditText {
 enabled,
 "1.25"
 },
 /* [12] */
 {104, 56, 120, 184},
 RadioButton {
 enabled,
 "inches"
 },
 /* [13] */
 {120, 56, 136, 184},
 RadioButton {
 enabled,
 "centimeters"
 },
 /* [14] */
 {136, 56, 152, 184},
 RadioButton {
 enabled,
 "points"
 }
 }
};

resource 'DLOG' (128, "About", purgeable, preload) {
 {83, 116, 227, 396},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 128,
 "About Dialog"
};

resource 'DLOG' (129, "Message", purgeable, preload) {
 {88, 61, 219, 451},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 129,
 "Show Message"
};

resource 'DLOG' (130, "Get String", purgeable, preload) {
 {98, 76, 205, 436},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 130,
 "Ask String"
};

resource 'DLOG' (131, "Yes/No", purgeable, preload) {
 {96, 76, 206, 436},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 131,
 "Ask Yes/No"
};

resource 'DLOG' (132, "Yes/No/Cancel", purgeable, preload) {
 {96, 76, 206, 436},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 132,
 "Ask Yes/No/Cancel"
};

resource 'DLOG' (133, "Font Size", purgeable, preload) {
 {98, 146, 205, 366},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 133,
 "Ask Font Size"
};

resource 'DLOG' (134, "Page Margins", purgeable, preload) {
 {52, 86, 254, 426},
 dBoxProc,
 invisible,
 noGoAway,
 0x0,
 134,
 "Page Margin Dialog"
};

 
AAPL
$524.94
Apple Inc.
+5.93
MSFT
$40.01
Microsoft Corpora
-0.39
GOOG
$536.10
Google Inc.
-20.44

MacTech Search:
Community Search:

Software Updates via MacUpdate

VMware Fusion 6.0.3 - Run Windows apps a...
VMware Fusion allows you to create a Virtual Machine on your Mac and run Windows (including Windows 8.1) and Windows software on your Mac. Run your favorite Windows applications alongside Mac... Read more
Tweetbot 1.5.1 - Popular iOS twitter cli...
Tweetbot is a full-featured OS X Twitter client with a lot of personality. Whether it's the meticulously-crafted interface, sounds and animation, or features like multiple timelines and column views... Read more
Mac DVDRipper Pro 4.1.7 - Copy, backup,...
Mac DVDRipper Pro is the DVD backup solution that lets you protect your DVDs from scratches, save your batteries by reading your movies from your hard disk, manage your collection with just a few... Read more
PDFpenPro 6.2 - Advanced PDF toolkit for...
PDFpenPro allows users to edit PDF's easily. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Create... Read more
PDFpen 6.2 - Edit and annotate PDFs with...
PDFpen allows users to easily edit PDF's. Add text, images and signatures. Fill out PDF forms. Merge or split PDF documents. Reorder and delete pages. Even correct text and edit graphics! Features... Read more
Monolingual 1.5.9 - Remove unwanted OS X...
Monolingual is a program for removing unnecesary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least... Read more
Maya 2015 - Professional 3D modeling and...
Maya is an award-winning software and powerful, integrated 3D modeling, animation, visual effects, and rendering solution. Because Maya is based on an open architecture, all your work can be scripted... Read more
Starcraft II: Wings of Liberty 1.1.1.180...
Download the patch by launching the Starcraft II game and downloading it through the Battle.net connection within the app. Starcraft II: Wings of Liberty is a strategy game played in real-time. You... Read more
Sibelius 7.5.0 - Music notation solution...
Sibelius is the world's best-selling music notation software for Mac. It is as intuitive to use as a pen, yet so powerful that it does most things in less than the blink of an eye. The demo includes... Read more
Typinator 5.9 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more

Latest Forum Discussions

See All

This Week at 148Apps: April 14-18, 2014
Spring Into Our App Reviews   | Read more »
Have a Special Dead Trigger 2 Easter Bas...
Have a Special Dead Trigger 2 Easter Basket Full of Goodies, Courtesy of Madfinger Games Posted by Rob Rich on April 18th, 2014 [ permalink ] Dead Trigger 2 | Read more »
Almost All of Playdek’s Library is on Sa...
Almost All of Playdek’s Library is on Sale Right Now, and You Should Check it Out Posted by Rob Rich on April 18th, 2014 [ permalink ] Playdek has released quite a few great iOS ports of board and card games over the years, and now most of them... | Read more »
Zynga Launches Brand New Farmville Exper...
Zynga Launches Brand New Farmville Experience with Farmville 2: Country Escape Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
David. Review
David. Review By Cata Modorcea on April 18th, 2014 Our Rating: :: MINIMALISTIC IN A DIFFERENT WAYUniversal App - Designed for iPhone and iPad David is a minimalistic game wrapped inside of a soothing atmosphere in which the hero... | Read more »
Eyefi Unveils New Eyefi Cloud Service Th...
Eyefi Unveils New Eyefi Cloud Service That Allows Users to Share Media Across Personal Devices Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
Tales from the Dragon Mountain: The Lair...
Tales from the Dragon Mountain: The Lair Review By Jennifer Allen on April 18th, 2014 Our Rating: :: STEADY ADVENTURINGiPad Only App - Designed for the iPad Treading a safe path, Tales from the Dragon Mountain: The Lair is a... | Read more »
Yahoo Updates Flickr App with Advanced E...
Yahoo Updates Flickr App with Advanced Editing Features and More Posted by Tre Lawrence on April 18th, 2014 [ permalink ] | Read more »
My Incredible Body - A Kid's App to...
My Incredible Body - A Kid's App to Learn about the Human Body 1.1.00 Device: iOS Universal Category: Education Price: $2.99, Version: 1.1.00 (iTunes) Description: Wouldn’t it be cool to look inside yourself and see what was going on... | Read more »
Trials Frontier Review
Trials Frontier Review By Carter Dotson on April 18th, 2014 Our Rating: :: A ROUGH LANDINGUniversal App - Designed for iPhone and iPad Trials Frontier finally brings the famed stunt racing franchise to mobile, but how much does its... | Read more »

Price Scanner via MacPrices.net

Deal Alert! 13-inch MacBook Pro on sale for $...
Best Buy has the 13″ 2.5GHz MacBook Pro on sale for $999.99 on their online store. Choose free shipping or free instant local store pickup (if available). Their price is $200 off MSRP. Price is valid... Read more
Free HopTo 2.2 Helps Enhance Your Productivit...
The HopTo app helps you do more on your iPad by providing more and easier adaccess to files and documents. Version 2.2 adds Egnyte and HopTo’s Mac OSX File Connector. If you already have the hopTo... Read more
National Distracted Driving Awareness Month:...
As the country recognizes National Distracted Driving Awareness Month, Sprint is reminding wireless consumers to focus on driving while behind the wheel, to not text or email while driving, and to... Read more
13-inch 2.4GHz Retina MacBook Pro available f...
Abt has the 13″ 2.4GHz 128GB Retina MacBook Pro available for $1229 including free shipping. Their price is $70 off MSRP. Read more
iMacs on sale for up to $160 off MSRP this we...
Best Buy has iMacs on sale for up to $160 off MSRP for a limited time. Choose free home shipping or free instant local store pickup (if available). Prices are valid for online orders only, in-store... Read more
iPad Airs on sale this weekend for up to $100...
Best Buy has WiFi iPad Airs on sale for $50 off MSRP and WiFi + Cellular iPad Airs on sale for $100 off MSRP on their online store for a limited time, with prices now starting at $449. Choose free... Read more
Apple restocks refurbished Mac minis starting...
The Apple Store has restocked Apple Certified Refurbished Mac minis for up to $150 off the cost of new models. Apple’s one-year warranty is included with each mini, and shipping is free: - 2.5GHz Mac... Read more
Hyundai Brings Apple CarPlay To The 2015 Sona...
Hyundai Motor America has announced it will bring Apple CarPlay functionality to the 2015 Sonata. CarPlay is pitched as a smarter, safer and easier way to use iPhone in the car and gives iPhone users... Read more
Updated iPads Coming Sooner Than We Had Thoug...
MacRumors, cites KGI securities analyst Ming Chi Kuo, well-respected as an Apple product prognisticator, saying that Apple will introduce an upgraded iPad Air and iPad mini in 2014/Q3, meaning the... Read more
Toshiba Unveils New High And Low End Laptop M...
Toshiba has announced new laptop models covering both the high-end and low-end of the notebook computer spectrum. Toshiba 4K Ultra HD Laptop Toshiba’s new Satellite P55t features one of the world’s... Read more

Jobs Board

Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Inc. Research Data Specialist - Appl...
…of Worldwide Market Research & Intelligence. The team is responsible for conducting Apple branded consumer market research. It is also responsible for analyzing data Read more
*Apple* Automotive Parts Department position...
Apple Automotive is one of the fastest growing dealer…and it shows. Consider making the switch to the Apple Automotive Group today! At Apple Automotive, we Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.