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.3 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.2 2000/08/17 15:09:18 chodorowski
18 * Fixed compiler warnings.
20 * Revision 42.1 2000/05/15 19:27:02 stegerg
21 * another hundreds of REG() macro replacements in func headers/protos.
23 * Revision 42.0 2000/05/09 22:10:11 mlemos
24 * Bumped to revision 42.0 before handing BGUI to AROS team
26 * Revision 41.11 2000/05/09 19:55:05 mlemos
27 * Merged with the branch Manuel_Lemos_fixes.
29 * Revision 41.10.2.2 1999/07/28 23:18:15 mlemos
30 * Fixed superclass call to dispose the objects.
32 * Revision 41.10.2.1 1998/11/23 14:59:51 mlemos
33 * Removed needless OM_GET method code.
35 * Revision 41.10 1998/02/25 21:13:06 mlemos
38 * Revision 1.1 1998/02/25 17:09:44 mlemos
44 /// Class definitions.
46 #include "include/classdefs.h"
49 * Object Instance data.
52 ULONG sd_Flags
; /* See below. */
53 Object
*sd_Title
; /* Separator title. */
54 UWORD sd_Place
; /* Position. */
57 #define SDF_THIN (1<<0) /* Thin lines. */
58 #define SDF_HIGHLIGHT (1<<1) /* Highlight title. */
59 #define SDF_HORIZONTAL (1<<2) /* Horizontal separator.*/
60 #define SDF_CENTER (1<<3) /* Center title. */
61 #define SDF_RECESSED (1<<4) /* Recess lines. */
66 * Create a shiny new object.
68 METHOD(SepClassNew
, struct opSet
*, ops
)
73 * Let the superclass create an object.
75 if ((rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
)))
77 AsmCoerceMethod(cl
, (Object
*)rc
, OM_SET
, ops
->ops_AttrList
, NULL
);
87 METHOD(SepClassDispose
, Msg
, msg
)
89 SD
*sd
= INST_DATA(cl
, obj
);
91 if (sd
->sd_Title
) DisposeObject(sd
->sd_Title
);
93 return AsmDoSuperMethodA(cl
, obj
, msg
);
101 METHOD(SepClassSet
, struct opSet
*, ops
)
103 SD
*sd
= INST_DATA(cl
, obj
);
106 struct TagItem
*tstate
= ops
->ops_AttrList
;
108 rc
= AsmDoSuperMethodA(cl
, obj
, (Msg
)ops
);
110 while ((tag
= NextTagItem(&tstate
)))
120 if (data
) sd
->sd_Flags
|= SDF_THIN
;
121 else sd
->sd_Flags
&= ~SDF_THIN
;
124 case SEP_CenterTitle
:
125 if (data
) sd
->sd_Flags
|= SDF_CENTER
;
126 else sd
->sd_Flags
&= ~SDF_CENTER
;
130 if (data
) sd
->sd_Flags
|= SDF_HORIZONTAL
;
131 else sd
->sd_Flags
&= ~SDF_HORIZONTAL
;
135 if (data
) sd
->sd_Flags
|= SDF_HIGHLIGHT
;
136 else sd
->sd_Flags
&= ~SDF_HIGHLIGHT
;
140 if (data
) sd
->sd_Flags
|= SDF_RECESSED
;
141 else sd
->sd_Flags
&= ~SDF_RECESSED
;
145 if (data
) sd
->sd_Place
= 1;
146 else sd
->sd_Place
= 0;
150 if (data
) sd
->sd_Place
= 2;
151 else sd
->sd_Place
= 0;
155 if (!sd
->sd_Title
) sd
->sd_Title
= BGUI_NewObject(BGUI_TEXT_GRAPHIC
, TEXTA_CopyText
, TRUE
, TAG_DONE
);
156 if (sd
->sd_Title
) DoSetMethodNG(sd
->sd_Title
, TEXTA_Text
, data
, TAG_DONE
);
160 if (!sd
->sd_Title
) sd
->sd_Title
= BGUI_NewObject(BGUI_TEXT_GRAPHIC
, TEXTA_CopyText
, TRUE
, TAG_DONE
);
161 if (sd
->sd_Title
) DoSetMethodNG(sd
->sd_Title
, TEXTA_TextID
, data
, TAG_DONE
);
173 METHOD(SepClassRender
, struct bmRender
*, bmr
)
175 SD
*sd
= INST_DATA(cl
, obj
);
176 BC
*bc
= BASE_DATA(obj
);
177 struct BaseInfo
*bi
= bmr
->bmr_BInfo
;
178 struct RastPort
*rp
= bi
->bi_RPort
;
183 * Render the baseclass.
185 AsmDoSuperMethodA(cl
, obj
, (Msg
)bmr
);
190 l
= bc
->bc_OuterBox
.Left
;
191 t
= bc
->bc_OuterBox
.Top
;
192 w
= bc
->bc_OuterBox
.Width
;
193 h
= bc
->bc_OuterBox
.Height
;
195 recessed
= sd
->sd_Flags
& SDF_RECESSED
;
205 if (sd
->sd_Flags
& SDF_HORIZONTAL
)
210 BSetDPenA(bi
, recessed
? SHADOWPEN
: SHINEPEN
);
213 * Center it in the given space?
217 if (sd
->sd_Flags
& SDF_CENTER
) t
+= h
>> 1;
218 else t
+= h
- (rp
->TxHeight
- rp
->TxBaseline
);
222 * Move to the correct location.
225 Draw(rp
, l
+ w
- 2, t
);
226 WritePixel(rp
, l
, t
+ 1);
231 BSetDPenA(bi
, recessed
? SHINEPEN
: SHADOWPEN
);
234 * Move to the correct location.
236 Move(rp
, l
+ 1, t
+ 1);
237 Draw(rp
, l
+ w
- 1, t
+ 1);
238 WritePixel(rp
, l
+ w
- 1, t
);
246 * Set font if necessary.
248 if (bc
->bc_TextFont
) BSetFont(bi
, bc
->bc_TextFont
);
253 RenderTitle(sd
->sd_Title
, bi
, l
, t
, w
,
254 sd
->sd_Flags
& SDF_HIGHLIGHT
, sd
->sd_Flags
& SDF_CENTER
, sd
->sd_Place
);
262 BSetDPenA(bi
, recessed
? SHADOWPEN
: SHINEPEN
);
267 s
= sd
->sd_Flags
& SDF_THIN
? 1 : 2;
278 Draw(rp
, l
, t
+ h
- 1);
283 if (!(sd
->sd_Flags
& SDF_THIN
))
285 Draw(rp
, l
+ 1, t
+ h
- 1);
298 BSetDPenA(bi
, recessed
? SHINEPEN
: SHADOWPEN
);
303 Move(rp
, l
+ s
, t
+ 1);
304 Draw(rp
, l
+ s
, t
+ h
- 1);
309 if (!(sd
->sd_Flags
& SDF_THIN
))
312 Draw(rp
, l
+ s
, t
+ h
- 1);
313 Draw(rp
, l
+ s
, t
+ 1);
314 Move(rp
, l
, t
+ h
- 1);
315 Draw(rp
, l
+ s
, t
+ h
- 1);
318 Draw(rp
, l
, t
+ h
- 1);
328 METHOD(SepClassHitTest
, Msg
, msg
)
338 METHOD(SepClassDimensions
, struct bmDimensions
*, bmd
)
340 SD
*sd
= INST_DATA(cl
, obj
);
341 struct BaseInfo
*bi
= bmd
->bmd_BInfo
;
342 BC
*bc
= BASE_DATA(obj
);
348 if (sd
->sd_Flags
& SDF_HORIZONTAL
)
353 if (bc
->bc_TextFont
&& sd
->sd_Title
)
354 BSetFont(bi
, bc
->bc_TextFont
);
358 if (sd
->sd_Title
) my
= bi
->bi_RPort
->TxHeight
;
363 mx
= sd
->sd_Flags
& SDF_THIN
? 2 : 4;
366 return CalcDimensions(cl
, obj
, bmd
, mx
, my
);
372 METHOD(SepClassLocalize
, struct bmLocalize
*, bml
)
374 SD
*sd
= INST_DATA(cl
, obj
);
377 if (sd
->sd_Title
) rc
= AsmDoMethodA(sd
->sd_Title
, (Msg
)bml
);
383 /// Class initialization.
385 * Class function table.
387 STATIC DPFUNC ClassFunc
[] = {
388 { BASE_RENDER
, SepClassRender
, },
389 { GM_HITTEST
, SepClassHitTest
, },
390 { BASE_DIMENSIONS
, SepClassDimensions
, },
391 { OM_NEW
, SepClassNew
, },
392 { OM_DISPOSE
, SepClassDispose
, },
393 { OM_SET
, SepClassSet
, },
394 { BASE_LOCALIZE
, SepClassLocalize
, },
399 * Initialize the separator class.
401 makeproto Class
*InitSepClass(void)
403 return BGUI_MakeClass(CLASS_SuperClassBGUI
, BGUI_BASE_GADGET
,
404 CLASS_ObjectSize
, sizeof(SD
),
405 CLASS_DFTable
, ClassFunc
,