home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-01-24 | 3.8 KB | 163 lines | [TEXT/CWIE] |
- unit Modal3;
-
- interface
-
- uses
- Types, MixedMode, QuickDraw, Windows, Dialogs, OSUtils, TransSkel, ButtonGlobals;
-
-
- procedure DoModal3;
-
- implementation
-
- const
-
- iPushDismiss = 1;
- iPushButton1 = 2;
- iPushButton2 = 3;
- iPushButton3 = 4;
- iRadioStaticText = 5;
- iRadioButton1 = 6;
- iRadioButton2 = 7;
- iRadioButton3 = 8;
- iRadioNone = 9;
- iCheckStaticText = 10;
- iCheckButton1 = 11;
- iCheckButton2 = 12;
- iCheckButton3 = 13;
- iOutline = 14;
-
-
- var
-
- defaultButton: Integer;
-
- drawProc: UserItemUPP;
-
-
- {--------------------------------------------------------------------}
- { Dialog 3 procedures }
- {--------------------------------------------------------------------}
-
- procedure OutlineButton (dlog: DialogPtr; item: Integer);
- begin
- SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
- end;
-
-
- procedure InstallOutliner (dlog: DialogPtr; item: Integer);
- var
- r: Rect;
- begin
- SkelGetDlogRect(dlog, item, r);
- InsetRect(r, -4, -4);
- SkelSetDlogRect(dlog, iOutline, r);
- SkelSetDlogProc(dlog, iOutline, drawProc);
- SkelDrawButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
- end;
-
-
- procedure RemoveOutliner (dlog: DialogPtr);
- begin
- SkelSetDlogProc(dlog, iOutline, nil);
- SkelEraseButtonOutline(SkelGetDlogCtl(dlog, defaultButton));
- end;
-
-
- procedure SetDefaultButton (dlog: DialogPtr; item: Integer);
- begin
- if (defaultButton <> 0) then
- RemoveOutliner(dlog);
- defaultButton := item;
- if (defaultButton <> 0) then
- InstallOutliner(dlog, defaultButton);
- end;
-
-
- procedure DoModal3;
- var
- filter: ModalFilterProcPtr;
- dlog: DialogPtr;
- savePort: GrafPtr;
- item: Integer;
- value: Integer;
- hilite: Integer;
- loop: Boolean;
- begin
- dlog := GetNewDialog(modal3Res, nil, WindowPtr(-1));
- if (dlog = DialogPtr(nil)) then
- begin
- SysBeep(1);
- exit(DoModal3);
- end;
-
- SkelPositionWindow(dlog, skelPositionOnMainDevice, horizRatio, vertRatio);
-
- GetPort(savePort);
- SetPort(dlog);
-
- {
- Set up a variable to point to the outline drawing procedure. For 68K code
- this is just a direct pointer to OutlineButton(). For PowerPC code it is a
- routine descriptor into which the address of OutlineButton() is stuffed.
- }
-
- drawProc := NewUserItemProc (@OutlineButton);
-
- { should really check whether or not drawProc is nil! }
-
- SetDefaultButton(dlog, iPushButton1);
- SkelSetDlogCtlValue(dlog, iCheckButton1, 1);
- SkelSetDlogCtlValue(dlog, iCheckButton2, 1);
- SkelSetDlogCtlValue(dlog, iCheckButton3, 1);
- SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, iRadioButton1);
-
- ShowWindow(dlog);
-
- loop := true;
- while (loop) do
- begin
- filter := SkelDlogFilter(nil, false);
- SkelDlogDefaultItem(defaultButton); { turns off if zero }
- ModalDialog(filter, item);
- SkelRmveDlogFilter;
- case item of
- iPushDismiss:
- loop := false;
- iPushButton1, iPushButton2, iPushButton3:
- begin
- { ignore hits in these items }
- end;
- iRadioButton1, iRadioButton2, iRadioButton3:
- begin
- SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, item);
- { remap item number from radio button range into pushbutton range }
- item := item + iPushButton1 - iRadioButton1;
- SetDefaultButton(dlog, item);
- end;
- iRadioNone:
- begin
- SkelSetDlogRadioButtonSet(dlog, iRadioButton1, iRadioNone, item);
- SetDefaultButton(dlog, 0); { no default button }
- end;
- iCheckButton1, iCheckButton2, iCheckButton3:
- begin
- value := SkelToggleDlogCtlValue(dlog, item);
- if (value <> 0) then
- hilite := normalHilite
- else
- hilite := dimHilite;
- { remap item number from checkbox range into pushbutton range }
- item := item + iPushButton1 - iCheckButton1;
- if (SkelSetDlogCtlHilite(dlog, item, hilite) and (item = defaultButton)) then
- SkelDrawButtonOutline(SkelGetDlogCtl(dlog, item));
- end;
- end;
- end;
-
- DisposeRoutineDescriptor (drawProc);
- DisposeDialog(dlog);
- SetPort(savePort);
- end;
-
- end.