home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1997-02-06 | 2.8 KB | 88 lines | [TEXT/3PRM] |
- implementation module dialogAbout;
-
-
- import StdBool, StdInt;
- import ioState, dialogAccess, dialogInternal;
- from dialogDevice import DoModalDialog;
-
-
- AboutDialogID :== -1;
-
- DummyDialogH :: DialogHandle s io;
- DummyDialogH = DialogH 0 "" Modal (0,0,0,0) [] [] (DialogRest Command [] 0);
-
-
- // AboutDialogToDialogHandle converts an AboutDialog into a DialogHandle.
-
- AboutDialogToDialogHandle :: !(DialogDef s (IOState s)) -> DialogHandle s (IOState s);
- AboutDialogToDialogHandle (AboutDialog an pd fs help)
- = DialogH AboutDialogID an Modal (0,0,0,0) [] [icon, ok : hbut] (DialogRest Command [] 2);
- where {
- icon= DialogIconButton 1 Center pd (AboutLook fs) Unable AboutOK;
- ok = DialogButton 2 Center "OK" Able AboutOK;
- hbut= MakeAboutHelpButton help;
- };
-
- AboutLook :: ![DrawFunction] !SelectState -> [DrawFunction];
- AboutLook drawfs _ = drawfs;
-
- // AboutOK :: !DialogInfo !*s !(IOState *s) -> (!*s,!IOState *s);
- AboutOK ddef s io = (s, DeviceCloseDialog io);
-
- MakeAboutHelpButton :: !(AboutHelpDef s (IOState s)) -> [DialogItem s (IOState s)];
- MakeAboutHelpButton NoHelp = [];
- MakeAboutHelpButton (AboutHelp title helpf)
- = [DialogButton 3 (RightTo 2) title Able (AboutHelpFunc helpf)];
-
- // AboutHelpFunc :: !(*s -> (IOState *s) -> (*s,IOState *s) ) !DialogInfo !*s !(IOState *s)
- // -> (!*s,!IOState *s);
- AboutHelpFunc helpf ddef s io = helpf s (DeviceCloseDialog io);
-
- DeviceCloseDialog :: !(IOState s) -> IOState s;
- DeviceCloseDialog ioState
- | not found = ioState1;
- = DeactivateDialog dRep ioState1;
- where {
- (found,dRep,ioState1) = IOStateRemoveActiveDialog ioState;
- };
-
-
- // OpenAboutDialog opens the About... dialog
-
- OpenAboutDialog :: !*s !(IOState *s) -> (!*s, !IOState *s);
- OpenAboutDialog s ioState
- | found = DoModalDialog (DialogHandleToDialogDef about) s ioState1;
- = DoModalDialog defaultAboutDef s ioState1;
- where {
- (found,about) = GetAboutDialog dHs;
- (dHs,ioState1) = IOStateGetDialogs ioState;
- defaultAboutDef = CommandDialog AboutDialogID "" [] 2 [
- StaticText 1 Center "This is a Clean program.",
- DialogButton 2 Center "OK" Able AboutOK ];
- };
-
- GetAboutDialog :: !(DialogHandles s) -> (!Bool, !DialogHandle s (IOState s));
- GetAboutDialog [(dH=:DialogH id _ _ _ _ _ _,_) : dHs]
- | id == AboutDialogID = (True, dH);
- = GetAboutDialog dHs;
- GetAboutDialog _ = (False, DummyDialogH);
-
-
- // Return the application name as defined in the AboutDialog.
-
- IOStateGetApplicationName :: !(IOState s) -> (!String, !IOState s);
- IOStateGetApplicationName ioState
- | not found = ("", ioState1);
- = (AboutHandleGetApplicationName about, ioState1);
- where {
- (dHs, ioState1)= IOStateGetDialogs ioState;
- (found, about) = GetAboutDialog dHs;
- };
-
- AboutHandleGetApplicationName :: !(DialogHandle s (IOState s)) -> String;
- AboutHandleGetApplicationName (DialogH _ name _ _ _ _ _) = name;