grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / icon / geticonrectangle.c
blobdaf08a50bcc887941693e6127c48016892df9c3b
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "icon_intern.h"
8 /*****************************************************************************
10 NAME */
11 #include <proto/icon.h>
13 AROS_LH5(BOOL, GetIconRectangleA,
15 /* SYNOPSIS */
16 AROS_LHA(struct RastPort *, rp, A0),
17 AROS_LHA(struct DiskObject *, icon, A1),
18 AROS_LHA(STRPTR, label, A2),
19 AROS_LHA(struct Rectangle *, rectangle, A3),
20 AROS_LHA(struct TagItem *, tags, A4),
21 /* LOCATION */
22 struct IconBase *, IconBase, 28, Icon)
24 /* FUNCTION
25 Query size of icon.
27 INPUTS
28 rp - reference RastPort (for font)
29 icon - icon to be queried
30 label - label string
31 rectangle - resulting size
33 RESULT
34 TRUE success
36 NOTES
37 Only very limited implemented.
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 HISTORY
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
53 struct NativeIcon *nativeicon;
54 BOOL isFrameless;
55 BOOL isBorderless;
56 struct Rectangle rect = { 0, 0, 0, 0};
58 isFrameless = GetTagData(ICONDRAWA_Frameless, FALSE, tags);
59 isBorderless = GetTagData(ICONDRAWA_Borderless, FALSE, tags);
61 if (!isBorderless) {
62 rect = LB(IconBase)->ib_EmbossRectangle;
63 if (!isFrameless) {
64 rect.MinX -= 1;
65 rect.MinY -= 1;
66 rect.MaxX += 1;
67 rect.MaxY += 1;
71 nativeicon = GetNativeIcon(icon, LB(IconBase));
72 if (nativeicon && nativeicon->ni_Screen)
74 rectangle->MinX = rect.MinX + 0;
75 rectangle->MinY = rect.MinY + 0;
76 rectangle->MaxX = rect.MaxX + nativeicon->ni_Width - 1;
77 rectangle->MaxY = rect.MaxY + nativeicon->ni_Height - 1;
78 } else
80 rectangle->MinX = rect.MinX + 0;
81 rectangle->MinY = rect.MinY + 0;
82 rectangle->MaxX = rect.MaxX + icon->do_Gadget.Width - 1;
83 rectangle->MaxY = rect.MaxY + icon->do_Gadget.Height - 1;
86 if (label != NULL) {
87 struct TextExtent extent;
88 LONG txtlen = strlen(label);
90 if (txtlen > IconBase->ib_MaxNameLength)
91 txtlen = IconBase->ib_MaxNameLength;
93 TextExtent(rp, label, txtlen, &extent);
95 rectangle->MaxY += extent.te_Height;
97 if (extent.te_Width > (rectangle->MaxX+1))
98 rectangle->MaxX = extent.te_Width - 1;
101 return TRUE;
103 AROS_LIBFUNC_EXIT
104 } /* GetIconRectangle */