2 /* Copyright (c) Nate Robins, 1997. */
4 /* This program is freely distributable without licensing fees
5 and is provided without guarantee or warrantee expressed or
6 implied. This program is -not- in the public domain. */
12 /* NOTE: These functions require a BApplication to be instantiated first */
15 return s
.Frame().IntegerWidth() + 1;
20 return s
.Frame().IntegerHeight() + 1;
23 /* the following function was stolen from the X sources as indicated. */
25 /* Copyright Massachusetts Institute of Technology 1985, 1986, 1987 */
26 /* $XConsortium: XParseGeom.c,v 11.18 91/02/21 17:23:05 rws Exp $ */
29 Permission to use, copy, modify, distribute, and sell this software and its
30 documentation for any purpose is hereby granted without fee, provided that
31 the above copyright notice appear in all copies and that both that
32 copyright notice and this permission notice appear in supporting
33 documentation, and that the name of M.I.T. not be used in advertising or
34 publicity pertaining to distribution of the software without specific,
35 written prior permission. M.I.T. makes no representations about the
36 suitability of this software for any purpose. It is provided "as is"
37 without express or implied warranty.
41 *Returns pointer to first char ins search which is also in what, else NULL.
43 static char *strscan (char *search
, char *what
)
45 int i
, len
= strlen (what
);
48 while ((c
= *(search
++)) != (int)NULL
)
49 for (i
= 0; i
< len
; i
++)
56 * XParseGeometry parses strings of the form
57 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
58 * width, height, xoffset, and yoffset are unsigned integers.
59 * Example: "=80x24+300-49"
60 * The equal sign is optional.
61 * It returns a bitmask that indicates which of the four values
62 * were actually found in the string. For each value found,
63 * the corresponding argument is updated; for each value
64 * not found, the corresponding argument is left unchanged.
68 ReadInteger(char *string
, char **NextString
)
70 register int Result
= 0;
75 else if (*string
== '-')
80 for (; (*string
>= '0') && (*string
<= '9'); string
++)
82 Result
= (Result
* 10) + (*string
- '0');
91 int XParseGeometry (char *string
, int *x
, int *y
,
92 unsigned int *width
, unsigned int *height
)
95 register char *strind
;
96 unsigned int tempWidth
=0, tempHeight
=0;
100 if ( (string
== NULL
) || (*string
== '\0')) return(mask
);
102 string
++; /* ignore possible '=' at beg of geometry spec */
104 strind
= (char *)string
;
105 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x') {
106 tempWidth
= ReadInteger(strind
, &nextCharacter
);
107 if (strind
== nextCharacter
)
109 strind
= nextCharacter
;
113 if (*strind
== 'x' || *strind
== 'X') {
115 tempHeight
= ReadInteger(strind
, &nextCharacter
);
116 if (strind
== nextCharacter
)
118 strind
= nextCharacter
;
122 if ((*strind
== '+') || (*strind
== '-')) {
123 if (*strind
== '-') {
125 tempX
= -ReadInteger(strind
, &nextCharacter
);
126 if (strind
== nextCharacter
)
128 strind
= nextCharacter
;
134 tempX
= ReadInteger(strind
, &nextCharacter
);
135 if (strind
== nextCharacter
)
137 strind
= nextCharacter
;
140 if ((*strind
== '+') || (*strind
== '-')) {
141 if (*strind
== '-') {
143 tempY
= -ReadInteger(strind
, &nextCharacter
);
144 if (strind
== nextCharacter
)
146 strind
= nextCharacter
;
153 tempY
= ReadInteger(strind
, &nextCharacter
);
154 if (strind
== nextCharacter
)
156 strind
= nextCharacter
;
162 /* If strind isn't at the end of the string the it's an invalid
163 geometry specification. */
165 if (*strind
!= '\0') return (0);
171 if (mask
& WidthValue
)
173 if (mask
& HeightValue
)
174 *height
= tempHeight
;