4 /* The Image structure as used by this class:
8 * SHORT LeftEdge; <---- Offset
11 * SHORT Width; <---- } 4 chars 'Oops' used for identification!
12 * SHORT Height; <---- }
14 * SHORT Depth; <---- maintained by boopsi (set to CUSTOMIMAGEDEPTH).
16 * USHORT *ImageData; <---- only used during init, then points to self!
18 * UBYTE PlanePick; <---- used for the foreground color
20 * UBYTE PlaneOnOff; <---- holds ToUpper (underlined char) (after creation!)
22 * struct Image *NextImage; <---- pointer to the next image. Handled by DrawImage().
27 #include <exec/types.h>
29 #include <exec/memory.h>
30 #include <exec/execbase.h>
31 #include <dos/dosextens.h>
32 #include <utility/tagitem.h>
33 #include <intuition/intuition.h>
34 #include <intuition/classes.h>
35 #include <intuition/classusr.h>
36 #include <intuition/gadgetclass.h>
37 #include <intuition/imageclass.h>
38 #include <intuition/sghooks.h>
39 #include <graphics/gfxbase.h>
40 #include <graphics/gfxmacros.h>
41 #include <libraries/gadtools.h>
42 #include <graphics/monitor.h>
43 //#include <devices/audio.h>
44 #include <proto/graphics.h>
45 #include <proto/gadtools.h>
46 #include <proto/exec.h>
47 #include <proto/layers.h>
48 #include <proto/utility.h>
49 #include <proto/console.h>
50 #include <proto/intuition.h>
51 #include <proto/dos.h>
55 #include <aros/asmcall.h>
60 /****************************************************************************************/
62 extern struct Library
*GadToolsBase
;
63 extern struct GfxBase
*GfxBase
;
64 extern struct IntuitionBase
*IntuitionBase
;
65 extern struct Window
*win
;
66 extern struct Screen
*scr
;
67 extern struct ExecBase
*SysBase
;
68 extern struct Device
*ConsoleDevice
;
70 extern void ShortDelay (void);
73 extern ULONG ASM
myBoopsiDispatch (
74 REGPARAM(a0
, Class
*,),
75 REGPARAM(a2
, struct Image
*,),
76 REGPARAM(a1
, struct impDraw
*,));
79 extern Class
*ButtonImgClass
;
81 /****************************************************************************************/
87 struct Gadget
* REGARGS
my_CreateButtonGadget (
92 struct InitData idata
;
96 label
= ng
->ng_GadgetText
;
97 ng
->ng_GadgetText
= NULL
;
99 if ((gad
= myCreateGadget (GENERIC_KIND
, gad
, ng
, TAG_END
)))
102 /* set gadget attributes */
103 gad
->Flags
|= GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
;
104 gad
->GadgetType
|= GTYP_BOOLGADGET
;
105 gad
->Activation
|= GACT_RELVERIFY
;
108 idata
.idata_Gadget
= gad
;
109 idata
.idata_VisualInfo
= ng
->ng_VisualInfo
;
110 idata
.idata_Label
= label
;
111 idata
.idata_TextAttr
= ng
->ng_TextAttr
;
112 idata
.idata_Underscore
= underscorechar
;
116 image
= NewObject (ButtonImgClass
, NULL
, IA_Data
, (IPTR
) &idata
, TAG_END
);
118 gad
->GadgetRender
= gad
->SelectRender
= image
;
121 ng
->ng_GadgetText
= label
;
126 /****************************************************************************************/
128 static struct Image
*IsButtonGad (struct Gadget
*gad
)
139 if (gad
->Flags
& (GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
))
140 if ((im
= (struct Image
*)gad
->SelectRender
))
141 if (im
->Depth
== CUSTOMIMAGEDEPTH
)
143 __tmp
.size
.Width
= im
->Width
;
144 __tmp
.size
.Height
= im
->Height
;
145 if (__tmp
.magic
== BUTTON_MAGIC_LONGWORD
)
146 if (im
->ImageData
== (UWORD
*)im
) return (im
);
152 /****************************************************************************************/
158 struct CombStringInfo
161 struct CombStringInfo
*self
;
162 struct StringInfo strinfo
;
163 struct StringExtend strextend
;
164 struct Hook edithook
;
167 /****************************************************************************************/
169 #define IEQUALIFIER_SHIFT (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
171 /****************************************************************************************/
174 AROS_UFH3(ULONG
, StrEditHookEntry
,
175 AROS_UFHA(struct Hook
*, hook
, A0
),
176 AROS_UFHA(struct SGWork
*, sgw
, A2
),
177 AROS_UFHA(ULONG
*, msg
, A1
))
183 REGPARAM(a0
, struct Hook
*, hook
),
184 REGPARAM(a2
, struct SGWork
*, sgw
),
185 REGPARAM(a1
, ULONG
*, msg
) )
188 struct StrGadUserData
*userdata
;
191 if( msg
[ 0 ] == SGH_KEY
)
193 rawcode
= sgw
->IEvent
->ie_Code
;
194 qual
= sgw
->IEvent
->ie_Qualifier
;
196 //kprintf("sgsg: editop = %d code = %x quali = %x\n", sgw->EditOp, rawcode, qual);
198 if( ( sgw
->EditOp
== EO_INSERTCHAR
) ||
199 ( sgw
->EditOp
== EO_REPLACECHAR
) ||
200 ( sgw
->EditOp
== EO_SPECIAL
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
201 ( sgw
->EditOp
== EO_NOOP
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
202 ( sgw
->EditOp
== EO_ENTER
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
203 ( sgw
->EditOp
== EO_BADFORMAT
) )
205 //kprintf("sgsg2\n");
206 if( ( qual
& IEQUALIFIER_RCOMMAND
) || ( sgw
->Code
== 27 ) )
208 sgw
->Actions
&= ~( SGA_USE
| SGA_BEEP
| SGA_REDISPLAY
);
209 sgw
->IEvent
->ie_Qualifier
&= ~IEQUALIFIER_RCOMMAND
;
211 if( !( qual
& IEQUALIFIER_REPEAT
) )
213 sgw
->Actions
|= SGA_REUSE
|SGA_END
;
214 sgw
->Code
= KEYB_SHORTCUT
;
219 if( ( userdata
= ( struct StrGadUserData
* ) sgw
->Gadget
->UserData
) )
221 if( userdata
->flags
& USERFLAG_MATCH_FILE
)
223 if( sgw
->Actions
& SGA_USE
)
225 if( Stricmp( sgw
->WorkBuffer
, sgw
->PrevBuffer
) )
227 if( !userdata
->fakeimsg
.Micros
)
229 userdata
->fakeimsg
.Micros
= 1;
230 PutMsg( userdata
->msgport
, ( struct Message
* ) &userdata
->fakeimsg
);
236 if( userdata
->flags
& USERFLAG_UP_DOWN_ARROW
)
238 if( ( rawcode
== RAWKEY_UP
) || ( rawcode
== RAWKEY_DOWN
) )
240 sgw
->Actions
&= ~( SGA_USE
| SGA_BEEP
| SGA_REDISPLAY
);
241 sgw
->Actions
|= SGA_REUSE
| SGA_END
;
242 sgw
->Code
= KEYB_SHORTCUT
;
246 } /* if( ( userdata = ( struct StrGadUserData * ) sgw->Gadget->UserData ) ) */
250 } /* if( msg[ 0 ] == SGH_KEY ) */
258 /****************************************************************************************/
260 struct Hook stredithook
=
263 ( HOOKFUNC
) StrEditHookEntry
, NULL
, ( APTR
) 0xff525421
266 /****************************************************************************************/
268 #ifndef GTST_EditHook
269 #define GTST_EditHook (GT_TagBase+55)
270 #define GTIN_EditHook GTST_EditHook
273 /****************************************************************************************/
275 struct Gadget
* REGARGS
my_CreateIntegerGadget (
277 struct NewGadget
*newgad
,
282 struct Gadget
*intgad
;
284 if ((intgad
= myCreateGadget (INTEGER_KIND
, gad
, newgad
,
285 GTIN_MaxChars
, maxchars
,
286 GTIN_Number
, value
, STRINGA_Justification
, just
,
287 GTST_EditHook
, (IPTR
) &stredithook
,
289 intgad
->UserData
= NULL
;
294 /****************************************************************************************/
296 struct Gadget
* REGARGS
my_CreateStringGadget (
298 struct NewGadget
*newgad
,
302 struct Gadget
*strgad
;
304 if ((strgad
= myCreateGadget (STRING_KIND
, gad
, newgad
, GTST_MaxChars
, maxchars
,
305 GTST_String
, (IPTR
) string
, GTST_EditHook
, (IPTR
) &stredithook
, TAG_END
)))
306 strgad
->UserData
= NULL
;
311 /****************************************************************************************/
313 void REGARGS
my_SetStringGadget (struct Window
*win
, struct Gadget
*gad
, char *str
)
317 myGT_SetGadgetAttrs (gad
, win
, NULL
, GTST_String
, (IPTR
) str
, TAG_END
);
320 /****************************************************************************************/
322 void REGARGS
my_SetIntegerGadget (struct Window
*win
, struct Gadget
*gad
, long val
)
326 myGT_SetGadgetAttrs (gad
, win
, NULL
, GTIN_Number
, val
, TAG_END
);
329 /****************************************************************************************/
331 void REGARGS
my_FreeGadgets (struct Gadget
*glist
)
339 /* FIXME: Any reason for locking here?
340 As far as I can tell all use of this function are reentrant and the
341 glist is never attached to Window when called.
342 If locking is needed for other reasons, semaphore would be better
343 than Forbid(). -Piru */
345 for (gad
= glist
; gad
; gad
= gad
->NextGadget
)
347 if ((im
= IsButtonGad (gad
))) DisposeObject (im
);
357 /****************************************************************************************/
359 void REGARGS
my_SelectGadget (struct Gadget
*gad
, struct Window
*win
)
361 gad
->Flags
^= GFLG_SELECTED
;
362 RefreshGList (gad
, win
, NULL
, 1);
365 /****************************************************************************************/
367 void REGARGS
my_DownGadget (struct Gadget
*gad
, UWORD code
, struct KeyButtonInfo
*info
)
369 my_SelectGadget (gad
, info
->win
);
372 info
->lastcode
= code
;
375 /****************************************************************************************/
377 #define SHIFT_KEY 0x60
379 /****************************************************************************************/
381 struct Gadget
*REGARGS
my_GetKeyGadget (UBYTE key
, struct Gadget
*glist
)
387 for (gad
= glist
; gad
; gad
= gad
->NextGadget
)
389 if ((im
= IsButtonGad (gad
)))
390 if ((underkey
= im
->PlaneOnOff
))
391 if (key
== (UBYTE
)ToUpper (underkey
)) return (gad
);
396 /****************************************************************************************/
398 ULONG REGARGS
CheckGadgetKey (int code
, int qual
, char *key
,
399 struct KeyButtonInfo
*info
)
401 struct InputEvent ev
;
403 int upkey
= (code
& IECODE_UP_PREFIX
);
406 if (!(code
& ~IECODE_UP_PREFIX
)) return (0);
408 /* Convert RAW to ASCII */
409 ev
.ie_NextEvent
= NULL
;
410 ev
.ie_Class
= IECLASS_RAWKEY
;
412 /* Ignore alt qualifier */
413 ev
.ie_Qualifier
= qual
& ~(IEQUALIFIER_LALT
|IEQUALIFIER_RALT
);
414 RawKeyConvert (&ev
, key
, 1, NULL
);
415 *key
= ToUpper (*key
);
417 if (!(qual
& IEQUALIFIER_REPEAT
))
421 /* Gadget released ? */
422 if (code
== (info
->lastcode
| IECODE_UP_PREFIX
))
424 if (!(info
->lastgad
->Activation
& GACT_TOGGLESELECT
))
425 my_SelectGadget (info
->lastgad
, info
->win
);
427 return ((ULONG
)info
->lastgad
->GadgetID
);
433 /* Shift pressed ? */
434 if ((code
& ~1) == SHIFT_KEY
)
438 my_SelectGadget (info
->lastgad
, info
->win
);
444 /* No gadget down yet ? */
448 if ((gad
= my_GetKeyGadget (*key
, info
->glist
)))
450 if (!(gad
->Flags
& GFLG_DISABLED
))
451 my_DownGadget (gad
, code
, info
);
454 else /* return with keycode in 'key' */
461 } /* if (upkey) else ... */
463 } /* if (!(qual & IEQUALIFIER_REPEAT)) */
469 /****************************************************************************************/
475 /* Read VisualInfo and TextAttr from newgadget structure */
476 /* Underscore char is always '_' */
478 struct Image
* REGARGS
my_CreateGadgetLabelImage (
479 struct Image
*previm
,
480 struct NewGadget
*ng
,
485 struct InitData idata
;
487 if (!previm
) return (NULL
);
489 idata
.idata_Gadget
= NULL
;
490 idata
.idata_Label
= label
;
491 idata
.idata_VisualInfo
= ng
->ng_VisualInfo
;
492 idata
.idata_TextAttr
= ng
->ng_TextAttr
;
493 idata
.idata_Underscore
= '_';
495 return (previm
->NextImage
= NewObject (ButtonImgClass
, NULL
, IA_Data
, (IPTR
) &idata
,
502 /****************************************************************************************/
504 void REGARGS
my_FreeLabelImages (struct Image
*images
)
508 images
= images
->NextImage
;
512 images
= images
->NextImage
;
517 /****************************************************************************************/