1 // GetInputFromWindow.c
8 #include <exec/types.h>
10 #include <intuition/intuition.h>
11 #include <intuition/gadgetclass.h>
13 #include <dos/filehandler.h>
14 #include <workbench/startup.h>
15 #include <libraries/gadtools.h>
16 #include <workbench/icon.h>
17 #include <devices/trackdisk.h>
18 #include <dos/rdargs.h>
20 #include <proto/exec.h>
21 #include <proto/intuition.h>
22 #include <proto/dos.h>
23 #include <proto/gadtools.h>
24 #include <proto/icon.h>
25 #include <proto/graphics.h>
26 #include <proto/utility.h>
31 #define FormatDisk_NUMBERS
32 #include STR(SCALOSLOCALE)
36 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
43 static void GetMsgidUnderScore(void);
44 //static ULONG FindUnderscoredToLower(STRPTR text);
46 static UWORD Name_key
, FFS_key
, INTL_key
, Verify_key
, WithTrash_key
;
47 static UWORD Dircache_key
, Trash_key
, Format_key
, QuickFormat_key
, Cancel_key
;
50 //------------------------------------------------------------------------------
51 //------------------------------------------------------------------------------
53 static void GetMsgidUnderScore(void)
55 Name_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_DEVNAME
));
57 FFS_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_FFS
));
59 INTL_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_INTL
));
61 Verify_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_VERIFY
));
63 WithTrash_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_TRASHCAN
));
65 Dircache_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_DIRCACHE
));
67 Trash_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_TRASHCAN_NAME
));
69 Format_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_GUI_FORMAT
));
71 QuickFormat_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_QUICK_FORMAT
));
73 Cancel_key
= FindUnderscoredToLower( (STRPTR
) GetLocString(MSGID_GADGET_GUI_CANCEL
));
76 //-----------------------------------------------------------------------------
78 ULONG
FindUnderscoredToLower(STRPTR text
)
83 if( c
== '_' ) return ToLower(*text
);
87 //-----------------------------------------------------------------------------
89 // Get input from the original window
90 prepResult
getPrepInput(void)
92 struct IntuiMessage
*mesg
;
95 struct Gadget
*gadget
;
96 struct TagItem tags
[2];
100 // Setup tags that will be used to toggle the states of checkbox gadgets
101 tags
[0].ti_Tag
= GTCB_Checked
;
102 tags
[1].ti_Tag
= TAG_DONE
;
103 tags
[1].ti_Data
= 0UL;
105 // Loop until the user presses 'OK' or 'Cancel'
109 Wait(1<<PrepWnd
->UserPort
->mp_SigBit
);
112 mesg
= GT_GetIMsg(PrepWnd
->UserPort
);
114 // Loop while there are messages to be processed
117 // Get the message type, etc.
120 gadget
= (struct Gadget
*)mesg
->IAddress
;
122 // Reply to the message
125 // Act on the message
128 // User clicked on close gadget. Treat it as a click on 'Cancel'
129 case IDCMP_CLOSEWINDOW
:
132 // User pressed a gadget
134 switch(gadget
->GadgetID
)
137 // (each toggles the appropriate status flag)
150 case GD_VerifyGadget
:
160 case GD_DirCacheGadget
:
161 DirCache
= !DirCache
;
169 case GD_QuickFmtGadget
:
173 case GD_CancelGadget
:
178 // Keypress (gadget equivalents)
179 case IDCMP_VANILLAKEY
:
180 if (code
== Name_key
)
181 ActivateGadget(PrepGadgets
[GD_NameGadget
], PrepWnd
,NULL
);
182 else if( code
== FFS_key
)
184 // Toggle the checkmark state of the gadget
185 tags
[0].ti_Data
= (FFS
= !FFS
);
186 GT_SetGadgetAttrsA(PrepGadgets
[GD_FFSGadget
], PrepWnd
,NULL
, tags
);
188 else if( code
== INTL_key
)
192 tags
[0].ti_Data
= (intl
= !intl
);
193 GT_SetGadgetAttrsA(PrepGadgets
[GD_IntlGadget
], PrepWnd
,NULL
, tags
);
196 else if( code
== Verify_key
)
198 tags
[0].ti_Data
= (Verify
= !Verify
);
199 GT_SetGadgetAttrsA(PrepGadgets
[GD_VerifyGadget
], PrepWnd
,NULL
, tags
);
201 else if( code
== WithTrash_key
)
203 tags
[0].ti_Data
= (Icon
= !Icon
);
204 GT_SetGadgetAttrsA(PrepGadgets
[GD_IconGadget
], PrepWnd
,NULL
, tags
);
206 else if( code
== Dircache_key
)
208 tags
[0].ti_Data
= (DirCache
= !DirCache
);
209 GT_SetGadgetAttrsA(PrepGadgets
[GD_DirCacheGadget
], PrepWnd
,NULL
, tags
);
211 else if( code
== Trash_key
)
215 ActivateGadget(PrepGadgets
[GD_TrashCanNameGadget
], PrepWnd
,NULL
);
218 else if( code
== Format_key
)
220 else if( code
== QuickFormat_key
)
222 else if( code
== Cancel_key
)
228 // Get the next message
229 mesg
= GT_GetIMsg(PrepWnd
->UserPort
);
232 // Update state of some gadgets.
233 GT_SetGadgetAttrs(PrepGadgets
[GD_IntlGadget
], PrepWnd
, NULL
, GA_Disabled
, DirCache
, TAG_DONE
);
235 GT_SetGadgetAttrs(PrepGadgets
[GD_TrashCanNameGadget
], PrepWnd
, NULL
, GA_Disabled
, !Icon
, TAG_DONE
);
237 d1(KPrintF(__FILE__
"/" __FUNC__
"/%ld: SELECTED FROM GUI: FFS = %ld INTL = %ld DIRCACHE = %ld ICON = %ld VERIFY = %ld\n",
238 __LINE__
, FFS
, intl
, DirCache
, Icon
, Verify
));