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.6 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.5 2003/01/18 19:09:56 chodorowski
18 * Instead of using the _AROS or __AROS preprocessor symbols, use __AROS__.
20 * Revision 42.4 2000/08/09 11:45:57 chodorowski
21 * Removed a lot of #ifdefs that disabled the AROS_LIB* macros when not building on AROS. This is now handled in contrib/bgui/include/bgui_compilerspecific.h.
23 * Revision 42.3 2000/05/29 00:40:23 bergers
24 * 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.
26 * Revision 42.2 2000/05/15 19:27:01 stegerg
27 * another hundreds of REG() macro replacements in func headers/protos.
29 * Revision 42.1 2000/05/14 23:32:47 stegerg
30 * changed over 200 function headers which all use register
31 * parameters (oh boy ...), because the simple REG() macro
32 * doesn't work with AROS. And there are still hundreds
33 * of headers left to be fixed :(
35 * Many of these functions would also work with stack
36 * params, but since i have fixed every single one
37 * I encountered up to now, I guess will have to do
38 * the same for the rest.
40 * Revision 42.0 2000/05/09 22:09:05 mlemos
41 * Bumped to revision 42.0 before handing BGUI to AROS team
43 * Revision 41.11 2000/05/09 19:54:20 mlemos
44 * Merged with the branch Manuel_Lemos_fixes.
46 * Revision 41.10.2.2 1999/07/04 05:16:05 mlemos
47 * Added a debuging version of the function BRectFill.
49 * Revision 41.10.2.1 1998/07/05 19:26:58 mlemos
50 * Added debugging code to trap invalid RectFill calls.
52 * Revision 41.10 1998/02/25 21:12:07 mlemos
55 * Revision 1.1 1998/02/25 17:08:24 mlemos
61 #include "include/classdefs.h"
64 * Default drawinfo pens.
66 makeproto UWORD DefDriPens
[12] = { 0, 1, 1, 2, 1, 3, 1, 0, 2, 1, 2, 1 };
71 STATIC UWORD DisPat
[2] = { 0x2222, 0x8888 };
74 * Calculate the text width.
76 makeproto ASM ULONG
TextWidth(REG(a1
) struct RastPort
*rp
, REG(a0
) UBYTE
*text
)
78 return TextWidthNum(rp
, text
, strlen(text
));
81 makeproto ASM ULONG
TextWidthNum(REG(a1
) struct RastPort
*rp
, REG(a0
) UBYTE
*text
, REG(d0
) ULONG len
)
87 * Call TextExtent to find out the text width.
89 TextExtent(rp
, text
, len
, &te
);
92 * Figure out extent width.
94 extent
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
97 * Return which ever is bigger.. extent or te.te_Width.
99 return( extent
/*( extent > te.te_Width ) ? extent : te.te_Width */);
103 * Disable the given area.
105 makeproto ASM VOID
BDisableBox(REG(a0
) struct BaseInfo
*bi
, REG(a1
) struct IBox
*area
)
107 BSetAfPt(bi
, DisPat
, 1);
109 BSetDPenA(bi
, SHADOWPEN
);
115 makeproto ASM VOID
SRectFillDebug(REG(a0
) struct RastPort
*rp
, REG(d0
) LONG l
, REG(d1
) LONG t
, REG(d2
) LONG r
, REG(d3
) LONG b
,REG(a1
) STRPTR file
,REG(d4
) ULONG line
)
117 ASM VOID
SRectFill(REG(a0
) struct RastPort
*rp
, REG(d0
) LONG l
, REG(d1
) LONG t
, REG(d2
) LONG r
, REG(d3
) LONG b
)
120 if ((r
>= l
) && (b
>= t
))
121 RectFill(rp
, l
, t
, r
, b
);
124 D(bug("***Invalid RectFill (%lx,%ld,%ld,%ld,%ld) (%s,%lu)\n",rp
,l
,t
,r
,b
,file
? file
: (STRPTR
)"Unknown file",line
));
129 * Do a safe rect-fill.
132 makeproto ASM VOID
BRectFillDebug(REG(a0
) struct BaseInfo
*bi
, REG(d0
) LONG l
, REG(d1
) LONG t
, REG(d2
) LONG r
, REG(d3
) LONG b
,REG(a1
) STRPTR file
,REG(d4
) ULONG line
)
134 SRectFillDebug(bi
->bi_RPort
, l
, t
, r
, b
,file
,line
);
137 ASM VOID
BRectFill(REG(a0
) struct BaseInfo
*bi
, REG(d0
) LONG l
, REG(d1
) LONG t
, REG(d2
) LONG r
, REG(d3
) LONG b
)
139 SRectFill(bi
->bi_RPort
, l
, t
, r
, b
);
145 * Render a frame/separator title.
147 makeproto VOID
RenderTitle(Object
*title
, struct BaseInfo
*bi
, WORD l
, WORD t
, WORD w
, BOOL highlight
, BOOL center
, UWORD place
)
156 DoMethod(title
, TEXTM_DIMENSIONS
, bi
->bi_RPort
, &box
.Width
, &box
.Height
);
159 * Figure out where to render.
161 if (box
.Width
> w
) box
.Width
= w
;
169 box
.Left
= l
+ w
- box
.Width
;
172 box
.Left
= l
+ ((w
- box
.Width
) >> 1);
175 if (box
.Left
< l
) box
.Left
= l
;
178 * Figure out y position.
180 if (center
) box
.Top
= t
- (box
.Height
>> 1);
181 else box
.Top
= t
- bi
->bi_RPort
->TxBaseline
;
186 BSetDPenA(bi
, BACKGROUNDPEN
);
193 BRectFill(bi
, box
.Left
- 4, box
.Top
, box
.Left
+ box
.Width
+ 4, box
.Top
+ box
.Height
);
195 BSetDPenA(bi
, highlight
? HIGHLIGHTTEXTPEN
: TEXTPEN
);
196 DoMethod(title
, TEXTM_RENDER
, bi
, &box
);
200 makeproto VOID ASM
SetDashedLine(REG(a0
) struct BaseInfo
*bi
, REG(d0
) UWORD offset
)
203 * Render a SHINE/SHADOW pen, dotted box or,
204 * when the two pens are equal a SHADOW/BACKGROUND
207 BSetDPenA(bi
, SHINEPEN
);
208 BSetDPenB(bi
, SHADOWPEN
);
210 BSetDrPt(bi
, 0xF0F0F0F0 >> offset
);
212 if (bi
->bi_RPort
->FgPen
== bi
->bi_RPort
->BgPen
)
213 BSetDPenA(bi
, BACKGROUNDPEN
);
217 * Quickly render a bevelled box.
219 makeproto VOID
RenderBevelBox(struct BaseInfo
*bi
, WORD l
, WORD t
, WORD r
, WORD b
, UWORD state
, BOOL recessed
, BOOL thin
)
221 struct RastPort
*rp
= bi
->bi_RPort
;
224 * Selected or normal?
226 if ((state
== IDS_SELECTED
) || (state
== IDS_INACTIVESELECTED
))
228 recessed
= !recessed
;
234 BSetDPenA(bi
, recessed
? SHADOWPEN
: SHINEPEN
);
237 VLine(rp
, l
, t
, b
- 1);
238 if (!thin
) VLine(rp
, l
+ 1, t
+ 1, b
- 1);
243 BSetDPenA(bi
, recessed
? SHINEPEN
: SHADOWPEN
);
246 VLine(rp
, r
, t
+ 1, b
);
247 if (!thin
) VLine(rp
, r
- 1, t
+ 1, b
- 1);
250 makeproto ASM VOID
BRectFillA(REG(a0
) struct BaseInfo
*bi
, REG(a1
) struct Rectangle
*rect
)
252 BRectFill(bi
, rect
->MinX
, rect
->MinY
, rect
->MaxX
, rect
->MaxY
);
255 makeproto ASM VOID
BBoxFill(REG(a0
) struct BaseInfo
*bi
, REG(d0
) LONG l
, REG(d1
) LONG t
, REG(d2
) LONG w
, REG(d3
) LONG h
)
257 SRectFill(bi
->bi_RPort
, l
, t
, l
+ w
- 1, t
+ h
- 1);
260 makeproto ASM VOID
BBoxFillA(REG(a0
) struct BaseInfo
*bi
, REG(a1
) struct IBox
*box
)
262 BBoxFill(bi
, box
->Left
, box
->Top
, box
->Width
, box
->Height
);
266 * Background filling.
269 makeproto ASM VOID
RenderBackFillRasterDebug(REG(a0
) struct RastPort
*rp
, REG(a1
) struct IBox
*ib
, REG(d0
) UWORD apen
, REG(d1
) UWORD bpen
,REG(a2
) STRPTR file
, REG(d2
) ULONG line
)
271 ASM VOID
RenderBackFillRaster(REG(a0
) struct RastPort
*rp
, REG(a1
) struct IBox
*ib
, REG(d0
) UWORD apen
, REG(d1
) UWORD bpen
)
274 static UWORD pat
[] = { 0x5555, 0xAAAA };
279 FSetABPenDrMd(rp
, apen
, bpen
, JAM2
);
295 SRectFillDebug(rp
, ib
->Left
, ib
->Top
, ib
->Left
+ ib
->Width
- 1, ib
->Top
+ ib
->Height
- 1,file
,line
);
297 SRectFill(rp
, ib
->Left
, ib
->Top
, ib
->Left
+ ib
->Width
- 1, ib
->Top
+ ib
->Height
- 1);
301 * Clear area pattern.
307 makeproto ASM VOID
RenderBackFill(REG(a0
) struct RastPort
*rp
, REG(a1
) struct IBox
*ib
, REG(a2
) UWORD
*pens
, REG(d0
) ULONG type
)
311 if (!pens
) pens
= DefDriPens
;
320 bpen
= BACKGROUNDPEN
;
325 bpen
= BACKGROUNDPEN
;
328 case SHINE_SHADOW_RASTER
:
335 bpen
= BACKGROUNDPEN
;
338 case SHINE_FILL_RASTER
:
343 case SHADOW_FILL_RASTER
:
359 apen
= BACKGROUNDPEN
;
363 RenderBackFillRaster(rp
, ib
, pens
[apen
], pens
[bpen
]);
369 makeproto ASM VOID
DottedBox(REG(a0
) struct BaseInfo
*bi
, REG(a1
) struct IBox
*ibx
)
372 int x2
= ibx
->Left
+ ibx
->Width
- 1;
374 int y2
= ibx
->Top
+ ibx
->Height
- 1;
376 ULONG secs
, micros
, hundredths
;
378 struct RastPort
*rp
= bi
->bi_RPort
;
381 * We clear any thick framing which may be
384 BSetDPenA(bi
, BACKGROUNDPEN
);
385 Move(rp
, x1
+ 1, y1
+ 1);
386 Draw(rp
, x1
+ 1, y2
- 1);
387 Draw(rp
, x2
- 1, y2
- 1);
388 Draw(rp
, x2
- 1, y1
+ 1);
389 Draw(rp
, x1
+ 2, y1
+ 1);
391 CurrentTime(&secs
, µs
);
392 hundredths
= ((secs
& 0xFFFFFF) * 100) + (micros
/ 10000);
393 SetDashedLine(bi
, (hundredths
/ 5) % 8);
402 Draw(rp
, x1
, y1
+ 1);
406 * Find out rendering state.
408 makeproto ASM ULONG
GadgetState(REG(a0
) struct BaseInfo
*bi
, REG(a1
) Object
*obj
, REG(d0
) BOOL norec
)
410 BOOL active
= !(GADGET(obj
)->Activation
& BORDERMASK
) || (bi
->bi_IWindow
->Flags
& WFLG_WINDOWACTIVE
);
411 BOOL normal
= !(GADGET(obj
)->Flags
& GFLG_SELECTED
) || norec
;
413 return active
? (ULONG
)(normal
? IDS_NORMAL
: IDS_SELECTED
)
414 : (ULONG
)(normal
? IDS_INACTIVENORMAL
: IDS_INACTIVESELECTED
);
419 AROS_LH6(VOID
, BGUI_FillRectPattern
,
420 AROS_LHA(struct RastPort
*, r
, A1
),
421 AROS_LHA(struct bguiPattern
*, bp
, A0
),
422 AROS_LHA(ULONG
, x1
, D0
),
423 AROS_LHA(ULONG
, y1
, D1
),
424 AROS_LHA(ULONG
, x2
, D2
),
425 AROS_LHA(ULONG
, y2
, D3
),
426 struct Library
*, BGUIBase
, 22, BGUI
)
428 makeproto SAVEDS ASM VOID
BGUI_FillRectPattern(REG(a1
) struct RastPort
*r
, REG(a0
) struct bguiPattern
*bp
,
429 REG(d0
) ULONG x1
, REG(d1
) ULONG y1
, REG(d2
) ULONG x2
, REG(d3
) ULONG y2
)
436 int x0
= bp
->bp_Left
;
438 int w
= bp
->bp_Width
;
439 int h
= bp
->bp_Height
;
441 int col_min
, col_max
;
442 int row_min
, row_max
;
444 int from_x
, to_x1
, to_x2
, to_w
;
445 int from_y
, to_y1
, to_y2
, to_h
;
447 struct BitMap
*bm
= bp
->bp_BitMap
;
453 col_max
= x2
++ / w
+ 1;
454 row_max
= y2
++ / h
+ 1;
456 for (i
= col_min
; i
<= col_max
; i
++)
463 from_x
= x0
+ x1
- to_x1
;
474 if ((to_w
= to_x2
- to_x1
) > 0)
476 for (j
= row_min
; j
<= row_max
; j
++)
483 from_y
= y0
+ y1
- to_y1
;
494 if ((to_h
= to_y2
- to_y1
) > 0)
496 BltBitMapRastPort(bm
, from_x
, from_y
, r
, to_x1
, to_y1
, to_w
, to_h
, 0xC0);
506 makeproto VOID ASM
HLine(REG(a1
) struct RastPort
*rp
, REG(d0
) UWORD l
, REG(d1
) UWORD t
, REG(d2
) UWORD r
)
512 makeproto VOID ASM
VLine(REG(a1
) struct RastPort
*rp
, REG(d0
) UWORD l
, REG(d1
) UWORD t
, REG(d2
) UWORD b
)
518 makeproto ASM ULONG
FGetAPen(REG(a1
) struct RastPort
*rp
)
523 if (OS30
) return GetAPen(rp
);
528 makeproto ASM ULONG
FGetBPen(REG(a1
) struct RastPort
*rp
)
533 if (OS30
) return GetBPen(rp
);
538 makeproto ASM ULONG
FGetDrMd(REG(a1
) struct RastPort
*rp
)
543 if (OS30
) return GetDrMd(rp
);
548 makeproto ASM ULONG
FGetDepth(REG(a1
) struct RastPort
*rp
)
551 return (ULONG
)GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
553 if (OS30
) return GetBitMapAttr(rp
->BitMap
, BMA_DEPTH
);
554 return rp
->BitMap
->Depth
;
558 makeproto ASM VOID
FSetAPen(REG(a1
) struct RastPort
*rp
, REG(d0
) ULONG pen
)
561 SetRPAttrs(rp
, RPTAG_APen
, pen
, TAG_END
);
563 if (OS30
) SetRPAttrs(rp
, RPTAG_APen
, pen
, TAG_END
);
564 else if (rp
->FgPen
!= pen
) SetAPen(rp
, pen
);
568 makeproto ASM VOID
FSetBPen(REG(a1
) struct RastPort
*rp
, REG(d0
) ULONG pen
)
571 SetRPAttrs(rp
, RPTAG_BPen
, pen
, TAG_END
);
573 if (OS30
) SetRPAttrs(rp
, RPTAG_BPen
, pen
, TAG_END
);
574 else if (rp
->BgPen
!= pen
) SetBPen(rp
, pen
);
578 makeproto ASM VOID
FSetDrMd(REG(a1
) struct RastPort
*rp
, REG(d0
) ULONG drmd
)
581 SetRPAttrs(rp
, RPTAG_DrMd
, drmd
, TAG_END
);
583 if (OS30
) SetRPAttrs(rp
, RPTAG_DrMd
, drmd
, TAG_END
);
584 else if (rp
->DrawMode
!= drmd
) SetDrMd(rp
, drmd
);
588 makeproto ASM VOID
FSetABPenDrMd(REG(a1
) struct RastPort
*rp
, REG(d0
) ULONG apen
, REG(d1
) ULONG bpen
, REG(d2
) ULONG mode
)
591 SetABPenDrMd(rp
, apen
, bpen
, mode
);
593 if (OS30
) SetABPenDrMd(rp
, apen
, bpen
, mode
);
603 makeproto ASM VOID
FSetFont(REG(a1
) struct RastPort
*rp
, REG(a0
) struct TextFont
*tf
)
606 SetRPAttrs(rp
, RPTAG_Font
, tf
, TAG_END
);
608 if (OS30
) SetRPAttrs(rp
, RPTAG_Font
, tf
, TAG_END
);
611 if (rp
->Font
!= tf
) SetFont(rp
, tf
);
616 makeproto ASM VOID
FSetFontStyle(REG(a1
) struct RastPort
*rp
, REG(d0
) ULONG style
)
618 SetSoftStyle(rp
, style
, AskSoftStyle(rp
));
621 makeproto ASM VOID
FClearAfPt(REG(a1
) struct RastPort
*rp
)
623 SetAfPt(rp
, NULL
, 0);
626 makeproto ASM VOID
BSetDPenA(REG(a0
) struct BaseInfo
*bi
, REG(d0
) LONG pen
)
628 FSetAPen(bi
->bi_RPort
, bi
->bi_Pens
[pen
]);
631 makeproto ASM VOID
BSetPenA(REG(a0
) struct BaseInfo
*bi
, REG(d0
) ULONG pen
)
633 FSetAPen(bi
->bi_RPort
, pen
);
636 makeproto ASM VOID
BSetDPenB(REG(a0
) struct BaseInfo
*bi
, REG(d0
) LONG pen
)
638 FSetBPen(bi
->bi_RPort
, bi
->bi_Pens
[pen
]);
641 makeproto ASM VOID
BSetPenB(REG(a0
) struct BaseInfo
*bi
, REG(d0
) ULONG pen
)
643 FSetBPen(bi
->bi_RPort
, pen
);
646 makeproto ASM VOID
BSetDrMd(REG(a0
) struct BaseInfo
*bi
, REG(d0
) ULONG drmd
)
648 FSetDrMd(bi
->bi_RPort
, drmd
);
651 makeproto ASM VOID
BSetFont(REG(a0
) struct BaseInfo
*bi
, REG(a1
) struct TextFont
*tf
)
653 FSetFont(bi
->bi_RPort
, tf
);
656 makeproto ASM VOID
BSetFontStyle(REG(a0
) struct BaseInfo
*bi
, REG(d0
) ULONG style
)
658 SetSoftStyle(bi
->bi_RPort
, style
, AskSoftStyle(bi
->bi_RPort
));
661 makeproto ASM VOID
BSetAfPt(REG(a0
) struct BaseInfo
*bi
, REG(a1
) UWORD
*pat
, REG(d0
) ULONG size
)
663 SetAfPt(bi
->bi_RPort
, pat
, size
);
666 makeproto ASM VOID
BClearAfPt(REG(a0
) struct BaseInfo
*bi
)
668 SetAfPt(bi
->bi_RPort
, NULL
, 0);
671 makeproto ASM VOID
BSetDrPt(REG(a0
) struct BaseInfo
*bi
, REG(d0
) ULONG pat
)
673 SetDrPt(bi
->bi_RPort
, pat
& 0xFFFF);
676 makeproto ASM VOID
BDrawImageState(REG(a0
) struct BaseInfo
*bi
, REG(a1
) Object
*image
,
677 REG(d0
) ULONG x
, REG(d1
) ULONG y
, REG(d2
) ULONG state
)
679 //tprintf("%08lx %08lx %ld %ld %04lx %08lx\n", /4*
680 DrawImageState(bi
->bi_RPort
, IMAGE(image
), x
, y
, state
, bi
->bi_DrInfo
);