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 */
28 Permission to use, copy, modify, distribute, and sell this software and its
29 documentation for any purpose is hereby granted without fee, provided that
30 the above copyright notice appear in all copies and that both that
31 copyright notice and this permission notice appear in supporting
32 documentation, and that the name of M.I.T. not be used in advertising or
33 publicity pertaining to distribution of the software without specific,
34 written prior permission. M.I.T. makes no representations about the
35 suitability of this software for any purpose. It is provided "as is"
36 without express or implied warranty.
39 #if 0 // Not used currently...
42 *Returns pointer to first char ins search which is also in what, else NULL.
44 static char *strscan (char *search
, char *what
)
46 int i
, len
= strlen (what
);
49 while ((c
= *(search
++))) {
50 for (i
= 0; i
< len
; i
++)
60 * XParseGeometry parses strings of the form
61 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
62 * width, height, xoffset, and yoffset are unsigned integers.
63 * Example: "=80x24+300-49"
64 * The equal sign is optional.
65 * It returns a bitmask that indicates which of the four values
66 * were actually found in the string. For each value found,
67 * the corresponding argument is updated; for each value
68 * not found, the corresponding argument is left unchanged.
72 ReadInteger(char *string
, char **NextString
)
74 register int Result
= 0;
79 else if (*string
== '-')
84 for (; (*string
>= '0') && (*string
<= '9'); string
++)
86 Result
= (Result
* 10) + (*string
- '0');
95 int XParseGeometry (char *string
, int *x
, int *y
,
96 unsigned int *width
, unsigned int *height
)
99 register char *strind
;
100 unsigned int tempWidth
=0, tempHeight
=0;
101 int tempX
=0, tempY
=0;
104 if ( (string
== NULL
) || (*string
== '\0')) return(mask
);
106 string
++; /* ignore possible '=' at beg of geometry spec */
108 strind
= (char *)string
;
109 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x') {
110 tempWidth
= ReadInteger(strind
, &nextCharacter
);
111 if (strind
== nextCharacter
)
113 strind
= nextCharacter
;
117 if (*strind
== 'x' || *strind
== 'X') {
119 tempHeight
= ReadInteger(strind
, &nextCharacter
);
120 if (strind
== nextCharacter
)
122 strind
= nextCharacter
;
126 if ((*strind
== '+') || (*strind
== '-')) {
127 if (*strind
== '-') {
129 tempX
= -ReadInteger(strind
, &nextCharacter
);
130 if (strind
== nextCharacter
)
132 strind
= nextCharacter
;
138 tempX
= ReadInteger(strind
, &nextCharacter
);
139 if (strind
== nextCharacter
)
141 strind
= nextCharacter
;
144 if ((*strind
== '+') || (*strind
== '-')) {
145 if (*strind
== '-') {
147 tempY
= -ReadInteger(strind
, &nextCharacter
);
148 if (strind
== nextCharacter
)
150 strind
= nextCharacter
;
157 tempY
= ReadInteger(strind
, &nextCharacter
);
158 if (strind
== nextCharacter
)
160 strind
= nextCharacter
;
166 /* If strind isn't at the end of the string the it's an invalid
167 geometry specification. */
169 if (*strind
!= '\0') return (0);
175 if (mask
& WidthValue
)
177 if (mask
& HeightValue
)
178 *height
= tempHeight
;