7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
14 * Revision 42.4 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.3 2003/01/18 19:09:59 chodorowski
18 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
20 * Revision 42.2 2000/05/29 00:40:24 bergers
21 * Update to compile with AROS now. Should also still compile with SASC etc since I only made changes that test the define __AROS__. The compilation is still very noisy but it does the trick for the main directory. Maybe members of the BGUI team should also have a look at the compiler warnings because some could also cause problems on other systems... (Comparison always TRUE due to datatype (or something like that)). And please compile it on an Amiga to see whether it still works... Thanks.
23 * Revision 42.1 2000/05/14 23:32:48 stegerg
24 * changed over 200 function headers which all use register
25 * parameters (oh boy ...), because the simple REG() macro
26 * doesn't work with AROS. And there are still hundreds
27 * of headers left to be fixed :(
29 * Many of these functions would also work with stack
30 * params, but since i have fixed every single one
31 * I encountered up to now, I guess will have to do
32 * the same for the rest.
34 * Revision 42.0 2000/05/09 22:09:42 mlemos
35 * Bumped to revision 42.0 before handing BGUI to AROS team
37 * Revision 41.11 2000/05/09 19:54:46 mlemos
38 * Merged with the branch Manuel_Lemos_fixes.
40 * Revision 41.10.2.4 1998/12/07 03:07:08 mlemos
41 * Replaced OpenFont and CloseFont calls by the respective BGUI debug macros.
43 * Revision 41.10.2.3 1998/11/23 14:59:16 mlemos
44 * Fixed mistaken initialization of allocated buffer.
46 * Revision 41.10.2.2 1998/11/16 20:11:04 mlemos
47 * Added missing brackets in the previous changes.
49 * Revision 41.10.2.1 1998/11/16 19:59:24 mlemos
50 * Replaced AllocVec and FreeVec calls by BGUI_AllocPoolMem and
51 * BGUI_FreePoolMem calls respectively.
53 * Revision 41.10 1998/02/25 21:12:40 mlemos
56 * Revision 1.1 1998/02/25 17:09:07 mlemos
63 #include "include/bgui_macros.h"
66 #include "include/classdefs.h"
68 makeproto
struct TextAttr Topaz80
=
76 makeproto ASM LONG
max(REG(d0
) LONG a
, REG(d1
) LONG b
)
77 { return (a
> b
) ? a
: b
; }
79 makeproto ASM LONG
min(REG(d0
) LONG a
, REG(d1
) LONG b
)
80 { return (a
< b
) ? a
: b
; }
82 makeproto ASM LONG
abs(REG(d0
) LONG a
)
83 { return (a
> 0) ? a
:-a
; }
85 makeproto ASM LONG
range(REG(d0
) LONG c
, REG(d1
) LONG a
, REG(d2
) LONG b
)
93 * Count the number of labels in an array.
95 makeproto ASM ULONG
CountLabels(REG(a0
) UBYTE
**labels
)
99 while (labels
[n
]) n
++;
101 return (ULONG
)(n
- 1);
105 * See if a point is in a box.
107 makeproto ASM BOOL
PointInBox(REG(a0
) struct IBox
*box
, REG(d0
) WORD x
, REG(d1
) WORD y
)
112 return (BOOL
)((x
>= 0) && (y
>= 0) && (x
< box
->Width
) && (y
< box
->Height
));
116 * Scale a width and height.
118 makeproto VOID
Scale(struct RastPort
*rp
, UWORD
*width
, UWORD
*height
, UWORD dwidth
, UWORD dheight
, struct TextAttr
*font
)
129 if ((tf
= BGUI_OpenFont(font
)))
140 if (tf
->tf_Flags
& FPF_PROPORTIONAL
)
142 fw
= (tf
->tf_Modulo
<< 3) / (tf
->tf_HiChar
- tf
->tf_LoChar
);
153 if (open
) BGUI_CloseFont(tf
);
158 *height
= fh
+ (dheight
- 8);
159 *width
= fw
+ (dwidth
- 8);
163 * Map a RAW key to an ansi character.
165 makeproto WORD
MapKey(UWORD code
, UWORD qualifier
, APTR
*iaddress
)
167 struct InputEvent ie
= { NULL
};
170 ie
.ie_Class
= IECLASS_RAWKEY
;
172 ie
.ie_Qualifier
= qualifier
;
173 ie
.ie_EventAddress
= *iaddress
;
175 if ( MapRawKey( &ie
, &chr
, 1, NULL
) != 1 )
182 * Show online-help requester.
184 makeproto ASM VOID
ShowHelpReq( REG(a0
) struct Window
*win
, REG(a1
) UBYTE
*text
)
186 struct bguiRequest req
= { };
190 req
.br_Title
= LOCSTR( MSG_BGUI_HELP_TITLE
);
191 req
.br_GadgetFormat
= LOCSTR( MSG_BGUI_HELP_CONTINUE
);
192 req
.br_TextFormat
= text
;
193 req
.br_Flags
= BREQF_CENTERWINDOW
| BREQF_LOCKWINDOW
| BREQF_AUTO_ASPECT
;
195 BGUI_RequestA( win
, &req
, NULL
);
200 * Re-allocate and format a buffer.
202 makeproto ASM UBYTE
*DoBuffer(REG(a0
) UBYTE
*text
, REG(a1
) UBYTE
**buf_ptr
, REG(a2
) ULONG
*buf_len
, REG(a3
) RAWARG args
)
207 * Find out the formatted string length.
209 len
= CompStrlenF( text
, args
);
212 * Longer than the current buffer?
214 if ( len
> *buf_len
) {
216 * Deallocate old buffer.
219 BGUI_FreePoolMem( *buf_ptr
);
221 * And allocate a new one.
223 if ( (*buf_ptr
= ( UBYTE
* )BGUI_AllocPoolMem( len
))) {
225 * Setup new buffer length.
241 DoSPrintF( *buf_ptr
, text
, args
);
246 * Set on multiple object.
248 makeproto VOID
DoMultiSet(Tag tag
, IPTR data
, ULONG count
, Object
*obj1
, ...)
254 for (i
= 0; i
< count
; i
++, obj1
= va_arg(ap
, Object
*))
255 if (obj1
) DoSetMethodNG(obj1
, tag
, data
, TAG_END
);
261 * Set a gadget's bounds.
263 makeproto ASM VOID
SetGadgetBounds(REG(a0
) Object
*obj
, REG(a1
) struct IBox
*bounds
)
265 DoSetMethodNG(obj
, GA_Left
, bounds
->Left
, GA_Top
, bounds
->Top
,
266 GA_Width
, bounds
->Width
, GA_Height
, bounds
->Height
, TAG_DONE
);
270 * Set an image's bounds.
272 makeproto ASM VOID
SetImageBounds(REG(a0
) Object
*obj
, REG(a1
) struct IBox
*bounds
)
274 DoSetMethodNG(obj
, IA_Left
, bounds
->Left
, IA_Top
, bounds
->Top
,
275 IA_Width
, bounds
->Width
, IA_Height
, bounds
->Height
, TAG_DONE
);
280 * Un-map a mapped tag-list.
282 makeproto ASM VOID
UnmapTags(REG(a0
) struct TagItem
*tags
, REG(a1
) struct TagItem
*map
)
284 struct TagItem
*tag
, *tag1
;
285 struct TagItem
*at
= map
;
288 * Go through the mapped tag-list.
290 while ((tag
= NextTagItem(&at
)))
293 * Is this tag in the unmapped list?
295 if ((tag1
= FindTagItem(tag
->ti_Data
, tags
)))
297 * Yes. Unmap this tag.
299 tag1
->ti_Tag
= tag
->ti_Tag
;
304 * Create a vector image.
306 makeproto ASM Object
*CreateVector(REG(a0
) struct TagItem
*attr
)
309 struct TagItem
*tstate
= attr
;
311 while ((tag
= NextTagItem(&tstate
)))
313 if (VIT_TAG(tag
->ti_Tag
))
314 return BGUI_NewObjectA(BGUI_VECTOR_IMAGE
, tag
);
320 * Fix the tag pointer.
322 makeproto ASM
struct TagItem
*BGUI_NextTagItem(REG(a0
) struct TagItem
**t
)
324 struct TagItem
*rt
, *tag
, *tag2
;
325 struct TagItem
*tstate
;
336 while ((tag
= NextTagItem(&tstate
)))