xkbgeom.h 17.1 KB
Newer Older
1 2 3 4 5 6 7 8
/************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.

Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
9 10
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
11
of the software without specific prior written permission.
12
Silicon Graphics makes no representation about the suitability
13 14 15
of this software for any purpose. It is provided "as is"
without any express or implied warranty.

16 17
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 20 21
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.

********************************************************/

#ifndef _XKBGEOM_H_
#define	_XKBGEOM_H_

#include "xkbstr.h"

#define XkbAddGeomKeyAlias 		SrvXkbAddGeomKeyAlias
#define XkbAddGeomColor 		SrvXkbAddGeomColor
#define XkbAddGeomDoodad		SrvXkbAddGeomDoodad
#define XkbAddGeomKey			SrvXkbAddGeomKey
#define XkbAddGeomOutline		SrvXkbAddGeomOutline
#define XkbAddGeomOverlay		SrvXkbAddGeomOverlay
#define XkbAddGeomOverlayRow		SrvXkbAddGeomOverlayRow
#define	XkbAddGeomOverlayKey		SrvXkbAddGeomOverlayKey
#define XkbAddGeomProperty		SrvXkbAddGeomProperty
#define XkbAddGeomRow			SrvXkbAddGeomRow
#define XkbAddGeomSection		SrvXkbAddGeomSection
#define XkbAddGeomShape			SrvXkbAddGeomShape
#define XkbAllocGeometry		SrvXkbAllocGeometry
#define XkbFreeGeomKeyAliases		SrvXkbFreeGeomKeyAliases
#define XkbFreeGeomColors		SrvXkbFreeGeomColors
#define XkbFreeGeomDoodads		SrvXkbFreeGeomDoodads
#define XkbFreeGeomProperties		SrvXkbFreeGeomProperties
#define	XkbFreeGeomKeys			SrvXkbFreeGeomKeys
#define	XkbFreeGeomRows			SrvXkbFreeGeomRows
#define XkbFreeGeomSections		SrvXkbFreeGeomSections
#define	XkbFreeGeomPoints		SrvXkbFreeGeomPoints
#define	XkbFreeGeomOutlines		SrvXkbFreeGeomOutlines
#define XkbFreeGeomShapes		SrvXkbFreeGeomShapes
#define XkbFreeGeometry			SrvXkbFreeGeometry

57 58 59 60
typedef struct _XkbProperty {
    char *name;
    char *value;
} XkbPropertyRec, *XkbPropertyPtr;
61 62

typedef struct _XkbColor {
63 64 65
    unsigned int pixel;
    char *spec;
} XkbColorRec, *XkbColorPtr;
66

67 68 69
typedef struct _XkbPoint {
    short x;
    short y;
70 71
} XkbPointRec, *XkbPointPtr;

72 73 74
typedef struct _XkbBounds {
    short x1, y1;
    short x2, y2;
75
} XkbBoundsRec, *XkbBoundsPtr;
76

77 78 79 80
#define	XkbBoundsWidth(b)	(((b)->x2)-((b)->x1))
#define	XkbBoundsHeight(b)	(((b)->y2)-((b)->y1))

typedef struct _XkbOutline {
81 82 83 84
    unsigned short num_points;
    unsigned short sz_points;
    unsigned short corner_radius;
    XkbPointPtr points;
85 86 87
} XkbOutlineRec, *XkbOutlinePtr;

typedef struct _XkbShape {
88 89 90 91 92 93 94
    Atom name;
    unsigned short num_outlines;
    unsigned short sz_outlines;
    XkbOutlinePtr outlines;
    XkbOutlinePtr approx;
    XkbOutlinePtr primary;
    XkbBoundsRec bounds;
95
} XkbShapeRec, *XkbShapePtr;
96

97 98 99
#define	XkbOutlineIndex(s,o)	((int)((o)-&(s)->outlines[0]))

typedef struct _XkbShapeDoodad {
100 101 102 103 104 105 106 107
    Atom name;
    unsigned char type;
    unsigned char priority;
    short top;
    short left;
    short angle;
    unsigned short color_ndx;
    unsigned short shape_ndx;
108
} XkbShapeDoodadRec, *XkbShapeDoodadPtr;
109

110 111 112 113 114 115
#define	XkbShapeDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
#define	XkbShapeDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
#define	XkbSetShapeDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
#define	XkbSetShapeDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])

typedef struct _XkbTextDoodad {
116 117 118 119 120 121 122 123 124 125 126
    Atom name;
    unsigned char type;
    unsigned char priority;
    short top;
    short left;
    short angle;
    short width;
    short height;
    unsigned short color_ndx;
    char *text;
    char *font;
127
} XkbTextDoodadRec, *XkbTextDoodadPtr;
128

129 130 131 132
#define	XkbTextDoodadColor(g,d)	(&(g)->colors[(d)->color_ndx])
#define	XkbSetTextDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])

typedef struct _XkbIndicatorDoodad {
133 134 135 136 137 138 139 140 141
    Atom name;
    unsigned char type;
    unsigned char priority;
    short top;
    short left;
    short angle;
    unsigned short shape_ndx;
    unsigned short on_color_ndx;
    unsigned short off_color_ndx;
142
} XkbIndicatorDoodadRec, *XkbIndicatorDoodadPtr;
143

144 145 146 147 148 149 150 151 152 153 154
#define	XkbIndicatorDoodadShape(g,d)	(&(g)->shapes[(d)->shape_ndx])
#define	XkbIndicatorDoodadOnColor(g,d)	(&(g)->colors[(d)->on_color_ndx])
#define	XkbIndicatorDoodadOffColor(g,d)	(&(g)->colors[(d)->off_color_ndx])
#define	XkbSetIndicatorDoodadOnColor(g,d,c) \
				((d)->on_color_ndx= (c)-&(g)->colors[0])
#define	XkbSetIndicatorDoodadOffColor(g,d,c) \
				((d)->off_color_ndx= (c)-&(g)->colors[0])
#define	XkbSetIndicatorDoodadShape(g,d,s) \
				((d)->shape_ndx= (s)-&(g)->shapes[0])

typedef struct _XkbLogoDoodad {
155 156 157 158 159 160 161 162 163
    Atom name;
    unsigned char type;
    unsigned char priority;
    short top;
    short left;
    short angle;
    unsigned short color_ndx;
    unsigned short shape_ndx;
    char *logo_name;
164
} XkbLogoDoodadRec, *XkbLogoDoodadPtr;
165

166 167 168 169 170 171
#define	XkbLogoDoodadColor(g,d)		(&(g)->colors[(d)->color_ndx])
#define	XkbLogoDoodadShape(g,d)		(&(g)->shapes[(d)->shape_ndx])
#define	XkbSetLogoDoodadColor(g,d,c)	((d)->color_ndx= (c)-&(g)->colors[0])
#define	XkbSetLogoDoodadShape(g,d,s)	((d)->shape_ndx= (s)-&(g)->shapes[0])

typedef struct _XkbAnyDoodad {
172 173 174 175 176 177
    Atom name;
    unsigned char type;
    unsigned char priority;
    short top;
    short left;
    short angle;
178 179 180
} XkbAnyDoodadRec, *XkbAnyDoodadPtr;

typedef union _XkbDoodad {
181 182 183 184 185
    XkbAnyDoodadRec any;
    XkbShapeDoodadRec shape;
    XkbTextDoodadRec text;
    XkbIndicatorDoodadRec indicator;
    XkbLogoDoodadRec logo;
186 187 188 189 190 191 192 193 194 195
} XkbDoodadRec, *XkbDoodadPtr;

#define	XkbUnknownDoodad	0
#define	XkbOutlineDoodad	1
#define	XkbSolidDoodad		2
#define	XkbTextDoodad		3
#define	XkbIndicatorDoodad	4
#define	XkbLogoDoodad		5

typedef struct _XkbKey {
196 197 198 199
    XkbKeyNameRec name;
    short gap;
    unsigned char shape_ndx;
    unsigned char color_ndx;
200
} XkbKeyRec, *XkbKeyPtr;
201

202 203 204 205 206 207
#define	XkbKeyShape(g,k)	(&(g)->shapes[(k)->shape_ndx])
#define	XkbKeyColor(g,k)	(&(g)->colors[(k)->color_ndx])
#define	XkbSetKeyShape(g,k,s)	((k)->shape_ndx= (s)-&(g)->shapes[0])
#define	XkbSetKeyColor(g,k,c)	((k)->color_ndx= (c)-&(g)->colors[0])

typedef struct _XkbRow {
208 209 210 211 212 213 214
    short top;
    short left;
    unsigned short num_keys;
    unsigned short sz_keys;
    int vertical;
    XkbKeyPtr keys;
    XkbBoundsRec bounds;
215 216 217
} XkbRowRec, *XkbRowPtr;

typedef struct _XkbSection {
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
    Atom name;
    unsigned char priority;
    short top;
    short left;
    unsigned short width;
    unsigned short height;
    short angle;
    unsigned short num_rows;
    unsigned short num_doodads;
    unsigned short num_overlays;
    unsigned short sz_rows;
    unsigned short sz_doodads;
    unsigned short sz_overlays;
    XkbRowPtr rows;
    XkbDoodadPtr doodads;
    XkbBoundsRec bounds;
    struct _XkbOverlay *overlays;
235 236
} XkbSectionRec, *XkbSectionPtr;

237 238 239 240
typedef struct _XkbOverlayKey {
    XkbKeyNameRec over;
    XkbKeyNameRec under;
} XkbOverlayKeyRec, *XkbOverlayKeyPtr;
241 242

typedef struct _XkbOverlayRow {
243 244 245 246 247
    unsigned short row_under;
    unsigned short num_keys;
    unsigned short sz_keys;
    XkbOverlayKeyPtr keys;
} XkbOverlayRowRec, *XkbOverlayRowPtr;
248 249

typedef struct _XkbOverlay {
250 251 252 253 254 255 256
    Atom name;
    XkbSectionPtr section_under;
    unsigned short num_rows;
    unsigned short sz_rows;
    XkbOverlayRowPtr rows;
    XkbBoundsPtr bounds;
} XkbOverlayRec, *XkbOverlayPtr;
257 258

typedef struct _XkbGeometry {
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
    Atom name;
    unsigned short width_mm;
    unsigned short height_mm;
    char *label_font;
    XkbColorPtr label_color;
    XkbColorPtr base_color;
    unsigned short sz_properties;
    unsigned short sz_colors;
    unsigned short sz_shapes;
    unsigned short sz_sections;
    unsigned short sz_doodads;
    unsigned short sz_key_aliases;
    unsigned short num_properties;
    unsigned short num_colors;
    unsigned short num_shapes;
    unsigned short num_sections;
    unsigned short num_doodads;
    unsigned short num_key_aliases;
    XkbPropertyPtr properties;
    XkbColorPtr colors;
    XkbShapePtr shapes;
    XkbSectionPtr sections;
    XkbDoodadPtr doodads;
    XkbKeyAliasPtr key_aliases;
283
} XkbGeometryRec;
284

285 286 287 288 289 290 291 292 293 294 295
#define	XkbGeomColorIndex(g,c)	((int)((c)-&(g)->colors[0]))

#define	XkbGeomPropertiesMask	(1<<0)
#define	XkbGeomColorsMask	(1<<1)
#define	XkbGeomShapesMask	(1<<2)
#define	XkbGeomSectionsMask	(1<<3)
#define	XkbGeomDoodadsMask	(1<<4)
#define	XkbGeomKeyAliasesMask	(1<<5)
#define	XkbGeomAllMask		(0x3f)

typedef struct _XkbGeometrySizes {
296 297 298 299 300 301 302 303
    unsigned int which;
    unsigned short num_properties;
    unsigned short num_colors;
    unsigned short num_shapes;
    unsigned short num_sections;
    unsigned short num_doodads;
    unsigned short num_key_aliases;
} XkbGeometrySizesRec, *XkbGeometrySizesPtr;
304

305 306 307 308
/**
 * Specifies which items should be cleared in an XKB geometry array
 * when the array is reallocated.
 */
309 310 311 312
typedef enum {
    XKB_GEOM_CLEAR_NONE,        /* Don't clear any items, just reallocate.   */
    XKB_GEOM_CLEAR_EXCESS,      /* Clear new extra items after reallocation. */
    XKB_GEOM_CLEAR_ALL          /* Clear all items after reallocation.       */
313 314
} XkbGeomClearance;

315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
extern XkbPropertyPtr XkbAddGeomProperty(XkbGeometryPtr /* geom */ ,
                                         char * /* name */ ,
                                         char * /* value */
    );

extern XkbKeyAliasPtr XkbAddGeomKeyAlias(XkbGeometryPtr /* geom */ ,
                                         char * /* alias */ ,
                                         char * /* real */
    );

extern XkbColorPtr XkbAddGeomColor(XkbGeometryPtr /* geom */ ,
                                   char * /* spec */ ,
                                   unsigned int /* pixel */
    );

extern XkbOutlinePtr XkbAddGeomOutline(XkbShapePtr /* shape */ ,
                                       int      /* sz_points */
    );

extern XkbShapePtr XkbAddGeomShape(XkbGeometryPtr /* geom */ ,
                                   Atom /* name */ ,
                                   int  /* sz_outlines */
    );

extern XkbKeyPtr XkbAddGeomKey(XkbRowPtr        /* row */
    );

extern XkbRowPtr XkbAddGeomRow(XkbSectionPtr /* section */ ,
                               int      /* sz_keys */
    );

extern XkbSectionPtr XkbAddGeomSection(XkbGeometryPtr /* geom */ ,
                                       Atom /* name */ ,
                                       int /* sz_rows */ ,
                                       int /* sz_doodads */ ,
                                       int      /* sz_overlays */
    );

extern XkbOverlayPtr XkbAddGeomOverlay(XkbSectionPtr /* section */ ,
                                       Atom /* name */ ,
                                       int      /* sz_rows */
    );

extern XkbOverlayRowPtr XkbAddGeomOverlayRow(XkbOverlayPtr /* overlay */ ,
                                             int /* row_under */ ,
                                             int        /* sz_keys */
    );

extern XkbOverlayKeyPtr XkbAddGeomOverlayKey(XkbOverlayPtr /* overlay */ ,
                                             XkbOverlayRowPtr /* row */ ,
                                             char * /* over */ ,
                                             char *     /* under */
    );

extern XkbDoodadPtr XkbAddGeomDoodad(XkbGeometryPtr /* geom */ ,
                                     XkbSectionPtr /* section */ ,
                                     Atom       /* name */
    );
373 374

extern void
375 376 377 378 379
 XkbFreeGeomKeyAliases(XkbGeometryPtr /* geom */ ,
                       int /* first */ ,
                       int /* count */ ,
                       Bool     /* freeAll */
    );
380 381

extern void
382 383 384 385 386
 XkbFreeGeomColors(XkbGeometryPtr /* geom */ ,
                   int /* first */ ,
                   int /* count */ ,
                   Bool         /* freeAll */
    );
387 388

extern void
389 390 391 392
 XkbFreeGeomDoodads(XkbDoodadPtr /* doodads */ ,
                    int /* nDoodads */ ,
                    Bool        /* freeAll */
    );
393 394

extern void
395 396 397 398 399
 XkbFreeGeomProperties(XkbGeometryPtr /* geom */ ,
                       int /* first */ ,
                       int /* count */ ,
                       Bool     /* freeAll */
    );
400 401

extern void
402 403 404 405 406
 XkbFreeGeomOverlayKeys(XkbOverlayRowPtr /* row */ ,
                        int /* first */ ,
                        int /* count */ ,
                        Bool    /* freeAll */
    );
407 408

extern void
409 410 411 412 413
 XkbFreeGeomOverlayRows(XkbOverlayPtr /* overlay */ ,
                        int /* first */ ,
                        int /* count */ ,
                        Bool    /* freeAll */
    );
414 415

extern void
416 417 418 419 420
 XkbFreeGeomOverlays(XkbSectionPtr /* section */ ,
                     int /* first */ ,
                     int /* count */ ,
                     Bool       /* freeAll */
    );
421 422

extern void
423 424 425 426 427
 XkbFreeGeomKeys(XkbRowPtr /* row */ ,
                 int /* first */ ,
                 int /* count */ ,
                 Bool           /* freeAll */
    );
428 429

extern void
430 431 432 433 434
 XkbFreeGeomRows(XkbSectionPtr /* section */ ,
                 int /* first */ ,
                 int /* count */ ,
                 Bool           /* freeAll */
    );
435 436

extern void
437 438 439 440 441
 XkbFreeGeomSections(XkbGeometryPtr /* geom */ ,
                     int /* first */ ,
                     int /* count */ ,
                     Bool       /* freeAll */
    );
442 443

extern void
444 445 446 447 448
 XkbFreeGeomPoints(XkbOutlinePtr /* outline */ ,
                   int /* first */ ,
                   int /* count */ ,
                   Bool         /* freeAll */
    );
449 450

extern void
451 452 453 454 455
 XkbFreeGeomOutlines(XkbShapePtr /* shape */ ,
                     int /* first */ ,
                     int /* count */ ,
                     Bool       /* freeAll */
    );
456 457

extern void
458 459 460 461 462
 XkbFreeGeomShapes(XkbGeometryPtr /* geom */ ,
                   int /* first */ ,
                   int /* count */ ,
                   Bool         /* freeAll */
    );
463 464

extern void
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
 XkbFreeGeometry(XkbGeometryPtr /* geom */ ,
                 unsigned int /* which */ ,
                 Bool           /* freeMap */
    );

extern Bool
 XkbGeomRealloc(void ** /* buffer */ ,
                int /* szItems */ ,
                int /* nrItems */ ,
                int /* itemSize */ ,
                XkbGeomClearance        /* clearance */
    );

extern Status XkbAllocGeomProps(XkbGeometryPtr /* geom */ ,
                                int     /* nProps */
    );

extern Status XkbAllocGeomKeyAliases(XkbGeometryPtr /* geom */ ,
                                     int        /* nAliases */
    );

extern Status XkbAllocGeomColors(XkbGeometryPtr /* geom */ ,
                                 int    /* nColors */
    );

extern Status XkbAllocGeomShapes(XkbGeometryPtr /* geom */ ,
                                 int    /* nShapes */
    );

extern Status XkbAllocGeomSections(XkbGeometryPtr /* geom */ ,
                                   int  /* nSections */
    );

extern Status XkbAllocGeomOverlays(XkbSectionPtr /* section */ ,
                                   int  /* num_needed */
    );

extern Status XkbAllocGeomOverlayRows(XkbOverlayPtr /* overlay */ ,
                                      int       /* num_needed */
    );

extern Status XkbAllocGeomOverlayKeys(XkbOverlayRowPtr /* row */ ,
                                      int       /* num_needed */
    );

extern Status XkbAllocGeomDoodads(XkbGeometryPtr /* geom */ ,
                                  int   /* nDoodads */
    );

extern Status XkbAllocGeomSectionDoodads(XkbSectionPtr /* section */ ,
                                         int    /* nDoodads */
    );

extern Status XkbAllocGeomOutlines(XkbShapePtr /* shape */ ,
                                   int  /* nOL */
    );

extern Status XkbAllocGeomRows(XkbSectionPtr /* section */ ,
                               int      /* nRows */
    );

extern Status XkbAllocGeomPoints(XkbOutlinePtr /* ol */ ,
                                 int    /* nPts */
    );

extern Status XkbAllocGeomKeys(XkbRowPtr /* row */ ,
                               int      /* nKeys */
    );

extern Status XkbAllocGeometry(XkbDescPtr /* xkb */ ,
                               XkbGeometrySizesPtr      /* sizes */
    );

extern Bool
 XkbComputeShapeTop(XkbShapePtr /* shape */ ,
                    XkbBoundsPtr        /* bounds */
    );

extern Bool
 XkbComputeShapeBounds(XkbShapePtr      /* shape */
    );
546

547
extern Bool
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
 XkbComputeRowBounds(XkbGeometryPtr /* geom */ ,
                     XkbSectionPtr /* section */ ,
                     XkbRowPtr  /* row */
    );

extern Bool
 XkbComputeSectionBounds(XkbGeometryPtr /* geom */ ,
                         XkbSectionPtr  /* section */
    );

extern char *XkbFindOverlayForKey(XkbGeometryPtr /* geom */ ,
                                  XkbSectionPtr /* wanted */ ,
                                  char *        /* under */
    );

#endif                          /* _XKBGEOM_H_ */