2 Copyright © 2011-2017, The AROS Development Team.
7 #include <aros/debug.h>
9 #include <clib/alib_protos.h>
11 #include <intuition/windecorclass.h>
12 #include <intuition/extensions.h>
13 #include <intuition/gadgetclass.h>
14 #include <graphics/rpattr.h>
15 #include <proto/arossupport.h>
16 #include <proto/intuition.h>
17 #include <proto/utility.h>
18 #include <proto/graphics.h>
19 #include <proto/cybergraphics.h>
20 #include <proto/exec.h>
23 #include "windowdecorclass.h"
24 #include "screendecorclass.h"
25 #include "drawfuncs.h"
28 #define SETIMAGE_WIN(id) wd->img_##id=sd->di->img_##id
32 struct DecorConfig
* dc
;
34 /* Pointers to images used for sys images */
35 struct NewImage
*img_close
;
36 struct NewImage
*img_depth
;
37 struct NewImage
*img_zoom
;
38 struct NewImage
*img_up
;
39 struct NewImage
*img_down
;
40 struct NewImage
*img_left
;
41 struct NewImage
*img_right
;
42 struct NewImage
*img_mui
;
43 struct NewImage
*img_popup
;
44 struct NewImage
*img_snapshot
;
45 struct NewImage
*img_iconify
;
46 struct NewImage
*img_lock
;
51 #define CHANGE_NO_CHANGE 0
52 #define CHANGE_SIZE_CHANGE 1 /* Whole gadget area has changed */
53 #define CHANGE_NO_SIZE_CHANGE 2 /* Size remained the same, contents has changed */
55 static ULONG
HasPropGadgetChanged(struct CachedPropGadget
*cached
, struct wdpDrawBorderPropKnob
*msg
)
57 /* More restrictive tests */
59 /* If the size has changed */
60 if (cached
->width
!= (msg
->wdp_PropRect
->MaxX
- msg
->wdp_PropRect
->MinX
+ 1))
61 return CHANGE_SIZE_CHANGE
;
62 if (cached
->height
!= (msg
->wdp_PropRect
->MaxY
- msg
->wdp_PropRect
->MinY
+ 1))
63 return CHANGE_SIZE_CHANGE
;
65 /* If there is no cached bitmap at all (this can happen NOT only at first call) */
66 if (cached
->bm
== NULL
)
67 return CHANGE_SIZE_CHANGE
;
69 /* Less restrictive tests */
71 /* If knob position has changed */
72 if (cached
->knobx
!= (msg
->wdp_RenderRect
->MinX
- msg
->wdp_PropRect
->MinX
))
73 return CHANGE_NO_SIZE_CHANGE
;
74 if (cached
->knoby
!= (msg
->wdp_RenderRect
->MinY
- msg
->wdp_PropRect
->MinY
))
75 return CHANGE_NO_SIZE_CHANGE
;
77 /* If knob is release state has changed */
78 if (cached
->gadgetflags
^ (msg
->wdp_Flags
& WDF_DBPK_HIT
))
79 return CHANGE_NO_SIZE_CHANGE
;
81 /* If the window activity status has changed */
82 if (cached
->windowflags
^ (msg
->wdp_Window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)))
83 return CHANGE_NO_SIZE_CHANGE
;
85 /* If knob size has changed */
86 if (cached
->knobwidth
!= (msg
->wdp_RenderRect
->MaxX
- msg
->wdp_RenderRect
->MinX
+ 1))
87 return CHANGE_NO_SIZE_CHANGE
;
88 if (cached
->knobheight
!= (msg
->wdp_RenderRect
->MaxY
- msg
->wdp_RenderRect
->MinY
+ 1))
89 return CHANGE_NO_SIZE_CHANGE
;
91 return CHANGE_NO_CHANGE
;
94 static VOID
CachePropGadget(struct CachedPropGadget
*cached
, struct wdpDrawBorderPropKnob
*msg
,
95 struct BitMap
*bitmap
)
98 cached
->width
= msg
->wdp_PropRect
->MaxX
- msg
->wdp_PropRect
->MinX
+ 1;
99 cached
->height
= msg
->wdp_PropRect
->MaxY
- msg
->wdp_PropRect
->MinY
+ 1;
100 cached
->windowflags
= (msg
->wdp_Window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
));
101 cached
->gadgetflags
= (msg
->wdp_Flags
& WDF_DBPK_HIT
);
102 cached
->knobwidth
= msg
->wdp_RenderRect
->MaxX
- msg
->wdp_RenderRect
->MinX
+ 1;
103 cached
->knobheight
= msg
->wdp_RenderRect
->MaxY
- msg
->wdp_RenderRect
->MinY
+ 1;
104 cached
->knobx
= msg
->wdp_RenderRect
->MinX
- msg
->wdp_PropRect
->MinX
;
105 cached
->knoby
= msg
->wdp_RenderRect
->MinY
- msg
->wdp_PropRect
->MinY
;
108 static ULONG
HasTitleBarChanged(struct CachedTitleBar
*cached
, struct Window
*window
)
112 /* More restrictive tests */
114 /* If the window size has changed */
115 if (cached
->width
!= window
->Width
)
116 return CHANGE_SIZE_CHANGE
;
117 if (cached
->height
!= window
->Height
)
118 return CHANGE_SIZE_CHANGE
;
120 /* If there is no cached bitmap at all (this can happen NOT only at first call) */
121 if (cached
->bm
== NULL
)
122 return CHANGE_SIZE_CHANGE
;
124 /* Less restrictive tests */
126 /* If the window activity status has changed */
127 if (cached
->windowflags
^ (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)))
128 return CHANGE_NO_SIZE_CHANGE
;
130 /* If the window title/title contents has changed */
132 len
= strlen(window
->Title
);
134 if (cached
->titlelen
!= len
)
135 return CHANGE_NO_SIZE_CHANGE
;
140 - length of both buffer is guarateed to be the same, see previous test
141 - both buffers are allocated
144 for (i
= 0; i
< len
; i
++)
145 if (cached
->title
[i
] != window
->Title
[i
])
146 return CHANGE_NO_SIZE_CHANGE
;
149 return CHANGE_NO_CHANGE
;
152 static VOID
CacheTitleBar(struct CachedTitleBar
*cached
, struct Window
*window
, struct BitMap
*bitmap
)
157 cached
->width
= window
->Width
;
158 cached
->height
= window
->Height
;
159 cached
->windowflags
= (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
));
161 /* Cache the title */
163 len
= strlen(window
->Title
);
165 if (cached
->titlelen
!= len
)
168 FreeVec(cached
->title
);
169 cached
->title
= AllocVec(len
+ 1, MEMF_ANY
| MEMF_CLEAR
);
171 cached
->titlelen
= len
;
172 strncpy(cached
->title
, window
->Title
, len
);
175 static ULONG
HasTitleBarShapeChanged(struct CachedTitleBarShape
*cached
, struct Window
*window
)
177 /* More restrictive tests */
179 /* If the window size has changed */
180 if (cached
->width
!= window
->Width
)
181 return CHANGE_SIZE_CHANGE
;
182 if (cached
->height
!= window
->Height
)
183 return CHANGE_SIZE_CHANGE
;
185 /* If there is no cached shape at all (this can happen NOT only at first call) */
186 if (cached
->shape
== NULL
)
187 return CHANGE_SIZE_CHANGE
;
189 /* Less restrictive tests */
191 /* If the window activity status has changed */
192 if (cached
->windowflags
^ (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)))
193 return CHANGE_NO_SIZE_CHANGE
;
195 return CHANGE_NO_CHANGE
;
198 static VOID
CacheTitleBarShape(struct CachedTitleBarShape
*cached
, struct Window
*window
, struct Region
*shape
)
200 cached
->shape
= shape
;
201 cached
->width
= window
->Width
;
202 cached
->height
= window
->Height
;
203 cached
->windowflags
= (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
));
206 static 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
)
212 if (!ni
->ok
) return xp
;
214 if ((sw
== 0) || (dw
== 0)) return xp
;
218 if (x
> win
->Width
) return xp
;
219 if ((x
+ w
) > win
->Width
) w
= win
->Width
- x
;
225 if (w
< ddw
) ddw
= w
;
226 WriteAlphaPixelArray(ni
, lut8
, sx
, sy
, x
, yp
, ddw
, dh
);
233 static void getrightgadgetsdimensions(struct windecor_data
*data
, struct Window
*win
, LONG
*xs
, LONG
*xe
)
241 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
243 if ((g
->Flags
& GFLG_RELRIGHT
) == GFLG_RELRIGHT
)
245 type
= g
->GadgetType
& GTYP_SYSTYPEMASK
;
246 if (data
->dc
->CloseGadgetOnRight
)
248 if (((type
& (GTYP_CLOSE
| GTYP_WDEPTH
| GTYP_WZOOM
)) != 0) || (g
->Activation
& GACT_TOPBORDER
))
252 if ((win
->Width
+ g
->LeftEdge
) < x0
) x0
= win
->Width
+ g
->LeftEdge
;
253 if ((win
->Width
+ g
->LeftEdge
+ g
->Width
) > x1
) x1
= win
->Width
+ g
->LeftEdge
+ g
->Width
;
259 if (((type
& (GTYP_WDEPTH
| GTYP_WZOOM
)) != 0) || (g
->Activation
& GACT_TOPBORDER
))
263 if ((win
->Width
+ g
->LeftEdge
) < x0
) x0
= win
->Width
+ g
->LeftEdge
;
264 if ((win
->Width
+ g
->LeftEdge
+ g
->Width
) > x1
) x1
= win
->Width
+ g
->LeftEdge
+ g
->Width
;
270 if (x0
== 1000000) x0
= 0;
275 static void getleftgadgetsdimensions(struct windecor_data
*data
, struct Window
*win
, LONG
*xs
, LONG
*xe
)
282 for (g
= win
->FirstGadget
; g
; g
= g
->NextGadget
)
285 if (((g
->Flags
& GFLG_RELRIGHT
) == 0) && (g
->Activation
& GACT_TOPBORDER
))
287 if ((g
->GadgetType
& GTYP_WDRAGGING
) == 0)
291 if (g
->LeftEdge
< x0
) x0
= g
->LeftEdge
;
292 if ((g
->LeftEdge
+ g
->Width
) > x1
) x1
= g
->LeftEdge
+ g
->Width
;
297 if (x0
== 1000000) x0
= 0;
302 static void DrawShapePartialTitleBar(struct WindowData
*wd
, struct NewLUT8Image
*shape
, struct windecor_data
*data
, struct Window
*window
)
304 LONG xl0
, xl1
, xr0
, xr1
, defwidth
;
305 ULONG textlen
= 0, titlelen
= 0, textpixellen
= 0;
306 struct TextExtent te
;
312 struct RastPort
*rp
= &window
->WScreen
->RastPort
;
313 hastitle
= window
->Title
!= NULL
? TRUE
: FALSE
;
314 hastitlebar
= (window
->BorderTop
> 0) ? TRUE
: FALSE
;
316 getleftgadgetsdimensions(data
, window
, &xl0
, &xl1
);
317 getrightgadgetsdimensions(data
, window
, &xr0
, &xr1
);
319 defwidth
= (xl0
!= xl1
) ? data
->dc
->BarPreGadget_s
: data
->dc
->BarPre_s
;
322 xr1
= window
->Width
- data
->dc
->BarPre_s
;
323 xr0
= window
->Width
- data
->dc
->BarPre_s
;
326 defwidth
+= (xl1
- xl0
);
328 defwidth
+= data
->dc
->BarJoinGB_s
;
329 defwidth
+= data
->dc
->BarJoinBT_s
;
330 defwidth
+= data
->dc
->BarJoinTB_s
;
331 defwidth
+= data
->dc
->BarJoinBG_s
;
332 defwidth
+= (xr1
- xr0
);
333 defwidth
+= (xr0
!= xr1
) ? data
->dc
->BarPostGadget_s
: data
->dc
->BarPost_s
;
335 if (defwidth
>= window
->Width
) hastitle
= FALSE
;
339 titlelen
= strlen(window
->Title
);
340 textlen
= TextFit(rp
, window
->Title
, titlelen
, &te
, NULL
, 1, window
->Width
-defwidth
, window
->BorderTop
- 2);
343 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
348 if (wd
->img_winbar_normal
->ok
&& hastitlebar
)
351 UWORD barh
= window
->BorderTop
;
352 struct NewImage
* img_winbar_normal
= wd
->img_winbar_normal
;
354 if (data
->dc
->BarHeight
!= barh
)
355 img_winbar_normal
= ScaleNewImage(wd
->img_winbar_normal
, wd
->img_winbar_normal
->w
, 2 * barh
);
357 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
360 dy
= barh
; /* Offset into source image */
364 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
,img_winbar_normal
, data
->dc
->BarPreGadget_o
, dy
, data
->dc
->BarPreGadget_s
, barh
, x
, 0, data
->dc
->BarPreGadget_s
, barh
);
365 if ((xl1
-xl0
) > 0) x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarLGadgetFill_o
, dy
, data
->dc
->BarLGadgetFill_s
, barh
, x
, 0, xl1
-xl0
, barh
);
369 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarPre_o
, dy
, data
->dc
->BarPre_s
, barh
, x
, 0, data
->dc
->BarPreGadget_s
, barh
);
371 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarJoinGB_o
, dy
, data
->dc
->BarJoinGB_s
, barh
, x
, 0, data
->dc
->BarJoinGB_s
, barh
);
372 if (hastitle
&& (textlen
> 0))
374 switch(data
->TextAlign
)
378 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarLFill_o
, dy
, data
->dc
->BarLFill_s
, barh
, x
, 0, 60, barh
);
387 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarJoinBT_o
, dy
, data
->dc
->BarJoinBT_s
, barh
, x
, 0, data
->dc
->BarJoinBT_s
, barh
);
388 if (textpixellen
> 0) x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarTitleFill_o
, dy
, data
->dc
->BarTitleFill_s
, barh
, x
, 0, textpixellen
, barh
);
389 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarJoinTB_o
, dy
, data
->dc
->BarJoinTB_s
, barh
, x
, 0, data
->dc
->BarJoinTB_s
, barh
);
391 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarRFill_o
, dy
, data
->dc
->BarRFill_s
, barh
, x
, 0, xr0
- x
- data
->dc
->BarJoinBG_s
, barh
);
392 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarJoinBG_o
, dy
, data
->dc
->BarJoinBG_s
, barh
, x
, 0, data
->dc
->BarJoinBG_s
, barh
);
393 if ((xr1
-xr0
) > 0) x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarRGadgetFill_o
, dy
, data
->dc
->BarRGadgetFill_s
, barh
, x
, 0, xr1
-xr0
, barh
);
396 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarPostGadget_o
, dy
, data
->dc
->BarPostGadget_s
, barh
, x
, 0, data
->dc
->BarPostGadget_s
, barh
);
400 x
= WriteTiledImageShape(data
->dc
->FillTitleBar
, window
, shape
, img_winbar_normal
, data
->dc
->BarPost_o
, dy
, data
->dc
->BarPost_s
, barh
, x
, 0, data
->dc
->BarPost_s
, barh
);
403 if (data
->dc
->BarHeight
!= barh
)
404 DisposeImageContainer(img_winbar_normal
);
408 static VOID
DrawPartialTitleBar(struct WindowData
*wd
, struct windecor_data
*data
, struct Window
*window
, struct RastPort
*dst_rp
, struct DrawInfo
*dri
, UWORD
*pens
)
410 LONG xl0
, xl1
, xr0
, xr1
, defwidth
;
411 ULONG textlen
= 0, titlelen
= 0, textpixellen
= 0;
412 struct TextExtent te
;
414 struct NewImage
*ni
= NULL
;
419 ULONG color
, s_col
, e_col
, arc
;
422 ULONG changetype
= CHANGE_NO_CHANGE
;
423 struct BitMap
*cachedtitlebarbitmap
= NULL
;
425 changetype
= HasTitleBarChanged(&wd
->tbar
, window
);
426 if (changetype
== CHANGE_SIZE_CHANGE
)
429 FreeBitMap(wd
->tbar
.bm
);
432 cachedtitlebarbitmap
= wd
->tbar
.bm
;
434 if (changetype
== CHANGE_NO_CHANGE
)
436 BltBitMapRastPort(cachedtitlebarbitmap
, 0, 0, dst_rp
, 0, 0, window
->Width
, window
->BorderTop
, 0xc0);
440 /* Regenerate the bitmap */
441 rp
= CreateRastPort();
444 /* Reuse the bitmap if there was no size change (ie. only change of state) */
445 if (changetype
== CHANGE_NO_SIZE_CHANGE
)
446 rp
->BitMap
= cachedtitlebarbitmap
;
448 rp
->BitMap
= AllocBitMap(window
->Width
, window
->BorderTop
, 1, 0, window
->WScreen
->RastPort
.BitMap
);
450 if (rp
->BitMap
== NULL
)
456 SetFont(rp
, dri
->dri_Font
);
461 hastitle
= window
->Title
!= NULL
? TRUE
: FALSE
;
462 hastitlebar
= (window
->BorderTop
> 0) ? TRUE
: FALSE
;
464 if (wd
->img_border_normal
->ok
) ni
= wd
->img_border_normal
;
466 if (ni
== NULL
) data
->dc
->UseGradients
= TRUE
;
470 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
472 s_col
= data
->dc
->ActivatedGradientColor_s
;
473 e_col
= data
->dc
->ActivatedGradientColor_e
;
474 arc
= data
->dc
->ActivatedGradientColor_a
;
478 s_col
= data
->dc
->DeactivatedGradientColor_s
;
479 e_col
= data
->dc
->DeactivatedGradientColor_e
;
480 arc
= data
->dc
->DeactivatedGradientColor_a
;
481 dy
= data
->dc
->BarHeight
;
482 if (!data
->dc
->UseGradients
)
484 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
486 pen
= wd
->DeactivePen
;
490 if (data
->dc
->FillTitleBar
)
492 if (data
->dc
->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
, 0, 0);
493 else HorizVertRepeatNewImage(ni
, color
, 0, 0, rp
, 0, 0, window
->Width
, window
->BorderTop
);
496 getleftgadgetsdimensions(data
, window
, &xl0
, &xl1
);
497 getrightgadgetsdimensions(data
, window
, &xr0
, &xr1
);
498 defwidth
= (xl0
!= xl1
) ? data
->dc
->BarPreGadget_s
: data
->dc
->BarPre_s
;
501 xr1
= window
->Width
- data
->dc
->BarPre_s
;
502 xr0
= window
->Width
- data
->dc
->BarPre_s
;
505 defwidth
+= (xl1
- xl0
);
507 defwidth
+= data
->dc
->BarJoinGB_s
;
508 defwidth
+= data
->dc
->BarJoinBT_s
;
509 defwidth
+= data
->dc
->BarJoinTB_s
;
510 defwidth
+= data
->dc
->BarJoinBG_s
;
511 defwidth
+= (xr1
- xr0
);
512 defwidth
+= (xr0
!= xr1
) ? data
->dc
->BarPostGadget_s
: data
->dc
->BarPost_s
;
514 if (defwidth
>= window
->Width
) hastitle
= FALSE
;
518 titlelen
= strlen(window
->Title
);
519 textlen
= TextFit(rp
, window
->Title
, titlelen
, &te
, NULL
, 1, window
->Width
-defwidth
, window
->BorderTop
- 2);
522 textpixellen
= te
.te_Extent
.MaxX
- te
.te_Extent
.MinX
+ 1;
526 if (wd
->img_winbar_normal
->ok
&& hastitlebar
)
529 UWORD barh
= window
->BorderTop
;
530 struct NewImage
* img_winbar_normal
= wd
->img_winbar_normal
;
532 if (data
->dc
->BarHeight
!= barh
)
533 img_winbar_normal
= ScaleNewImage(wd
->img_winbar_normal
, wd
->img_winbar_normal
->w
, 2 * barh
);
535 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
538 dy
= barh
; /* Offset into source image */
542 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarPreGadget_o
, dy
, data
->dc
->BarPreGadget_s
, barh
, x
, 0, data
->dc
->BarPreGadget_s
, barh
);
543 if ((xl1
-xl0
) > 0) x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
,img_winbar_normal
, data
->dc
->BarLGadgetFill_o
, dy
, data
->dc
->BarLGadgetFill_s
, barh
, x
, 0, xl1
-xl0
, barh
);
547 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarPre_o
, dy
, data
->dc
->BarPre_s
, barh
, x
, 0, data
->dc
->BarPreGadget_s
, barh
);
549 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
,img_winbar_normal
, data
->dc
->BarJoinGB_o
, dy
, data
->dc
->BarJoinGB_s
, barh
, x
, 0, data
->dc
->BarJoinGB_s
, barh
);
550 if (hastitle
&& (textlen
> 0))
552 switch(data
->TextAlign
)
556 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarLFill_o
, dy
, data
->dc
->BarLFill_s
, barh
, x
, 0, 60, barh
);
565 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarJoinBT_o
, dy
, data
->dc
->BarJoinBT_s
, barh
, x
, 0, data
->dc
->BarJoinBT_s
, barh
);
567 if (textpixellen
> 0) x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarTitleFill_o
, dy
, data
->dc
->BarTitleFill_s
, barh
, x
, 0, textpixellen
, barh
);
568 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarJoinTB_o
, dy
, data
->dc
->BarJoinTB_s
, barh
, x
, 0, data
->dc
->BarJoinTB_s
, barh
);
570 /* Part right to window title */
571 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarRFill_o
, dy
, data
->dc
->BarRFill_s
, barh
, x
, 0, xr0
- x
- data
->dc
->BarJoinBG_s
, barh
);
572 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarJoinBG_o
, dy
, data
->dc
->BarJoinBG_s
, barh
, x
, 0, data
->dc
->BarJoinBG_s
, barh
);
573 if ((xr1
-xr0
) > 0) x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarRGadgetFill_o
, dy
, data
->dc
->BarRGadgetFill_s
, barh
, x
, 0, xr1
-xr0
, barh
);
576 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarPostGadget_o
, dy
, data
->dc
->BarPostGadget_s
, barh
, x
, 0, data
->dc
->BarPostGadget_s
, barh
);
580 x
= WriteTiledImageTitle(data
->dc
->FillTitleBar
, window
, rp
, img_winbar_normal
, data
->dc
->BarPost_o
, dy
, data
->dc
->BarPost_s
, barh
, x
, 0, data
->dc
->BarPost_s
, barh
);
583 if (data
->dc
->BarHeight
!= barh
)
584 DisposeImageContainer(img_winbar_normal
);
587 if ((textlen
> 0) && hastitle
)
589 SetAPen(rp
, pens
[(window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) ? FILLTEXTPEN
: TEXTPEN
]);
591 UWORD tx
= textstart
;
592 UWORD tymax
= window
->BorderTop
- (dri
->dri_Font
->tf_YSize
- dri
->dri_Font
->tf_Baseline
) - 1;
593 UWORD ty
= (window
->BorderTop
+ dri
->dri_Font
->tf_Baseline
- 1) >> 1;
594 if (ty
> tymax
) ty
= tymax
;
596 if (!wd
->truecolor
|| ((data
->dc
->TitleOutline
== FALSE
) && (data
->dc
->TitleShadow
== FALSE
)))
599 Text(rp
, window
->Title
, textlen
);
601 else if (data
->dc
->TitleOutline
)
604 SetSoftStyle(rp
, FSF_BOLD
, AskSoftStyle(rp
));
605 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->dc
->TitleColorShadow
, TAG_DONE
);
607 Move(rp
, tx
+ 1, ty
); Text(rp
, window
->Title
, textlen
);
608 Move(rp
, tx
+ 2, ty
); Text(rp
, window
->Title
, textlen
);
609 Move(rp
, tx
, ty
); Text(rp
, window
->Title
, textlen
);
610 Move(rp
, tx
, ty
+ 1); Text(rp
, window
->Title
, textlen
);
611 Move(rp
, tx
, ty
+ 2); Text(rp
, window
->Title
, textlen
);
612 Move(rp
, tx
+ 1, ty
+ 2); Text(rp
, window
->Title
, textlen
);
613 Move(rp
, tx
+ 2, ty
+ 1); Text(rp
, window
->Title
, textlen
);
614 Move(rp
, tx
+ 2, ty
+ 2); Text(rp
, window
->Title
, textlen
);
616 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->dc
->TitleColorText
, TAG_DONE
);
617 Move(rp
, tx
+ 1, ty
+ 1);
618 Text(rp
, window
->Title
, textlen
);
619 SetSoftStyle(rp
, FS_NORMAL
, AskSoftStyle(rp
));
623 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->dc
->TitleColorShadow
, TAG_DONE
);
624 Move(rp
, tx
+ 1, ty
+ 1 );
625 Text(rp
, window
->Title
, textlen
);
627 SetRPAttrs(rp
, RPTAG_PenMode
, FALSE
, RPTAG_FgColor
, data
->dc
->TitleColorText
, TAG_DONE
);
629 Text(rp
, window
->Title
, textlen
);
634 BltBitMapRastPort(rp
->BitMap
, 0, 0, dst_rp
, 0, 0, window
->Width
, window
->BorderTop
, 0xc0);
636 /* Cache the actual bitmap */
637 CacheTitleBar(&wd
->tbar
, window
, rp
->BitMap
);
642 static VOID
DisposeWindowSkinning(struct windecor_data
*data
)
647 static BOOL
InitWindowSkinning(struct windecor_data
*data
, struct DecorImages
* di
, struct DecorConfig
* dc
)
654 data
->TextAlign
= WD_DWTA_LEFT
;
656 /* Set pointers to gadget images, used only to get gadget sizes as they
657 are requested prior to creation of menu object */
658 data
->img_close
= di
->img_close
;
659 data
->img_depth
= di
->img_depth
;
660 data
->img_zoom
= di
->img_zoom
;
661 data
->img_up
= di
->img_up
;
662 data
->img_down
= di
->img_down
;
663 data
->img_left
= di
->img_left
;
664 data
->img_right
= di
->img_right
;
665 data
->img_mui
= di
->img_mui
;
666 data
->img_popup
= di
->img_popup
;
667 data
->img_snapshot
= di
->img_snapshot
;
668 data
->img_iconify
= di
->img_iconify
;
669 data
->img_lock
= di
->img_lock
;
671 if (data
->img_close
&& data
->img_depth
&& data
->img_zoom
&& data
->img_up
&&
672 data
->img_down
&& data
->img_left
&& data
->img_right
)
675 DisposeWindowSkinning(data
);
679 /**************************************************************************************************/
680 static IPTR
windecor_new(Class
*cl
, Object
*obj
, struct opSet
*msg
)
682 struct windecor_data
*data
;
684 D(bug("[Decoration:Win] %s(tags @ 0x%p)\n", __func__
, msg
->ops_AttrList
));
686 obj
= (Object
*)DoSuperMethodA(cl
, obj
, (Msg
)msg
);
689 data
= INST_DATA(cl
, obj
);
691 struct DecorImages
* di
= (struct DecorImages
*) GetTagData(WDA_DecorImages
, (IPTR
)NULL
, msg
->ops_AttrList
);
692 struct DecorConfig
* dc
= (struct DecorConfig
*) GetTagData(WDA_DecorConfig
, (IPTR
)NULL
, msg
->ops_AttrList
);
694 D(bug("[Decoration:Win] %s: DecorImages @ 0x%p\n", __func__
, di
));
695 D(bug("[Decoration:Win] %s: DecorConfig @ 0x%p\n", __func__
, dc
));
697 if (!InitWindowSkinning(data
, di
, dc
))
699 CoerceMethod(cl
, obj
, OM_DISPOSE
);
707 /**************************************************************************************************/
708 static IPTR
windecor_dispose(Class
*cl
, Object
*obj
, struct opSet
*msg
)
710 struct windecor_data
*data
= INST_DATA(cl
, obj
);
712 DisposeWindowSkinning(data
);
717 /**************************************************************************************************/
718 static IPTR
windecor_get(Class
*cl
, Object
*obj
, struct opGet
*msg
)
720 switch(msg
->opg_AttrID
)
722 case WDA_TrueColorOnly
:
723 *msg
->opg_Storage
= TRUE
;
726 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
731 /**************************************************************************************************/
732 static IPTR
windecor_draw_sysimage(Class
*cl
, Object
*obj
, struct wdpDrawSysImage
*msg
)
734 struct windecor_data
*data
= INST_DATA(cl
, obj
);
735 struct RastPort
*rp
= msg
->wdp_RPort
;
736 struct NewImage
*ni
= NULL
;
737 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
738 LONG state
= msg
->wdp_State
;
739 LONG left
= msg
->wdp_X
;
740 LONG top
= msg
->wdp_Y
;
741 LONG width
= msg
->wdp_Width
;
742 LONG height
= msg
->wdp_Height
;
746 BOOL titlegadget
= FALSE
;
748 switch(msg
->wdp_Which
)
751 if (wd
->img_size
->ok
)
755 if (data
->dc
->GadgetsThreeState
)
756 addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_size
->w
/ 3)) /2;
758 addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_size
->w
>> 2)) /2;
759 addy
= (data
->dc
->BottomBorderGadgets
- wd
->img_size
->h
) / 2;
764 if (wd
->img_close
->ok
)
782 if (wd
->img_popup
->ok
)
791 if (wd
->img_snapshot
->ok
)
793 ni
= wd
->img_snapshot
;
800 if (wd
->img_lock
->ok
)
809 if (wd
->img_iconify
->ok
)
811 ni
= wd
->img_iconify
;
818 if (wd
->img_depth
->ok
)
827 if (wd
->img_zoom
->ok
)
837 if (data
->dc
->GadgetsThreeState
) addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_up
->w
/ 3)) /2; else addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_up
->w
>> 2)) /2;
838 addy
= data
->dc
->UpDownAddY
/ 2;
844 if (data
->dc
->GadgetsThreeState
) addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_down
->w
/ 3)) /2; else addx
= (data
->dc
->RightBorderGadgets
- (wd
->img_down
->w
>> 2)) /2;
845 addy
= data
->dc
->UpDownAddY
/ 2;
851 addx
= data
->dc
->LeftRightAddX
/ 2;
852 addy
= (data
->dc
->BottomBorderGadgets
- wd
->img_left
->h
) / 2;
858 addx
= data
->dc
->LeftRightAddX
/ 2;
859 addy
= (data
->dc
->BottomBorderGadgets
- wd
->img_right
->h
) /2;
864 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
867 if (!isset
) return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
869 /* Reblit title bar */
870 if (wd
&& titlegadget
&& wd
->tbar
.bm
)
871 BltBitMapRastPort(wd
->tbar
.bm
, left
+ addx
, top
+ addy
, rp
, left
+ addx
, top
+ addy
, width
, height
, 0xc0);
876 DrawScaledStatefulGadgetImageToRP(rp
, ni
, state
, left
+ addx
, top
+ addy
, -1, height
);
878 DrawStatefulGadgetImageToRP(rp
, ni
, state
, left
+ addx
, top
+ addy
);
884 /**************************************************************************************************/
885 static IPTR
windecor_draw_winborder(Class
*cl
, Object
*obj
, struct wdpDrawWinBorder
*msg
)
887 struct windecor_data
*data
= INST_DATA(cl
, obj
);
888 struct RastPort
*rp
= msg
->wdp_RPort
;
889 struct Window
*window
= msg
->wdp_Window
;
890 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
891 struct NewImage
*ni
= NULL
;
892 UWORD
*pens
= msg
->wdp_Dri
->dri_Pens
;
893 ULONG bc
, color
, s_col
, e_col
, arc
;
894 UWORD bl
, bt
, br
, bb
, ww
, wh
;
897 D(bug("[Decoration:Win] %s(0x%p)\n", __func__
, obj
);)
898 D(bug("[Decoration:Win] %s: window @ 0x%p\n", __func__
, window
);)
900 if (wd
->img_border_normal
->ok
)
901 ni
= wd
->img_border_normal
;
904 data
->dc
->UseGradients
= TRUE
;
906 BOOL tc
= wd
->truecolor
;
908 LONG dpen
= pens
[SHADOWPEN
];
909 LONG lpen
= pens
[SHINEPEN
];
910 LONG mpen
= pens
[SHINEPEN
];
912 bl
= window
->BorderLeft
;
913 bt
= window
->BorderTop
;
914 bb
= window
->BorderBottom
;
915 br
= window
->BorderRight
;
921 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
923 D(bug("[Decoration:Win] %s: ACTIVE\n", __func__
);)
925 s_col
= data
->dc
->ActivatedGradientColor_s
;
926 e_col
= data
->dc
->ActivatedGradientColor_e
;
927 arc
= data
->dc
->ActivatedGradientColor_a
;
928 bc
= data
->dc
->BaseColors_a
;
930 D(bug("[Decoration:Win] %s: INACTIVE\n", __func__
);)
931 pen
= wd
->DeactivePen
;
932 s_col
= data
->dc
->DeactivatedGradientColor_s
;
933 e_col
= data
->dc
->DeactivatedGradientColor_e
;
934 arc
= data
->dc
->DeactivatedGradientColor_a
;
935 bc
= data
->dc
->BaseColors_d
;
936 if (!data
->dc
->UseGradients
)
938 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
943 DrawPartialTitleBar(wd
, data
, window
, rp
, msg
->wdp_Dri
, pens
);
945 /* Draw left, right and bottom frames */
946 if (!(msg
->wdp_Flags
& WDF_DWB_TOP_ONLY
))
951 if (data
->dc
->WinFrameStyle
> 0)
954 if (data
->dc
->UseGradients
)
956 /* Create one pixel wide buffer */
957 buf
= AllocVec(1 * window
->Height
* 3, MEMF_ANY
| MEMF_CLEAR
);
959 /* Fill the buffer with gradient */
960 FillMemoryBufferRGBGradient(buf
, pen
, 0, 0, window
->Width
- 1, window
->Height
- 1, 0, 0,
961 1, window
->Height
, s_col
, e_col
, arc
);
964 if (data
->dc
->UseGradients
)
966 /* Reuse the buffer for blitting frames */
967 if (window
->BorderLeft
> overlap
) HorizRepeatBuffer(buf
, window
->BorderTop
, pen
, wd
->truecolor
, rp
,
968 0, window
->BorderTop
,
969 window
->BorderLeft
, window
->Height
- window
->BorderTop
);
970 if (window
->BorderRight
> overlap
) HorizRepeatBuffer(buf
, window
->BorderTop
, pen
, wd
->truecolor
, rp
,
971 window
->Width
- window
->BorderRight
, window
->BorderTop
,
972 window
->BorderRight
, window
->Height
- window
->BorderTop
);
973 if (window
->BorderBottom
> overlap
) HorizRepeatBuffer(buf
, window
->Height
- window
->BorderBottom
, pen
, wd
->truecolor
, rp
,
974 0, window
->Height
- window
->BorderBottom
,
975 window
->Width
, window
->BorderBottom
);
979 if (window
->BorderLeft
> overlap
) HorizVertRepeatNewImage(ni
, color
, 0, window
->BorderTop
, rp
,
980 0, window
->BorderTop
,
981 window
->BorderLeft
- 1, window
->Height
- window
->BorderTop
);
982 if (window
->BorderRight
> overlap
) HorizVertRepeatNewImage(ni
, color
, window
->Width
- window
->BorderRight
, window
->BorderTop
, rp
,
983 window
->Width
- window
->BorderRight
, window
->BorderTop
,
984 window
->BorderRight
, window
->Height
- window
->BorderTop
);
985 if (window
->BorderBottom
> overlap
) HorizVertRepeatNewImage(ni
, color
, 0, window
->Height
- window
->BorderBottom
, rp
,
986 0, window
->Height
- window
->BorderBottom
,
987 window
->Width
, window
->BorderBottom
);
990 /* Shading borders */
991 if (data
->dc
->WinFrameStyle
> 0)
995 if (bl
> 0) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, bbt
, 0, bbt
, 0, wh
- 1);
996 if (bb
> 0) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, wh
- 1, 0, wh
- 1, ww
- 1, wh
- 1);
997 if (br
> 0) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, bbt
, ww
- 1, bbt
, ww
- 1, wh
- 1);
998 if (bl
> 1) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, bbt
, bl
- 1, bbt
, bl
- 1, wh
- bb
);
999 if (bb
> 1) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, wh
- bb
, bl
- 1, wh
- bb
, ww
- br
, wh
- bb
);
1000 if (br
> 1) ShadeLine(dpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_d
, bbt
, ww
- br
, bbt
, ww
- br
, wh
- bb
);
1001 if (bl
> 2) ShadeLine(lpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_l
, bbt
, 1, bbt
, 1, wh
- 2);
1003 if (bb
> 1) ShadeLine(mpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_m
, bbt
, bl
- 2, bbt
, bl
- 2, wh
- bb
+ 1);
1004 else ShadeLine(mpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_m
, bbt
, bl
- 2, bbt
, bl
- 2, wh
- bb
);
1006 if (br
> 2) ShadeLine(mpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_m
, bbt
, ww
- 2, bbt
, ww
- 2, wh
- 2);
1007 if (bb
> 2) ShadeLine(mpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_m
, wh
- 2, 1, wh
- 2, ww
- 2, wh
- 2);
1009 if ((bl
> 0) && (br
> 0)) ShadeLine(lpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_l
, wh
- bb
+ 1, bl
, wh
- bb
+ 1, ww
- br
, wh
- bb
+ 1);
1012 if (bb
> 1) ShadeLine(lpen
, tc
, data
->dc
->UseGradients
, rp
, ni
, bc
, data
->dc
->ShadeValues_l
, bbt
, ww
- br
+ 1, bbt
, ww
- br
+ 1, wh
- bb
+ 1);
1020 /**************************************************************************************************/
1021 static IPTR
windecor_layout_bordergadgets(Class
*cl
, Object
*obj
, struct wdpLayoutBorderGadgets
*msg
)
1023 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1024 struct Window
*window
= msg
->wdp_Window
;
1025 struct Gadget
*gadget
= msg
->wdp_Gadgets
;
1026 struct Gadget
*draggadget
= NULL
;
1027 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1028 ULONG eb
= msg
->wdp_ExtraButtons
;
1034 LONG refheight
= window
->BorderTop
;
1036 DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1038 hasclose
= (window
->Flags
& WFLG_CLOSEGADGET
) ? TRUE
: FALSE
;
1039 hasdepth
= (window
->Flags
& WFLG_DEPTHGADGET
) ? TRUE
: FALSE
;
1040 haszoom
= ((window
->Flags
& WFLG_HASZOOM
) || ((window
->Flags
& WFLG_SIZEGADGET
) && hasdepth
)) ? TRUE
: FALSE
;
1043 if ((msg
->wdp_Flags
& WDF_LBG_SYSTEMGADGET
) != 0)
1045 if (gadget
->GadgetType
== GTYP_CUSTOMGADGET
)
1047 switch(gadget
->GadgetID
)
1050 if (wd
->img_mui
->ok
)
1052 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_mui
->w
/ 3); else width
= (wd
->img_mui
->w
>> 2);
1054 gadget
->Width
= width
;
1055 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1059 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
1061 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1063 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1067 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1068 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1072 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1074 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1075 gadget
->Flags
|= GFLG_RELRIGHT
;
1081 if (wd
->img_popup
->ok
)
1083 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_popup
->w
/ 3); else width
= (wd
->img_popup
->w
>> 2);
1085 gadget
->Width
= width
;
1086 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1088 if ((eb
& ETG_MUI
) != 0)
1090 if (wd
->img_mui
->ok
)
1092 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
1098 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
1101 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1103 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1107 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1108 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1112 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1114 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1115 gadget
->Flags
|= GFLG_RELRIGHT
;
1121 if (wd
->img_snapshot
->ok
)
1123 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_snapshot
->w
/ 3); else width
= (wd
->img_snapshot
->w
>> 2);
1125 gadget
->Width
= width
;
1126 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1128 if ((eb
& ETG_MUI
) != 0)
1131 if (wd
->img_mui
->ok
)
1133 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
1137 if ((eb
& ETG_POPUP
) != 0)
1139 if (wd
->img_popup
->ok
)
1141 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
1147 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
1150 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1152 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1157 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1158 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1162 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1165 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1166 gadget
->Flags
|= GFLG_RELRIGHT
;
1172 if (wd
->img_iconify
->ok
)
1174 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_iconify
->w
/ 3); else width
= (wd
->img_iconify
->w
>> 2);
1176 gadget
->Width
= width
;
1177 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1179 if ((eb
& ETG_MUI
) != 0)
1181 if (wd
->img_mui
->ok
)
1183 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
1187 if ((eb
& ETG_POPUP
) != 0)
1189 if (wd
->img_popup
->ok
)
1191 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
1195 if ((eb
& ETG_SNAPSHOT
) != 0)
1197 if (wd
->img_snapshot
->ok
)
1199 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_snapshot
->w
/ 3); else width
+= (wd
->img_snapshot
->w
>> 2);
1205 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
1208 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1210 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1214 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1215 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1219 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1221 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1222 gadget
->Flags
|= GFLG_RELRIGHT
;
1228 if (wd
->img_lock
->ok
)
1230 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_lock
->w
/ 3); else width
= (wd
->img_lock
->w
>> 2);
1232 gadget
->Width
= width
;
1233 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1235 if ((eb
& ETG_MUI
) != 0)
1237 if (wd
->img_mui
->ok
)
1239 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_mui
->w
/ 3); else width
+= (wd
->img_mui
->w
>> 2);
1243 if ((eb
& ETG_POPUP
) != 0)
1245 if (wd
->img_popup
->ok
)
1247 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_popup
->w
/ 3); else width
+= (wd
->img_popup
->w
>> 2);
1251 if ((eb
& ETG_SNAPSHOT
) != 0)
1253 if (wd
->img_snapshot
->ok
)
1255 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_snapshot
->w
/ 3); else width
+= (wd
->img_snapshot
->w
>> 2);
1259 if ((eb
& ETG_ICONIFY
) != 0)
1261 if (wd
->img_iconify
->ok
)
1263 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_iconify
->w
/ 3); else width
+= (wd
->img_iconify
->w
>> 2);
1269 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_zoom
->w
/ 3); else width
+= (wd
->img_zoom
->w
>> 2);
1272 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1274 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1278 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1279 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1283 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1285 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1286 gadget
->Flags
|= GFLG_RELRIGHT
;
1295 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
1298 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_close
->w
/ 3); else width
= (wd
->img_close
->w
>> 2);
1299 gadget
->Width
= width
;
1300 wd
->closewidth
= width
;
1301 if (data
->dc
->CloseGadgetOnRight
)
1303 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1304 gadget
->Flags
|= GFLG_RELRIGHT
;
1305 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1309 gadget
->LeftEdge
= data
->dc
->BarPreGadget_s
;
1311 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1315 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_depth
->w
/ 3); else width
= (wd
->img_depth
->w
>> 2);
1316 gadget
->Width
= width
;
1317 wd
->depthwidth
= width
;
1318 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1320 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1322 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1323 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1324 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1325 gadget
->Flags
|= GFLG_RELRIGHT
;
1329 if (data
->dc
->GadgetsThreeState
) width
= (wd
->img_zoom
->w
/ 3); else width
= (wd
->img_zoom
->w
>> 2);
1330 gadget
->Width
= width
;
1331 wd
->zoomwidth
= width
;
1332 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1333 if (hasclose
&& data
->dc
->CloseGadgetOnRight
)
1335 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_close
->w
/ 3); else width
+= (wd
->img_close
->w
>> 2);
1339 if (data
->dc
->GadgetsThreeState
) width
+= (wd
->img_depth
->w
/ 3); else width
+= (wd
->img_depth
->w
>> 2);
1340 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1344 gadget
->LeftEdge
= -data
->dc
->BarPostGadget_s
- width
;
1346 gadget
->Flags
&= ~GFLG_RELWIDTH
;
1347 gadget
->Flags
|= GFLG_RELRIGHT
;
1351 case GTYP_WDRAGGING
:
1359 int sysrgad
= -data
->dc
->BarPostGadget_s
- 1;
1361 if (data
->dc
->CloseGadgetOnRight
&& hasclose
) sysrgad
-= wd
->closewidth
;
1362 if (hasdepth
) sysrgad
-= wd
->depthwidth
;
1363 if (haszoom
) sysrgad
-= wd
->zoomwidth
;
1366 if ((gadget
->GadgetType
& GTYP_SYSTYPEMASK
) == 0)
1368 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
1370 case GTYP_WDRAGGING
:
1374 if ((gadget
->Flags
& GFLG_EXTENDED
) != 0)
1376 if ((((struct ExtGadget
*) gadget
)->MoreFlags
& GMORE_BOOPSIGADGET
) != 0)
1379 GetAttr(GA_RightBorder
, (Object
*) gadget
, &rtsm
);
1382 if (GetAttr(PGA_Top
, (Object
*) gadget
, &rtsm
))
1384 SetAttrs((Object
*) gadget
, GA_RelRight
, - data
->dc
->RightBorderGadgets
+ ((data
->dc
->RightBorderGadgets
- (wd
->img_verticalcontainer
->w
>> 1) + 1) >> 1) + 1, GA_Width
, wd
->img_verticalcontainer
->w
>> 1, TAG_DONE
);
1388 GetAttr(GA_Width
, (Object
*) gadget
, &rtsm
);
1389 SetAttrs((Object
*) gadget
, GA_RelRight
, - data
->dc
->RightBorderGadgets
+ ((data
->dc
->RightBorderGadgets
- rtsm
+ 1) >> 1) + 1, TAG_DONE
);
1394 GetAttr(GA_BottomBorder
, (Object
*) gadget
, &rtsm
);
1397 if (GetAttr(PGA_Top
, (Object
*) gadget
, &rtsm
))
1399 SetAttrs((Object
*) gadget
, GA_RelBottom
, - data
->dc
->BottomBorderGadgets
+ ((data
->dc
->BottomBorderGadgets
- (wd
->img_horizontalcontainer
->h
>> 1) + 1) >> 1) +1, GA_Height
, (wd
->img_horizontalcontainer
->h
>> 1), TAG_DONE
);
1403 GetAttr(GA_Height
, (Object
*) gadget
, &rtsm
);
1404 SetAttrs((Object
*) gadget
, GA_RelBottom
, - data
->dc
->BottomBorderGadgets
+ ((data
->dc
->BottomBorderGadgets
- rtsm
+ 1) >> 1) + 1, TAG_DONE
);
1413 if (msg
->wdp_Flags
& WDF_LBG_MULTIPLE
)
1415 gadget
= gadget
->NextGadget
;
1422 gadget
= msg
->wdp_Gadgets
;
1426 if ((gadget
->GadgetType
& GTYP_SYSTYPEMASK
) == 0)
1428 if ((gadget
->Activation
& GACT_TOPBORDER
) != 0)
1430 if ((gadget
->Flags
& GFLG_RELRIGHT
) != 0)
1432 gadget
->TopEdge
= (refheight
- gadget
->Height
) / 2;
1433 sysrgad
-= gadget
->Width
;
1434 gadget
->LeftEdge
= sysrgad
;
1438 gadget
= gadget
->NextGadget
;
1441 gadget
= msg
->wdp_Gadgets
;
1443 if ((msg
->wdp_Flags
& WDF_LBG_SYSTEMGADGET
) != 0) while(gadget
)
1445 switch(gadget
->GadgetType
& GTYP_SYSTYPEMASK
)
1447 case GTYP_WDRAGGING
:
1448 gadget
->Width
= sysrgad
;
1449 if (hasclose
&& !data
->dc
->CloseGadgetOnRight
)
1451 gadget
->Width
-= data
->dc
->BarPreGadget_s
;
1452 if (data
->dc
->GadgetsThreeState
) gadget
->Width
-= (wd
->img_close
->w
/ 3); else gadget
->Width
-= (wd
->img_close
->w
>> 2);
1456 gadget
= gadget
->NextGadget
;
1466 /**************************************************************************************************/
1467 static IPTR
windecor_draw_borderpropback(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropBack
*msg
)
1469 /* Simply return, we need to render the back in the knob method */
1470 /* because we want to use irregular (alpha images) for the sliders */
1474 /**************************************************************************************************/
1475 static IPTR
windecor_draw_borderpropknob(Class
*cl
, Object
*obj
, struct wdpDrawBorderPropKnob
*msg
)
1477 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1478 struct Window
*window
= msg
->wdp_Window
;
1479 struct RastPort
*winrp
= msg
->wdp_RPort
;
1480 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1482 struct RastPort
*rp
;
1483 struct Gadget
*gadget
= msg
->wdp_Gadget
;
1484 struct Rectangle
*r
;
1485 struct PropInfo
*pi
= ((struct PropInfo
*)gadget
->SpecialInfo
);
1486 struct NewImage
*ni
= NULL
;
1487 BOOL hit
= (msg
->wdp_Flags
& WDF_DBPK_HIT
) ? TRUE
: FALSE
;
1488 ULONG y
, x
, bx0
, bx1
, by0
, by1
;
1490 ULONG s_col
, e_col
, arc
;
1492 struct BitMap
*cachedgadgetbitmap
= NULL
;
1493 ULONG changetype
= CHANGE_NO_CHANGE
;
1496 if (!(pi
->Flags
& PROPNEWLOOK
) || (gadget
->Activation
&& (GACT_RIGHTBORDER
| GACT_BOTTOMBORDER
) == 0))
1498 return DoSuperMethodA(cl
, obj
, (Msg
)msg
);
1501 /* Detect change in gadget dimensions (which needs to trigger redraw) */
1502 if ((pi
->Flags
& FREEVERT
) != 0)
1504 changetype
= HasPropGadgetChanged(&wd
->vert
, msg
);
1506 if (changetype
== CHANGE_SIZE_CHANGE
)
1508 /* Free is there was size change */
1509 if (wd
->vert
.bm
!= NULL
)
1510 FreeBitMap(wd
->vert
.bm
);
1513 cachedgadgetbitmap
= wd
->vert
.bm
;
1515 else if ((pi
->Flags
& FREEHORIZ
) != 0)
1517 changetype
= HasPropGadgetChanged(&wd
->horiz
, msg
);
1519 if (changetype
== CHANGE_SIZE_CHANGE
)
1521 /* Free is there was size change */
1522 if (wd
->horiz
.bm
!= NULL
)
1523 FreeBitMap(wd
->horiz
.bm
);
1524 wd
->horiz
.bm
= NULL
;
1526 cachedgadgetbitmap
= wd
->horiz
.bm
;
1530 return TRUE
; /* Return TRUE - after all this is not an error */
1532 /* Reuse the bitmap if that is possible */
1533 if (changetype
== CHANGE_NO_CHANGE
)
1535 /* Final blitting of gadget bitmap to window rast port */
1536 BltBitMapRastPort(cachedgadgetbitmap
, 0, 0, winrp
, msg
->wdp_PropRect
->MinX
,
1537 msg
->wdp_PropRect
->MinY
,
1538 msg
->wdp_PropRect
->MaxX
- msg
->wdp_PropRect
->MinX
+ 1,
1539 msg
->wdp_PropRect
->MaxY
- msg
->wdp_PropRect
->MinY
+ 1, 0xc0);
1543 /* Regenerate the bitmap */
1544 r
= msg
->wdp_PropRect
;
1551 rp
= CreateRastPort();
1554 /* Reuse the bitmap if there was no size change (ie. only move of knob) */
1555 if (changetype
== CHANGE_NO_SIZE_CHANGE
)
1556 rp
->BitMap
= cachedgadgetbitmap
;
1558 rp
->BitMap
= AllocBitMap(bx1
- bx0
+ 1, by1
- by0
+ 1, 1, 0, window
->WScreen
->RastPort
.BitMap
);
1560 if (rp
->BitMap
== NULL
)
1569 if (wd
->img_border_normal
->ok
) ni
= wd
->img_border_normal
;
1571 if (ni
== NULL
) data
->dc
->UseGradients
= TRUE
;
1573 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
))
1575 s_col
= data
->dc
->ActivatedGradientColor_s
;
1576 e_col
= data
->dc
->ActivatedGradientColor_e
;
1577 arc
= data
->dc
->ActivatedGradientColor_a
;
1578 pen
= wd
->ActivePen
;
1582 s_col
= data
->dc
->DeactivatedGradientColor_s
;
1583 e_col
= data
->dc
->DeactivatedGradientColor_e
;
1584 arc
= data
->dc
->DeactivatedGradientColor_a
;
1585 if (!data
->dc
->UseGradients
)
1587 if (wd
->img_border_deactivated
->ok
) ni
= wd
->img_border_deactivated
;
1589 pen
= wd
->DeactivePen
;
1592 /* Drawing background - this solves WDM_DRAW_BORDERPROPBACK without need of
1593 reading from window when drawing container and knob */
1594 if (data
->dc
->UseGradients
)
1596 FillPixelArrayGradient(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
, bx0
, by0
);
1602 ULONG color
= 0x00cccccc;
1603 HorizVertRepeatNewImage(ni
, color
, bx0
, by0
, rp
, 0, 0, bx1
- bx0
+ 1, by1
- by0
+ 1);
1607 /* Drawing knob container */
1608 r
= msg
->wdp_PropRect
;
1612 bx1
= r
->MaxX
- r
->MinX
;
1613 by1
= r
->MaxY
- r
->MinY
;
1615 if ((pi
->Flags
& FREEVERT
) != 0)
1617 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) subimage
= 0; else subimage
= 1;
1619 size
= by1
- by0
- data
->dc
->ContainerTop_s
- data
->dc
->ContainerBottom_s
+ 1;
1620 y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, subimage
, data
->dc
->ContainerTop_o
, data
->dc
->ContainerTop_s
, bx0
, y
, data
->dc
->ContainerTop_s
);
1621 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, subimage
, data
->dc
->ContainerVertTile_o
, data
->dc
->ContainerVertTile_s
, bx0
, y
, size
);
1623 y
= WriteTiledImageVertical(rp
, wd
->img_verticalcontainer
, subimage
, data
->dc
->ContainerBottom_o
, data
->dc
->ContainerBottom_s
, bx0
, y
, data
->dc
->ContainerBottom_s
);
1626 else if ((pi
->Flags
& FREEHORIZ
) != 0)
1628 if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) subimage
= 0; else subimage
= 1;
1630 size
= bx1
- bx0
- data
->dc
->ContainerLeft_s
- data
->dc
->ContainerRight_s
+ 1;
1631 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, subimage
, data
->dc
->ContainerLeft_o
, data
->dc
->ContainerLeft_s
, x
, by0
, data
->dc
->ContainerLeft_s
);
1632 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, subimage
, data
->dc
->ContainerHorTile_o
, data
->dc
->ContainerHorTile_s
, x
, by0
, size
);
1633 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalcontainer
, subimage
, data
->dc
->ContainerRight_o
, data
->dc
->ContainerRight_s
, x
, by0
, data
->dc
->ContainerRight_s
);
1638 bx0
= msg
->wdp_PropRect
->MinX
;
1639 by0
= msg
->wdp_PropRect
->MinY
;
1640 bx1
= msg
->wdp_PropRect
->MaxX
;
1641 by1
= msg
->wdp_PropRect
->MaxY
;
1643 r
= msg
->wdp_RenderRect
;
1644 if ((pi
->Flags
& FREEVERT
) != 0)
1646 if (hit
) subimage
= 1; else if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) subimage
= 0; else subimage
= 2;
1648 size
= r
->MaxY
- r
->MinY
- data
->dc
->KnobTop_s
- data
->dc
->KnobBottom_s
+ 1;
1650 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobTop_o
, data
->dc
->KnobTop_s
, r
->MinX
- bx0
, y
, data
->dc
->KnobTop_s
);
1653 if (size
> data
->dc
->KnobVertGripper_s
)
1655 size
= size
- data
->dc
->KnobVertGripper_s
;
1656 int size_bak
= size
;
1658 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobTileTop_o
, data
->dc
->KnobTileTop_s
, r
->MinX
- bx0
, y
, size
);
1659 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobVertGripper_o
, data
->dc
->KnobVertGripper_s
, r
->MinX
- bx0
, y
, data
->dc
->KnobVertGripper_s
);
1660 size
= size_bak
- size
;
1661 if (size
> 0) y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobTileBottom_o
, data
->dc
->KnobTileBottom_s
, r
->MinX
- bx0
, y
, size
);
1665 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobTileTop_o
, data
->dc
->KnobTileTop_s
, r
->MinX
- bx0
, y
, size
);
1668 y
= WriteTiledImageVertical(rp
, wd
->img_verticalknob
, subimage
, data
->dc
->KnobBottom_o
, data
->dc
->KnobBottom_s
, r
->MinX
- bx0
, y
, data
->dc
->KnobBottom_s
);
1670 else if ((pi
->Flags
& FREEHORIZ
) != 0)
1672 if (hit
) subimage
= 1; else if (window
->Flags
& (WFLG_WINDOWACTIVE
| WFLG_TOOLBOX
)) subimage
= 0; else subimage
= 2;
1674 size
= r
->MaxX
- r
->MinX
- data
->dc
->KnobLeft_s
- data
->dc
->KnobRight_s
+ 1;
1675 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobLeft_o
, data
->dc
->KnobLeft_s
, x
, r
->MinY
- by0
, data
->dc
->KnobLeft_s
);
1679 if (size
> data
->dc
->KnobHorGripper_s
)
1681 size
= size
- data
->dc
->KnobHorGripper_s
;
1682 int size_bak
= size
;
1684 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobTileLeft_o
, data
->dc
->KnobTileLeft_s
, x
, r
->MinY
- by0
, size
);
1685 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobHorGripper_o
, data
->dc
->KnobHorGripper_s
, x
, r
->MinY
- by0
, data
->dc
->KnobHorGripper_s
);
1686 size
= size_bak
- size
;
1687 if (size
> 0) x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobTileRight_o
, data
->dc
->KnobTileRight_s
, x
, r
->MinY
- by0
, size
);
1691 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobTileRight_o
, data
->dc
->KnobTileRight_s
, x
, r
->MinY
- by0
, size
);
1694 x
= WriteTiledImageHorizontal(rp
, wd
->img_horizontalknob
, subimage
, data
->dc
->KnobRight_o
, data
->dc
->KnobRight_s
, x
, r
->MinY
- by0
, data
->dc
->KnobRight_s
);
1697 /* Final blitting of gadget bitmap to window rast port */
1698 BltBitMapRastPort(rp
->BitMap
, 0, 0, winrp
, msg
->wdp_PropRect
->MinX
,
1699 msg
->wdp_PropRect
->MinY
,
1700 msg
->wdp_PropRect
->MaxX
- msg
->wdp_PropRect
->MinX
+ 1,
1701 msg
->wdp_PropRect
->MaxY
- msg
->wdp_PropRect
->MinY
+ 1, 0xc0);
1703 /* Cache the actual bitmap */
1704 if ((pi
->Flags
& FREEVERT
) != 0)
1705 CachePropGadget(&wd
->vert
, msg
, rp
->BitMap
);
1706 else if ((pi
->Flags
& FREEHORIZ
) != 0)
1707 CachePropGadget(&wd
->horiz
, msg
, rp
->BitMap
);
1714 /**************************************************************************************************/
1715 static IPTR
windecor_getdefsizes(Class
*cl
, Object
*obj
, struct wdpGetDefSizeSysImage
*msg
)
1717 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1718 struct NewImage
*n
= NULL
;
1721 BOOL titlegadget
= FALSE
;
1723 switch(msg
->wdp_Which
)
1727 w
= data
->dc
->RightBorderGadgets
;
1728 h
= data
->dc
->BottomBorderGadgets
;
1733 n
= data
->img_close
;
1745 n
= data
->img_popup
;
1751 n
= data
->img_snapshot
;
1757 n
= data
->img_iconify
;
1770 w
= data
->dc
->RightBorderGadgets
;
1771 h
= data
->img_up
->h
+ data
->dc
->UpDownAddY
;
1777 w
= data
->dc
->RightBorderGadgets
;
1778 h
= data
->img_down
->h
+ data
->dc
->UpDownAddY
;
1784 if (data
->dc
->GadgetsThreeState
) w
= (data
->img_left
->w
/ 3); else w
= (data
->img_left
->w
>> 2);
1785 w
+= data
->dc
->LeftRightAddX
;
1786 h
= data
->dc
->BottomBorderGadgets
;
1792 if (data
->dc
->GadgetsThreeState
) w
= (data
->img_right
->w
/ 3); else w
= (data
->img_right
->w
>> 2);
1793 w
+= data
->dc
->LeftRightAddX
;
1794 h
= data
->dc
->BottomBorderGadgets
;
1799 n
= data
->img_depth
;
1814 if (!isset
) return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
1818 *msg
->wdp_Width
= w
;
1819 *msg
->wdp_Height
= h
;
1825 if (data
->dc
->GadgetsThreeState
)
1827 *msg
->wdp_Width
= (n
->w
/ 3);
1828 *msg
->wdp_Height
= n
->h
;
1832 *msg
->wdp_Width
= (n
->w
>> 2);
1833 *msg
->wdp_Height
= n
->h
;
1836 if(titlegadget
&& (msg
->wdp_ReferenceFont
->tf_YSize
+ 2 > data
->dc
->BarHeight
))
1838 /* Scale height so that the gadget is not proportionally resized (so that width does not change) */
1839 *msg
->wdp_Height
*= msg
->wdp_ReferenceFont
->tf_YSize
+ 2;
1840 *msg
->wdp_Height
/= data
->dc
->BarHeight
;
1842 } else return DoSuperMethodA(cl
, obj
, (Msg
) msg
);
1848 /**************************************************************************************************/
1849 static IPTR
windecor_windowshape(Class
*cl
, Object
*obj
, struct wdpWindowShape
*msg
)
1851 struct windecor_data
*data
= INST_DATA(cl
, obj
);
1852 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1853 struct Window
*window
= msg
->wdp_Window
;
1855 if (data
->dc
->BarMasking
)
1857 if (HasTitleBarShapeChanged(&wd
->tbarshape
, window
) != CHANGE_NO_CHANGE
)
1859 struct NewLUT8ImageContainer
*shape
;
1860 struct Region
* newreg
= NULL
;
1862 if (wd
->tbarshape
.shape
!= NULL
)
1864 DisposeRegion(wd
->tbarshape
.shape
);
1865 wd
->tbarshape
.shape
= NULL
;
1868 shape
= (struct NewLUT8ImageContainer
*)NewLUT8ImageContainer(window
->Width
, window
->BorderTop
);
1871 if (window
->BorderTop
> 0) DrawShapePartialTitleBar(wd
, (struct NewLUT8Image
*)shape
, data
, window
);
1873 newreg
= RegionFromLUT8Image(msg
->wdp_Width
, msg
->wdp_Height
, (struct NewLUT8Image
*)shape
);
1874 DisposeLUT8ImageContainer((struct NewLUT8Image
*)shape
);
1876 CacheTitleBarShape(&wd
->tbarshape
, window
, newreg
);
1880 /* Make a copy of region and return it */
1881 return (IPTR
)CopyRegion(wd
->tbarshape
.shape
);
1885 if (!data
->dc
->BarRounded
) return (IPTR
) NULL
;
1887 struct Region
*newshape
;
1889 int x2
= msg
->wdp_Width
-1;
1890 int y2
= msg
->wdp_Height
-1;
1892 if ((newshape
= NewRegion()))
1894 struct Rectangle rect
;
1895 BOOL success
= TRUE
;
1901 success
&= OrRectRegion(newshape
, &rect
);
1907 success
&= OrRectRegion(newshape
, &rect
);
1913 success
&= OrRectRegion(newshape
, &rect
);
1919 success
&= OrRectRegion(newshape
, &rect
);
1925 success
&= OrRectRegion(newshape
, &rect
);
1931 success
&= OrRectRegion(newshape
, &rect
);
1937 success
&= OrRectRegion(newshape
, &rect
);
1939 return (IPTR
) newshape
;
1942 /**************************************************************************************************/
1943 static IPTR
windecor_initwindow(Class
*cl
, Object
*obj
, struct wdpInitWindow
*msg
)
1945 struct WindowData
*wd
= (struct WindowData
*)msg
->wdp_UserBuffer
;
1946 struct ScreenData
*sd
= (struct ScreenData
*)msg
->wdp_ScreenUserBuffer
;
1948 wd
->truecolor
= msg
->wdp_TrueColor
;
1950 wd
->ActivePen
= sd
->ActivePen
;
1951 wd
->DeactivePen
= sd
->DeactivePen
;
1954 wd
->horiz
.bm
= NULL
;
1957 SETIMAGE_WIN(close
);
1958 SETIMAGE_WIN(depth
);
1963 SETIMAGE_WIN(right
);
1965 SETIMAGE_WIN(popup
);
1966 SETIMAGE_WIN(snapshot
);
1967 SETIMAGE_WIN(iconify
);
1969 SETIMAGE_WIN(winbar_normal
);
1970 SETIMAGE_WIN(border_normal
);
1971 SETIMAGE_WIN(border_deactivated
);
1972 SETIMAGE_WIN(verticalcontainer
);
1973 SETIMAGE_WIN(verticalknob
);
1974 SETIMAGE_WIN(horizontalcontainer
);
1975 SETIMAGE_WIN(horizontalknob
);
1980 /**************************************************************************************************/
1981 static IPTR
windecor_exitwindow(Class
*cl
, Object
*obj
, struct wdpExitWindow
*msg
)
1983 struct WindowData
*wd
= (struct WindowData
*) msg
->wdp_UserBuffer
;
1985 if (wd
->vert
.bm
) FreeBitMap(wd
->vert
.bm
);
1986 if (wd
->horiz
.bm
) FreeBitMap(wd
->horiz
.bm
);
1987 if (wd
->tbar
.bm
) FreeBitMap(wd
->tbar
.bm
);
1988 if (wd
->tbarshape
.shape
) DisposeRegion(wd
->tbarshape
.shape
);
1989 if (wd
->tbar
.title
) FreeVec(wd
->tbar
.title
);
1994 /**************************************************************************************************/
1995 static IPTR
windecor_dispatcher(struct IClass
*cl
, Object
*obj
, Msg msg
)
1999 switch(msg
->MethodID
)
2002 retval
= windecor_new(cl
, obj
, (struct opSet
*)msg
);
2006 retval
= windecor_dispose(cl
, obj
, (struct opSet
*)msg
);
2010 retval
= windecor_get(cl
, obj
, (struct opGet
*)msg
);
2013 case WDM_DRAW_SYSIMAGE
:
2014 retval
= windecor_draw_sysimage(cl
, obj
, (struct wdpDrawSysImage
*)msg
);
2017 case WDM_DRAW_WINBORDER
:
2018 retval
= windecor_draw_winborder(cl
, obj
, (struct wdpDrawWinBorder
*)msg
);
2021 case WDM_LAYOUT_BORDERGADGETS
:
2022 retval
= windecor_layout_bordergadgets(cl
, obj
, (struct wdpLayoutBorderGadgets
*)msg
);
2025 case WDM_DRAW_BORDERPROPBACK
:
2026 retval
= windecor_draw_borderpropback(cl
, obj
, (struct wdpDrawBorderPropBack
*)msg
);
2029 case WDM_DRAW_BORDERPROPKNOB
:
2030 retval
= windecor_draw_borderpropknob(cl
, obj
, (struct wdpDrawBorderPropKnob
*)msg
);
2033 case WDM_GETDEFSIZE_SYSIMAGE
:
2034 retval
= windecor_getdefsizes(cl
, obj
, (struct wdpGetDefSizeSysImage
*) msg
);
2037 case WDM_WINDOWSHAPE
:
2038 retval
= windecor_windowshape(cl
, obj
, (struct wdpWindowShape
*) msg
);
2041 case WDM_INITWINDOW
:
2042 retval
= windecor_initwindow(cl
, obj
, (struct wdpInitWindow
*) msg
);
2045 case WDM_EXITWINDOW
:
2046 retval
= windecor_exitwindow(cl
, obj
, (struct wdpExitWindow
*) msg
);
2050 retval
= DoSuperMethodA(cl
, obj
, msg
);
2057 struct IClass
* MakeWindowDecorClass()
2059 struct IClass
* cl
= MakeClass(NULL
, WINDECORCLASS
, NULL
, sizeof(struct windecor_data
), 0);
2062 cl
->cl_Dispatcher
.h_Entry
= HookEntry
;
2063 cl
->cl_Dispatcher
.h_SubEntry
= (HOOKFUNC
)windecor_dispatcher
;