XParseGeometry(3X) XParseGeometry(3X)NAME XParseGeometry, XParseColor - parse window geometry and color SYNOPSIS int XParseGeometry (parsestring, x-return, y-return, width-return, height-return) char *parsestring; int *x-return,*y-return; int *width-return,*height-return; Status XParseColor (display, colormap, spec, exact-def-return) Display *display; Colormap colormap; char *spec; XColor *exact-def-return; DESCRIPTION The XParseGeometry function returns a bitmask that indicates which of four values (width, height, xoffset, and yoffset) were actually found in parsestring and whether the x and y values are negative. By convention, X applications use a standard string to indi- cate window size and placement. XParseGeometry makes it easier to conform to this standard because it allows you to parse the standard window geometry. Specifically, this function lets you parse strings of the form: [=][<width>x<height>][{+-}<xoffset>{+-}<yoffset>] The items in this form map into the arguments associated with this function. (Items enclosed in <> are integers, items in [] are optional, and items enclosed in {} indicate a choice of one. Note that the brackets should not appear in the actual string.) By convention, -0 is not equal to +0, because, for example, the user needs to position the window relative to the right or bottom edge. For each value found, the corresponding ar- gument is updated. For each value not found, the argument is left unchanged. The bits are represented by XValue, YValue, WidthValue, HeightValue, XNegative, or YNegative and are defined in <X11/Xutil.h>. They are set whenever one of the values is defined or one of the signs is set. If the function returns either the XValue or YValue flag, you should place the window at the requested position. The XParseColor function provides a simple way to create a standard user interface to color. It takes a string specif- November, 1990 1
XParseGeometry(3X) XParseGeometry(3X)ication of a color, typically from a command line or XGetDe- fault option, and returns the corresponding red, green, and blue values that are suitable for a subsequent call to XAl- locColor or XStoreColor. The color can be specified either as a color name (as in XAllocNamedColor) or as an initial hash mark (#) followed by a numeric specification, in one of the following formats: #RGB (4 bits each) #RRGGBB (8 bits each) #RRRGGGBBB (12 bits each) #RRRRGGGGBBBB (16 bits each) The R, G, and B represent single hexadecimal digits (both uppercase and lowercase). When fewer than 16 bits each are specified, they represent the most-significant bits of the value. For example, #3a7 is the same as #3000a0007000. The colormap argument is used only to determine which screen to look up the color on. For example, you can use the screen's default colormap. If the initial character is a hash mark but the string oth- erwise fails to fit the above formats or if the initial character is not a hash mark and the named color does not exist in the server's database, XParseColor fails and re- turns 0. Arguments These functions accept the following arguments: colormap Specifies the colormap ID. display Specifies the connection to the X server. exact-def-return Returns the exact colors for later use and sets the DoRed, DoGreen, and DoBlue flags. parsestring Specifies the string to be parsed. spec Specifies the color name string. Uppercase and lowercase characters are acceptable. width-return, height-return Return the determined width and height. x-return, y-return Return the determined x offset and y offset. 2 November, 1990
XParseGeometry(3X) XParseGeometry(3X)ERRORS BadColor A value for a Colormap argument does not name a de- fined colormap. The XParseColor function can generate a BadColor error. SEE ALSO Xlib - C Language Interface November, 1990 3