2 Copyright © 1999, David Le Corfec.
3 Copyright © 2002, The AROS Development Team.
14 #include <exec/types.h>
15 #include <exec/memory.h>
17 #include <clib/alib_protos.h>
18 #include <intuition/screens.h>
19 #include <proto/exec.h>
20 #include <proto/graphics.h>
21 #include <proto/utility.h>
22 #include <proto/intuition.h>
23 #include <proto/muimaster.h>
26 #include "textengine.h"
27 #include "bubbleengine.h"
30 #include "muimaster_intern.h"
35 extern struct Library
*MUIMasterBase
;
37 /************************************************************************/
39 #define WA_Shape WA_ShapeRegion
41 /************************************************************************/
43 typedef struct ZBubble
52 #define WINLEFT (_window(obj)->LeftEdge + x)
53 #define WINTOP (_window(obj)->TopEdge + y)
55 #define WINWIDTH (bubble->ztext->width + (ROUNDEDGE_SIZE + BORDER_X) * 2)
57 ((bubble->ztext->height + BORDER_Y * 2) < ROUNDEDGE_SIZE * 2 + 1) ? \
58 ROUNDEDGE_SIZE * 2 + 1 : (bubble->ztext->height + BORDER_Y * 2)
60 #define BUBBLEF_CREATESHORTHELP_CALLED 1
62 /************************************************************************/
81 #define ROUNDEDGE_SIZE 13
85 static WORD roundtab
[ROUNDEDGE_SIZE
] =
102 static struct Region
*zune_bubble_shape_create(Object
*obj
,
103 ZBubble
*bubble
, WORD w
, WORD h
)
105 struct Region
*shape
= NewRegion();
112 for (y
= 0; y
< ROUNDEDGE_SIZE
; y
++)
114 r
.MinX
= roundtab
[y
];
116 r
.MaxX
= w
- 1 - r
.MinX
;
119 OrRectRegion(shape
, &r
);
124 OrRectRegion(shape
, &r
);
132 OrRectRegion(shape
, &r
);
138 static void zune_bubble_draw(Object
*obj
, ZBubble
*bubble
)
140 struct RastPort
*rp
= bubble
->win
->RPort
, *objrp
;
141 WORD x1
, x2
, y
, w
, h
, prev_x1
= -1;
143 w
= bubble
->win
->Width
;
144 h
= bubble
->win
->Height
;
146 for (y
= 0; y
< ROUNDEDGE_SIZE
; y
++, prev_x1
= x1
)
153 SetAPen(rp
, _pens(obj
)[MPEN_SHADOW
]);
157 SetAPen(rp
, _pens(obj
)[MPEN_SHINE
]);
160 RectFill(rp
, x1
, y
, x2
, y
);
161 RectFill(rp
, x1
, h
- 1 - y
, x2
, h
- 1 - y
);
167 SetAPen(rp
, _pens(obj
)[MPEN_SHADOW
]);
168 RectFill(rp
, x1
, y
, prev_x1
, y
);
169 RectFill(rp
, x1
, h
- 1 - y
, prev_x1
, h
- 1 - y
);
170 RectFill(rp
, w
- 1 - prev_x1
, y
, w
- 1 - x1
, y
);
171 RectFill(rp
, w
- 1 - prev_x1
, h
- 1 - y
, w
- 1 - x1
, h
- 1 - y
);
176 SetAPen(rp
, _pens(obj
)[MPEN_SHINE
]);
177 RectFill(rp
, 1, y
, w
- 2, h
- 1 - y
);
179 SetAPen(rp
, _pens(obj
)[MPEN_SHADOW
]);
180 RectFill(rp
, 0, y
, 0, h
- 1 - y
);
181 RectFill(rp
, w
- 1, y
, w
- 1, h
- 1 - y
);
186 zune_text_draw(bubble
->ztext
, obj
, ROUNDEDGE_SIZE
+ BORDER_X
,
187 ROUNDEDGE_SIZE
+ BORDER_X
+ bubble
->ztext
->width
- 1,
188 (bubble
->win
->Height
- bubble
->ztext
->height
+ 1) / 2);
193 APTR
zune_bubble_create(Object
*obj
, LONG x
, LONG y
, char *text
,
198 if (!(_flags(obj
) & MADF_CANDRAW
))
201 bubble
= mui_alloc_struct(ZBubble
);
207 text
= (STRPTR
) DoMethod(obj
, MUIM_CreateShortHelp
, x
, y
);
208 bubble
->flags
|= BUBBLEF_CREATESHORTHELP_CALLED
;
219 bubble
->ztext
= zune_text_new(NULL
, bubble
->text
, ZTEXT_ARG_NONE
, 0);
222 zune_bubble_delete(obj
, bubble
);
226 zune_text_get_bounds(bubble
->ztext
, obj
);
229 zune_bubble_shape_create(obj
, bubble
, WINWIDTH
, WINHEIGHT
);
231 bubble
->win
= OpenWindowTags(NULL
, WA_CustomScreen
, (IPTR
) _screen(obj
),
235 WA_Height
, WINHEIGHT
,
239 WA_BackFill
, (IPTR
) LAYERS_NOBACKFILL
,
240 WA_ShapeRegion
, (IPTR
) bubble
->shape
, TAG_DONE
);
244 zune_bubble_delete(obj
, bubble
);
248 zune_bubble_draw(obj
, bubble
);
253 void zune_bubble_delete(Object
*obj
, APTR bubble
)
255 ZBubble
*b
= (ZBubble
*) bubble
;
262 DisposeRegion(b
->shape
);
264 zune_text_destroy(b
->ztext
);
266 if (b
->flags
& BUBBLEF_CREATESHORTHELP_CALLED
)
268 DoMethod(obj
, MUIM_DeleteShortHelp
, (IPTR
) b
->text
);