2 Copyright 1995-2007, The AROS Development Team.
6 /******************************************************************************
22 Allows user definable skins for the intuition windows, menus and gadgets.
26 Must be launched before Wanderer - usually in the S:startup-sequence
36 ******************************************************************************/
38 #include <clib/alib_protos.h>
40 #include <proto/exec.h>
41 #include <proto/dos.h>
42 #include <proto/graphics.h>
43 #include <proto/layers.h>
44 #include <proto/intuition.h>
45 #include <proto/utility.h>
46 #include <proto/cybergraphics.h>
47 #include <proto/datatypes.h>
50 #include <intuition/classusr.h>
51 #include <intuition/classes.h>
52 #include <intuition/windecorclass.h>
53 #include <intuition/scrdecorclass.h>
54 #include <intuition/menudecorclass.h>
55 #include <intuition/extensions.h>
56 #include <intuition/intuitionbase.h>
57 #include <graphics/rpattr.h>
58 #include <graphics/gfxmacros.h>
59 #include <libraries/mui.h>
60 #include <libraries/cybergraphics.h>
61 #include <datatypes/pictureclass.h>
62 #include <utility/tagitem.h>
66 #include <aros/debug.h>
67 #include <aros/detach.h>
74 /**************************************************************************************************/
76 #define PUTIMAGE_WIN(id) data->img_##id=data->sd->img_##id
77 #define PUTIMAGE_MEN(id) data->img_##id=data->sd->img_##id
79 #define SETIMAGE_SCR(id) SetImage(data->img_##id, &sd->img_##id, truecolor, screen)
80 #define SETIMAGE_WIN(id) wd->img_##id=&sd->img_##id
81 #define SETIMAGE_MEN(id) md->img_##id=&sd->img_##id
83 #define DELIMAGE_SCR(id) RemoveLUTImage(&sd->img_##id)
86 #define GET_A(rgb) ((rgb >> 24) & 0xff)
87 #define GET_R(rgb) ((rgb >> 16) & 0xff)
88 #define GET_G(rgb) ((rgb >> 8) & 0xff)
89 #define GET_B(rgb) (rgb & 0xff)
90 #define SET_ARGB(a, r, g, b) a << 24 | r << 16 | g << 8 | b
92 #define GET_A(rgb) (rgb & 0xff)
93 #define GET_R(rgb) ((rgb >> 8) & 0xff)
94 #define GET_G(rgb) ((rgb >> 16) & 0xff)
95 #define GET_B(rgb) ((rgb >> 24) & 0xff)
96 #define SET_ARGB(a, r, g, b) b << 24 | g << 16 | r << 8 | a
99 #define MDA_Configuration 0x10002
100 #define SDA_Configuration 0x20002
101 #define WDA_Configuration 0x30002
103 #define MDA_ScreenData 0x10003
104 #define SDA_ScreenData 0x20003
105 #define WDA_ScreenData 0x30003
107 struct IClass
*cl
, *scrcl
, *menucl
;
115 UWORD tile_left
, tile_top
, tile_bottom
, tile_right
;
116 UWORD inner_left
, inner_top
, inner_bottom
, inner_right
;
119 struct BitMap
*bitmap
;
132 /**************************************************************************************************/
136 struct NewImage
*img_sdepth
;
137 struct NewImage
*img_sbarlogo
;
138 struct NewImage
*img_stitlebar
;
140 struct NewImage
*img_size
;
141 struct NewImage
*img_close
;
142 struct NewImage
*img_depth
;
143 struct NewImage
*img_zoom
;
144 struct NewImage
*img_up
;
145 struct NewImage
*img_down
;
146 struct NewImage
*img_left
;
147 struct NewImage
*img_right
;
148 struct NewImage
*img_mui
;
149 struct NewImage
*img_popup
;
150 struct NewImage
*img_snapshot
;
151 struct NewImage
*img_iconify
;
152 struct NewImage
*img_lock
;
153 struct NewImage
*img_winbar_normal
;
154 struct NewImage
*img_border_normal
;
155 struct NewImage
*img_border_deactivated
;
156 struct NewImage
*img_verticalcontainer
;
157 struct NewImage
*img_verticalknob
;
158 struct NewImage
*img_horizontalcontainer
;
159 struct NewImage
*img_horizontalknob
;
161 struct NewImage
*img_menu
;
162 struct NewImage
*img_amigakey
;
163 struct NewImage
*img_menucheck
;
164 struct NewImage
*img_submenu
;
174 int leftborder
, bottomborder
, rightborder
;
175 int lut_col_a
, lut_col_d
;
176 int text_col
, shadow_col
;
184 struct scrdecor_data
*sd
;
185 struct DrawInfo
*dri
;
187 struct NewImage
*img_size
;
188 struct NewImage
*img_close
;
189 struct NewImage
*img_depth
;
190 struct NewImage
*img_zoom
;
191 struct NewImage
*img_up
;
192 struct NewImage
*img_down
;
193 struct NewImage
*img_left
;
194 struct NewImage
*img_right
;
195 struct NewImage
*img_mui
;
196 struct NewImage
*img_popup
;
197 struct NewImage
*img_snapshot
;
198 struct NewImage
*img_iconify
;
199 struct NewImage
*img_lock
;
200 struct NewImage
*img_winbar_normal
;
201 struct NewImage
*img_border_normal
;
202 struct NewImage
*img_border_deactivated
;
203 struct NewImage
*img_verticalcontainer
;
204 struct NewImage
*img_verticalknob
;
205 struct NewImage
*img_horizontalcontainer
;
206 struct NewImage
*img_horizontalknob
;
227 int BarLGadgetFill_o
;
228 int BarLGadgetFill_s
;
241 int BarRGadgetFill_o
;
242 int BarRGadgetFill_s
;
248 int ContainerTop_o
, ContainerTop_s
;
249 int ContainerVertTile_o
, ContainerVertTile_s
;
250 int ContainerBottom_o
, ContainerBottom_s
;
251 int KnobTop_o
, KnobTop_s
;
252 int KnobTileTop_o
, KnobTileTop_s
;
253 int KnobVertGripper_o
, KnobVertGripper_s
;
254 int KnobTileBottom_o
, KnobTileBottom_s
;
255 int KnobBottom_o
, KnobBottom_s
;
256 int ContainerLeft_o
, ContainerLeft_s
;
257 int ContainerHorTile_o
, ContainerHorTile_s
;
258 int ContainerRight_o
, ContainerRight_s
;
259 int KnobLeft_o
, KnobLeft_s
;
260 int KnobTileLeft_o
, KnobTileLeft_s
;
261 int KnobHorGripper_o
, KnobHorGripper_s
;
262 int KnobTileRight_o
, KnobTileRight_s
;
263 int KnobRight_o
, KnobRight_s
;
264 int sizeaddx
, sizeaddy
;
265 int updownaddx
, updownaddy
;
266 int leftrightaddx
, leftrightaddy
;
267 int rightbordergads
, bottombordergads
;
268 int rightbordernogads
, bottombordernogads
;
269 int horscrollerheight
;
270 int scrollerinnerspacing
;
272 int a_col_s
, a_col_e
;
273 int d_col_s
, d_col_e
;
274 int b_col_a
, b_col_d
;
275 int light
, middle
, dark
;
276 int text_col
, shadow_col
;
280 struct menudecor_data
282 struct scrdecor_data
*sd
;
284 struct DrawInfo
*dri
;
286 struct NewImage
*img_menu
;
287 struct NewImage
*img_amigakey
;
288 struct NewImage
*img_menucheck
;
289 struct NewImage
*img_submenu
;
296 struct NewImage
*img_size
;
297 struct NewImage
*img_close
;
298 struct NewImage
*img_depth
;
299 struct NewImage
*img_zoom
;
300 struct NewImage
*img_up
;
301 struct NewImage
*img_down
;
302 struct NewImage
*img_left
;
303 struct NewImage
*img_right
;
304 struct NewImage
*img_mui
;
305 struct NewImage
*img_popup
;
306 struct NewImage
*img_snapshot
;
307 struct NewImage
*img_iconify
;
308 struct NewImage
*img_lock
;
309 struct NewImage
*img_winbar_normal
;
310 struct NewImage
*img_border_normal
;
311 struct NewImage
*img_border_deactivated
;
312 struct NewImage
*img_verticalcontainer
;
313 struct NewImage
*img_verticalknob
;
314 struct NewImage
*img_horizontalcontainer
;
315 struct NewImage
*img_horizontalknob
;
322 WORD closewidth
, depthwidth
, zoomwidth
;
332 struct NewImage
*img_menu
;
333 struct NewImage
*img_amigakey
;
334 struct NewImage
*img_menucheck
;
335 struct NewImage
*img_submenu
;
345 struct NewImage img_sdepth
;
346 struct NewImage img_sbarlogo
;
347 struct NewImage img_stitlebar
;
349 struct NewImage img_size
;
350 struct NewImage img_close
;
351 struct NewImage img_depth
;
352 struct NewImage img_zoom
;
353 struct NewImage img_up
;
354 struct NewImage img_down
;
355 struct NewImage img_left
;
356 struct NewImage img_right
;
357 struct NewImage img_mui
;
358 struct NewImage img_popup
;
359 struct NewImage img_snapshot
;
360 struct NewImage img_iconify
;
361 struct NewImage img_lock
;
362 struct NewImage img_winbar_normal
;
363 struct NewImage img_border_normal
;
364 struct NewImage img_border_deactivated
;
365 struct NewImage img_verticalcontainer
;
366 struct NewImage img_verticalknob
;
367 struct NewImage img_horizontalcontainer
;
368 struct NewImage img_horizontalknob
;
370 struct NewImage img_menu
;
371 struct NewImage img_amigakey
;
372 struct NewImage img_menucheck
;
373 struct NewImage img_submenu
;
385 BOOL
InitWindowSkinning(STRPTR path
, struct windecor_data
*data
);
386 BOOL
InitMenuSkinning(STRPTR path
, struct menudecor_data
*data
);
387 BOOL
InitScreenSkinning(STRPTR path
, struct scrdecor_data
*data
);
388 void DisposeWindowSkinning(struct windecor_data
*data
);
389 void DisposeMenuSkinning(struct menudecor_data
*data
);
390 void DisposeScreenSkinning(struct scrdecor_data
*data
);
392 void DrawTileToRP(struct RastPort
*rp
, struct NewImage
*ni
, ULONG col
, UWORD offx
, UWORD offy
, UWORD x
, UWORD y
, WORD w
, WORD h
);
393 void DrawPartialTitleBar(struct WindowData
*wd
, struct windecor_data
* data
, struct Window
*win
, struct RastPort
*dst_rp
, struct DrawInfo
*dri
, UWORD align
, UWORD start
, UWORD width
, UWORD
*pens
);
395 static Object
*LoadPicture(CONST_STRPTR filename
, struct Screen
*scr
)
400 o
= NewDTObject((APTR
)filename
,
401 DTA_GroupID
, GID_PICTURE
,
402 OBP_Precision
, PRECISION_EXACT
,
403 PDTA_Screen
, (IPTR
)scr
,
404 PDTA_FreeSourceBitMap
, TRUE
,
405 PDTA_DestMode
, PMODE_V43
,
406 PDTA_UseFriendBitMap
, TRUE
,
412 struct BitMapHeader
*bmhd
;
414 GetDTAttrs(o
,PDTA_BitMapHeader
, (IPTR
)&bmhd
, TAG_DONE
);
416 struct FrameInfo fri
= {0};
418 D(bug("DTM_FRAMEBOX\n", o
));
419 DoMethod(o
,DTM_FRAMEBOX
,NULL
,(IPTR
)&fri
,(IPTR
)&fri
,sizeof(struct FrameInfo
),0);
421 if (fri
.fri_Dimensions
.Depth
>0)
423 D(bug("DTM_PROCLAYOUT\n", o
));
424 if (DoMethod(o
,DTM_PROCLAYOUT
,NULL
,1))
435 void SetImage(struct NewImage
*in
, struct NewImage
*out
, BOOL truecolor
, struct Screen
* scr
)
442 out
->istiled
= in
->istiled
;
443 out
->data
= in
->data
;
444 out
->tile_left
= in
->tile_left
;
445 out
->tile_right
= in
->tile_right
;
446 out
->tile_top
= in
->tile_top
;
447 out
->tile_bottom
= in
->tile_bottom
;
448 out
->inner_left
= in
->inner_left
;
449 out
->inner_right
= in
->inner_right
;
450 out
->inner_top
= in
->inner_top
;
451 out
->inner_bottom
= in
->inner_bottom
;
455 out
->ok
= (in
->data
!= NULL
) ? TRUE
: FALSE
;
459 STRPTR file
= AllocVec(strlen(in
->filename
) + 5, MEMF_ANY
| MEMF_CLEAR
);
462 strcpy(file
, in
->filename
);
463 strcat(file
, "_LUT");
464 out
->o
= LoadPicture(file
, scr
);
467 out
->filename
= in
->filename
;
468 if (out
->o
== NULL
) out
->o
= LoadPicture(in
->filename
, scr
);
471 GetDTAttrs(out
->o
, PDTA_DestBitMap
, (IPTR
)&out
->bitmap
, TAG_DONE
);
472 if (out
->bitmap
== NULL
) GetDTAttrs(out
->o
, PDTA_BitMap
, (IPTR
)&out
->bitmap
, TAG_DONE
);
474 if (out
->bitmap
) GetDTAttrs(out
->o
, PDTA_MaskPlane
, (IPTR
)&out
->mask
, TAG_DONE
);
475 if (out
->bitmap
== NULL
)
477 DisposeDTObject(out
->o
);
479 } else out
->ok
= TRUE
;
485 void RemoveLUTImage(struct NewImage
*ni
)
491 if (ni
->o
) DisposeDTObject(ni
->o
);
499 void DrawAlphaStateImageToRP(struct windecor_data
*data
, struct RastPort
*rp
, struct NewImage
*ni
, ULONG state
, UWORD xp
, UWORD yp
, BOOL multiple
)
505 int images
= (data
== NULL
) ? 2 : data
->threestate
? 3 : 4;
510 d
= (UBYTE
*) ni
->data
;
521 d
+= ix
/ images
* 4;
523 case IDS_INACTIVENORMAL
:
524 dx
+= ix
/ images
* 2;
525 d
+= ix
/ images
* 8;
532 if (ni
->bitmap
== NULL
)
534 WritePixelArrayAlpha(d
, 0 , 0, ix
*4, rp
, xp
, yp
, ix
/ images
, iy
, 0xffffffff);
540 BltMaskBitMapRastPort(ni
->bitmap
, dx
, 0, rp
, xp
, yp
, ix
/ images
, iy
, 0xe0, (PLANEPTR
) ni
->mask
);
542 else BltBitMapRastPort(ni
->bitmap
, dx
, 0, rp
, xp
, yp
, ix
/ images
, iy
, 0xc0);
547 void DrawPartImageToRP(struct RastPort
*rp
, struct NewImage
*ni
, UWORD x
, UWORD y
, UWORD sx
, UWORD sy
, UWORD sw
, UWORD sh
)
551 if (ni
->bitmap
== NULL
)
553 WritePixelArray(ni
->data
, sx
, sy
, ni
->w
*4, rp
, x
, y
, sw
, sh
, RECTFMT_ARGB
);
557 BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, y
, sw
, sh
, 0xc0);
562 void DisposeImageContainer(struct NewImage
*ni
)
570 if (ni
->o
) DisposeDTObject(ni
->o
);
571 if (ni
->filename
) FreeVec(ni
->filename
);
576 void DisposeLUT8ImageContainer(struct NewLUT8Image
*ni
)
588 struct NewLUT8Image
*NewLUT8ImageContainer(UWORD w
, UWORD h
)
590 struct NewLUT8Image
*ni
;
592 ni
= AllocVec(sizeof(struct NewLUT8Image
), MEMF_ANY
| MEMF_CLEAR
);
597 ni
->data
= AllocVec(w
* h
, MEMF_ANY
| MEMF_CLEAR
);
598 if (ni
->data
== NULL
)
607 struct NewImage
*NewImageContainer(UWORD w
, UWORD h
)
611 ni
= AllocVec(sizeof(struct NewImage
), MEMF_ANY
| MEMF_CLEAR
);
616 ni
->data
= AllocVec(w
* h
* sizeof (ULONG
), MEMF_ANY
| MEMF_CLEAR
);
617 if (ni
->data
== NULL
)
626 struct NewImage
*GetImageFromFile(STRPTR path
, STRPTR name
, BOOL fixmode
)
628 struct BitMapHeader
*bmhd
;
629 struct NewImage
*ni
= NULL
;
630 struct BitMap
*map
= NULL
;
631 struct RastPort
*rp
= NULL
;
633 struct pdtBlitPixelArray pa
;
635 UWORD w
, h
, tc
, x
, y
;
642 strcpy(Buffer
, name
);
643 strcat(Buffer
, "Default");
646 strcpy(Buffer
, name
);
648 pic
= NewDTObject(Buffer
, DTA_SourceType
, DTST_FILE
,
649 DTA_GroupID
, GID_PICTURE
,
651 PDTA_DestMode
, PMODE_V43
,
656 get(pic
, PDTA_BitMapHeader
, &bmhd
);
661 h
= bmhd
->bmh_Height
;
662 mask
= bmhd
->bmh_Masking
;
663 ni
= NewImageContainer(w
, h
);
666 int len
= strlen(path
) + strlen(Buffer
) +2;
667 ni
->filename
= AllocVec(len
, MEMF_CLEAR
| MEMF_ANY
);
668 if (ni
->filename
!= NULL
)
670 strncpy(ni
->filename
, path
, len
);
671 AddPart(ni
->filename
, Buffer
, len
);
673 pa
.MethodID
= PDTM_READPIXELARRAY
;
674 pa
.pbpa_PixelData
= (APTR
) ni
->data
;
675 pa
.pbpa_PixelFormat
= PBPAFMT_ARGB
;
676 pa
.pbpa_PixelArrayMod
= w
*4;
681 DoMethodA(pic
, (Msg
) &pa
);
683 if (bmhd
->bmh_Depth
<= 8)
685 get(pic
, PDTA_BitMap
, &map
);
686 if (map
&& (mask
== mskHasTransparentColor
))
688 rp
= CreateRastPort();
689 if (rp
) rp
->BitMap
= map
;
690 tc
= bmhd
->bmh_Transparent
;
697 for (y
= 0; y
< h
; y
++)
699 for (x
= 0; x
< w
; x
++)
702 if (ReadPixel(rp
, x
, y
) == 0) dst
[x
+y
*w
] &= 0xffffff00; else dst
[x
+y
*w
] |= 0x000000ff;
704 if (ReadPixel(rp
, x
, y
) == 0) dst
[x
+y
*w
] &= 0x00ffffff; else dst
[x
+y
*w
] |= 0xff000000;
713 if (mask
!= mskHasAlpha
)
716 for (a
= 0; a
< (w
*h
); a
++) ni
->data
[a
] |= 0x000000ff;
718 for (a
= 0; a
< (w
*h
); a
++) ni
->data
[a
] |= 0xff000000;
725 DisposeImageContainer(ni
);
731 DisposeDTObject(pic
);
737 struct NewImage
*GetImageFromRP(struct RastPort
*rp
, UWORD x
, UWORD y
, UWORD w
, UWORD h
)
741 ni
= NewImageContainer(w
, h
);
744 ReadPixelArray(ni
->data
, 0, 0, w
*4, rp
, x
, y
, w
, h
, RECTFMT_ARGB
);
749 void PutImageToRP(struct RastPort
*rp
, struct NewImage
*ni
, UWORD x
, UWORD y
) {
753 if (ni
->data
) WritePixelArray(ni
->data
, 0, 0, ni
->w
*4, rp
, x
, y
, ni
->w
, ni
->h
, RECTFMT_ARGB
);
754 DisposeImageContainer(ni
);
758 /* the following code is taken from zune sources and modified */
760 void FillPixelArrayGradientDelta(LONG pen
, BOOL tc
, struct RastPort
*rp
, int xt
, int yt
, int xb
, int yb
, int xp
, int yp
, int w
, int h
, ULONG start_rgb
, ULONG end_rgb
, int angle
, int dx
, int dy
)
763 /* The basic idea of this algorithm is to calc the intersection between the
764 * diagonal of the rectangle (xs,ys) with dimension (xw,yw) a with the line starting
765 * at (x,y) (every pixel inside the rectangle) and angle angle with direction vector (vx,vy).
767 * Having the intersection point we then know the color of the pixel.
769 * TODO: Turn the algorithm into a incremental one
770 * Remove the use of floating point variables
772 double rad
= angle
*M_PI
/180;
773 double cosarc
= cos(rad
);
774 double sinarc
= sin(rad
);
776 struct myrgb startRGB
,endRGB
;
778 int diffR
, diffG
, diffB
;
780 int r
,t
; /* some helper variables to short the code */
782 int y1
; /* The intersection point */
783 int incr_y1
; /* increment of y1 */
785 int xadd
,ystart
,yadd
;
786 // double vx = -cosarc;
787 // double vy = sinarc;
788 int vx
= (int)(-cosarc
*0xff);
789 int vy
= (int)(sinarc
*0xff);
791 int width
= xb
- xt
+ 1;
792 int height
= yb
- yt
+ 1;
794 if ((w
<= 0) || (h
<= 0)) return;
797 if (pen
!= -1) SetAPen(rp
, pen
); else SetAPen(rp
, 2);
798 RectFill(rp
, xp
, yp
, xp
+ w
- 1, yp
+ h
- 1);
802 UBYTE
*buf
= AllocVec(w
*h
*3, 0);
803 if (buf
== NULL
) return;
804 startRGB
.red
= (start_rgb
>> 16) & 0xff;
805 startRGB
.green
= (start_rgb
>> 8) & 0xff;
806 startRGB
.blue
= start_rgb
& 0xff;
808 endRGB
.red
= (end_rgb
>> 16) & 0xff;
809 endRGB
.green
= (end_rgb
>> 8) & 0xff;
810 endRGB
.blue
= end_rgb
& 0xff;
812 diffR
= endRGB
.red
- startRGB
.red
;
813 diffG
= endRGB
.green
- startRGB
.green
;
814 diffB
= endRGB
.blue
- startRGB
.blue
;
816 /* Normalize the angle */
817 if (angle
< 0) angle
= 360 - ((-angle
)%360);
818 if (angle
>= 0) angle
= angle
% 360;
820 if (angle
<= 90 || (angle
> 180 && angle
<= 270))
822 /* The to be intersected diagonal goes from the top left edge to the bottom right edge */
829 /* The to be intersected diagonal goes from the bottom left edge to the top right edge */
836 if (angle
> 90 && angle
<= 270)
838 /* for these angle we have y1 = height - y1. Instead of
840 * y1 = height - (-vy*(yw* xs -xw* ys) + yw*(vy* x -vx* y)) /(-yw*vx + xw*vy);
844 * y1 = (-vy*(yw*(-xs)-xw*(-ys+height)) + yw*(vy*(-x)-vx*(-y+height)))/(-yw*vx + xw*vy);
846 * so height - y1 can be expressed with the normal formular adapting some parameters.
848 * Note that if one would exchanging startRGB/endRGB the values would only work
849 * for linear color gradients
865 r
= -vy
*(yw
*xs
-xw
*ys
);
868 /* The formular as shown above is
870 * y1 = ((-vy*(yw*xs-xw*ys) + yw*(vy*x-vx*y)) /(-yw*vx + xw*vy));
872 * We see that only yw*(vy*x-vx*y) changes during the loop.
876 * Current Pixel: y1(x,y) = (r + yw*(vy*x-vx*y))/t = r/t + yw*(vy*x-vx*y)/t
877 * Next Pixel: y1(x+xadd,y) = (r + vw*(vy*(x+xadd)-vx*y))/t
879 * t*(y1(x+xadd,y) - y1(x,y)) = yw*(vy*(x+xadd)-vx*y) - yw*(vy*x-vx*y) = yw*vy*xadd;
883 incr_y1
= yw
*vy
*xadd
;
885 for (l
= 0, y
= ystart
+ ((yp
- yt
)* yadd
); l
< h
; l
++, y
+=yadd
)
888 /* Calculate initial y1 accu, can be brought out of the loop as well (x=0). It's probably a
889 * a good idea to add here also a value of (t-1)/2 to ensure the correct rounding
890 * This (and for r) is also a place were actually a overflow can happen |yw|=16 |y|=16. So for
891 * vx nothing is left, currently 9 bits are used for vx or vy */
892 int y1_mul_t_accu
= r
- yw
*vx
*y
;
896 for (c
= 0, x
= ((xp
- xt
) * xadd
); c
< w
; c
++, x
+=xadd
)
900 /* Calculate the intersection of two lines, this is not the fastet way to do but
901 * it is intuitive. Note: very slow! Will be optimzed later (remove FFP usage
902 * and making it incremental)...update: it's now incremental and no FFP is used
903 * but it probably can be optimized more by removing some more of the divisions and
904 * further specialize the stuff here (use of three accus). */
905 /* y1 = (int)((-vy*(yw*xs-xw*ys) + yw*(vy*x-vx*y)) /(-yw*vx + xw*vy));*/
906 y1
= y1_mul_t_accu
/ t
;
908 red
= startRGB
.red
+ (int)(diffR
*y1
/height
);
909 green
= startRGB
.green
+ (int)(diffG
*y1
/height
);
910 blue
= startRGB
.blue
+ (int)(diffB
*y1
/height
);
911 /* By using full 32 bits this can be made faster as well */
916 y1_mul_t_accu
+= incr_y1
;
918 /* By bringing building the gradient array in the same format as the RastPort BitMap a call
919 * to WritePixelArray() can be made also faster */
921 WritePixelArray(buf
,0,0,w
*3, rp
,dx
,dy
,w
,h
,RECTFMT_RGB
);
925 void FillPixelArrayGradient(LONG pen
, BOOL tc
, struct RastPort
*rp
, int xt
, int yt
, int xb
, int yb
, int xp
, int yp
, int w
, int h
, ULONG start_rgb
, ULONG end_rgb
, int angle
)
927 FillPixelArrayGradientDelta(pen
, tc
, rp
, xt
, yt
, xb
, yb
, xp
, yp
, w
, h
, start_rgb
, end_rgb
, angle
, xp
, yp
);
931 void DrawPartToImage(struct NewImage
*src
, struct NewImage
*dest
, UWORD sx
, UWORD sy
, UWORD sw
, UWORD sh
, UWORD dx
, UWORD dy
)
935 for (y
= 0; y
< sh
; y
++)
937 for (x
= 0; x
< sw
; x
++)
939 dest
->data
[dx
+ x
+ (dy
+ y
) * dest
->w
] = src
->data
[sx
+ x
+ (sy
+ y
) * src
->w
];
944 void DrawTileToImage(struct NewImage
*src
, struct NewImage
*dest
, UWORD _sx
, UWORD _sy
, UWORD _sw
, UWORD _sh
, UWORD _dx
, UWORD _dy
, UWORD _dw
, UWORD _dh
)
948 LONG dh
, height
, dw
, width
;
950 if (src
== NULL
) return;
951 if (dest
== NULL
) return;
959 if ((height
-dh
)<0) dh
= height
;
966 if ((width
-dw
)<0) dw
= width
;
968 DrawPartToImage(src
, dest
, _sx
, _sy
, dw
, dh
, dx
, dy
);
975 void DrawMapTileToRP(struct NewImage
*src
, struct RastPort
*rp
, UWORD _sx
, UWORD _sy
, UWORD _sw
, UWORD _sh
, UWORD _dx
, UWORD _dy
, UWORD _dw
, UWORD _dh
)
979 LONG dh
, height
, dw
, width
;
981 if (src
== NULL
) return;
982 if (rp
== NULL
) return;
988 if (!src
->ok
) return;
992 if ((height
-dh
)<0) dh
= height
;
999 if ((width
-dw
)<0) dw
= width
;
1004 BltMaskBitMapRastPort(src
->bitmap
, _sx
, _sy
, rp
, dx
, dy
, dw
, dh
, 0xe0, (PLANEPTR
) src
->mask
);
1006 else BltBitMapRastPort(src
->bitmap
, _sx
, _sy
, rp
, dx
, dy
, dw
, dh
, 0xc0);
1013 /**************************************************************************************************/
1015 char *SkipChars(char *v
)
1026 return (int) atol(c
);
1029 void GetIntegers(char *v
, int *v1
, int *v2
)
1032 char va1
[32], va2
[32];
1037 cnt
= sscanf(c
, "%s %s", va1
, va2
);
1051 void GetTripleIntegers(char *v
, int *v1
, int *v2
, int *v3
)
1059 cnt
= sscanf(ch
, "%x %x %d", &a
, &b
, &c
);
1069 void GetColors(char *v
, int *v1
, int *v2
)
1077 cnt
= sscanf(ch
, "%x %x", &a
, &b
);
1087 BOOL
GetBool(char *v
, char *id
)
1089 if (strstr(v
, id
)) return TRUE
; else return FALSE
;
1092 static IPTR
windecor_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
1094 struct windecor_data
*data
;
1096 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1099 data
= INST_DATA(cl
, obj
);
1101 STRPTR path
= (STRPTR
) GetTagData(WDA_Configuration
, (IPTR
) "Theme:", msg
->ops_AttrList
);
1102 data
->sd
= (struct scrdecor_data
*) GetTagData(WDA_ScreenData
, 0, msg
->ops_AttrList
);
1104 if (!InitWindowSkinning(path
, data
))
1106 CoerceMethod(cl
,obj
,OM_DISPOSE
);
1114 static IPTR
windecor_dispose(Class
*cl
, Object
*obj
, struct opSet
*msg
)
1116 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1118 DisposeWindowSkinning(data
);
1122 /**************************************************************************************************/
1124 static IPTR
windecor_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
1126 switch(msg
->opg_AttrID
)
1128 case WDA_TrueColorOnly
:
1129 *msg
->opg_Storage
= TRUE
;
1132 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1137 /**************************************************************************************************/
1139 /**************************************************************************************************/
1141 IPTR
windecor_draw_sysimage(Class
*cl
, Object
*obj
, struct wdpDrawSysImage
*msg
)
1143 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1144 struct RastPort
*rp
= msg
->wdp_RPort
;
1145 struct NewImage
*ni
= NULL
;
1146 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1147 LONG state
= msg
->wdp_State
;
1148 LONG left
= msg
->wdp_X
;
1149 LONG top
= msg
->wdp_Y
;
1150 LONG width
= msg
->wdp_Width
;
1151 LONG height
= msg
->wdp_Height
;
1155 BOOL titlegadget
= FALSE
;
1157 switch(msg
->wdp_Which
)
1160 if (wd
->img_size
->ok
)
1164 if (data
->threestate
) addx
= (data
->rightbordergads
- (data
->img_size
->w
/ 3)) /2; else addx
= (data
->rightbordergads
- (data
->img_size
->w
>> 2)) /2;
1165 addy
= (data
->bottombordergads
- data
->img_size
->h
) / 2;
1170 if (wd
->img_close
->ok
)
1179 if (wd
->img_mui
->ok
)
1188 if (wd
->img_popup
->ok
)
1197 if (wd
->img_snapshot
->ok
)
1199 ni
= wd
->img_snapshot
;
1206 if (wd
->img_lock
->ok
)
1215 if (wd
->img_iconify
->ok
)
1217 ni
= wd
->img_iconify
;
1224 if (wd
->img_depth
->ok
)
1233 if (wd
->img_zoom
->ok
)
1243 if (data
->threestate
) addx
= (data
->rightbordergads
- (data
->img_up
->w
/ 3)) /2; else addx
= (data
->rightbordergads
- (data
->img_up
->w
>> 2)) /2;
1244 addy
= data
->updownaddy
/ 2;
1250 if (data
->threestate
) addx
= (data
->rightbordergads
- (data
->img_down
->w
/ 3)) /2; else addx
= (data
->rightbordergads
- (data
->img_down
->w
>> 2)) /2;
1251 addy
= data
->updownaddy
/ 2;
1257 addx
= data
->leftrightaddx
/ 2;
1258 addy
= (data
->bottombordergads
- data
->img_left
->h
) / 2;
1264 addx
= data
->leftrightaddx
/ 2;
1265 addy
= (data
->bottombordergads
- data
->img_right
->h
) /2;
1270 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1273 if (!isset
) return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1275 if (wd
&& titlegadget
) if (wd
->rp
) if (wd
->rp
->BitMap
) BltBitMapRastPort(wd
->rp
->BitMap
, left
+addy
, top
+addy
, rp
, left
+addy
, top
+addy
, width
, height
, 0xc0);
1277 if (ni
) DrawAlphaStateImageToRP(data
, rp
, ni
, state
, left
+addx
, top
+addy
, TRUE
);
1282 /**************************************************************************************************/
1284 void getrightgadgetsdimensions(struct windecor_data
*data
, struct Window
*win
, int *xs
, int *xe
)
1292 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
1294 if ((g
->Flags
& GFLG_RELRIGHT
) == GFLG_RELRIGHT
)
1296 type
= g
->GadgetType
& GTYP_SYSTYPEMASK
;
1297 if (data
->closeright
)
1299 if (((type
& (GTYP_CLOSE
| GTYP_WDEPTH
| GTYP_WZOOM
)) != 0) || (g
->Activation
& GACT_TOPBORDER
))
1303 if ((win
->Width
+ g
->LeftEdge
) < x0
) x0
= win
->Width
+ g
->LeftEdge
;
1304 if ((win
->Width
+ g
->LeftEdge
+ g
->Width
) > x1
) x1
= win
->Width
+ g
->LeftEdge
+ g
->Width
;
1310 if (((type
& (GTYP_WDEPTH
| GTYP_WZOOM
)) != 0) || (g
->Activation
& GACT_TOPBORDER
))
1314 if ((win
->Width
+ g
->LeftEdge
) < x0
) x0
= win
->Width
+ g
->LeftEdge
;
1315 if ((win
->Width
+ g
->LeftEdge
+ g
->Width
) > x1
) x1
= win
->Width
+ g
->LeftEdge
+ g
->Width
;
1321 if (x0
== 1000000) x0
= 0;
1326 void getleftgadgetsdimensions(struct windecor_data
*data
, struct Window
*win
, int *xs
, int *xe
)
1333 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
1336 if (((g
->Flags
& GFLG_RELRIGHT
) == 0) && (g
->Activation
& GACT_TOPBORDER
))
1338 if ((g
->GadgetType
& GTYP_WDRAGGING
) == 0)
1342 if (g
->LeftEdge
< x0
) x0
= g
->LeftEdge
;
1343 if ((g
->LeftEdge
+ g
->Width
) > x1
) x1
= g
->LeftEdge
+ g
->Width
;
1348 if (x0
== 1000000) x0
= 0;
1353 /**************************************************************************************************/
1355 void ShadeLine(LONG pen
, BOOL tc
, struct windecor_data
*d
, struct RastPort
*rp
, struct NewImage
*ni
, ULONG basecolor
, UWORD fact
, UWORD _offy
, UWORD x0
, UWORD y0
, UWORD x1
, UWORD y1
)
1362 if ((x1
< x0
) || (y1
< y0
)) return;
1370 if (d
->usegradients
)
1373 c3
= (c
>> 24) & 0xff;
1374 c2
= (c
>> 16) & 0xff;
1375 c1
= (c
>> 8) & 0xff;
1385 if (c0
> 255) c0
= 255;
1386 if (c1
> 255) c1
= 255;
1387 if (c2
> 255) c2
= 255;
1388 if (c3
> 255) c3
= 255;
1389 c
= (c3
<< 24) | (c2
<< 16) | (c1
<< 8) | c0
;
1390 SetRPAttrs(rp
, RPTAG_FgColor
, c
, TAG_DONE
);
1399 for (py
= y0
; py
< y1
; py
++)
1401 y
= (py
- offy
) % ni
->h
;
1402 c
= ni
->data
[x
+ y
* ni
->w
];
1403 c0
= (c
>> 24) & 0xff;
1404 c1
= (c
>> 16) & 0xff;
1405 c2
= (c
>> 8) & 0xff;
1415 if (c0
> 255) c0
= 255;
1416 if (c1
> 255) c1
= 255;
1417 if (c2
> 255) c2
= 255;
1418 if (c3
> 255) c3
= 255;
1419 c
= (c3
<< 24) | (c2
<< 16) | (c1
<< 8) | c0
;
1420 WriteRGBPixel(rp
, x0
, py
, c
);
1423 y
= (y0
- offy
) % ni
->h
;
1424 for (px
= x0
; px
< x1
; px
++) {
1426 c
= ni
->data
[x
+ y
* ni
->w
];
1427 c0
= (c
>> 24) & 0xff;
1428 c1
= (c
>> 16) & 0xff;
1429 c2
= (c
>> 8) & 0xff;
1439 if (c0
> 255) c0
= 255;
1440 if (c1
> 255) c1
= 255;
1441 if (c2
> 255) c2
= 255;
1442 if (c3
> 255) c3
= 255;
1443 c
= (c3
<< 24) | (c2
<< 16) | (c1
<< 8) | c0
;
1444 WriteRGBPixel(rp
, px
, y0
, c
);
1455 int WriteTiledImage(struct Window
*win
, struct RastPort
*rp
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1461 if (!ni
->ok
) return xp
;
1463 if ((sw
== 0) || (dw
== 0)) return xp
;
1466 if (x
> win
->Width
) return xp
;
1467 if ((x
+ w
) > win
->Width
) w
= win
->Width
- x
;
1473 if (w
< ddw
) ddw
= w
;
1474 if (ni
->bitmap
== NULL
)
1476 WritePixelArrayAlpha(ni
->data
, sx
, sy
, ni
->w
*4, rp
, x
, yp
, ddw
, dh
, 0xffffffff);
1482 BltMaskBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xe0, (PLANEPTR
) ni
->mask
);
1484 else BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xc0);
1492 int WriteTiledImageNoAlpha(struct Window
*win
, struct RastPort
*rp
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1498 if (!ni
->ok
) return x
;
1500 if ((sw
== 0) || (dw
== 0)) return xp
;
1504 if (x
> win
->Width
) return xp
;
1505 if ((x
+ w
) > win
->Width
) w
= win
->Width
- x
;
1511 if (w
< ddw
) ddw
= w
;
1512 if (ni
->bitmap
== NULL
)
1514 WritePixelArray(ni
->data
, sx
, sy
, ni
->w
*4, rp
, x
, yp
, ddw
, dh
, RECTFMT_ARGB
);
1518 BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xc0);
1527 void WriteAlphaPixelArray(struct NewImage
*src
, struct NewLUT8Image
*dst
, int sx
, int sy
, int dx
, int dy
, int w
, int h
)
1529 ULONG
*s
= src
->data
;
1531 UBYTE
*d
= dst
->data
;
1534 for (y
= 0; y
< h
; y
++)
1536 for (x
= 0; x
< w
; x
++)
1538 argb
= s
[sx
+ x
+ (sy
+ y
) * src
->w
];
1539 d
[dx
+ x
+ (dy
+ y
) * dst
->w
] = GET_A(argb
);
1544 int WriteTiledImageTitle(BOOL fill
, struct Window
*win
, struct RastPort
*rp
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1550 if (!ni
->ok
) return x
;
1552 if (!fill
) return WriteTiledImageNoAlpha(win
, rp
, ni
, sx
, sy
, sw
, sh
, xp
, yp
, dw
, dh
);
1554 if ((sw
== 0) || (dw
== 0)) return xp
;
1558 if (x
> win
->Width
) return xp
;
1559 if ((x
+ w
) > win
->Width
) w
= win
->Width
- x
;
1565 if (w
< ddw
) ddw
= w
;
1566 if (ni
->bitmap
== NULL
)
1568 if (fill
) WritePixelArrayAlpha(ni
->data
, sx
, sy
, ni
->w
*4, rp
, x
, yp
, ddw
, dh
, 0xffffffff); //RECTFMT_ARGB);
1569 else WritePixelArray(ni
->data
, sx
, sy
, ni
->w
*4, rp
, x
, yp
, ddw
, dh
, RECTFMT_ARGB
);
1578 BltMaskBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xe0, (PLANEPTR
) ni
->mask
);
1580 else BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xc0);
1584 BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, x
, yp
, ddw
, dh
, 0xc0);
1593 int WriteTiledImageShape(BOOL fill
, struct Window
*win
, struct NewLUT8Image
*lut8
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1599 if (!ni
->ok
) return xp
;
1601 if ((sw
== 0) || (dw
== 0)) return xp
;
1605 if (x
> win
->Width
) return xp
;
1606 if ((x
+ w
) > win
->Width
) w
= win
->Width
- x
;
1612 if (w
< ddw
) ddw
= w
;
1613 WriteAlphaPixelArray(ni
, lut8
, sx
, sy
, x
, yp
, ddw
, dh
);
1620 int WriteTiledImageHorizontal(struct RastPort
*rp
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1622 return WriteTiledImage(NULL
, rp
, ni
, sx
, sy
, sw
, sh
, xp
, yp
, dw
, dh
);
1625 int WriteTiledImageVertical(struct RastPort
*rp
, struct NewImage
*ni
, int sx
, int sy
, int sw
, int sh
, int xp
, int yp
, int dw
, int dh
)
1631 if (!ni
->ok
) return y
;
1633 if ((sh
== 0) || (dh
== 0)) return yp
;
1638 if (h
< ddh
) ddh
= h
;
1639 if (ni
->bitmap
== NULL
)
1641 WritePixelArrayAlpha(ni
->data
, sx
, sy
, ni
->w
*4, rp
, xp
, y
, dw
, ddh
, 0xffffffff);
1647 BltMaskBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, xp
, y
, dw
, ddh
, 0xe0, (PLANEPTR
) ni
->mask
);
1649 else BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, xp
, y
, dw
, ddh
, 0xc0);
1657 IPTR
windecor_draw_winborder(Class
*cl
, Object
*obj
, struct wdpDrawWinBorder
*msg
)
1659 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1660 struct RastPort
*rp
= msg
->wdp_RPort
;
1661 struct Window
*window
= msg
->wdp_Window
;
1662 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1663 struct NewImage
*ni
= NULL
;
1664 UWORD
*pens
= msg
->wdp_Dri
->dri_Pens
;
1665 ULONG bc
, color
, s_col
, e_col
, arc
;
1666 UWORD bl
, bt
, br
, bb
, ww
, wh
;
1670 if (wd
->img_border_normal
->ok
) ni
= wd
->img_border_normal
;
1672 if (ni
== NULL
) data
->usegradients
= TRUE
;
1674 BOOL tc
= wd
->truecolor
;
1676 LONG dpen
= pens
[SHADOWPEN
];
1677 LONG lpen
= pens
[SHINEPEN
];
1678 LONG mpen
= pens
[SHINEPEN
];
1680 bl
= window
->BorderLeft
;
1681 bt
= window
->BorderTop
;
1682 bb
= window
->BorderBottom
;
1683 br
= window
->BorderRight
;
1685 wh
= window
->Height
;
1689 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
1691 pen
= wd
->ActivePen
;
1692 s_col
= data
->a_col_s
;
1693 e_col
= data
->a_col_e
;
1698 pen
= wd
->DeactivePen
;
1699 s_col
= data
->d_col_s
;
1700 e_col
= data
->d_col_e
;
1702 dy
= data
->winbarheight
;
1704 if (!data
->usegradients
)
1706 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
1710 // if (data->filltitlebar)
1712 // if (data->usegradients) FillPixelArrayGradient(pen, wd->truecolor, rp, 0, 0, window->Width, window->Height, 0, 0, window->Width, window->BorderTop, s_col, e_col, arc);
1713 // else DrawTileToRP(rp, ni, color, 0, 0, 0, 0, window->Width, window->BorderTop);
1716 if (window
->BorderTop
== data
->winbarheight
) DrawPartialTitleBar(wd
, data
, window
, rp
, msg
->wdp_Dri
, data
->txt_align
, 0, window
->Width
, pens
);
1717 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
1719 if (window
->BorderLeft
> 2)
1721 if (data
->usegradients
) FillPixelArrayGradient(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
-1, window
->Height
-1, 0, window
->BorderTop
, window
->BorderLeft
, window
->Height
- window
->BorderTop
, s_col
, e_col
, arc
);
1722 else DrawTileToRP(rp
, ni
, color
, 0, 0, 0, window
->BorderTop
, window
->BorderLeft
- 1, window
->Height
- window
->BorderTop
);
1724 if (window
->BorderRight
> 2)
1726 if (data
->usegradients
) FillPixelArrayGradient(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
-1, window
->Height
-1, window
->Width
- window
->BorderRight
, window
->BorderTop
, window
->BorderRight
, window
->Height
- window
->BorderTop
, s_col
, e_col
, arc
);
1727 else DrawTileToRP(rp
, ni
, color
, 0, 0, window
->Width
- window
->BorderRight
, window
->BorderTop
, window
->BorderRight
, window
->Height
- window
->BorderTop
);
1729 if (window
->BorderBottom
> 2)
1731 if (data
->usegradients
) FillPixelArrayGradient(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
-1, window
->Height
-1, 0, window
->Height
- window
->BorderBottom
, window
->Width
, window
->BorderBottom
, s_col
, e_col
, arc
);
1732 else DrawTileToRP(rp
, ni
, color
, 0, 0, 0, window
->Height
- window
->BorderBottom
, window
->Width
, window
->BorderBottom
);
1737 if (bt
!= data
->winbarheight
) {
1739 if (bt
> 1) bq
= bt
- 1;
1740 if (window
->BorderTop
> 2)
1742 if (data
->usegradients
) FillPixelArrayGradient(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
-1, window
->Height
-1, 0, 0 , window
->Width
- 1, window
->BorderTop
- 1, s_col
, e_col
, arc
);
1743 else DrawTileToRP(rp
, ni
, color
, 0, 0, 0, 0 , window
->Width
, window
->BorderTop
);
1745 if (bt
> 0) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, 0, 0, 0, ww
- 1, 0);
1746 if (bq
> 0) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, bq
, 0, bq
, ww
- 1, bq
);
1747 if (bt
> 1) ShadeLine(lpen
, tc
, data
, rp
, ni
, bc
, data
->light
, 1, 1, 1, ww
- 2, 1);
1751 if (bl
> 0) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, bbt
, 0, bbt
, 0, wh
- 1);
1752 if (bb
> 0) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, wh
- 1, 0, wh
- 1, ww
- 1, wh
- 1);
1753 if (br
> 0) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, bbt
, ww
- 1, bbt
, ww
- 1, wh
- 1);
1754 if (bl
> 1) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, bbt
, bl
- 1, bbt
, bl
- 1, wh
- bb
);
1755 if (bb
> 1) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, wh
- bb
, bl
- 1, wh
- bb
, ww
- br
, wh
- bb
);
1756 if (br
> 1) ShadeLine(dpen
, tc
, data
, rp
, ni
, bc
, data
->dark
, bbt
, ww
- br
, bbt
, ww
- br
, wh
- bb
);
1757 if (bl
> 2) ShadeLine(lpen
, tc
, data
, rp
, ni
, bc
, data
->light
, bbt
, 1, bbt
, 1, wh
- 2);
1759 if (bb
> 1) ShadeLine(mpen
, tc
, data
, rp
, ni
, bc
, data
->middle
, bbt
, bl
- 2, bbt
, bl
- 2, wh
- bb
+ 1);
1760 else ShadeLine(mpen
, tc
, data
, rp
, ni
, bc
, data
->middle
, bbt
, bl
- 2, bbt
, bl
- 2, wh
- bb
);
1762 if (br
> 2) ShadeLine(mpen
, tc
, data
, rp
, ni
, bc
, data
->middle
, bbt
, ww
- 2, bbt
, ww
- 2, wh
- 2);
1763 if (bb
> 2) ShadeLine(mpen
, tc
, data
, rp
, ni
, bc
, data
->middle
, wh
- 2, 1, wh
- 2, ww
- 2, wh
- 2);
1765 if ((bl
> 0) && (br
> 0)) ShadeLine(lpen
, tc
, data
, rp
, ni
, bc
, data
->light
, wh
- bb
+ 1, bl
, wh
- bb
+ 1, ww
- br
, wh
- bb
+ 1);
1768 if (bb
> 1) ShadeLine(lpen
, tc
, data
, rp
, ni
, bc
, data
->light
, bbt
, ww
- br
+ 1, bbt
, ww
- br
+ 1, wh
- bb
+ 1);
1774 void DrawTileToRP(struct RastPort
*rp
, struct NewImage
*ni
, ULONG color
, UWORD offx
, UWORD offy
, UWORD x
, UWORD y
, WORD w
, WORD h
)
1777 ULONG ow
, oh
, sy
, sx
, dy
, dx
;
1778 LONG dh
, height
, dw
, width
;
1780 if ((w
<= 0) || (h
<= 0)) return;
1784 FillPixelArray(rp
, x
, y
, w
, h
, color
);
1791 sy
= (y
- offy
)% oh
;
1797 if ((height
-dh
)<0) dh
= height
;
1800 sx
= (x
- offx
) % ow
;
1806 if ((width
-dw
)<0) dw
= width
;
1808 if (ni
->bitmap
== NULL
)
1810 WritePixelArray(ni
->data
, sx
, sy
, ni
->w
*4, rp
, dx
, dy
, dw
, dh
, RECTFMT_ARGB
);
1814 BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, dx
, dy
, dw
, dh
, 0xc0);
1826 void DrawTileToRPRoot(struct RastPort
*rp
, struct NewImage
*ni
, ULONG color
, UWORD offx
, UWORD offy
, UWORD x
, UWORD y
, WORD w
, WORD h
)
1829 ULONG ow
, oh
, sy
, sx
, dy
, dx
, _dy
, _dx
;
1830 LONG dh
, height
, dw
, width
;
1832 if (!ni
->ok
) return;
1834 if ((w
<= 0) || (h
<= 0)) return;
1838 FillPixelArray(rp
, x
, y
, w
, h
, color
);
1847 sy
= (y
- offy
)% oh
;
1853 if ((height
-dh
)<0) dh
= height
;
1856 sx
= (x
- offx
) % ow
;
1863 if ((width
-dw
)<0) dw
= width
;
1865 if (ni
->bitmap
== NULL
)
1867 WritePixelArray(ni
->data
, sx
, sy
, ni
->w
*4, rp
, _dx
, _dy
, dw
, dh
, RECTFMT_ARGB
);
1871 BltBitMapRastPort(ni
->bitmap
, sx
, sy
, rp
, _dx
, _dy
, dw
, dh
, 0xc0);
1885 void SetImageTint(struct NewImage
*dst
, UWORD ratio
, ULONG argb
)
1890 UWORD r
, g
, b
, w
, h
;
1891 UBYTE rs
, gs
, bs
, rd
, gd
, bd
;
1894 if (dst
== NULL
) return;
1901 rs
= (argb
>> 16) & 0xff;
1902 gs
= (argb
>> 8) & 0xff;
1905 for (y
= 0; y
< h
; y
++)
1907 for (x
= 0; x
< w
; x
++)
1913 r
= ((rs
* ratio
) >> 8) + ((rd
* (255 - ratio
)) >> 8);
1914 g
= ((gs
* ratio
) >> 8) + ((gd
* (255 - ratio
)) >> 8);
1915 b
= ((bs
* ratio
) >> 8) + ((bd
* (255 - ratio
)) >> 8);
1921 d
[x
+ y
* w
] = SET_ARGB(255, r
, g
, b
);
1926 void MixImage(struct NewImage
*dst
, struct NewImage
*src
, UWORD ratio
, UWORD w
, UWORD h
, UWORD dx
, UWORD dy
)
1931 UBYTE as
, rs
, gs
, bs
, rd
, gd
, bd
;
1935 if (src
== NULL
) return;
1936 if (dst
== NULL
) return;
1941 if (src
) if (src
->istiled
) tiled
= TRUE
;
1943 for (y
= 0; y
< h
; y
++)
1945 for (x
= 0; x
< w
; x
++)
1947 rgba
= s
[x
+y
*src
->w
];
1952 rgb
= d
[x
+dx
+ (y
+dy
) * dst
->w
];
1958 r
= ((rs
* ratio
) >> 8) + ((rd
* (255 - ratio
)) >> 8);
1959 g
= ((gs
* ratio
) >> 8) + ((gd
* (255 - ratio
)) >> 8);
1960 b
= ((bs
* ratio
) >> 8) + ((bd
* (255 - ratio
)) >> 8);
1963 r
= ((r
* as
) >> 8) + ((rd
* (255 - as
)) >> 8);
1964 g
= ((g
* as
) >> 8) + ((gd
* (255 - as
)) >> 8);
1965 b
= ((b
* as
) >> 8) + ((bd
* (255 - as
)) >> 8);
1972 d
[x
+dx
+ (y
+dy
) * dst
->w
] = SET_ARGB(as
, r
, g
, b
);
1977 void BlurSourceAndMixTexture(struct NewImage
*pic
, struct NewImage
*texture
, UWORD ratio
)
1979 int x
, y
, ytw
, t1
, t2
, b1
, b2
, l1
, l2
, r1
, r2
;
1980 UWORD red
, green
, blue
, alpha
= 0, rs
, gs
, bs
, as
;
1982 int width
, w
, height
, ah
, aw
, xpos
, ypos
;
1986 if (pic
== NULL
) return;
1987 if (pic
->data
== NULL
) return;
1990 if (texture
) if (texture
->istiled
) tiled
= TRUE
;
1998 for (y
= 0; y
< th
; y
++)
2004 if (y
== 0) t1
= t2
= 0;
2005 else if (y
== 1) t2
= t1
;
2007 if (y
== (th
-1)) b1
= b2
= 0;
2008 else if (y
== (th
-2)) b2
= b1
;
2012 for (x
= 0; x
< tw
; x
++)
2019 if (x
== 0) l1
= r1
= 0;
2020 else if (x
== 1) l2
= l1
;
2022 if (x
== (tw
-1)) r1
= r2
= 0;
2023 else if (x
== (tw
-2)) r2
= r1
;
2030 rgb
= raw
[x
+ytw
-t2
];
2032 green
+= GET_G(rgb
);
2035 rgb
= raw
[x
+ytw
-l1
-t1
];
2037 green
+= GET_G(rgb
);
2040 rgb
= raw
[x
+ytw
-t1
];
2042 green
+= GET_G(rgb
);
2045 rgb
= raw
[x
+ytw
-t1
];
2047 green
+= GET_G(rgb
);
2050 rgb
= raw
[x
+ytw
-t1
+r1
];
2052 green
+= GET_G(rgb
);
2055 rgb
= raw
[x
+ytw
-l2
];
2057 green
+= GET_G(rgb
);
2060 rgb
= raw
[x
+ytw
-l1
];
2062 green
+= GET_G(rgb
);
2065 rgb
= raw
[x
+ytw
+r1
];
2067 green
+= GET_G(rgb
);
2070 rgb
= raw
[x
+ytw
+r2
];
2072 green
+= GET_G(rgb
);
2075 rgb
= raw
[x
+ytw
+b1
-l1
];
2077 green
+= GET_G(rgb
);
2080 rgb
= raw
[x
+ytw
+b1
];
2082 green
+= GET_G(rgb
);
2085 rgb
= raw
[x
+ytw
+b1
+r1
];
2087 green
+= GET_G(rgb
);
2090 rgb
= raw
[x
+ytw
+b2
];
2092 green
+= GET_G(rgb
);
2103 as
= 255 - GET_A(texture
->data
[x
+ y
* texture
->w
]);
2108 red
= ((rs
* as
) >> 8) + ((red
* (255 - as
)) >> 8);
2109 green
= ((gs
* as
) >> 8) + ((green
* (255 - as
)) >> 8);
2110 blue
= ((bs
* as
) >> 8) + ((blue
* (255 - as
)) >> 8);
2112 raw
[x
+ytw
] = SET_ARGB(as
, red
, green
, blue
);
2117 raw
[x
+ytw
] = SET_ARGB(alpha
, red
, green
, blue
);
2130 if (ah
> height
) ah
= height
;
2137 MixImage(pic
, texture
, 255 - (2.55 * ratio
), aw
, ah
, xpos
, ypos
);
2148 void TileImageToImage(struct NewImage
*src
, struct NewImage
*dest
)
2153 if (dest
== NULL
) return;
2154 if (src
== NULL
) return;
2161 if (src
->istiled
== FALSE
) return;
2162 dest
->istiled
= TRUE
;
2164 if ((src
->tile_top
+ src
->tile_bottom
) > dest
->h
) return;
2165 if ((src
->tile_left
+ src
->tile_right
) > dest
->w
) return;
2167 DrawTileToImage(src
, dest
, 0, y
, src
->tile_left
, src
->tile_top
, 0 , 0, src
->tile_left
, src
->tile_top
);
2168 DrawTileToImage(src
, dest
, 0, y
+ h
- src
->tile_bottom
, src
->tile_left
, src
->tile_bottom
, 0 , dest
->h
- src
->tile_bottom
, src
->tile_left
, src
->tile_bottom
);
2169 DrawTileToImage(src
, dest
, src
->w
- src
->tile_right
, y
, src
->tile_right
, src
->tile_top
, dest
->w
- src
->tile_right
, 0, src
->tile_right
, src
->tile_top
);
2170 DrawTileToImage(src
, dest
, src
->w
- src
->tile_right
, y
+ h
- src
->tile_bottom
, src
->tile_right
, src
->tile_bottom
, dest
->w
- src
->tile_right
, dest
->h
- src
->tile_bottom
, src
->tile_right
, src
->tile_bottom
);
2172 DrawTileToImage(src
, dest
, src
->tile_left
, y
, src
->w
- src
->tile_left
- src
->tile_right
, src
->tile_top
, src
->tile_left
, 0, dest
->w
- src
->tile_left
- src
->tile_right
, src
->tile_top
);
2173 DrawTileToImage(src
, dest
, src
->tile_left
, y
+ h
- src
->tile_bottom
, src
->w
- src
->tile_left
- src
->tile_right
, src
->tile_bottom
, src
->tile_left
, dest
->h
- src
->tile_bottom
, dest
->w
- src
->tile_left
- src
->tile_right
, src
->tile_bottom
);
2174 DrawTileToImage(src
, dest
, 0, y
+ src
->tile_top
, src
->tile_left
, h
- src
->tile_bottom
- src
->tile_top
, 0 , src
->tile_top
+ 0, src
->tile_left
, dest
->h
- src
->tile_top
- src
->tile_bottom
- 0);
2175 DrawTileToImage(src
, dest
, src
->w
- src
->tile_right
, y
+ src
->tile_top
, src
->tile_right
, h
- src
->tile_bottom
- src
->tile_top
, dest
->w
- src
->tile_right
, src
->tile_top
+ 0, src
->tile_right
, dest
->h
- src
->tile_top
- src
->tile_bottom
- 0);
2176 DrawTileToImage(src
, dest
, src
->tile_left
, y
+ src
->tile_top
, src
->w
- src
->tile_left
- src
->tile_right
, h
- src
->tile_bottom
- src
->tile_top
, src
->tile_left
, src
->tile_top
+ 0, dest
->w
- src
->tile_left
- src
->tile_right
, dest
->h
- src
->tile_top
- src
->tile_bottom
- 0);
2179 void TileMapToBitmap(struct NewImage
*src
, struct BitMap
*map
, UWORD dw
, UWORD dh
)
2183 if (map
== NULL
) return;
2184 if (src
== NULL
) return;
2189 if (src
->istiled
== FALSE
) return;
2191 if ((src
->tile_top
+ src
->tile_bottom
) > dh
) return;
2192 if ((src
->tile_left
+ src
->tile_right
) > dw
) return;
2194 struct RastPort
*dest
= CreateRastPort();
2200 DrawMapTileToRP(src
, dest
, 0, y
, src
->tile_left
, src
->tile_top
, 0 , 0, src
->tile_left
, src
->tile_top
);
2201 DrawMapTileToRP(src
, dest
, 0, y
+ h
- src
->tile_bottom
, src
->tile_left
, src
->tile_bottom
, 0 , dh
- src
->tile_bottom
, src
->tile_left
, src
->tile_bottom
);
2202 DrawMapTileToRP(src
, dest
, src
->w
- src
->tile_right
, y
, src
->tile_right
, src
->tile_top
, dw
- src
->tile_right
, 0, src
->tile_right
, src
->tile_top
);
2203 DrawMapTileToRP(src
, dest
, src
->w
- src
->tile_right
, y
+ h
- src
->tile_bottom
, src
->tile_right
, src
->tile_bottom
, dw
- src
->tile_right
, dh
- src
->tile_bottom
, src
->tile_right
, src
->tile_bottom
);
2205 DrawMapTileToRP(src
, dest
, src
->tile_left
, y
, src
->w
- src
->tile_left
- src
->tile_right
, src
->tile_top
, src
->tile_left
, 0, dw
- src
->tile_left
- src
->tile_right
, src
->tile_top
);
2206 DrawMapTileToRP(src
, dest
, src
->tile_left
, y
+ h
- src
->tile_bottom
, src
->w
- src
->tile_left
- src
->tile_right
, src
->tile_bottom
, src
->tile_left
, dh
- src
->tile_bottom
, dw
- src
->tile_left
- src
->tile_right
, src
->tile_bottom
);
2207 DrawMapTileToRP(src
, dest
, 0, y
+ src
->tile_top
, src
->tile_left
, h
- src
->tile_bottom
- src
->tile_top
, 0 , src
->tile_top
+ 0, src
->tile_left
, dh
- src
->tile_top
- src
->tile_bottom
- 0);
2208 DrawMapTileToRP(src
, dest
, src
->w
- src
->tile_right
, y
+ src
->tile_top
, src
->tile_right
, h
- src
->tile_bottom
- src
->tile_top
, dw
- src
->tile_right
, src
->tile_top
+ 0, src
->tile_right
, dh
- src
->tile_top
- src
->tile_bottom
- 0);
2209 DrawMapTileToRP(src
, dest
, src
->tile_left
, y
+ src
->tile_top
, src
->w
- src
->tile_left
- src
->tile_right
, h
- src
->tile_bottom
- src
->tile_top
, src
->tile_left
, src
->tile_top
+ 0, dw
- src
->tile_left
- src
->tile_right
, dh
- src
->tile_top
- src
->tile_bottom
- 0);
2214 void RenderBackgroundTiled(struct NewImage
*pic
, struct NewImage
*texture
, UWORD ratio
)
2216 struct NewImage
*ni
;
2220 ni
= NewImageContainer(pic
->w
, pic
->h
);
2223 if (texture
->istiled
)
2225 TileImageToImage(texture
, ni
);
2226 BlurSourceAndMixTexture(pic
, ni
, ratio
);
2228 else BlurSourceAndMixTexture(pic
, texture
, ratio
);
2230 DisposeImageContainer(ni
);
2232 else BlurSourceAndMixTexture(pic
, texture
, ratio
);
2234 else BlurSourceAndMixTexture(pic
, NULL
, ratio
);
2237 void RenderBackground(struct NewImage
*pic
, struct NewImage
*texture
, UWORD ratio
)
2241 if (texture
->istiled
) RenderBackgroundTiled(pic
, texture
, ratio
); else BlurSourceAndMixTexture(pic
, texture
, ratio
);
2243 else BlurSourceAndMixTexture(pic
, NULL
, ratio
);
2246 /**************************************************************************************************/
2248 void DrawPartialTitleBar(struct WindowData
*wd
, struct windecor_data
*data
, struct Window
*window
, struct RastPort
*dst_rp
, struct DrawInfo
*dri
, UWORD align
, UWORD start
, UWORD width
, UWORD
*pens
)
2250 int xl0
, xl1
, xr0
, xr1
, defwidth
;
2251 ULONG textlen
= 0, titlelen
= 0, textpixellen
= 0;
2252 struct TextExtent te
;
2253 struct RastPort
*rp
;
2254 struct NewImage
*ni
= NULL
;
2262 UWORD textstart
= 0, barh
, x
;
2263 ULONG bc
, color
, s_col
, e_col
, arc
;
2268 if ((wd
->rp
== NULL
) || (window
->Width
!= wd
->w
) || (window
->BorderTop
!= wd
->h
))
2272 FreeBitMap(wd
->rp
->BitMap
);
2273 FreeRastPort(wd
->rp
);
2278 wd
->h
= window
->BorderTop
;
2279 wd
->w
= window
->Width
;
2283 rp
= CreateRastPort();
2286 SetFont(rp
, dri
->dri_Font
);
2287 rp
->BitMap
= AllocBitMap(window
->Width
, window
->BorderTop
, 1, 0, window
->WScreen
->RastPort
.BitMap
);
2288 if (rp
->BitMap
== NULL
)
2299 hastitle
= window
->Title
!= NULL
? TRUE
: FALSE
;
2300 hasclose
= (window
->Flags
& WFLG_CLOSEGADGET
) ? TRUE
: FALSE
;
2301 hasdepth
= (window
->Flags
& WFLG_DEPTHGADGET
) ? TRUE
: FALSE
;
2302 hasdrag
= (window
->Flags
& WFLG_DRAGBAR
) ? TRUE
: FALSE
;
2303 haszoom
= ((window
->Flags
& WFLG_HASZOOM
) || ((window
->Flags
& WFLG_SIZEGADGET
) && hasdepth
)) ? TRUE
: FALSE
;
2304 hastitlebar
= (window
->BorderTop
== data
->winbarheight
) ? TRUE
: FALSE
;
2306 if (wd
->img_border_normal
->ok
) ni
= wd
->img_border_normal
;
2308 if (ni
== NULL
) data
->usegradients
= TRUE
;
2312 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
2314 s_col
= data
->a_col_s
;
2315 e_col
= data
->a_col_e
;
2319 pen
= wd
->ActivePen
;
2321 s_col
= data
->d_col_s
;
2322 e_col
= data
->d_col_e
;
2324 dy
= data
->winbarheight
;
2326 if (!data
->usegradients
)
2328 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
2330 pen
= wd
->DeactivePen
;
2334 if (data
->filltitlebar
)
2336 if (data
->usegradients
) FillPixelArrayGradient(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
- 1, window
->Height
- 1, 0, 0, window
->Width
, window
->BorderTop
, s_col
, e_col
, arc
);
2337 else DrawTileToRP(rp
, ni
, color
, 0, 0, 0, 0, window
->Width
, window
->BorderTop
);
2340 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
2346 dy
= data
->winbarheight
;
2348 getleftgadgetsdimensions(data
, window
, &xl0
, &xl1
);
2349 getrightgadgetsdimensions(data
, window
, &xr0
, &xr1
);
2350 defwidth
= (xl0
!= xl1
) ? data
->BarPreGadget_s
: data
->BarPre_s
;
2353 xr1
= window
->Width
- data
->BarPre_s
;
2354 xr0
= window
->Width
- data
->BarPre_s
;
2357 defwidth
+= (xl1
- xl0
);
2359 defwidth
+= data
->BarJoinGB_s
;
2360 defwidth
+= data
->BarJoinBT_s
;
2361 defwidth
+= data
->BarJoinTB_s
;
2362 defwidth
+= data
->BarJoinBG_s
;
2363 defwidth
+= (xr1
- xr0
);
2364 defwidth
+= (xr0
!= xr1
) ? data
->BarPostGadget_s
: data
->BarPost_s
;
2366 if (defwidth
>= window
->Width
) hastitle
= FALSE
;
2370 titlelen
= strlen(window
->Title
);
2371 textlen
= TextFit(rp
, window
->Title
, titlelen
, &te
, NULL
, 1, window
->Width
-defwidth
, window
->BorderTop
- 2);
2374 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
2378 if (wd
->img_winbar_normal
->ok
&& hastitlebar
)
2380 barh
= data
->img_winbar_normal
->h
;
2383 if (barh
> data
->winbarheight
) barh
= data
->winbarheight
;
2388 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarPreGadget_o
, dy
, data
->BarPreGadget_s
, barh
, x
, 0, data
->BarPreGadget_s
, barh
);
2389 if ((xl1
-xl0
) > 0) x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarLGadgetFill_o
, dy
, data
->BarLGadgetFill_s
, barh
, x
, 0, xl1
-xl0
, barh
);
2393 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarPre_o
, dy
, data
->BarPre_s
, barh
, x
, 0, data
->BarPreGadget_s
, barh
);
2395 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarJoinGB_o
, dy
, data
->BarJoinGB_s
, barh
, x
, 0, data
->BarJoinGB_s
, barh
);
2396 if (hastitle
&& (textlen
> 0))
2400 case WD_DWTA_CENTER
:
2402 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarLFill_o
, dy
, data
->BarLFill_s
, barh
, x
, 0, 60, barh
);
2411 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarJoinBT_o
, dy
, data
->BarJoinBT_s
, barh
, x
, 0, data
->BarJoinBT_s
, barh
);
2413 if (textpixellen
> 0) x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarTitleFill_o
, dy
, data
->BarTitleFill_s
, barh
, x
, 0, textpixellen
, barh
);
2414 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarJoinTB_o
, dy
, data
->BarJoinTB_s
, barh
, x
, 0, data
->BarJoinTB_s
, barh
);
2416 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarRFill_o
, dy
, data
->BarRFill_s
, barh
, x
, 0, xr0
- x
- data
->BarJoinBG_s
, barh
);
2417 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarJoinBG_o
, dy
, data
->BarJoinBG_s
, barh
, x
, 0, data
->BarJoinBG_s
, barh
);
2418 if ((xr1
-xr0
) > 0) x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarRGadgetFill_o
, dy
, data
->BarRGadgetFill_s
, barh
, x
, 0, xr1
-xr0
, barh
);
2421 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarPostGadget_o
, dy
, data
->BarPostGadget_s
, barh
, x
, 0, data
->BarPostGadget_s
, barh
);
2425 x
= WriteTiledImageTitle(data
->filltitlebar
, window
, rp
, wd
->img_winbar_normal
, data
->BarPost_o
, dy
, data
->BarPost_s
, barh
, x
, 0, data
->BarPost_s
, barh
);
2429 if ((textlen
> 0) && hastitle
)
2431 SetAPen(rp
, pens
[(window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) ? FILLTEXTPEN
: TEXTPEN
]);
2433 UWORD tx
= textstart
;
2434 UWORD ty
= ((data
->winbarheight
- dri
->dri_Font
->tf_YSize
) >> 1) + dri
->dri_Font
->tf_Baseline
;
2436 if (!wd
->truecolor
|| ((data
->outline
== FALSE
) && (data
->shadow
== FALSE
)))
2439 Text(rp
, window
->Title
, textlen
);
2441 else if (data
->outline
)
2444 SetSoftStyle(rp
, FSF_BOLD
, AskSoftStyle(rp
));
2445 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->shadow_col
, TAG_DONE
);
2447 Move(rp
, tx
+ 1, ty
); Text(rp
, window
->Title
, textlen
);
2448 Move(rp
, tx
+ 2, ty
); Text(rp
, window
->Title
, textlen
);
2449 Move(rp
, tx
, ty
); Text(rp
, window
->Title
, textlen
);
2450 Move(rp
, tx
, ty
+ 1); Text(rp
, window
->Title
, textlen
);
2451 Move(rp
, tx
, ty
+ 2); Text(rp
, window
->Title
, textlen
);
2452 Move(rp
, tx
+ 1, ty
+ 2); Text(rp
, window
->Title
, textlen
);
2453 Move(rp
, tx
+ 2, ty
+ 1); Text(rp
, window
->Title
, textlen
);
2454 Move(rp
, tx
+ 2, ty
+ 2); Text(rp
, window
->Title
, textlen
);
2456 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->text_col
, TAG_DONE
);
2457 Move(rp
, tx
+ 1, ty
+ 1);
2458 Text(rp
, window
->Title
, textlen
);
2459 SetSoftStyle(rp
, FS_NORMAL
, AskSoftStyle(rp
));
2463 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->shadow_col
, TAG_DONE
);
2464 Move(rp
, tx
+ 1, ty
+ 1 );
2465 Text(rp
, window
->Title
, textlen
);
2467 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->text_col
, TAG_DONE
);
2469 Text(rp
, window
->Title
, textlen
);
2475 for (g
= window
->FirstGadget
; g
; g
= g
->NextGadget
)
2477 if (g
->Activation
& GACT_TOPBORDER
&& (g
->GadgetType
& GTYP_SYSTYPEMASK
) != GTYP_WDRAGGING
)
2481 if (!(g
->Flags
& GFLG_RELRIGHT
))
2487 x
= g
->LeftEdge
+ window
->Width
- 1;
2489 struct NewImage
*ni
= NULL
;
2490 UWORD state
= IDS_NORMAL
;
2492 if ((window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) == 0)
2494 state
= IDS_INACTIVENORMAL
;
2496 else if (g
->Flags
& GFLG_SELECTED
) state
= IDS_SELECTED
;
2498 if (g
->GadgetType
& GTYP_SYSTYPEMASK
) {
2499 switch(g
->GadgetType
& GTYP_SYSTYPEMASK
)
2525 ni
= wd
->img_snapshot
;
2529 ni
= wd
->img_iconify
;
2538 if (ni
) DrawAlphaStateImageToRP(data
, rp
, ni
, state
, x
, y
, TRUE
);
2541 BltBitMapRastPort(rp
->BitMap
, start
, 0, dst_rp
, start
, 0, width
, window
->BorderTop
, 0xc0);
2544 /**************************************************************************************************/
2547 IPTR
windecor_layout_bordergadgets(Class
*cl
, Object
*obj
, struct wdpLayoutBorderGadgets
*msg
)
2549 struct windecor_data
*data
= INST_DATA(cl
, obj
);
2550 struct Window
*window
= msg
->wdp_Window
;
2551 struct Gadget
*gadget
= msg
->wdp_Gadgets
;
2552 struct Gadget
*draggadget
= NULL
;
2553 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
2554 ULONG eb
= msg
->wdp_ExtraButtons
;
2564 LONG rightborder
= 0;
2565 LONG bottomborder
= 0;
2567 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
2569 hastitle
= window
->Title
!= NULL
? TRUE
: FALSE
;
2570 hasclose
= (window
->Flags
& WFLG_CLOSEGADGET
) ? TRUE
: FALSE
;
2571 hassize
= (window
->Flags
& WFLG_SIZEGADGET
) ? TRUE
: FALSE
;
2572 hasdepth
= (window
->Flags
& WFLG_DEPTHGADGET
) ? TRUE
: FALSE
;
2573 hasdrag
= (window
->Flags
& WFLG_DRAGBAR
) ? TRUE
: FALSE
;
2574 borderless
= (window
->Flags
& WFLG_BORDERLESS
) ? TRUE
: FALSE
;
2575 haszoom
= ((window
->Flags
& WFLG_HASZOOM
) || ((window
->Flags
& WFLG_SIZEGADGET
) && hasdepth
)) ? TRUE
: FALSE
;
2578 if ((msg
->wdp_Flags
& WDF_LBG_SYSTEMGADGET
) != 0)
2580 if (gadget
->GadgetType
== GTYP_CUSTOMGADGET
)
2582 switch(gadget
->GadgetID
)
2585 if (wd
->img_mui
->ok
)
2587 if (data
->threestate
) width
= (wd
->img_mui
->w
/ 3); else width
= (wd
->img_mui
->w
>> 2);
2589 gadget
->Width
= width
;
2590 gadget
->Height
= wd
->img_mui
->h
;
2591 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2595 if (data
->threestate
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
2597 if (hasclose
&& data
->closeright
)
2599 if (data
->threestate
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
2603 if (data
->threestate
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
2604 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2608 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2610 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2611 gadget
->Flags
|= GFLG_RELRIGHT
;
2617 if (wd
->img_popup
->ok
)
2619 if (data
->threestate
) width
= (wd
->img_popup
->w
/ 3); else width
= (wd
->img_popup
->w
>> 2);
2621 gadget
->Width
= width
;
2622 gadget
->Height
= wd
->img_popup
->h
;
2623 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2625 if ((eb
& ETG_MUI
) != 0)
2627 if (wd
->img_mui
->ok
)
2629 if (data
->threestate
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
2635 if (data
->threestate
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
2638 if (hasclose
&& data
->closeright
)
2640 if (data
->threestate
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
2644 if (data
->threestate
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
2645 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2649 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2651 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2652 gadget
->Flags
|= GFLG_RELRIGHT
;
2658 if (wd
->img_snapshot
->ok
)
2660 if (data
->threestate
) width
= (wd
->img_snapshot
->w
/ 3); else width
= (wd
->img_snapshot
->w
>> 2);
2662 gadget
->Width
= width
;
2663 gadget
->Height
= wd
->img_snapshot
->h
;
2664 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2666 if ((eb
& ETG_MUI
) != 0)
2669 if (wd
->img_mui
->ok
)
2671 if (data
->threestate
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
2675 if ((eb
& ETG_POPUP
) != 0)
2677 if (wd
->img_popup
->ok
)
2679 if (data
->threestate
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
2685 if (data
->threestate
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
2688 if (hasclose
&& data
->closeright
)
2690 if (data
->threestate
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
2695 if (data
->threestate
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
2696 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2700 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2703 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2704 gadget
->Flags
|= GFLG_RELRIGHT
;
2710 if (wd
->img_iconify
->ok
)
2712 if (data
->threestate
) width
= (wd
->img_iconify
->w
/ 3); else width
= (wd
->img_iconify
->w
>> 2);
2714 gadget
->Width
= width
;
2715 gadget
->Height
= wd
->img_iconify
->h
;
2716 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2718 if ((eb
& ETG_MUI
) != 0)
2720 if (wd
->img_mui
->ok
)
2722 if (data
->threestate
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
2726 if ((eb
& ETG_POPUP
) != 0)
2728 if (wd
->img_popup
->ok
)
2730 if (data
->threestate
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
2734 if ((eb
& ETG_SNAPSHOT
) != 0)
2736 if (wd
->img_snapshot
->ok
)
2738 if (data
->threestate
) width
+= (wd
->img_snapshot
->w
/ 3); else width
+= (wd
->img_snapshot
->w
>> 2);
2744 if (data
->threestate
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
2747 if (hasclose
&& data
->closeright
)
2749 if (data
->threestate
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
2753 if (data
->threestate
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
2754 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2758 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2760 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2761 gadget
->Flags
|= GFLG_RELRIGHT
;
2767 if (wd
->img_lock
->ok
)
2769 if (data
->threestate
) width
= (wd
->img_lock
->w
/ 3); else width
= (wd
->img_lock
->w
>> 2);
2771 gadget
->Width
= width
;
2772 gadget
->Height
= wd
->img_lock
->h
;
2773 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2775 if ((eb
& ETG_MUI
) != 0)
2777 if (wd
->img_mui
->ok
)
2779 if (data
->threestate
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
2783 if ((eb
& ETG_POPUP
) != 0)
2785 if (wd
->img_popup
->ok
)
2787 if (data
->threestate
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
2791 if ((eb
& ETG_SNAPSHOT
) != 0)
2793 if (wd
->img_snapshot
->ok
)
2795 if (data
->threestate
) width
+= (wd
->img_snapshot
->w
/ 3); else width
+= (wd
->img_snapshot
->w
>> 2);
2799 if ((eb
& ETG_ICONIFY
) != 0)
2801 if (wd
->img_iconify
->ok
)
2803 if (data
->threestate
) width
+= (wd
->img_iconify
->w
/ 3); else width
+= (wd
->img_iconify
->w
>> 2);
2809 if (data
->threestate
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
2812 if (hasclose
&& data
->closeright
)
2814 if (data
->threestate
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
2818 if (data
->threestate
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
2819 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2823 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2825 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2826 gadget
->Flags
|= GFLG_RELRIGHT
;
2835 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
2838 if (data
->threestate
) width
= (data
->img_close
->w
/ 3); else width
= (data
->img_close
->w
>> 2);
2839 gadget
->Width
= width
;
2840 wd
->closewidth
= width
;
2841 gadget
->Height
= data
->img_close
->h
;
2842 if (data
->closeright
)
2844 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2845 gadget
->Flags
|= GFLG_RELRIGHT
;
2846 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2850 gadget
->LeftEdge
= data
->BarPreGadget_s
;
2852 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2856 if (data
->threestate
) width
= (data
->img_depth
->w
/ 3); else width
= (data
->img_depth
->w
>> 2);
2857 gadget
->Width
= width
;
2858 wd
->depthwidth
= width
;
2859 gadget
->Height
= data
->img_depth
->h
;
2860 if (hasclose
&& data
->closeright
)
2862 if (data
->threestate
) width
+= (data
->img_close
->w
/ 3); else width
+= (data
->img_close
->w
>> 2);
2864 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2865 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2866 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2867 gadget
->Flags
|= GFLG_RELRIGHT
;
2871 if (data
->threestate
) width
= (data
->img_zoom
->w
/ 3); else width
= (data
->img_zoom
->w
>> 2);
2872 gadget
->Width
= width
;
2873 wd
->zoomwidth
= width
;
2874 gadget
->Height
= data
->img_zoom
->h
;
2875 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2876 if (hasclose
&& data
->closeright
)
2878 if (data
->threestate
) width
+= (data
->img_close
->w
/ 3); else width
+= (data
->img_close
->w
>> 2);
2882 if (data
->threestate
) width
+= (data
->img_depth
->w
/ 3); else width
+= (data
->img_depth
->w
>> 2);
2883 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2887 gadget
->LeftEdge
= -data
->BarPostGadget_s
- width
;
2889 gadget
->Flags
&= ~GFLG_RELWIDTH
;
2890 gadget
->Flags
|= GFLG_RELRIGHT
;
2895 rightborder
= data
->rightbordergads
;
2896 if ((gadget
->Flags
& WFLG_SIZEBBOTTOM
) != 0) bottomborder
= data
->bottombordergads
;
2899 case GTYP_WDRAGGING
:
2907 int sysrgad
= -data
->BarPostGadget_s
- 1;
2909 if (data
->closeright
&& hasclose
) sysrgad
-= wd
->closewidth
;
2910 if (hasdepth
) sysrgad
-= wd
->depthwidth
;
2911 if (haszoom
) sysrgad
-= wd
->zoomwidth
;
2914 if ((gadget
->GadgetType
& GTYP_SYSTYPEMASK
) == 0)
2916 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
2918 case GTYP_WDRAGGING
:
2922 if ((gadget
->Flags
& GFLG_EXTENDED
) != 0)
2924 if ((((struct ExtGadget
*) gadget
)->MoreFlags
& GMORE_BOOPSIGADGET
) != 0)
2927 get((Object
*) gadget
, GA_RightBorder
, &rtsm
);
2930 if (get((Object
*) gadget
, PGA_Top
, &rtsm
))
2932 SetAttrs((Object
*) gadget
, GA_RelRight
, - data
->rightbordergads
+ ((data
->rightbordergads
- (data
->img_verticalcontainer
->w
>> 1) + 1) >> 1) + 1, GA_Width
, data
->img_verticalcontainer
->w
>> 1, TAG_DONE
);
2936 get((Object
*) gadget
, GA_Width
, &rtsm
);
2937 SetAttrs((Object
*) gadget
, GA_RelRight
, - data
->rightbordergads
+ ((data
->rightbordergads
- rtsm
+ 1) >> 1) + 1, TAG_DONE
);
2942 get((Object
*) gadget
, GA_BottomBorder
, &rtsm
);
2945 if (get((Object
*) gadget
, PGA_Top
, &rtsm
))
2947 SetAttrs((Object
*) gadget
, GA_RelBottom
, - data
->bottombordergads
+ ((data
->bottombordergads
- (data
->img_horizontalcontainer
->h
>> 1) + 1) >> 1) +1, GA_Height
, (data
->img_horizontalcontainer
->h
>> 1), TAG_DONE
);
2951 get((Object
*) gadget
, GA_Height
, &rtsm
);
2952 SetAttrs((Object
*) gadget
, GA_RelBottom
, - data
->bottombordergads
+ ((data
->bottombordergads
- rtsm
+ 1) >> 1) + 1, TAG_DONE
);
2961 if (msg
->wdp_Flags
& WDF_LBG_MULTIPLE
)
2963 gadget
= gadget
->NextGadget
;
2970 gadget
= msg
->wdp_Gadgets
;
2974 if ((gadget
->GadgetType
& GTYP_SYSTYPEMASK
) == 0)
2976 if ((gadget
->Activation
& GACT_TOPBORDER
) != 0)
2978 if ((gadget
->Flags
& GFLG_RELRIGHT
) != 0)
2980 gadget
->TopEdge
= (data
->winbarheight
- gadget
->Height
) / 2;
2981 sysrgad
-= gadget
->Width
;
2982 gadget
->LeftEdge
= sysrgad
;
2986 gadget
= gadget
->NextGadget
;
2989 gadget
= msg
->wdp_Gadgets
;
2991 if ((msg
->wdp_Flags
& WDF_LBG_SYSTEMGADGET
) != 0) while(gadget
)
2993 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
2995 case GTYP_WDRAGGING
:
2996 gadget
->Width
= sysrgad
;
2997 if (hasclose
&& !data
->closeright
)
2999 gadget
->Width
-= data
->BarPreGadget_s
;
3000 if (data
->threestate
) gadget
->Width
-= (data
->img_close
->w
/ 3); else gadget
->Width
-= (data
->img_close
->w
>> 2);
3004 gadget
= gadget
->NextGadget
;
3014 /**************************************************************************************************/
3016 IPTR
windecor_draw_borderpropback(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropBack
*msg
)
3018 /* Simply return, we need to render the back in the knob method */
3019 /* because we want to use irregular (alpha images) for the sliders */
3023 /**************************************************************************************************/
3025 IPTR
windecor_draw_borderpropknob(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropKnob
*msg
)
3027 struct windecor_data
*data
= INST_DATA(cl
, obj
);
3028 struct Window
*window
= msg
->wdp_Window
;
3029 struct RastPort
*winrp
= msg
->wdp_RPort
;
3030 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
3032 struct RastPort
*rp
;
3033 struct Gadget
*gadget
= msg
->wdp_Gadget
;
3034 struct Rectangle
*r
;
3035 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
3036 struct NewImage
*ni
= NULL
;
3037 BOOL hit
= (msg
->wdp_Flags
& WDF_DBPK_HIT
) ? TRUE
: FALSE
;
3038 ULONG y
, x
, bx0
, bx1
, by0
, by1
;
3040 ULONG bc
, color
, s_col
, e_col
, arc
;
3043 if (!(pi
->Flags
& PROPNEWLOOK
) || (gadget
->Activation
&& (GACT_RIGHTBORDER
| GACT_BOTTOMBORDER
) == 0))
3045 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
3048 r
= msg
->wdp_PropRect
;
3055 rp
= CreateRastPort();
3058 struct Rectangle cliprect
= {0, 0, bx1
- bx0
, by1
- by0
};
3059 struct TagItem rptags
[] =
3061 {RPTAG_ClipRectangle
, (IPTR
)&cliprect
},
3065 rp
->BitMap
= AllocBitMap(bx1
- bx0
+ 1, by1
- by0
+ 1, 1, 0, window
->WScreen
->RastPort
.BitMap
);
3066 if (rp
->BitMap
== NULL
)
3072 SetRPAttrsA(rp
, rptags
);
3078 if (wd
->img_border_normal
->ok
) ni
= wd
->img_border_normal
;
3080 if (ni
== NULL
) data
->usegradients
= TRUE
;
3082 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
3084 s_col
= data
->a_col_s
;
3085 e_col
= data
->a_col_e
;
3088 pen
= wd
->ActivePen
;
3092 s_col
= data
->d_col_s
;
3093 e_col
= data
->d_col_e
;
3096 if (!data
->usegradients
)
3098 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
3100 pen
= wd
->DeactivePen
;
3103 if (data
->usegradients
)
3106 FillPixelArrayGradientDelta(pen
, wd
->truecolor
, rp
, 0, 0, window
->Width
-1, window
->Height
-1, 0, 0, bx1
- bx0
+ 1, by1
- by0
+ 1, s_col
, e_col
, arc
, 0, 0);
3115 ULONG color
= 0x00cccccc;
3117 DrawTileToRPRoot(rp
, ni
, color
, 0, 0, bx0
, by0
, bx1
- bx0
+ 1, by1
- by0
+ 1);
3122 r
= msg
->wdp_PropRect
;
3126 bx1
= r
->MaxX
- r
->MinX
;
3127 by1
= r
->MaxY
- r
->MinY
;
3129 if ((pi
->Flags
& FREEVERT
) != 0)
3132 is
= data
->img_verticalcontainer
->w
>> 1;
3133 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) pos
= 0; else pos
= is
;
3135 size
= by1
- by0
- data
->ContainerTop_s
- data
->ContainerBottom_s
+ 1;
3136 y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, pos
, data
->ContainerTop_o
, is
, data
->ContainerTop_s
, bx0
, y
, is
, data
->ContainerTop_s
);
3137 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, pos
, data
->ContainerVertTile_o
, is
, data
->ContainerVertTile_s
, bx0
, y
, is
, size
);
3139 y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, pos
, data
->ContainerBottom_o
, is
, data
->ContainerBottom_s
, bx0
, y
, is
, data
->ContainerBottom_s
);
3142 else if ((pi
->Flags
& FREEHORIZ
) != 0)
3145 is
= data
->img_horizontalcontainer
->h
>> 1;
3146 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) pos
= 0; else pos
= is
;
3148 size
= bx1
- bx0
- data
->ContainerLeft_s
- data
->ContainerRight_s
+ 1;
3149 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, data
->ContainerLeft_o
, pos
, data
->ContainerLeft_s
, is
, x
, by0
, data
->ContainerLeft_s
, is
);
3150 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, data
->ContainerHorTile_o
, pos
, data
->ContainerHorTile_s
, is
, x
, by0
, size
, is
);
3151 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, data
->ContainerRight_o
, pos
, data
->ContainerRight_s
, is
, x
, by0
, data
->ContainerRight_s
, is
);
3154 bx0
= msg
->wdp_PropRect
->MinX
;
3155 by0
= msg
->wdp_PropRect
->MinY
;
3156 bx1
= msg
->wdp_PropRect
->MaxX
;
3157 by1
= msg
->wdp_PropRect
->MaxY
;
3159 r
= msg
->wdp_RenderRect
;
3160 if ((pi
->Flags
& FREEVERT
) != 0)
3162 is
= data
->img_verticalknob
->w
/ 3;
3163 if (hit
) pos
= is
; else if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) pos
= 0; else pos
= is
* 2;
3165 size
= r
->MaxY
- r
->MinY
- data
->KnobTop_s
- data
->KnobBottom_s
+ 1;
3167 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobTop_o
, is
, data
->KnobTop_s
, r
->MinX
- bx0
, y
, is
, data
->KnobTop_s
);
3170 if (size
> data
->KnobVertGripper_s
)
3172 size
= size
- data
->KnobVertGripper_s
;
3173 int size_bak
= size
;
3175 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobTileTop_o
, is
, data
->KnobTileTop_s
, r
->MinX
- bx0
, y
, is
, size
);
3176 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobVertGripper_o
, is
, data
->KnobVertGripper_s
, r
->MinX
- bx0
, y
, is
, data
->KnobVertGripper_s
);
3177 size
= size_bak
- size
;
3178 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobTileBottom_o
, is
, data
->KnobTileBottom_s
, r
->MinX
- bx0
, y
, is
, size
);
3182 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobTileTop_o
, is
, data
->KnobTileTop_s
, r
->MinX
- bx0
, y
, is
, size
);
3185 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, pos
, data
->KnobBottom_o
, is
, data
->KnobBottom_s
, r
->MinX
- bx0
, y
, is
, data
->KnobBottom_s
);
3187 else if ((pi
->Flags
& FREEHORIZ
) != 0)
3190 is
= data
->img_horizontalknob
->h
/ 3;
3191 if (hit
) pos
= is
; else if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) pos
= 0; else pos
= is
* 2;
3193 size
= r
->MaxX
- r
->MinX
- data
->KnobLeft_s
- data
->KnobRight_s
+ 1;
3194 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobLeft_o
, pos
, data
->KnobLeft_s
, is
, x
, r
->MinY
- by0
, data
->KnobLeft_s
, is
);
3198 if (size
> data
->KnobHorGripper_s
)
3200 size
= size
- data
->KnobHorGripper_s
;
3201 int size_bak
= size
;
3203 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobTileLeft_o
, pos
, data
->KnobTileLeft_s
, is
, x
, r
->MinY
- by0
, size
, is
);
3204 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobHorGripper_o
, pos
, data
->KnobHorGripper_s
, is
, x
, r
->MinY
- by0
, data
->KnobHorGripper_s
, is
);
3205 size
= size_bak
- size
;
3206 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobTileRight_o
, pos
, data
->KnobTileRight_s
, is
, x
, r
->MinY
- by0
, size
, is
);
3210 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobTileRight_o
, pos
, data
->KnobTileRight_s
, is
, x
, r
->MinY
- by0
, size
, is
);
3213 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, data
->KnobRight_o
, pos
, data
->KnobRight_s
, is
, x
, r
->MinY
- by0
, data
->KnobRight_s
, is
);
3216 BltBitMapRastPort(rp
->BitMap
, 0, 0, winrp
, msg
->wdp_PropRect
->MinX
, msg
->wdp_PropRect
->MinY
, bx1
- bx0
+ 1, by1
- by0
+ 1, 0xc0);
3218 FreeBitMap(rp
->BitMap
);
3224 IPTR
windecor_getdefsizes(Class
*cl
, Object
*obj
, struct wdpGetDefSizeSysImage
*msg
)
3226 struct windecor_data
*data
= INST_DATA(cl
, obj
);
3227 struct NewImage
*n
= NULL
;
3230 switch(msg
->wdp_Which
)
3234 w
= data
->rightbordergads
;
3235 h
= data
->bottombordergads
;
3240 n
= data
->img_close
;
3250 n
= data
->img_popup
;
3255 n
= data
->img_snapshot
;
3260 n
= data
->img_iconify
;
3271 w
= data
->rightbordergads
;
3272 h
= data
->img_up
->h
+ data
->updownaddy
;
3278 w
= data
->rightbordergads
;
3279 h
= data
->img_down
->h
+ data
->updownaddy
;
3285 if (data
->threestate
) w
= (data
->img_left
->w
/ 3); else w
= (data
->img_left
->w
>> 2);
3286 w
+= data
->leftrightaddx
;
3287 h
= data
->bottombordergads
;
3293 if (data
->threestate
) w
= (data
->img_right
->w
/ 3); else w
= (data
->img_right
->w
>> 2);
3294 w
+= data
->leftrightaddx
;
3295 h
= data
->bottombordergads
;
3300 n
= data
->img_depth
;
3313 if (!isset
) return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3317 *msg
->wdp_Width
= w
;
3318 *msg
->wdp_Height
= h
;
3323 if (data
->threestate
)
3325 *msg
->wdp_Width
= (n
->w
/ 3);
3326 *msg
->wdp_Height
= n
->h
;
3330 *msg
->wdp_Width
= (n
->w
>> 2);
3331 *msg
->wdp_Height
= n
->h
;
3333 } else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3339 struct Region
*RegionFromLUT8Image(int w
, int h
, struct NewLUT8Image
*s
)
3341 struct Region
*shape
;
3343 BOOL transp
, transpstate
;
3344 BOOL failed
= FALSE
;
3346 if (s
== NULL
) return NULL
;
3348 UBYTE
*src
= s
->data
;
3350 shape
= NewRegion();
3353 struct Rectangle rect
= {0, s
->h
, w
-1, h
-1};
3354 if (!OrRectRegion(shape
, &rect
)) failed
= TRUE
;
3355 for(y
= 0; y
< s
->h
; y
++)
3357 struct Rectangle rect
= {0, y
, 0, y
};
3359 for(x
= 0; x
< s
->w
; x
++)
3361 transp
= src
[y
* s
->w
+ x
] == 0;
3366 rect
.MaxX
= rect
.MinX
= x
;
3367 transpstate
= FALSE
;
3372 OrRectRegion(shape
, &rect
);
3381 if (!transpstate
) if (!OrRectRegion(shape
, &rect
)) failed
= TRUE
;
3385 DisposeRegion(shape
);
3393 void DrawShapePartialTitleBar(struct WindowData
*wd
, struct NewLUT8Image
*shape
, struct windecor_data
*data
, struct Window
*window
, UWORD align
, UWORD start
, UWORD width
)
3395 int xl0
, xl1
, xr0
, xr1
, defwidth
;
3396 ULONG textlen
= 0, titlelen
= 0, textpixellen
= 0;
3397 struct TextExtent te
;
3401 UWORD textstart
= 0, barh
, x
;
3404 struct RastPort
*rp
= &window
->WScreen
->RastPort
;
3405 hastitle
= window
->Title
!= NULL
? TRUE
: FALSE
;
3406 hastitlebar
= (window
->BorderTop
== data
->winbarheight
) ? TRUE
: FALSE
;
3408 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
3414 dy
= data
->winbarheight
;
3416 getleftgadgetsdimensions(data
, window
, &xl0
, &xl1
);
3417 getrightgadgetsdimensions(data
, window
, &xr0
, &xr1
);
3419 defwidth
= (xl0
!= xl1
) ? data
->BarPreGadget_s
: data
->BarPre_s
;
3422 xr1
= window
->Width
- data
->BarPre_s
;
3423 xr0
= window
->Width
- data
->BarPre_s
;
3426 defwidth
+= (xl1
- xl0
);
3428 defwidth
+= data
->BarJoinGB_s
;
3429 defwidth
+= data
->BarJoinBT_s
;
3430 defwidth
+= data
->BarJoinTB_s
;
3431 defwidth
+= data
->BarJoinBG_s
;
3432 defwidth
+= (xr1
- xr0
);
3433 defwidth
+= (xr0
!= xr1
) ? data
->BarPostGadget_s
: data
->BarPost_s
;
3435 if (defwidth
>= window
->Width
) hastitle
= FALSE
;
3439 titlelen
= strlen(window
->Title
);
3440 textlen
= TextFit(rp
, window
->Title
, titlelen
, &te
, NULL
, 1, window
->Width
-defwidth
, window
->BorderTop
- 2);
3443 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
3448 if (data
->img_winbar_normal
->ok
&& hastitlebar
)
3450 barh
= data
->img_winbar_normal
->h
;
3453 if (barh
> data
->winbarheight
) barh
= data
->winbarheight
;
3458 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarPreGadget_o
, dy
, data
->BarPreGadget_s
, barh
, x
, 0, data
->BarPreGadget_s
, barh
);
3459 if ((xl1
-xl0
) > 0) x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarLGadgetFill_o
, dy
, data
->BarLGadgetFill_s
, barh
, x
, 0, xl1
-xl0
, barh
);
3463 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarPre_o
, dy
, data
->BarPre_s
, barh
, x
, 0, data
->BarPreGadget_s
, barh
);
3465 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarJoinGB_o
, dy
, data
->BarJoinGB_s
, barh
, x
, 0, data
->BarJoinGB_s
, barh
);
3466 if (hastitle
&& (textlen
> 0))
3470 case WD_DWTA_CENTER
:
3472 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarLFill_o
, dy
, data
->BarLFill_s
, barh
, x
, 0, 60, barh
);
3481 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarJoinBT_o
, dy
, data
->BarJoinBT_s
, barh
, x
, 0, data
->BarJoinBT_s
, barh
);
3483 if (textpixellen
> 0) x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarTitleFill_o
, dy
, data
->BarTitleFill_s
, barh
, x
, 0, textpixellen
, barh
);
3484 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarJoinTB_o
, dy
, data
->BarJoinTB_s
, barh
, x
, 0, data
->BarJoinTB_s
, barh
);
3486 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarRFill_o
, dy
, data
->BarRFill_s
, barh
, x
, 0, xr0
- x
- data
->BarJoinBG_s
, barh
);
3487 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarJoinBG_o
, dy
, data
->BarJoinBG_s
, barh
, x
, 0, data
->BarJoinBG_s
, barh
);
3488 if ((xr1
-xr0
) > 0) x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarRGadgetFill_o
, dy
, data
->BarRGadgetFill_s
, barh
, x
, 0, xr1
-xr0
, barh
);
3491 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarPostGadget_o
, dy
, data
->BarPostGadget_s
, barh
, x
, 0, data
->BarPostGadget_s
, barh
);
3495 x
= WriteTiledImageShape(data
->filltitlebar
, window
, shape
, data
->img_winbar_normal
, data
->BarPost_o
, dy
, data
->BarPost_s
, barh
, x
, 0, data
->BarPost_s
, barh
);
3503 /**************************************************************************************************/
3504 IPTR
windecor_windowshape(Class
*cl
, Object
*obj
, struct wdpWindowShape
*msg
)
3506 struct windecor_data
*data
= INST_DATA(cl
, obj
);
3507 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
3508 struct Window
*window
= msg
->wdp_Window
;
3510 if (data
->barmasking
)
3512 struct NewLUT8ImageContainer
*shape
;
3514 shape
= (struct NewLUT8ImageContainer
*)NewLUT8ImageContainer(window
->Width
, window
->BorderTop
);
3517 if (window
->BorderTop
== data
->winbarheight
) DrawShapePartialTitleBar(wd
, (struct NewLUT8Image
*)shape
, data
, window
, data
->txt_align
, 0, window
->Width
);
3518 back
=(IPTR
) RegionFromLUT8Image(msg
->wdp_Width
, msg
->wdp_Height
, (struct NewLUT8Image
*)shape
);
3520 DisposeLUT8ImageContainer((struct NewLUT8Image
*)shape
);
3527 if (!data
->rounded
) return (IPTR
) NULL
;
3529 struct Region
*newshape
;
3531 int x2
= msg
->wdp_Width
-1;
3532 int y2
= msg
->wdp_Height
-1;
3534 if ((newshape
= NewRegion()))
3536 struct Rectangle rect
;
3537 BOOL success
= TRUE
;
3543 success
&= OrRectRegion(newshape
, &rect
);
3549 success
&= OrRectRegion(newshape
, &rect
);
3555 success
&= OrRectRegion(newshape
, &rect
);
3561 success
&= OrRectRegion(newshape
, &rect
);
3567 success
&= OrRectRegion(newshape
, &rect
);
3573 success
&= OrRectRegion(newshape
, &rect
);
3579 success
&= OrRectRegion(newshape
, &rect
);
3581 return (IPTR
) newshape
;
3584 /**************************************************************************************************/
3586 IPTR
windecor_initwindow(Class
*cl
, Object
*obj
, struct wdpInitWindow
*msg
)
3588 struct WindowData
*wd
= (struct WindowData
*)msg
->wdp_UserBuffer
;
3589 struct ScreenData
*sd
= (struct ScreenData
*)msg
->wdp_ScreenUserBuffer
;
3591 wd
->truecolor
= msg
->wdp_TrueColor
;
3593 wd
->ActivePen
= sd
->ActivePen
;
3594 wd
->DeactivePen
= sd
->DeactivePen
;
3597 SETIMAGE_WIN(close
);
3598 SETIMAGE_WIN(depth
);
3603 SETIMAGE_WIN(right
);
3605 SETIMAGE_WIN(popup
);
3606 SETIMAGE_WIN(snapshot
);
3607 SETIMAGE_WIN(iconify
);
3609 SETIMAGE_WIN(winbar_normal
);
3610 SETIMAGE_WIN(border_normal
);
3611 SETIMAGE_WIN(border_deactivated
);
3612 SETIMAGE_WIN(verticalcontainer
);
3613 SETIMAGE_WIN(verticalknob
);
3614 SETIMAGE_WIN(horizontalcontainer
);
3615 SETIMAGE_WIN(horizontalknob
);
3620 /**************************************************************************************************/
3622 IPTR
windecor_exitwindow(Class
*cl
, Object
*obj
, struct wdpExitWindow
*msg
)
3624 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
3628 if (wd
->rp
->BitMap
) FreeBitMap(wd
->rp
->BitMap
);
3629 FreeRastPort(wd
->rp
);
3635 IPTR
windecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
3639 switch(msg
->MethodID
)
3642 retval
= windecor_new(cl
, obj
, (struct opSet
*)msg
);
3646 retval
= windecor_dispose(cl
, obj
, (struct opSet
*)msg
);
3650 retval
= windecor_get(cl
, obj
, (struct opGet
*)msg
);
3653 case WDM_DRAW_SYSIMAGE
:
3654 retval
= windecor_draw_sysimage(cl
, obj
, (struct wdpDrawSysImage
*)msg
);
3657 case WDM_DRAW_WINBORDER
:
3658 retval
= windecor_draw_winborder(cl
, obj
, (struct wdpDrawWinBorder
*)msg
);
3661 case WDM_LAYOUT_BORDERGADGETS
:
3662 retval
= windecor_layout_bordergadgets(cl
, obj
, (struct wdpLayoutBorderGadgets
*)msg
);
3665 case WDM_DRAW_BORDERPROPBACK
:
3666 retval
= windecor_draw_borderpropback(cl
, obj
, (struct wdpDrawBorderPropBack
*)msg
);
3669 case WDM_DRAW_BORDERPROPKNOB
:
3670 retval
= windecor_draw_borderpropknob(cl
, obj
, (struct wdpDrawBorderPropKnob
*)msg
);
3673 case WDM_GETDEFSIZE_SYSIMAGE
:
3674 retval
= windecor_getdefsizes(cl
, obj
, (struct wdpGetDefSizeSysImage
*) msg
);
3677 case WDM_WINDOWSHAPE
:
3678 retval
= windecor_windowshape(cl
, obj
, (struct wdpWindowShape
*) msg
);
3681 case WDM_INITWINDOW
:
3682 retval
= windecor_initwindow(cl
, obj
, (struct wdpInitWindow
*) msg
);
3685 case WDM_EXITWINDOW
:
3686 retval
= windecor_exitwindow(cl
, obj
, (struct wdpExitWindow
*) msg
);
3690 retval
= DoSuperMethodA(cl
, obj
, msg
);
3697 static IPTR
scrdecor_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
3699 struct scrdecor_data
*data
;
3702 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
3706 data
= INST_DATA(cl
, obj
);
3707 STRPTR path
= (STRPTR
) GetTagData(SDA_Configuration
, (IPTR
) "Theme:", msg
->ops_AttrList
);
3709 if (!InitScreenSkinning(path
, data
))
3711 CoerceMethod(cl
,obj
,OM_DISPOSE
);
3716 barh
= data
->sbarheight
;
3718 if (data
->img_sbarlogo
) if (data
->img_sbarlogo
->h
> barh
) barh
= data
->img_sbarlogo
->h
;
3719 if (data
->img_stitlebar
) if (data
->img_stitlebar
->h
> barh
) barh
= data
->img_stitlebar
->h
;
3725 static IPTR
scrdecor_dispose(Class
*cl
, Object
*obj
, struct opSet
*msg
)
3727 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3729 DisposeScreenSkinning(data
);
3734 /**************************************************************************************************/
3736 static IPTR
scrdecor_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
3739 switch(msg
->opg_AttrID
)
3741 case SDA_TrueColorOnly
:
3742 *msg
->opg_Storage
= TRUE
;
3745 case SDA_ScreenData
:
3746 *msg
->opg_Storage
= (IPTR
)INST_DATA(cl
, obj
);
3750 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
3755 /**************************************************************************************************/
3757 static void scr_findtitlearea(struct Screen
*scr
, LONG
*left
, LONG
*right
)
3762 *right
= scr
->Width
- 1;
3764 for (g
= scr
->FirstGadget
; g
; g
= g
->NextGadget
)
3766 if (!(g
->Flags
& GFLG_RELRIGHT
))
3768 if (g
->LeftEdge
+ g
->Width
> *left
) *left
= g
->LeftEdge
+ g
->Width
;
3772 if (g
->LeftEdge
+ scr
->Width
- 1 - 1 < *right
) *right
= g
->LeftEdge
+ scr
->Width
- 1 - 1;
3777 IPTR
scrdecor_draw_screenbar(Class
*cl
, Object
*obj
, struct sdpDrawScreenBar
*msg
)
3779 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3780 struct ScreenData
*sd
= (struct ScreenData
*) msg
->sdp_UserBuffer
;
3781 struct TextExtent te
;
3782 struct RastPort
*rp
= msg
->sdp_RPort
;
3783 struct Screen
*scr
= msg
->sdp_Screen
;
3784 LONG left
, right
, titlelen
= 0;
3785 BOOL hastitle
= TRUE
;
3787 if (sd
->img_stitlebar
.ok
) WriteTiledImage(NULL
, rp
, &sd
->img_stitlebar
, 0, 0, data
->img_stitlebar
->w
, data
->img_stitlebar
->h
, 0, 0, scr
->Width
, data
->img_stitlebar
->h
);
3788 if (sd
->img_sbarlogo
.ok
) WriteTiledImage(NULL
, rp
, &sd
->img_sbarlogo
, 0, 0, data
->img_sbarlogo
->w
, data
->img_sbarlogo
->h
, data
->slogo_off
, (scr
->BarHeight
+ 1 - data
->img_sbarlogo
->h
) / 2, data
->img_sbarlogo
->w
, data
->img_sbarlogo
->h
);
3789 if (scr
->Title
== NULL
) hastitle
= FALSE
;
3793 scr_findtitlearea(scr
, &left
, &right
);
3794 titlelen
= strlen(scr
->Title
);
3795 titlelen
= TextFit(rp
, scr
->Title
, titlelen
, &te
, NULL
, 1, right
- data
->stitle_off
, data
->sbarheight
);
3796 if (titlelen
== 0) hastitle
= 0;
3801 UWORD tx
= data
->stitle_off
;
3802 UWORD ty
= (scr
->BarHeight
+ 1 - msg
->sdp_Dri
->dri_Font
->tf_YSize
) / 2 + rp
->TxBaseline
;
3804 SetFont(rp
, msg
->sdp_Dri
->dri_Font
);
3806 // Move(rp, data->stitle_off, (scr->BarHeight + 1 - msg->sdp_Dri->dri_Font->tf_YSize) / 2 + rp->TxBaseline);
3807 // Text(rp, scr->Title, titlelen);
3809 if (!sd
->truecolor
|| ((data
->outline
== FALSE
) && (data
->shadow
== FALSE
)))
3812 Text(rp
, scr
->Title
, titlelen
);
3814 else if (data
->outline
)
3817 SetSoftStyle(rp
, FSF_BOLD
, AskSoftStyle(rp
));
3818 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->shadow_col
, TAG_DONE
);
3820 Move(rp
, tx
+ 1, ty
); Text(rp
, scr
->Title
, titlelen
);
3821 Move(rp
, tx
+ 2, ty
); Text(rp
, scr
->Title
, titlelen
);
3822 Move(rp
, tx
, ty
); Text(rp
, scr
->Title
, titlelen
);
3823 Move(rp
, tx
, ty
+ 1); Text(rp
, scr
->Title
, titlelen
);
3824 Move(rp
, tx
, ty
+ 2); Text(rp
, scr
->Title
, titlelen
);
3825 Move(rp
, tx
+ 1, ty
+ 2); Text(rp
, scr
->Title
, titlelen
);
3826 Move(rp
, tx
+ 2, ty
+ 1); Text(rp
, scr
->Title
, titlelen
);
3827 Move(rp
, tx
+ 2, ty
+ 2); Text(rp
, scr
->Title
, titlelen
);
3829 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->text_col
, TAG_DONE
);
3830 Move(rp
, tx
+ 1, ty
+ 1);
3831 Text(rp
, scr
->Title
, titlelen
);
3832 SetSoftStyle(rp
, FS_NORMAL
, AskSoftStyle(rp
));
3836 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->shadow_col
, TAG_DONE
);
3837 Move(rp
, tx
+ 1, ty
+ 1 );
3838 Text(rp
, scr
->Title
, titlelen
);
3840 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->text_col
, TAG_DONE
);
3842 Text(rp
, scr
->Title
, titlelen
);
3849 IPTR
scrdecor_getdefsize_sysimage(Class
*cl
, Object
*obj
, struct sdpGetDefSizeSysImage
*msg
)
3851 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3853 if (msg
->sdp_Which
== SDEPTHIMAGE
)
3855 if (data
->img_sdepth
)
3857 *msg
->sdp_Height
= data
->img_sdepth
->h
;
3858 *msg
->sdp_Width
= data
->img_sdepth
->w
>> 1;
3860 else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3862 else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3867 IPTR
scrdecor_draw_sysimage(Class
*cl
, Object
*obj
, struct sdpDrawSysImage
*msg
)
3869 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3870 struct ScreenData
*sd
= (struct ScreenData
*) msg
->sdp_UserBuffer
;
3872 struct RastPort
*rp
= msg
->sdp_RPort
;
3873 LONG left
= msg
->sdp_X
;
3874 LONG top
= msg
->sdp_Y
;
3875 LONG state
= msg
->sdp_State
;
3877 if (msg
->sdp_Which
== SDEPTHIMAGE
)
3879 if (data
->img_sdepth
)
3881 DrawAlphaStateImageToRP(NULL
, rp
, &sd
->img_sdepth
, state
, left
, top
, TRUE
);
3883 else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3885 else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
3890 IPTR
scrdecor_layoutscrgadgets(Class
*cl
, Object
*obj
, struct sdpLayoutScreenGadgets
*msg
)
3892 struct Gadget
*gadget
= msg
->sdp_Gadgets
;
3894 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3898 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
3901 gadget
->LeftEdge
= -gadget
->Width
;
3902 gadget
->TopEdge
= (data
->sbarheight
- data
->img_sdepth
->h
) >> 1;
3903 gadget
->Flags
&= ~GFLG_RELWIDTH
;
3904 gadget
->Flags
|= GFLG_RELRIGHT
;
3908 if (msg
->sdp_Flags
& SDF_LSG_MULTIPLE
)
3910 gadget
= gadget
->NextGadget
;
3922 IPTR
scrdecor_initscreen(Class
*cl
, Object
*obj
, struct sdpInitScreen
*msg
)
3924 struct scrdecor_data
*data
= INST_DATA(cl
, obj
);
3925 struct ScreenData
*sd
= (struct ScreenData
*)msg
->sdp_UserBuffer
;
3926 struct Screen
*screen
= msg
->sdp_Screen
;
3928 sd
->truecolor
= msg
->sdp_TrueColor
;
3930 BOOL truecolor
= sd
->truecolor
;
3932 msg
->sdp_WBorTop
= data
->winbarheight
- 1 - msg
->sdp_FontHeight
;
3933 msg
->sdp_BarHBorder
= 1;
3934 msg
->sdp_BarHeight
= data
->sbarheight
- 1; //compatiblity issue
3935 msg
->sdp_WBorLeft
= data
->leftborder
;
3936 msg
->sdp_WBorRight
= data
->rightborder
;
3937 msg
->sdp_WBorBottom
= data
->bottomborder
;
3940 sd
->DeactivePen
= -1;
3942 sd
->ActivePen
= ObtainPen(screen
->ViewPort
.ColorMap
, -1, (data
->lut_col_a
<< 8) & 0xff000000, (data
->lut_col_a
<< 16) & 0xff000000, (data
->lut_col_a
<< 24) & 0xff000000, PEN_EXCLUSIVE
);
3943 sd
->DeactivePen
= ObtainPen(screen
->ViewPort
.ColorMap
, -1, (data
->lut_col_d
<< 8) & 0xff000000, (data
->lut_col_d
<< 16) & 0xff000000, (data
->lut_col_d
<< 24) & 0xff000000, PEN_EXCLUSIVE
);
3946 SETIMAGE_SCR(sdepth
);
3947 SETIMAGE_SCR(sbarlogo
);
3948 SETIMAGE_SCR(stitlebar
);
3951 SETIMAGE_SCR(close
);
3952 SETIMAGE_SCR(depth
);
3957 SETIMAGE_SCR(right
);
3959 SETIMAGE_SCR(popup
);
3960 SETIMAGE_SCR(snapshot
);
3961 SETIMAGE_SCR(iconify
);
3963 SETIMAGE_SCR(winbar_normal
);
3964 SETIMAGE_SCR(border_normal
);
3965 SETIMAGE_SCR(border_deactivated
);
3966 SETIMAGE_SCR(verticalcontainer
);
3967 SETIMAGE_SCR(verticalknob
);
3968 SETIMAGE_SCR(horizontalcontainer
);
3969 SETIMAGE_SCR(horizontalknob
);
3972 SETIMAGE_SCR(amigakey
);
3973 SETIMAGE_SCR(menucheck
);
3974 SETIMAGE_SCR(submenu
);
3979 IPTR
scrdecor_exitscreen(Class
*cl
, Object
*obj
, struct sdpExitScreen
*msg
)
3981 struct ScreenData
*sd
= (struct ScreenData
*)msg
->sdp_UserBuffer
;
3983 DELIMAGE_SCR(sdepth
);
3984 DELIMAGE_SCR(sbarlogo
);
3985 DELIMAGE_SCR(stitlebar
);
3988 DELIMAGE_SCR(close
);
3989 DELIMAGE_SCR(depth
);
3994 DELIMAGE_SCR(right
);
3996 DELIMAGE_SCR(popup
);
3997 DELIMAGE_SCR(snapshot
);
3998 DELIMAGE_SCR(iconify
);
4000 DELIMAGE_SCR(winbar_normal
);
4001 DELIMAGE_SCR(border_normal
);
4002 DELIMAGE_SCR(border_deactivated
);
4003 DELIMAGE_SCR(verticalcontainer
);
4004 DELIMAGE_SCR(verticalknob
);
4005 DELIMAGE_SCR(horizontalcontainer
);
4006 DELIMAGE_SCR(horizontalknob
);
4009 DELIMAGE_SCR(amigakey
);
4010 DELIMAGE_SCR(menucheck
);
4011 DELIMAGE_SCR(submenu
);
4016 /**************************************************************************************************/
4018 IPTR
scrdecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
4022 switch(msg
->MethodID
)
4025 retval
= scrdecor_new(cl
, obj
, (struct opSet
*)msg
);
4029 retval
= scrdecor_dispose(cl
, obj
, (struct opSet
*)msg
);
4033 retval
= scrdecor_get(cl
, obj
, (struct opGet
*)msg
);
4036 case SDM_GETDEFSIZE_SYSIMAGE
:
4037 retval
= scrdecor_getdefsize_sysimage(cl
, obj
, (struct sdpGetDefSizeSysImage
*)msg
);
4040 case SDM_DRAW_SCREENBAR
:
4041 retval
= scrdecor_draw_screenbar(cl
, obj
, (struct sdpDrawScreenBar
*)msg
);
4044 case SDM_DRAW_SYSIMAGE
:
4045 retval
= scrdecor_draw_sysimage(cl
, obj
, (struct sdpDrawSysImage
*)msg
);
4048 case SDM_LAYOUT_SCREENGADGETS
:
4049 retval
= scrdecor_layoutscrgadgets(cl
, obj
, (struct sdpLayoutScreenGadgets
*)msg
);
4052 case SDM_INITSCREEN
:
4053 retval
= scrdecor_initscreen(cl
, obj
, (struct sdpInitScreen
*)msg
);
4056 case SDM_EXITSCREEN
:
4057 retval
= scrdecor_exitscreen(cl
, obj
, (struct sdpExitScreen
*)msg
);
4061 retval
= DoSuperMethodA(cl
, obj
, msg
);
4068 IPTR
menudecor_getdefsizes(Class
*cl
, Object
*obj
, struct mdpGetDefSizeSysImage
*msg
)
4070 struct menudecor_data
*data
= INST_DATA(cl
, obj
);
4072 struct NewImage
*n
= NULL
;
4075 switch(msg
->mdp_Which
)
4078 n
= data
->img_amigakey
;
4083 n
= data
->img_menucheck
;
4088 n
= data
->img_submenu
;
4096 if (!isset
|| (n
==NULL
)) return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
4098 *msg
->mdp_Width
= n
->w
;
4099 *msg
->mdp_Height
= n
->h
;
4103 IPTR
menudecor_draw_sysimage(Class
*cl
, Object
*obj
, struct mdpDrawSysImage
*msg
)
4105 struct ScreenData
*md
= (struct ScreenData
*) msg
->mdp_UserBuffer
;
4106 struct RastPort
*rp
= msg
->mdp_RPort
;
4107 struct NewImage
*ni
= NULL
;
4108 LONG state
= msg
->mdp_State
;
4109 LONG left
= msg
->mdp_X
;
4110 LONG top
= msg
->mdp_Y
;
4115 switch(msg
->mdp_Which
)
4118 if (md
->img_amigakey
.ok
)
4120 ni
= &md
->img_amigakey
;
4126 if (md
->img_amigakey
.ok
)
4128 ni
= &md
->img_menucheck
;
4134 if (md
->img_submenu
.ok
)
4136 ni
= &md
->img_submenu
;
4142 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
4145 if (!isset
|| (ni
== NULL
)) return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
4147 DrawAlphaStateImageToRP(NULL
, rp
, ni
, state
, left
+addx
, top
+addy
, FALSE
);
4152 /**************************************************************************************************/
4154 IPTR
menudecor_renderbackground(Class
*cl
, Object
*obj
, struct mdpDrawBackground
*msg
)
4156 struct RastPort
*rp
= msg
->mdp_RPort
;
4157 struct NewImage
*ni
;
4158 struct MenuData
*md
= (struct MenuData
*) msg
->mdp_UserBuffer
;
4159 UWORD flags
= msg
->mdp_Flags
;
4161 if (!msg
->mdp_TrueColor
)
4164 if ((flags
& HIGHITEM
) && md
->map
)
4171 BltBitMapRastPort(md
->map
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
, rp
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
, msg
->mdp_ItemWidth
, msg
->mdp_ItemHeight
, 0xc0);
4179 if ((flags
& HIGHITEM
) && md
->ni
)
4181 ni
= NewImageContainer(msg
->mdp_ItemWidth
, msg
->mdp_ItemHeight
);
4184 DrawPartToImage(md
->ni
, ni
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
, msg
->mdp_ItemWidth
, msg
->mdp_ItemHeight
, 0, 0);
4185 SetImageTint(ni
, 60, 0x00888800);
4186 PutImageToRP(rp
, ni
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
);
4191 if (md
->ni
) DrawPartImageToRP(rp
, md
->ni
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
, msg
->mdp_ItemLeft
, msg
->mdp_ItemTop
, msg
->mdp_ItemWidth
, msg
->mdp_ItemHeight
);
4197 IPTR
menudecor_initmenu(Class
*cl
, Object
*obj
, struct mdpInitMenu
*msg
)
4199 struct RastPort
*rp
= msg
->mdp_RPort
;
4200 struct MenuData
*md
= (struct MenuData
*) msg
->mdp_UserBuffer
;
4201 struct ScreenData
*sd
= (struct ScreenData
*) msg
->mdp_ScreenUserBuffer
;
4204 SETIMAGE_MEN(amigakey
);
4205 SETIMAGE_MEN(menucheck
);
4206 SETIMAGE_MEN(submenu
);
4208 md
->truecolor
= msg
->mdp_TrueColor
;
4210 // if (!msg->mdp_TrueColor) return DoSuperMethodA(cl, obj, (Msg) msg);
4214 md
->ni
= GetImageFromRP(rp
, msg
->mdp_Left
, msg
->mdp_Top
, msg
->mdp_Width
, msg
->mdp_Height
);
4217 RenderBackground(md
->ni
, md
->img_menu
, 20);
4222 md
->map
= AllocBitMap(msg
->mdp_Width
, msg
->mdp_Height
, 1, BMF_CLEAR
, rp
->BitMap
);
4224 BltBitMap(rp
->BitMap
, msg
->mdp_Left
, msg
->mdp_Top
, md
->map
, 0, 0, msg
->mdp_Width
, msg
->mdp_Height
, 0xc0, 0xff, NULL
);
4226 TileMapToBitmap(md
->img_menu
, md
->map
, msg
->mdp_Width
, msg
->mdp_Height
);
4233 IPTR
menudecor_exitmenu(Class
*cl
, Object
*obj
, struct mdpExitMenu
*msg
)
4235 struct MenuData
*md
= (struct MenuData
*) msg
->mdp_UserBuffer
;
4237 if (md
->ni
) DisposeImageContainer(md
->ni
);
4238 if (md
->map
) FreeBitMap(md
->map
);
4243 IPTR
menudecor_getmenuspaces(Class
*cl
, Object
*obj
, struct mdpGetMenuSpaces
*msg
)
4245 struct menudecor_data
*data
= INST_DATA(cl
, obj
);
4249 msg
->mdp_InnerLeft
= data
->img_menu
->inner_left
;
4250 msg
->mdp_InnerTop
= data
->img_menu
->inner_top
;
4251 msg
->mdp_InnerRight
= data
->img_menu
->inner_right
;
4252 msg
->mdp_InnerBottom
= data
->img_menu
->inner_bottom
;
4253 msg
->mdp_ItemInnerLeft
= 1;
4254 msg
->mdp_ItemInnerTop
= 2;
4255 msg
->mdp_ItemInnerRight
= 2;
4256 msg
->mdp_ItemInnerBottom
= 1;
4257 if ((data
->img_menu
->tile_left
+ data
->img_menu
->tile_right
) > (data
->img_menu
->inner_left
+ data
->img_menu
->inner_right
)) msg
->mdp_MinWidth
= data
->img_menu
->tile_left
+ data
->img_menu
->tile_right
; else msg
->mdp_MinWidth
= data
->img_menu
->inner_left
+ data
->img_menu
->inner_right
;
4258 if ((data
->img_menu
->tile_top
+ data
->img_menu
->tile_bottom
) > (data
->img_menu
->inner_top
+ data
->img_menu
->inner_bottom
)) msg
->mdp_MinHeight
= data
->img_menu
->tile_top
+ data
->img_menu
->tile_bottom
; else msg
->mdp_MinHeight
= data
->img_menu
->inner_top
+ data
->img_menu
->inner_bottom
;
4263 void DisposeMenuSkinning(struct menudecor_data
*data
)
4267 BOOL
InitMenuSkinning(STRPTR path
, struct menudecor_data
*data
) {
4276 int tile_bottom
= 0;
4279 int inner_right
= 0;
4280 int inner_bottom
= 0;
4284 lock
= Lock(path
, ACCESS_READ
);
4287 olddir
= CurrentDir(lock
);
4291 file
= Open("Menu/Config", MODE_OLDFILE
);
4296 line
= FGets(file
, buffer
, 256);
4299 if ((v
= strstr(line
, "TileLeft ")) == line
)
4301 tile_left
= GetInt(v
);
4304 else if ((v
= strstr(line
, "TileTop ")) == line
)
4306 tile_top
= GetInt(v
);
4309 else if ((v
= strstr(line
, "TileRight ")) == line
)
4311 tile_right
= GetInt(v
);
4314 else if ((v
= strstr(line
, "TileBottom ")) == line
)
4316 tile_bottom
= GetInt(v
);
4319 else if ((v
= strstr(line
, "InnerLeft ")) == line
)
4321 inner_left
= GetInt(v
);
4323 else if ((v
= strstr(line
, "InnerTop ")) == line
)
4325 inner_top
= GetInt(v
);
4327 else if ((v
= strstr(line
, "InnerRight ")) == line
)
4329 inner_right
= GetInt(v
);
4331 else if ((v
= strstr(line
, "InnerBottom ")) == line
)
4333 inner_bottom
= GetInt(v
);
4342 PUTIMAGE_MEN(amigakey
);
4343 PUTIMAGE_MEN(menucheck
);
4344 PUTIMAGE_MEN(submenu
);
4348 data
->img_menu
->tile_left
= tile_left
;
4349 data
->img_menu
->tile_right
= tile_right
;
4350 data
->img_menu
->tile_top
= tile_top
;
4351 data
->img_menu
->tile_bottom
= tile_bottom
;
4352 data
->img_menu
->inner_left
= inner_left
;
4353 data
->img_menu
->inner_right
= inner_right
;
4354 data
->img_menu
->inner_top
= inner_top
;
4355 data
->img_menu
->inner_bottom
= inner_bottom
;
4356 data
->img_menu
->istiled
= tiled
;
4358 if (olddir
) CurrentDir(olddir
);
4360 if (data
->img_menu
) return TRUE
;
4361 DisposeMenuSkinning(data
);
4365 IPTR
menudecor__OM_NEW(Class
*cl
, Object
*obj
, struct opSet
*msg
)
4367 struct menudecor_data
*data
;
4369 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
4372 data
= INST_DATA(cl
, obj
);
4374 STRPTR path
= (STRPTR
) GetTagData(MDA_Configuration
, (IPTR
) "Theme:", msg
->ops_AttrList
);
4375 data
->sd
= (struct scrdecor_data
*) GetTagData(MDA_ScreenData
, 0, msg
->ops_AttrList
);
4377 if (!InitMenuSkinning(path
, data
))
4379 CoerceMethod(cl
,obj
,OM_DISPOSE
);
4387 IPTR
menudecor__OM_DISPOSE(Class
*cl
, Object
*obj
, struct opSet
*msg
)
4389 struct menudecor_data
*data
= INST_DATA(cl
, obj
);
4391 DisposeMenuSkinning(data
);
4393 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
4396 IPTR
menudecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
4400 switch(msg
->MethodID
)
4403 retval
= menudecor__OM_NEW(cl
, obj
, (struct opSet
*) msg
);
4407 retval
= menudecor__OM_DISPOSE(cl
, obj
, (struct opSet
*) msg
);
4410 case MDM_DRAW_SYSIMAGE
:
4411 retval
= menudecor_draw_sysimage(cl
, obj
, (struct mdpDrawSysImage
*)msg
);
4414 case MDM_GETDEFSIZE_SYSIMAGE
:
4415 retval
= menudecor_getdefsizes(cl
, obj
, (struct mdpGetDefSizeSysImage
*) msg
);
4418 case MDM_DRAWBACKGROUND
:
4419 retval
= menudecor_renderbackground(cl
, obj
, (struct mdpDrawBackground
*)msg
);
4423 retval
= menudecor_initmenu(cl
, obj
, (struct mdpInitMenu
*)msg
);
4427 retval
= menudecor_exitmenu(cl
, obj
, (struct mdpExitMenu
*)msg
);
4430 case MDM_GETMENUSPACES
:
4431 retval
= menudecor_getmenuspaces(cl
, obj
, (struct mdpGetMenuSpaces
*)msg
);
4435 retval
= DoSuperMethodA(cl
, obj
, msg
);
4442 /**************************************************************************************************/
4444 void DisposeWindowSkinning(struct windecor_data
*data
)
4449 BOOL
InitWindowSkinning(STRPTR path
, struct windecor_data
*data
) {
4456 lock
= Lock(path
, ACCESS_READ
);
4459 olddir
= CurrentDir(lock
);
4463 data
->rounded
= FALSE
;
4464 data
->threestate
= FALSE
;
4465 data
->barmasking
= FALSE
;
4466 data
->winbarheight
= 0; //screen, window
4470 data
->BarJoinTB_o
= 0;
4471 data
->BarJoinTB_s
= 0;
4472 data
->BarPreGadget_o
= 0;
4473 data
->BarPreGadget_s
= 0;
4476 data
->BarLGadgetFill_o
= 0;
4477 data
->BarLGadgetFill_s
= 0;
4478 data
->BarJoinGB_o
= 0;
4479 data
->BarJoinGB_s
= 0;
4480 data
->BarLFill_o
= 0;
4481 data
->BarLFill_s
= 0;
4482 data
->BarJoinBT_o
= 0;
4483 data
->BarJoinBT_s
= 0;
4484 data
->BarTitleFill_o
= 0;
4485 data
->BarTitleFill_s
= 0;
4486 data
->BarRFill_o
= 0;
4487 data
->BarRFill_s
= 0;
4488 data
->BarJoinBG_o
= 0;
4489 data
->BarJoinBG_s
= 0;
4490 data
->BarRGadgetFill_o
= 0;
4491 data
->BarRGadgetFill_s
= 0;
4492 data
->BarPostGadget_o
= 0;
4493 data
->BarPostGadget_s
= 0;
4494 data
->BarPost_o
= 0;
4495 data
->BarPost_s
= 0;
4496 data
->txt_align
= WD_DWTA_LEFT
;
4497 data
->usegradients
= FALSE
;
4498 data
->closeright
= FALSE
;
4499 data
->barvert
= FALSE
;
4500 data
->filltitlebar
= FALSE
;
4501 data
->outline
= FALSE
;
4502 data
->shadow
= FALSE
;
4504 data
->a_col_s
= 0xaaaaaaaa;
4505 data
->a_col_e
= 0xeeeeeeff;
4506 data
->d_col_s
= 0x66666666;
4507 data
->d_col_e
= 0xaaaaaabb;
4509 data
->text_col
= 0x00cccccc;
4510 data
->shadow_col
= 0x00444444;
4518 file
= Open("System/Config", MODE_OLDFILE
);
4523 line
= FGets(file
, buffer
, 256);
4526 if ((v
= strstr(line
, "NoInactiveSelected ")) == line
) {
4527 data
->threestate
= GetBool(v
, "Yes");
4528 } else if ((v
= strstr(line
, "BarRounded ")) == line
) {
4529 data
->rounded
= GetBool(v
, "Yes");
4530 } else if ((v
= strstr(line
, "WindowTitleMode ")) == line
) {
4531 data
->outline
= GetBool(v
, "Outline");
4532 data
->shadow
= GetBool(v
, "Shadow");
4533 } else if ((v
= strstr(line
, "FillTitleBar ")) == line
) {
4534 data
->filltitlebar
= GetBool(v
, "Yes");
4535 } else if ((v
= strstr(line
, "BarMasking ")) == line
) {
4536 data
->barmasking
= GetBool(v
, "Yes");
4537 } else if ((v
= strstr(line
, "CloseRight ")) == line
) {
4538 data
->closeright
= GetBool(v
, "Yes");
4539 } else if ((v
= strstr(line
, "UseGradients ")) == line
) {
4540 data
->usegradients
= GetBool(v
, "Yes");
4541 } else if ((v
= strstr(line
, "BarLayout ")) == line
) {
4542 data
->barvert
= GetBool(v
, "Vertical");
4543 } else if ((v
= strstr(line
, "RightBorderGads ")) == line
) {
4544 data
->rightbordergads
= GetInt(v
);
4545 } else if ((v
= strstr(line
, "HorScrollerHeight ")) == line
) {
4546 data
->horscrollerheight
= GetInt(v
);
4547 } else if ((v
= strstr(line
, "ScrollerInnerSpacing ")) == line
) {
4548 data
->scrollerinnerspacing
= GetInt(v
);
4549 } else if ((v
= strstr(line
, "BottomBorderGads ")) == line
) {
4550 data
->bottombordergads
= GetInt(v
);
4551 } else if ((v
= strstr(line
, "RightBorderNoGads ")) == line
) {
4552 data
->rightbordernogads
= GetInt(v
);
4553 } else if ((v
= strstr(line
, "BottomBorderNoGads ")) == line
) {
4554 data
->bottombordernogads
= GetInt(v
);
4555 } else if ((v
= strstr(line
, "BarHeight ")) == line
) {
4556 data
->winbarheight
= GetInt(v
); //screen, window
4557 } else if ((v
= strstr(line
, "BarJoinTB ")) == line
) {
4558 GetIntegers(v
, &data
->BarJoinTB_o
, &data
->BarJoinTB_s
);
4559 } else if ((v
= strstr(line
, "BarPreGadget ")) == line
) {
4560 GetIntegers(v
, &data
->BarPreGadget_o
, &data
->BarPreGadget_s
);
4561 } else if ((v
= strstr(line
, "BarPre ")) == line
) {
4562 GetIntegers(v
, &data
->BarPre_o
, &data
->BarPre_s
);
4563 } else if ((v
= strstr(line
, "BarLGadgetFill ")) == line
) {
4564 GetIntegers(v
, &data
->BarLGadgetFill_o
, &data
->BarLGadgetFill_s
);
4565 } else if ((v
= strstr(line
, "BarJoinGB ")) == line
) {
4566 GetIntegers(v
, &data
->BarJoinGB_o
, &data
->BarJoinGB_s
);
4567 } else if ((v
= strstr(line
, "BarLFill ")) == line
) {
4568 GetIntegers(v
, &data
->BarLFill_o
, &data
->BarLFill_s
);
4569 } else if ((v
= strstr(line
, "BarJoinBT ")) == line
) {
4570 GetIntegers(v
, &data
->BarJoinBT_o
, &data
->BarJoinBT_s
);
4571 } else if ((v
= strstr(line
, "BarTitleFill ")) == line
) {
4572 GetIntegers(v
, &data
->BarTitleFill_o
, &data
->BarTitleFill_s
);
4573 } else if ((v
= strstr(line
, "BarRFill ")) == line
) {
4574 GetIntegers(v
, &data
->BarRFill_o
, &data
->BarRFill_s
);
4575 } else if ((v
= strstr(line
, "BarJoinBG ")) == line
) {
4576 GetIntegers(v
, &data
->BarJoinBG_o
, &data
->BarJoinBG_s
);
4577 } else if ((v
= strstr(line
, "BarRGadgetFill ")) == line
) {
4578 GetIntegers(v
, &data
->BarRGadgetFill_o
, &data
->BarRGadgetFill_s
);
4579 } else if ((v
= strstr(line
, "BarPostGadget ")) == line
) {
4580 GetIntegers(v
, &data
->BarPostGadget_o
, &data
->BarPostGadget_s
);
4581 } else if ((v
= strstr(line
, "BarPost ")) == line
) {
4582 GetIntegers(v
, &data
->BarPost_o
, &data
->BarPost_s
);
4583 } else if ((v
= strstr(line
, "ContainerTop ")) == line
) {
4584 GetIntegers(v
, &data
->ContainerTop_o
, &data
->ContainerTop_s
);
4585 } else if ((v
= strstr(line
, "ContainerVertTile ")) == line
) {
4586 GetIntegers(v
, &data
->ContainerVertTile_o
, &data
->ContainerVertTile_s
);
4587 } else if ((v
= strstr(line
, "KnobTop ")) == line
) {
4588 GetIntegers(v
, &data
->KnobTop_o
, &data
->KnobTop_s
);
4589 } else if ((v
= strstr(line
, "KnobTileTop ")) == line
) {
4590 GetIntegers(v
, &data
->KnobTileTop_o
, &data
->KnobTileTop_s
);
4591 } else if ((v
= strstr(line
, "KnobVertGripper ")) == line
) {
4592 GetIntegers(v
, &data
->KnobVertGripper_o
, &data
->KnobVertGripper_s
);
4593 } else if ((v
= strstr(line
, "KnobTileBottom ")) == line
) {
4594 GetIntegers(v
, &data
->KnobTileBottom_o
, &data
->KnobTileBottom_s
);
4595 } else if ((v
= strstr(line
, "KnobBottom ")) == line
) {
4596 GetIntegers(v
, &data
->KnobBottom_o
, &data
->KnobBottom_s
);
4597 } else if ((v
= strstr(line
, "ContainerBottom ")) == line
) {
4598 GetIntegers(v
, &data
->ContainerBottom_o
, &data
->ContainerBottom_s
);
4599 } else if ((v
= strstr(line
, "ContainerLeft ")) == line
) {
4600 GetIntegers(v
, &data
->ContainerLeft_o
, &data
->ContainerLeft_s
);
4601 } else if ((v
= strstr(line
, "ContainerHorTile ")) == line
) {
4602 GetIntegers(v
, &data
->ContainerHorTile_o
, &data
->ContainerHorTile_s
);
4603 } else if ((v
= strstr(line
, "KnobLeft ")) == line
) {
4604 GetIntegers(v
, &data
->KnobLeft_o
, &data
->KnobLeft_s
);
4605 } else if ((v
= strstr(line
, "KnobTileLeft ")) == line
) {
4606 GetIntegers(v
, &data
->KnobTileLeft_o
, &data
->KnobTileLeft_s
);
4607 } else if ((v
= strstr(line
, "KnobHorGripper ")) == line
) {
4608 GetIntegers(v
, &data
->KnobHorGripper_o
, &data
->KnobHorGripper_s
);
4609 } else if ((v
= strstr(line
, "KnobTileRight ")) == line
) {
4610 GetIntegers(v
, &data
->KnobTileRight_o
, &data
->KnobTileRight_s
);
4611 } else if ((v
= strstr(line
, "KnobRight ")) == line
) {
4612 GetIntegers(v
, &data
->KnobRight_o
, &data
->KnobRight_s
);
4613 } else if ((v
= strstr(line
, "ContainerRight ")) == line
) {
4614 GetIntegers(v
, &data
->ContainerRight_o
, &data
->ContainerRight_s
);
4615 } else if ((v
= strstr(line
, "AddSize ")) == line
) {
4616 GetIntegers(v
, &data
->sizeaddx
, &data
->sizeaddy
);
4617 } else if ((v
= strstr(line
, "AddUpDown ")) == line
) {
4618 GetIntegers(v
, &data
->updownaddx
, &data
->updownaddy
);
4619 } else if ((v
= strstr(line
, "AddLeftRight ")) == line
) {
4620 GetIntegers(v
, &data
->leftrightaddx
, &data
->leftrightaddy
);
4621 } else if ((v
= strstr(line
, "ActivatedGradient ")) == line
) {
4622 GetTripleIntegers(v
, &data
->a_col_s
, &data
->a_col_e
, &data
->a_arc
);
4623 } else if ((v
= strstr(line
, "DeactivatedGradient ")) == line
) {
4624 GetTripleIntegers(v
, &data
->d_col_s
, &data
->d_col_e
, &data
->d_arc
);
4625 } else if ((v
= strstr(line
, "ShadeValues ")) == line
) {
4626 GetTripleIntegers(v
, &data
->light
, &data
->middle
, &data
->dark
);
4627 } else if ((v
= strstr(line
, "BaseColors ")) == line
) {
4628 GetColors(v
, &data
->b_col_a
, &data
->b_col_d
);
4629 } else if ((v
= strstr(line
, "WindowTitleColors ")) == line
) {
4630 GetColors(v
, &data
->text_col
, &data
->shadow_col
);
4639 PUTIMAGE_WIN(close
);
4640 PUTIMAGE_WIN(depth
);
4645 PUTIMAGE_WIN(right
);
4647 PUTIMAGE_WIN(popup
);
4648 PUTIMAGE_WIN(snapshot
);
4649 PUTIMAGE_WIN(iconify
);
4651 PUTIMAGE_WIN(winbar_normal
);
4652 PUTIMAGE_WIN(border_normal
);
4653 PUTIMAGE_WIN(border_deactivated
);
4654 PUTIMAGE_WIN(verticalcontainer
);
4655 PUTIMAGE_WIN(verticalknob
);
4656 PUTIMAGE_WIN(horizontalcontainer
);
4657 PUTIMAGE_WIN(horizontalknob
);
4659 if (olddir
) CurrentDir(olddir
);
4662 if (data
->img_horizontalcontainer
&& data
->img_horizontalknob
&& data
->img_verticalcontainer
&& data
->img_verticalknob
&& data
->img_size
&& data
->img_close
&& data
->img_depth
&& data
->img_zoom
&& data
->img_up
&& data
->img_down
&& data
->img_left
&& data
->img_right
&& data
->img_winbar_normal
) return TRUE
;
4663 DisposeWindowSkinning(data
);
4668 void DisposeScreenSkinning(struct scrdecor_data
*data
)
4670 DisposeImageContainer(data
->img_sdepth
);
4671 DisposeImageContainer(data
->img_sbarlogo
);
4672 DisposeImageContainer(data
->img_stitlebar
);
4674 DisposeImageContainer(data
->img_size
);
4675 DisposeImageContainer(data
->img_close
);
4676 DisposeImageContainer(data
->img_depth
);
4677 DisposeImageContainer(data
->img_zoom
);
4678 DisposeImageContainer(data
->img_mui
);
4679 DisposeImageContainer(data
->img_popup
);
4680 DisposeImageContainer(data
->img_snapshot
);
4681 DisposeImageContainer(data
->img_iconify
);
4682 DisposeImageContainer(data
->img_lock
);
4683 DisposeImageContainer(data
->img_up
);
4684 DisposeImageContainer(data
->img_down
);
4685 DisposeImageContainer(data
->img_left
);
4686 DisposeImageContainer(data
->img_right
);
4687 DisposeImageContainer(data
->img_winbar_normal
);
4688 DisposeImageContainer(data
->img_border_normal
);
4689 DisposeImageContainer(data
->img_border_deactivated
);
4690 DisposeImageContainer(data
->img_verticalcontainer
);
4691 DisposeImageContainer(data
->img_verticalknob
);
4692 DisposeImageContainer(data
->img_horizontalcontainer
);
4693 DisposeImageContainer(data
->img_horizontalknob
);
4695 DisposeImageContainer(data
->img_menu
);
4696 DisposeImageContainer(data
->img_menucheck
);
4697 DisposeImageContainer(data
->img_amigakey
);
4698 DisposeImageContainer(data
->img_submenu
);
4700 data
->img_size
= NULL
;
4701 data
->img_close
= NULL
;
4702 data
->img_depth
= NULL
;
4703 data
->img_zoom
= NULL
;
4704 data
->img_mui
= NULL
;
4705 data
->img_popup
= NULL
;
4706 data
->img_snapshot
= NULL
;
4707 data
->img_iconify
= NULL
;
4708 data
->img_lock
= NULL
;
4709 data
->img_up
= NULL
;
4710 data
->img_down
= NULL
;
4711 data
->img_left
= NULL
;
4712 data
->img_right
= NULL
;
4713 data
->img_winbar_normal
= NULL
;
4714 data
->img_border_normal
= NULL
;
4715 data
->img_border_deactivated
= NULL
;
4716 data
->img_verticalcontainer
= NULL
;
4717 data
->img_verticalknob
= NULL
;
4718 data
->img_horizontalcontainer
= NULL
;
4719 data
->img_horizontalknob
= NULL
;
4721 data
->img_sdepth
= NULL
;
4722 data
->img_sbarlogo
= NULL
;
4723 data
->img_stitlebar
= NULL
;
4726 BOOL
InitScreenSkinning(STRPTR path
, struct scrdecor_data
*data
) {
4733 lock
= Lock(path
, ACCESS_READ
);
4736 olddir
= CurrentDir(lock
);
4740 data
->leftborder
= 4;
4741 data
->rightborder
= 4;
4742 data
->bottomborder
= 4;
4744 data
->lut_col_a
= 0x00cccccc;
4745 data
->lut_col_d
= 0x00888888;
4747 data
->outline
= FALSE
;
4748 data
->shadow
= FALSE
;
4750 data
->text_col
= 0x00cccccc;
4751 data
->shadow_col
= 0x00444444;
4753 file
= Open("System/Config", MODE_OLDFILE
);
4758 line
= FGets(file
, buffer
, 256);
4761 if ((v
= strstr(line
, "LeftBorder ")) == line
) {
4762 data
->leftborder
= GetInt(v
);
4763 } else if ((v
= strstr(line
, "RightBorder ")) == line
) {
4764 data
->rightborder
= GetInt(v
);
4765 } else if ((v
= strstr(line
, "BottomBorder ")) == line
) {
4766 data
->bottomborder
= GetInt(v
);
4767 } else if ((v
= strstr(line
, "LogoOffset ")) == line
) {
4768 data
->slogo_off
= GetInt(v
);
4769 } else if ((v
= strstr(line
, "TitleOffset ")) == line
) {
4770 data
->stitle_off
= GetInt(v
);
4771 } else if ((v
= strstr(line
, "SBarHeight ")) == line
) {
4772 data
->sbarheight
= GetInt(v
);
4773 } else if ((v
= strstr(line
, "BarHeight ")) == line
) {
4774 data
->winbarheight
= GetInt(v
); //screen, window
4775 } else if ((v
= strstr(line
, "LUTBaseColors ")) == line
) {
4776 GetColors(v
, &data
->lut_col_a
, &data
->lut_col_d
);
4777 } else if ((v
= strstr(line
, "ScreenTitleColors ")) == line
) {
4778 GetColors(v
, &data
->text_col
, &data
->shadow_col
);
4779 } else if ((v
= strstr(line
, "ScreenTitleMode ")) == line
) {
4780 data
->outline
= GetBool(v
, "Outline");
4781 data
->shadow
= GetBool(v
, "Shadow");
4789 data
->img_sdepth
= GetImageFromFile(path
, "System/SDepth/", TRUE
);
4790 data
->img_stitlebar
= GetImageFromFile(path
, "System/STitlebar/", TRUE
);
4791 data
->img_sbarlogo
= GetImageFromFile(path
, "System/SBarLogo/Default", FALSE
);
4793 data
->img_size
= GetImageFromFile(path
, "System/Size/", TRUE
);
4794 data
->img_close
= GetImageFromFile(path
, "System/Close/", TRUE
);
4795 data
->img_depth
= GetImageFromFile(path
, "System/Depth/", TRUE
);
4796 data
->img_zoom
= GetImageFromFile(path
, "System/Zoom/", TRUE
);
4797 data
->img_mui
= GetImageFromFile(path
, "System/MUI/", TRUE
);
4798 data
->img_popup
= GetImageFromFile(path
, "System/PopUp/", TRUE
);
4799 data
->img_snapshot
= GetImageFromFile(path
, "System/Snapshot/", TRUE
);
4800 data
->img_iconify
= GetImageFromFile(path
, "System/Iconify/", TRUE
);
4801 data
->img_lock
= GetImageFromFile(path
, "System/Lock/", TRUE
);
4802 data
->img_up
= GetImageFromFile(path
, "System/ArrowUp/", TRUE
);
4803 data
->img_down
= GetImageFromFile(path
, "System/ArrowDown/", TRUE
);
4804 data
->img_left
= GetImageFromFile(path
, "System/ArrowLeft/", TRUE
);
4805 data
->img_right
= GetImageFromFile(path
, "System/ArrowRight/", TRUE
);
4806 data
->img_winbar_normal
= GetImageFromFile(path
, "System/Titlebar/", TRUE
);
4807 data
->img_border_normal
= GetImageFromFile(path
, "System/Borders/Default", FALSE
);
4808 data
->img_border_deactivated
= GetImageFromFile(path
, "System/Borders/Default_Deactivated", FALSE
);
4809 data
->img_verticalcontainer
= GetImageFromFile(path
, "System/Container/Vertical", FALSE
);
4810 data
->img_verticalknob
= GetImageFromFile(path
, "System/Knob/Vertical", FALSE
);
4811 data
->img_horizontalcontainer
= GetImageFromFile(path
, "System/Container/Horizontal", FALSE
);
4812 data
->img_horizontalknob
= GetImageFromFile(path
, "System/Knob/Horizontal", FALSE
);
4814 data
->img_menu
= GetImageFromFile(path
, "Menu/Background/Default", FALSE
);
4815 data
->img_amigakey
= GetImageFromFile(path
, "Menu/AmigaKey/", TRUE
);
4816 data
->img_menucheck
= GetImageFromFile(path
, "Menu/Checkmark/", TRUE
);
4817 data
->img_submenu
= GetImageFromFile(path
, "Menu/SubMenu/", TRUE
);
4819 if (data
->img_stitlebar
)
4821 data
->img_stitlebar
->tile_left
= 8;
4822 data
->img_stitlebar
->tile_right
= 8;
4823 data
->img_stitlebar
->tile_top
= 9;
4824 data
->img_stitlebar
->tile_bottom
= 8;
4827 if (olddir
) CurrentDir(olddir
);
4830 if (data
->img_sdepth
) return TRUE
;
4831 DisposeScreenSkinning(data
);
4835 STRPTR __detached_name
= "Decoration";
4837 #define MAGIC_PRIVATE_SKIN 0x0001
4839 struct SkinMessage
{
4840 struct MagicMessage msg
;
4846 void DeleteDecorator(struct NewDecorator
*nd
)
4848 if (nd
== NULL
) return;
4849 if (nd
->nd_Menu
!= NULL
) DisposeObject(nd
->nd_Menu
);
4850 if (nd
->nd_Window
!= NULL
) DisposeObject(nd
->nd_Window
);
4851 if (nd
->nd_Screen
!= NULL
) DisposeObject(nd
->nd_Screen
);
4855 struct NewDecorator
*GetDecorator(STRPTR path
)
4857 struct NewDecorator
*nd
= NULL
;
4861 if (path
!= NULL
) newpath
= path
; else newpath
= "Theme:";
4863 struct TagItem ScreenTags
[] = { {SDA_UserBuffer
, sizeof(struct ScreenData
)}, {SDA_Configuration
, (ULONG
) newpath
}, {TAG_DONE
} };
4866 nd
= AllocVec(sizeof(struct NewDecorator
), MEMF_CLEAR
| MEMF_ANY
);
4869 nd
->nd_Screen
= NewObjectA(scrcl
, NULL
, ScreenTags
);
4875 get(nd
->nd_Screen
, SDA_ScreenData
, &screendata
);
4877 struct TagItem WindowTags
[] = { {WDA_UserBuffer
, sizeof(struct WindowData
)}, {WDA_Configuration
, (ULONG
) newpath
}, {WDA_ScreenData
, (IPTR
)screendata
}, {TAG_DONE
} };
4878 struct TagItem MenuTags
[] = { {MDA_UserBuffer
, sizeof(struct MenuData
)}, {MDA_Configuration
, (ULONG
) newpath
}, {MDA_ScreenData
, (IPTR
)screendata
}, {TAG_DONE
} };
4881 nd
->nd_Window
= NewObjectA(cl
, NULL
, WindowTags
);
4882 nd
->nd_Menu
= NewObjectA(menucl
, NULL
, MenuTags
);
4883 if ((nd
->nd_Menu
== NULL
) || (nd
->nd_Window
== NULL
) || (nd
->nd_Screen
== NULL
))
4885 DeleteDecorator(nd
);
4891 DeleteDecorator(nd
);
4898 #define ARGUMENT_TEMPLATE "PATH,SCREENID=ID/K"
4907 IPTR rd_Args
[] = {0, 0, };
4909 struct RDArgs
*args
, *newargs
;
4911 /* the 1M $$ Question why "Decoration ?" does not work in the shell? */
4913 newargs
= (struct RDArgs
*) AllocDosObject(DOS_RDARGS
, NULL
);
4915 if (newargs
== NULL
) return 0;
4917 newargs
->RDA_ExtHelp
= usage
;
4918 newargs
->RDA_Flags
= 0;
4920 args
= ReadArgs(ARGUMENT_TEMPLATE
, rd_Args
, newargs
);
4923 FreeDosObject (DOS_RDARGS
, (APTR
) newargs
);
4928 if (FindPort("DECORATIONS")) {
4929 struct MsgPort
*port
= CreateMsgPort();
4931 struct SkinMessage msg
;
4932 msg
.msg
.mn_ReplyPort
= port
;
4933 msg
.msg
.mn_Magic
= MAGIC_PRIVATE_SKIN
;
4935 msg
.path
= (STRPTR
) rd_Args
[0];
4936 msg
.id
= (STRPTR
) rd_Args
[1];
4937 PutMsg(FindPort("DECORATIONS"), (struct Message
*) &msg
);
4941 DeleteMsgPort(port
);
4948 cl
= MakeClass(NULL
, WINDECORCLASS
, NULL
, sizeof(struct windecor_data
), 0);
4951 cl
->cl_Dispatcher
.h_Entry
= HookEntry
;
4952 cl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)windecor_dispatcher
;
4954 scrcl
= MakeClass(NULL
, SCRDECORCLASS
, NULL
, sizeof(struct scrdecor_data
), 0);
4957 scrcl
->cl_Dispatcher
.h_Entry
= HookEntry
;
4958 scrcl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)scrdecor_dispatcher
;
4960 menucl
= MakeClass(NULL
, MENUDECORCLASS
, NULL
, sizeof(struct menudecor_data
), 0);
4963 menucl
->cl_Dispatcher
.h_Entry
= HookEntry
;
4964 menucl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)menudecor_dispatcher
;
4966 struct MsgPort
*port
= CreateMsgPort();
4970 skinSignal
= 1 << port
->mp_SigBit
;
4971 port
->mp_Node
.ln_Name
="DECORATIONS";
4974 struct NewDecorator
*decor
= GetDecorator((STRPTR
) rd_Args
[0]);
4978 decor
->nd_Pattern
= (STRPTR
) rd_Args
[1];
4979 decor
->nd_Port
= port
;
4980 ChangeDecoration(DECORATION_SET
, decor
);
4985 BOOL running
= TRUE
;
4989 ULONG sigs
= Wait(SIGBREAKF_CTRL_C
| skinSignal
);
4990 if ((sigs
& SIGBREAKF_CTRL_C
) != 0)
4992 // running = FALSE; /* at the moment no exit */
4994 else if ((sigs
& skinSignal
) != 0)
4996 struct DecoratorMessage
*dmsg
;
4997 struct SkinMessage
* msg
= (struct SkinMessage
*) GetMsg(port
);
5000 switch(msg
->msg
.mn_Magic
)
5002 case MAGIC_PRIVATE_SKIN
:
5003 decor
= GetDecorator(msg
->path
);
5006 decor
->nd_Pattern
= msg
->id
;
5007 decor
->nd_Port
= port
;
5008 ChangeDecoration(DECORATION_SET
, decor
);
5011 case MAGIC_DECORATOR
:
5012 dmsg
= (struct DecoratorMessage
*) msg
;
5013 DeleteDecorator((struct NewDecorator
*) dmsg
->dm_Object
);
5016 ReplyMsg((struct Message
*) msg
);
5017 msg
= (struct SkinMessage
*) GetMsg(port
);
5028 FreeDosObject (DOS_RDARGS
, (APTR
) newargs
);