Fixed building of catalogs.
[AROS.git] / workbench / classes / gadgets / aroscycle / support.c
blob41818df887319f7a143047f41f8c4416581a1a08
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Support functions for AROSCycleClass.
6 Lang: english
7 */
9 /***********************************************************************************/
11 #include <string.h>
12 #include <exec/types.h>
13 #include <proto/intuition.h>
14 #include <intuition/screens.h>
15 #include <proto/graphics.h>
16 #include <graphics/rastport.h>
17 #include <graphics/text.h>
18 #include <libraries/gadtools.h>
20 #include "aroscycle_intern.h"
22 /***********************************************************************************/
24 #define CYCLEIMAGEWIDTH 19
26 /***********************************************************************************/
28 UWORD disabledpattern[2] = {0x4444, 0x1111};
30 /* draws a disabled pattern */
31 void drawdisabledpattern(struct RastPort *rport, UWORD pen,
32 WORD left, WORD top, UWORD width, UWORD height
35 SetABPenDrMd(rport, pen, 0, JAM1);
36 rport->AreaPtrn = disabledpattern;
37 rport->AreaPtSz = 1;
38 RectFill(rport, left, top, left+width-1, top+height-1);
42 /***********************************************************************************/
44 void renderlabel(struct Gadget *gad,
45 STRPTR string,
46 struct RastPort *rport,
47 struct GadgetInfo *ginfo
50 UWORD *pens = ginfo->gi_DrInfo->dri_Pens;
51 WORD x,y,h;
52 int len = strlen(string);
54 SetABPenDrMd(rport, pens[TEXTPEN], pens[BACKGROUNDPEN], JAM1);
55 Move(rport,
56 gad->LeftEdge + (gad->Width - CYCLEIMAGEWIDTH - TextLength(rport, string, len)) / 2,
57 gad->TopEdge + (gad->Height - rport->Font->tf_YSize) / 2 + rport->Font->tf_Baseline);
58 Text(rport, string, len);
60 x = gad->LeftEdge + gad->Width - CYCLEIMAGEWIDTH;
62 /* separator bar */
64 SetAPen(rport, pens[SHINEPEN]);
65 RectFill(rport, x + 1, gad->TopEdge + 2, x + 1, gad->TopEdge + gad->Height - 1 - 2);
66 SetAPen(rport, pens[SHADOWPEN]);
67 RectFill(rport, x, gad->TopEdge + 2, x, gad->TopEdge + gad->Height - 1 - 2);
69 /* cycle image */
71 h = gad->Height / 2;
73 x += 6;
75 for(y = 0; y < 4; y++)
77 RectFill(rport,x + y,
78 gad->TopEdge + gad->Height - 1 - h - y - 1,
79 x + 6 - y,
80 gad->TopEdge + gad->Height - 1 - h - y - 1);
82 RectFill(rport,x + y,
83 gad->TopEdge + h + y + 1,
84 x + 6 - y,
85 gad->TopEdge + h + y + 1);
89 /***********************************************************************************/
91 BOOL pointingadget(struct Gadget *gad, struct GadgetInfo *gi, WORD x, WORD y)
93 WORD gadw, gadh;
95 gadw = gad->Width;
96 if (gad->Flags & GFLG_RELWIDTH) gadw += gi->gi_Domain.Width;
98 gadh = gad->Height;
99 if (gad->Flags & GFLG_RELHEIGHT) gadh += gi->gi_Domain.Height;
101 return ((x >= 0) && (y >= 0) && (x < gadw) && (y < gadh)) ? TRUE : FALSE;
104 /***********************************************************************************/