2d1bc655cbd61be671044c9254fc47995874ee68
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.
40 #if 0 // Not used currently...
43 *Returns pointer to first char ins search which is also in what, else NULL.
45 static char *strscan (char *search
, char *what
)
47 int i
, len
= strlen (what
);
50 while ((c
= *(search
++))) {
51 for (i
= 0; i
< len
; i
++)
61 * XParseGeometry parses strings of the form
62 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
63 * width, height, xoffset, and yoffset are unsigned integers.
64 * Example: "=80x24+300-49"
65 * The equal sign is optional.
66 * It returns a bitmask that indicates which of the four values
67 * were actually found in the string. For each value found,
68 * the corresponding argument is updated; for each value
69 * not found, the corresponding argument is left unchanged.
73 ReadInteger(char *string
, char **NextString
)
75 register int Result
= 0;
80 else if (*string
== '-')
85 for (; (*string
>= '0') && (*string
<= '9'); string
++)
87 Result
= (Result
* 10) + (*string
- '0');
96 int XParseGeometry (char *string
, int *x
, int *y
,
97 unsigned int *width
, unsigned int *height
)
100 register char *strind
;
101 unsigned int tempWidth
=0, tempHeight
=0;
102 int tempX
=0, tempY
=0;
105 if ( (string
== NULL
) || (*string
== '\0')) return(mask
);
107 string
++; /* ignore possible '=' at beg of geometry spec */
109 strind
= (char *)string
;
110 if (*strind
!= '+' && *strind
!= '-' && *strind
!= 'x') {
111 tempWidth
= ReadInteger(strind
, &nextCharacter
);
112 if (strind
== nextCharacter
)
114 strind
= nextCharacter
;
118 if (*strind
== 'x' || *strind
== 'X') {
120 tempHeight
= ReadInteger(strind
, &nextCharacter
);
121 if (strind
== nextCharacter
)
123 strind
= nextCharacter
;
127 if ((*strind
== '+') || (*strind
== '-')) {
128 if (*strind
== '-') {
130 tempX
= -ReadInteger(strind
, &nextCharacter
);
131 if (strind
== nextCharacter
)
133 strind
= nextCharacter
;
139 tempX
= ReadInteger(strind
, &nextCharacter
);
140 if (strind
== nextCharacter
)
142 strind
= nextCharacter
;
145 if ((*strind
== '+') || (*strind
== '-')) {
146 if (*strind
== '-') {
148 tempY
= -ReadInteger(strind
, &nextCharacter
);
149 if (strind
== nextCharacter
)
151 strind
= nextCharacter
;
158 tempY
= ReadInteger(strind
, &nextCharacter
);
159 if (strind
== nextCharacter
)
161 strind
= nextCharacter
;
167 /* If strind isn't at the end of the string the it's an invalid
168 geometry specification. */
170 if (*strind
!= '\0') return (0);
176 if (mask
& WidthValue
)
178 if (mask
& HeightValue
)
179 *height
= tempHeight
;