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);
71 extern APTR STDARGS
DofmtArgs (char *, char *,...);
75 extern ULONG ASM
myBoopsiDispatch (
76 REGPARAM(a0
, Class
*,),
77 REGPARAM(a2
, struct Image
*,),
78 REGPARAM(a1
, struct impDraw
*,));
81 extern Class
*ButtonImgClass
;
83 /****************************************************************************************/
89 struct Gadget
* REGARGS
my_CreateButtonGadget (
94 struct InitData idata
;
98 label
= ng
->ng_GadgetText
;
99 ng
->ng_GadgetText
= NULL
;
101 if ((gad
= myCreateGadget (GENERIC_KIND
, gad
, ng
, TAG_END
)))
104 /* set gadget attributes */
105 gad
->Flags
|= GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
;
106 gad
->GadgetType
|= GTYP_BOOLGADGET
;
107 gad
->Activation
|= GACT_RELVERIFY
;
110 idata
.idata_Gadget
= gad
;
111 idata
.idata_VisualInfo
= ng
->ng_VisualInfo
;
112 idata
.idata_Label
= label
;
113 idata
.idata_TextAttr
= ng
->ng_TextAttr
;
114 idata
.idata_Underscore
= underscorechar
;
118 image
= NewObject (ButtonImgClass
, NULL
, IA_Data
, (IPTR
) &idata
, TAG_END
);
120 gad
->GadgetRender
= gad
->SelectRender
= image
;
123 ng
->ng_GadgetText
= label
;
128 /****************************************************************************************/
130 static struct Image
*IsButtonGad (struct Gadget
*gad
)
141 if (gad
->Flags
& (GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
))
142 if ((im
= (struct Image
*)gad
->SelectRender
))
143 if (im
->Depth
== CUSTOMIMAGEDEPTH
)
145 __tmp
.size
.Width
= im
->Width
;
146 __tmp
.size
.Height
= im
->Height
;
147 if (__tmp
.magic
== BUTTON_MAGIC_LONGWORD
)
148 if (im
->ImageData
== (UWORD
*)im
) return (im
);
154 /****************************************************************************************/
160 struct CombStringInfo
163 struct CombStringInfo
*self
;
164 struct StringInfo strinfo
;
165 struct StringExtend strextend
;
166 struct Hook edithook
;
169 /****************************************************************************************/
171 #define IEQUALIFIER_SHIFT (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)
173 /****************************************************************************************/
176 AROS_UFH3(ULONG
, StrEditHookEntry
,
177 AROS_UFHA(struct Hook
*, hook
, A0
),
178 AROS_UFHA(struct SGWork
*, sgw
, A2
),
179 AROS_UFHA(ULONG
*, msg
, A1
))
185 REGPARAM(a0
, struct Hook
*, hook
),
186 REGPARAM(a2
, struct SGWork
*, sgw
),
187 REGPARAM(a1
, ULONG
*, msg
) )
190 struct StrGadUserData
*userdata
;
193 if( msg
[ 0 ] == SGH_KEY
)
195 rawcode
= sgw
->IEvent
->ie_Code
;
196 qual
= sgw
->IEvent
->ie_Qualifier
;
198 //kprintf("sgsg: editop = %d code = %x quali = %x\n", sgw->EditOp, rawcode, qual);
200 if( ( sgw
->EditOp
== EO_INSERTCHAR
) ||
201 ( sgw
->EditOp
== EO_REPLACECHAR
) ||
202 ( sgw
->EditOp
== EO_SPECIAL
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
203 ( sgw
->EditOp
== EO_NOOP
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
204 ( sgw
->EditOp
== EO_ENTER
) || /* CHECKME: AROS/AMIGAOS: ADDED THIS LINE */
205 ( sgw
->EditOp
== EO_BADFORMAT
) )
207 //kprintf("sgsg2\n");
208 if( ( qual
& IEQUALIFIER_RCOMMAND
) || ( sgw
->Code
== 27 ) )
210 sgw
->Actions
&= ~( SGA_USE
| SGA_BEEP
| SGA_REDISPLAY
);
211 sgw
->IEvent
->ie_Qualifier
&= ~IEQUALIFIER_RCOMMAND
;
213 if( !( qual
& IEQUALIFIER_REPEAT
) )
215 sgw
->Actions
|= SGA_REUSE
|SGA_END
;
216 sgw
->Code
= KEYB_SHORTCUT
;
221 if( ( userdata
= ( struct StrGadUserData
* ) sgw
->Gadget
->UserData
) )
223 if( userdata
->flags
& USERFLAG_MATCH_FILE
)
225 if( sgw
->Actions
& SGA_USE
)
227 if( Stricmp( sgw
->WorkBuffer
, sgw
->PrevBuffer
) )
229 if( !userdata
->fakeimsg
.Micros
)
231 userdata
->fakeimsg
.Micros
= 1;
232 PutMsg( userdata
->msgport
, ( struct Message
* ) &userdata
->fakeimsg
);
238 if( userdata
->flags
& USERFLAG_UP_DOWN_ARROW
)
240 if( ( rawcode
== RAWKEY_UP
) || ( rawcode
== RAWKEY_DOWN
) )
242 sgw
->Actions
&= ~( SGA_USE
| SGA_BEEP
| SGA_REDISPLAY
);
243 sgw
->Actions
|= SGA_REUSE
| SGA_END
;
244 sgw
->Code
= KEYB_SHORTCUT
;
248 } /* if( ( userdata = ( struct StrGadUserData * ) sgw->Gadget->UserData ) ) */
252 } /* if( msg[ 0 ] == SGH_KEY ) */
260 /****************************************************************************************/
262 struct Hook stredithook
=
265 ( HOOKFUNC
) StrEditHookEntry
, NULL
, ( APTR
) 0xff525421
268 /****************************************************************************************/
270 #ifndef GTST_EditHook
271 #define GTST_EditHook (GT_TagBase+55)
272 #define GTIN_EditHook GTST_EditHook
275 /****************************************************************************************/
277 struct Gadget
* REGARGS
my_CreateIntegerGadget (
279 struct NewGadget
*newgad
,
284 struct Gadget
*intgad
;
286 if ((intgad
= myCreateGadget (INTEGER_KIND
, gad
, newgad
,
287 GTIN_MaxChars
, maxchars
,
288 GTIN_Number
, value
, STRINGA_Justification
, just
,
289 GTST_EditHook
, (IPTR
) &stredithook
,
291 intgad
->UserData
= NULL
;
296 /****************************************************************************************/
298 struct Gadget
* REGARGS
my_CreateStringGadget (
300 struct NewGadget
*newgad
,
304 struct Gadget
*strgad
;
306 if ((strgad
= myCreateGadget (STRING_KIND
, gad
, newgad
, GTST_MaxChars
, maxchars
,
307 GTST_String
, (IPTR
) string
, GTST_EditHook
, (IPTR
) &stredithook
, TAG_END
)))
308 strgad
->UserData
= NULL
;
313 /****************************************************************************************/
315 void REGARGS
my_SetStringGadget (struct Window
*win
, struct Gadget
*gad
, char *str
)
319 myGT_SetGadgetAttrs (gad
, win
, NULL
, GTST_String
, (IPTR
) str
, TAG_END
);
322 /****************************************************************************************/
324 void REGARGS
my_SetIntegerGadget (struct Window
*win
, struct Gadget
*gad
, long val
)
328 myGT_SetGadgetAttrs (gad
, win
, NULL
, GTIN_Number
, val
, TAG_END
);
331 /****************************************************************************************/
333 void REGARGS
my_FreeGadgets (struct Gadget
*glist
)
341 /* FIXME: Any reason for locking here?
342 As far as I can tell all use of this function are reentrant and the
343 glist is never attached to Window when called.
344 If locking is needed for other reasons, semaphore would be better
345 than Forbid(). -Piru */
347 for (gad
= glist
; gad
; gad
= gad
->NextGadget
)
349 if ((im
= IsButtonGad (gad
))) DisposeObject (im
);
359 /****************************************************************************************/
361 void REGARGS
my_SelectGadget (struct Gadget
*gad
, struct Window
*win
)
363 gad
->Flags
^= GFLG_SELECTED
;
364 RefreshGList (gad
, win
, NULL
, 1);
367 /****************************************************************************************/
369 void REGARGS
my_DownGadget (struct Gadget
*gad
, UWORD code
, struct KeyButtonInfo
*info
)
371 my_SelectGadget (gad
, info
->win
);
374 info
->lastcode
= code
;
377 /****************************************************************************************/
379 #define SHIFT_KEY 0x60
381 /****************************************************************************************/
383 struct Gadget
*REGARGS
my_GetKeyGadget (UBYTE key
, struct Gadget
*glist
)
389 for (gad
= glist
; gad
; gad
= gad
->NextGadget
)
391 if ((im
= IsButtonGad (gad
)))
392 if ((underkey
= im
->PlaneOnOff
))
393 if (key
== (UBYTE
)ToUpper (underkey
)) return (gad
);
398 /****************************************************************************************/
400 ULONG REGARGS
CheckGadgetKey (int code
, int qual
, char *key
,
401 struct KeyButtonInfo
*info
)
403 struct InputEvent ev
;
405 int upkey
= (code
& IECODE_UP_PREFIX
);
408 if (!(code
& ~IECODE_UP_PREFIX
)) return (0);
410 /* Convert RAW to ASCII */
411 ev
.ie_NextEvent
= NULL
;
412 ev
.ie_Class
= IECLASS_RAWKEY
;
414 /* Ignore alt qualifier */
415 ev
.ie_Qualifier
= qual
& ~(IEQUALIFIER_LALT
|IEQUALIFIER_RALT
);
416 RawKeyConvert (&ev
, key
, 1, NULL
);
417 *key
= ToUpper (*key
);
419 if (!(qual
& IEQUALIFIER_REPEAT
))
423 /* Gadget released ? */
424 if (code
== (info
->lastcode
| IECODE_UP_PREFIX
))
426 if (!(info
->lastgad
->Activation
& GACT_TOGGLESELECT
))
427 my_SelectGadget (info
->lastgad
, info
->win
);
429 return ((ULONG
)info
->lastgad
->GadgetID
);
435 /* Shift pressed ? */
436 if ((code
& ~1) == SHIFT_KEY
)
440 my_SelectGadget (info
->lastgad
, info
->win
);
446 /* No gadget down yet ? */
450 if ((gad
= my_GetKeyGadget (*key
, info
->glist
)))
452 if (!(gad
->Flags
& GFLG_DISABLED
))
453 my_DownGadget (gad
, code
, info
);
456 else /* return with keycode in 'key' */
463 } /* if (upkey) else ... */
465 } /* if (!(qual & IEQUALIFIER_REPEAT)) */
471 /****************************************************************************************/
477 /* Read VisualInfo and TextAttr from newgadget structure */
478 /* Underscore char is always '_' */
480 struct Image
* REGARGS
my_CreateGadgetLabelImage (
481 struct Image
*previm
,
482 struct NewGadget
*ng
,
487 struct InitData idata
;
489 if (!previm
) return (NULL
);
491 idata
.idata_Gadget
= NULL
;
492 idata
.idata_Label
= label
;
493 idata
.idata_VisualInfo
= ng
->ng_VisualInfo
;
494 idata
.idata_TextAttr
= ng
->ng_TextAttr
;
495 idata
.idata_Underscore
= '_';
497 return (previm
->NextImage
= NewObject (ButtonImgClass
, NULL
, IA_Data
, (IPTR
) &idata
,
504 /****************************************************************************************/
506 void REGARGS
my_FreeLabelImages (struct Image
*images
)
510 images
= images
->NextImage
;
514 images
= images
->NextImage
;
519 /****************************************************************************************/