1 /* 2 Graphics IO Wrapper (easier to use and more powerful than GLUT) 3 */ 4 5 #ifndef GW_H 6 #define GW_H 7 8 #ifdef __cplusplus 9 # define NOMANGLE 10 extern "C" 11 { 12 #endif /* __cplusplus */ 13 14 #include <sys/types.h> 15 16 /* Include OS specific header files */ 17 #ifdef __MSW__ 18 19 #else 20 # include <GL/glx.h> 21 #endif 22 23 #include "stategl.h" 24 25 26 /* 27 * Type make-ups: 28 */ 29 #ifndef Pixel 30 # define Pixel unsigned long 31 #endif 32 #ifndef Bool 33 # define Bool char 34 #endif 35 #ifndef Boolean 36 # define Boolean Bool 37 #endif 38 39 #ifdef __MSW__ 40 # ifndef False 41 # define False 0 42 # endif 43 # ifndef True 44 # define True 1 45 # endif 46 #endif /* __MSW__ */ 47 48 #ifdef __MSW__ 49 # ifndef u_int8_t 50 # define u_int8_t unsigned char 51 # endif 52 # ifndef u_int16_t 53 # define u_int16_t unsigned short 54 # endif 55 # ifndef u_int32_t 56 # define u_int32_t unsigned int 57 # endif 58 #endif /* __MSW__ */ 59 60 #ifndef BYTES_PER_PIXEL8 61 # define BYTES_PER_PIXEL8 1 62 #endif 63 #ifndef BYTES_PER_PIXEL15 64 # define BYTES_PER_PIXEL15 2 65 #endif 66 #ifndef BYTES_PER_PIXEL16 67 # define BYTES_PER_PIXEL16 2 68 #endif 69 #ifndef BYTES_PER_PIXEL24 70 # define BYTES_PER_PIXEL24 4 71 #endif 72 #ifndef BYTES_PER_PIXEL32 73 # define BYTES_PER_PIXEL32 4 74 #endif 75 76 77 /* 78 * Toplevel window size bounds (in pixels): 79 */ 80 #define GW_MIN_TOPLEVEL_WIDTH 8 81 #define GW_MIN_TOPLEVEL_HEIGHT 8 82 83 #define GW_MIN_TOPLEVEL_WIDTH_INC 1 84 #define GW_MIN_TOPLEVEL_HEIGHT_INC 1 85 86 /* 87 * Geometry string maximum length: 88 */ 89 #define GW_GEOMETRY_STRING_MAX 256 90 91 /* 92 * Default double and trible click intervals (in milliseconds): 93 */ 94 #define GW_2BUTTON_PRESS_INTERVAL 600 95 #define GW_3BUTTON_PRESS_INTERVAL 600 96 97 98 /* 99 * Non-ascii key values for GW sent to calling functions: 100 */ 101 #define GWKeyAlt 0x0100 102 #define GWKeyCtrl 0x0101 103 #define GWKeyShift 0x0102 104 105 #define GWKeyF1 0x0200 106 #define GWKeyF2 0x0201 107 #define GWKeyF3 0x0202 108 #define GWKeyF4 0x0203 109 #define GWKeyF5 0x0204 110 #define GWKeyF6 0x0205 111 #define GWKeyF7 0x0206 112 #define GWKeyF8 0x0207 113 #define GWKeyF9 0x0208 114 #define GWKeyF10 0x0209 115 #define GWKeyF11 0x020a 116 #define GWKeyF12 0x020b 117 #define GWKeyF13 0x020c 118 #define GWKeyF14 0x020d 119 #define GWKeyF15 0x020e 120 #define GWKeyF16 0x020f 121 #define GWKeyF17 0x0210 122 #define GWKeyF18 0x0211 123 #define GWKeyF19 0x0212 124 #define GWKeyF20 0x0213 125 126 #define GWKeyUp 0x0300 127 #define GWKeyDown 0x0301 128 #define GWKeyLeft 0x0302 129 #define GWKeyRight 0x0303 130 #define GWKeyCenter 0x0304 131 #define GWKeyHome 0x0305 132 #define GWKeyEnd 0x0306 133 #define GWKeyPageUp 0x0307 134 #define GWKeyPageDown 0x0308 135 136 #define GWKeyBackSpace 0x0400 137 #define GWKeyDelete 0x0401 138 #define GWKeyInsert 0x0402 139 140 #define GWKeyPause 0x0500 141 #define GWKeyScrollLock 0x0501 142 #define GWKeySysReq 0x0502 143 144 145 /* 146 * Visibility Types: 147 */ 148 typedef enum { 149 GWVisibilityUnobscured, 150 GWVisibilityPartiallyObscured, 151 GWVisibilityFullyObscured 152 } gw_visibility; 153 154 /* 155 * Event Types: 156 */ 157 typedef enum { 158 GWEventTypeButtonPress = 1, 159 GWEventTypeButtonRelease = 2, 160 GWEventTypePointerMotion = 3, 161 GWEventType2ButtonPress = 4, /* Double click */ 162 GWEventType3ButtonPress = 5 /* Trible click */ 163 } gw_event_type; 164 165 /* 166 * GW Pointer Cursor Types: 167 */ 168 typedef enum { 169 GWPointerCursorStandard, /* Basic arrow */ 170 GWPointerCursorBusy, /* Usually hourglass or watch */ 171 GWPointerCursorText, /* Text cursor */ 172 GWPointerCursorTranslate, /* 4 arrows in all directions */ 173 GWPointerCursorZoom, /* Square with smaller square (ie resizine) */ 174 GWPointerCursorInvisible /* Totally invisible cursor */ 175 } gw_pointer_cursor; 176 177 178 /* 179 * GW Font Type: 180 */ 181 #define GWFont u_int8_t 182 183 184 #ifdef __MSW__ 185 /* 186 * Window geometry (for Win32 use): 187 */ 188 typedef struct { 189 int x, 190 y; 191 int width, 192 height; 193 } WRectangle; 194 #endif /* __MSW__ */ 195 196 /* 197 * Vidmode information structure: 198 */ 199 typedef struct { 200 int width, /* Display size in pixels */ 201 height, 202 vwidth, /* Virtual screen size in pixels */ 203 vheight; 204 } gw_vidmode_struct; 205 206 /* 207 * Accelerator Key: 208 */ 209 typedef struct { 210 int key; /* Any character value or GWKey* */ 211 int modifier; /* GWKeyAlt, GWKeyCtrl, GWKeyShift, or 0 */ 212 } gw_accelerator_struct; 213 214 215 #ifdef X_H 216 /* 217 * Icon Codes: 218 */ 219 typedef enum { 220 GWX_ICON_NONE, 221 GWX_ICON_INFO, 222 GWX_ICON_WARNING, 223 GWX_ICON_ERROR, 224 GWX_ICON_QUESTION 225 } gwx_icon; 226 227 /* 228 * Widget Flags: 229 */ 230 typedef enum { 231 GWX_MAPPED = (1 << 0), 232 GWX_CAN_FOCUS = (1 << 1), 233 GWX_HAS_FOCUS = (1 << 2), 234 GWX_CAN_DEFAULT = (1 << 3), 235 GWX_HAS_DEFAULT = (1 << 4), 236 GWX_SENSITIVE = (1 << 5) 237 } gwx_widget_flags; 238 239 /* 240 * Widget: 241 * 242 * All GWX widgets have the first set of members as prototyped 243 * in GWX_WIDGET_MEMBERS_PROTOTYPE. 244 */ 245 #define GWX_WIDGET_MEMBERS_PROTOTYPE \ 246 gwx_widget_flags flags; \ 247 Window toplevel, \ 248 parent; \ 249 Pixmap toplevel_buf; \ 250 int x, /* Position */ \ 251 y; \ 252 unsigned int width, /* Size */ \ 253 height; 254 typedef struct { 255 256 GWX_WIDGET_MEMBERS_PROTOTYPE 257 258 } gwx_widget_struct; 259 #define GWX_WIDGET(p) ((gwx_widget_struct *)(p)) 260 #define GWX_WIDGET_MAPPED(p) (((p) != NULL) ? \ 261 (GWX_WIDGET(p)->flags & GWX_MAPPED) : False) 262 #define GWX_WIDGET_CAN_FOCUS(p) (((p) != NULL) ? \ 263 (GWX_WIDGET(p)->flags & GWX_CAN_FOCUS) : False) 264 #define GWX_WIDGET_HAS_FOCUS(p) (((p) != NULL) ? \ 265 (GWX_WIDGET(p)->flags & GWX_HAS_FOCUS) : False) 266 #define GWX_WIDGET_CAN_DEFAULT(p) (((p) != NULL) ? \ 267 (GWX_WIDGET(p)->flags & GWX_CAN_DEFAULT) : False) 268 #define GWX_WIDGET_HAS_DEFAULT(p) (((p) != NULL) ? \ 269 (GWX_WIDGET(p)->flags & GWX_HAS_DEFAULT) : False) 270 #define GWX_WIDGET_SENSITIVE(p) (((p) != NULL) ? \ 271 (GWX_WIDGET(p)->flags & GWX_SENSITIVE) : False) 272 273 274 /* 275 * Button widget for X dialogs: 276 */ 277 typedef enum { 278 GWX_BUTTON_STATE_UNARMED, 279 GWX_BUTTON_STATE_ARMED, 280 GWX_BUTTON_STATE_HIGHLIGHTED 281 } gwx_button_state; 282 typedef struct { 283 284 GWX_WIDGET_MEMBERS_PROTOTYPE 285 286 void *dialog; /* Parent gwx_dialog_struct */ 287 288 gwx_button_state state; 289 290 /* Accelerator keys */ 291 gw_accelerator_struct **accelerator; 292 int total_accelerators; 293 294 /* Colors */ 295 Pixel color_fg, 296 color_bg, 297 color_fg_insensitive, 298 color_bg_highlighted, 299 color_highlight, 300 color_shade; 301 Boolean colors_initialized; 302 303 XFontStruct *font; 304 char *label; 305 int label_len_pixels, 306 label_height_pixels; 307 308 /* Button press callback, btn_ptr, client_data */ 309 void (*func_cb)( 310 void *, /* Button */ 311 void * /* Data */ 312 ); 313 void *client_data; 314 315 } gwx_button_struct; 316 #define GWX_BUTTON(p) ((gwx_button_struct *)(p)) 317 318 319 /* 320 * Message dialog for X: 321 */ 322 typedef enum { 323 GWX_DIALOG_TYPE_MESG, 324 GWX_DIALOG_TYPE_CONF, 325 GWX_DIALOG_TYPE_CONF_CANCEL /* With cancel button */ 326 } gwx_dialog_type; 327 typedef struct { 328 329 GWX_WIDGET_MEMBERS_PROTOTYPE 330 331 gwx_dialog_type type; 332 333 unsigned int margin; 334 335 Pixel color_fg, color_bg, 336 color_highlight, color_shade; 337 Boolean colors_initialized; 338 Window icon_w; 339 Pixmap icon, 340 icon_mask; 341 unsigned int icon_width, 342 icon_height; 343 344 XFontStruct *font; 345 346 /* Lines of messages */ 347 char **strv; 348 int strc, 349 longest_line; 350 int longest_line_pixels, 351 line_height_pixels, 352 lines_height_pixels; 353 354 gwx_button_struct ok_btn, 355 yes_btn, 356 no_btn, 357 cancel_btn; 358 359 } gwx_dialog_struct; 360 #define GWX_DIALOG(p) ((gwx_dialog_struct *)(p)) 361 362 #undef GWX_WIDGET_MEMBERS_PROTOTYPE 363 364 #endif /* X_H */ 365 366 367 /* 368 * GW Display: 369 */ 370 typedef struct { 371 372 int gl_version_major, 373 gl_version_minor; 374 375 /* Correction to calculated aspects coefficients, this value 376 * is added to aspect coefficients to correct for displays 377 * that have non 4/3 aspect ratios 378 */ 379 float aspect_offset; 380 381 /* Maximum texture sizes, in texels. A value of 0 may suggest 382 * that texture is not supported 383 */ 384 GLint texture_1d_max, 385 texture_2d_max, 386 texture_3d_max; 387 388 #ifdef X_H 389 int glx_version_major, 390 glx_version_minor; 391 Boolean direct_rendering; 392 Display *display; 393 XVisualInfo *visual_info; 394 Boolean has_double_buffer; 395 int alpha_channel_bits; 396 Boolean has_vidmode_ext; 397 int vidmode_ext_event_offset; 398 Visual *visual; 399 GC gc; 400 int depth; 401 Pixel black_pix, 402 white_pix; 403 Colormap colormap; 404 Atom atom_wm_motif_all_clients, 405 atom_wm_motif_hints, 406 atom_wm_motif_info, 407 atom_wm_motif_menu, 408 atom_wm_motif_messages, 409 atom_wm_motif_offset, 410 atom_wm_motif_query, 411 atom_wm_close_window, /* _NET_CLOSE_WINDOW */ 412 atom_wm_delete_window, /* WM_DELETE_WINDOW */ 413 atom_wm_ping, 414 atom_wm_save_yourself, 415 atom_wm_state, 416 atom_wm_take_focus, 417 atom_wm_workarea; /* _NET_WORKAREA */ 418 419 char *def_xfont_name; 420 421 Boolean cursor_shown; 422 Cursor cursor_standard, 423 cursor_busy, 424 cursor_text, 425 cursor_translate, 426 cursor_zoom, 427 cursor_invisible; 428 429 /* Root window and its geometry */ 430 Window root; 431 int root_width, 432 root_height; 433 434 /* Work area viewport (not GL frame buffer viewport) */ 435 int viewport_x, 436 viewport_y, 437 viewport_width, 438 viewport_height; 439 440 /* GLX rendering contexts and toplevel Windows */ 441 int gl_context_num; /* Current GLX context */ 442 int total_gl_contexts; /* Total; GLX contexts, 443 * toplevel Windows, and 444 * toplevel rectangles */ 445 GLXContext *glx_context; 446 Window *toplevel; 447 XRectangle *toplevel_geometry; 448 449 int *draw_count; /* Posted draws */ 450 451 /* Last ButtonPress timestamp */ 452 Time last_button_press; 453 454 /* Button press count, used for double and triple clicks */ 455 int button_press_count; 456 457 /* Indicates that pointer is currently grabbed if not None */ 458 Window grab_window; 459 460 /* Indicates if currently full screen */ 461 Boolean fullscreen; 462 /* Current GL context number in full screen (-1 for none) */ 463 int fullscreen_context_num; 464 /* Previous vidmode geometry for GUI */ 465 XRectangle vidmode_last_gui_geometry; 466 /* Previous window coordinates for toplevel window in GUI mode 467 * (prior to using vidmode to go full screen). 468 */ 469 int vidmode_last_gui_wx, 470 vidmode_last_gui_wy; 471 472 gwx_dialog_struct mesg_dialog; 473 gwx_dialog_struct conf_dialog; 474 #endif /* X_H */ 475 #ifdef __MSW__ 476 int glw_version_major, 477 glw_version_minor; 478 int depth; /* Depth in bits */ 479 Boolean has_double_buffer; 480 int alpha_channel_bits; 481 void *pid; /* (HINSTANCE) */ 482 483 /* Root window (monitor) geometry */ 484 void *root; /* (HWND) */ 485 int root_width, 486 root_height; 487 488 /* GLW rendering contexts and toplevel Windows */ 489 int gl_context_num; /* Current GLX context */ 490 int total_gl_contexts; /* Total; GLX contexts, 491 * toplevel Windows, and 492 * toplevel rectangles */ 493 void **toplevel; /* Toplevel Windows (HWND) */ 494 void **dc; /* Device contexts (HDC) */ 495 void **rc; /* Rendering contexts (HGLRC) */ 496 WRectangle *toplevel_geometry; 497 498 int *draw_count; /* Posted draws */ 499 500 Boolean keyboard_autorepeat; 501 502 /* Records the state of each key, the key's ASCII value 503 * corresponds to the index of the key_state array 504 */ 505 #define GW_KEY_STATE_TABLE_MAX_KEYS 256 506 Boolean key_state[GW_KEY_STATE_TABLE_MAX_KEYS]; 507 508 /* Last WM_*BUTTONDOWN message in milliseconds */ 509 unsigned long last_button_press; 510 511 /* Button press count, used for double and triple clicks */ 512 int button_press_count; 513 514 Boolean fullscreen; 515 int last_gui_wx, 516 last_gui_wy, 517 last_gui_wwidth, 518 last_gui_wheight; 519 520 Boolean cursor_shown; 521 void *cursor_current; /* Shared, do not reference */ 522 void *cursor_standard, 523 *cursor_busy, 524 *cursor_text, 525 *cursor_translate, 526 *cursor_zoom; 527 528 #endif /* __MSW__ */ 529 530 531 /* Draw callback */ 532 void (*func_draw)( 533 int, /* Context Number */ 534 void * /* Data */ 535 ); 536 void *func_draw_data; 537 538 /* Resize callback */ 539 void (*func_resize)( 540 int, /* Context Number */ 541 void *, /* Data */ 542 int, int, /* X, Y */ 543 int, int /* Width, Height */ 544 ); 545 void *func_resize_data; 546 547 /* Keypress callback */ 548 void (*func_keyboard)( 549 void *, /* Data */ 550 int, /* Key */ 551 Boolean, /* State (True = press) */ 552 unsigned long /* Timestamp (in ms) */ 553 ); 554 void *func_keyboard_data; 555 556 /* Pointer callback */ 557 void (*func_pointer)( 558 int, /* Context Number */ 559 void *, /* Data */ 560 int, int, /* X, Y */ 561 gw_event_type, /* Event Type */ 562 int, /* Button Number */ 563 unsigned long /* Timestamp (in ms) */ 564 ); 565 void *func_pointer_data; 566 567 /* Visibility Change callback */ 568 void (*func_visibility)( 569 int, /* Context Number */ 570 void *, /* Data */ 571 gw_visibility /* Visiblity Type */ 572 ); 573 void *func_visibility_data; 574 575 /* Save Yourself callback */ 576 void (*func_save_yourself)( 577 int, /* Context Number */ 578 void * /* Data */ 579 ); 580 void *func_save_yourself_data; 581 582 /* Close callback */ 583 void (*func_close)( 584 int, /* Context Number */ 585 void *, /* Data */ 586 void * /* Window ID */ 587 ); 588 void *func_close_data; 589 590 /* Timeout callback */ 591 void (*func_timeout)( 592 void * /* Data */ 593 ); 594 void *func_timeout_data; 595 596 /* Modifier Key states */ 597 Boolean alt_key_state, 598 ctrl_key_state, 599 shift_key_state; 600 601 GWFont *current_font; 602 603 /* OpenGL state record structure for our GL context */ 604 state_gl_struct state_gl; 605 Boolean allow_autorepeat; 606 } gw_display_struct; 607 #define GW_DISPLAY(p) ((gw_display_struct *)(p)) 608 609 610 #ifdef X_H 611 extern int GWGetCharacterFromKeyCode(gw_display_struct *dpy, KeyCode keycode); 612 extern Window GWGetParent(gw_display_struct *dpy, Window w); 613 #endif /* X_H */ 614 extern void GWSetWindowIconFile( 615 gw_display_struct *display, int ctx_num, 616 const char *icon_path, const char *icon_name 617 ); 618 #ifdef X_H 619 extern Window GWCreateWindow( 620 gw_display_struct *dpy, 621 Window parent, 622 int x, int y, 623 int width, int height, 624 const char *title 625 ); 626 #endif /* X_H */ 627 #ifdef __MSW__ 628 extern int GWCreateWindow( 629 gw_display_struct *dpy, 630 void *parent, 631 void **hwnd_rtn, 632 void **dc_rtn, 633 void **rc_rtn, 634 int x, int y, 635 int width, int height, 636 int depth, /* In bits */ 637 const char *title 638 ); 639 #endif /* __MSW__ */ 640 641 /* GW init/management/shutdown */ 642 extern gw_display_struct *GWInit(int argc, char **argv); 643 extern void GWManage(gw_display_struct *display); 644 extern void GWShutdown(gw_display_struct *display); 645 646 /* GW sync */ 647 extern void GWFlush(gw_display_struct *display); 648 extern void GWFlush(gw_display_struct *display); 649 extern int GWEventsPending(gw_display_struct *display); 650 651 /* GW dialog message and response */ 652 #define GWOutputMessageTypeGeneral 0 653 #define GWOutputMessageTypeWarning 1 654 #define GWOutputMessageTypeError 2 655 #define GWOutputMessageTypeQuestion 3 656 extern void GWOutputMessage( 657 gw_display_struct *display, 658 int type, /* One of GWOutputMessageType* */ 659 const char *subject, 660 const char *message, 661 const char *help_details 662 ); 663 #define GWConfirmationNotAvailable -1 664 #define GWConfirmationNo 0 665 #define GWConfirmationYes 1 666 #define GWConfirmationCancel 2 667 extern int GWConfirmation( 668 gw_display_struct *display, 669 int type, /* One of GWOutputMessageType* */ 670 const char *subject, 671 const char *message, 672 const char *help_details, 673 int default_response /* One of GWConfirmation* */ 674 ); 675 extern int GWConfirmationSimple( 676 gw_display_struct *display, 677 const char *message 678 ); 679 680 /* GW callback setting */ 681 extern void GWSetDrawCB( 682 gw_display_struct *display, 683 void (*func)(int, void *), 684 void *data 685 ); 686 extern void GWSetResizeCB( 687 gw_display_struct *display, 688 void (*func)(int, void *, int, int, int, int), 689 void *data 690 ); 691 extern void GWSetKeyboardCB( 692 gw_display_struct *display, 693 void (*func)(void *, int, Boolean, unsigned long), 694 void *data 695 ); 696 extern void GWSetPointerCB( 697 gw_display_struct *display, 698 void (*func)(int, void *, int, int, gw_event_type, int, unsigned long), 699 void *data 700 ); 701 extern void GWSetVisibilityCB( 702 gw_display_struct *display, 703 void (*func)(int, void *, gw_visibility), 704 void *data 705 ); 706 extern void GWSetSaveYourselfCB( 707 gw_display_struct *display, 708 void (*func)(int, void *), 709 void *data 710 ); 711 extern void GWSetCloseCB( 712 gw_display_struct *display, 713 void (*func)(int, void *, void *), 714 void *data 715 ); 716 extern void GWSetTimeoutCB( 717 gw_display_struct *display, 718 void (*func)(void *), 719 void *data 720 ); 721 722 /* GW context */ 723 extern int GWContextNew( 724 gw_display_struct *display, 725 int x, int y, int width, int height, 726 const char *title, 727 const char *icon_path, const char *icon_name, 728 Bool no_windows 729 ); 730 extern void GWContextDelete( 731 gw_display_struct *display, int ctx_num 732 ); 733 extern int GWContextCurrent(gw_display_struct *display); 734 extern int GWContextGet( 735 gw_display_struct *display, int ctx_num, 736 void **window_id_rtn, void **gl_context_rtn, 737 int *x_rtn, int *y_rtn, int *width_rtn, int *height_rtn 738 ); 739 extern int GWContextSet(gw_display_struct *display, int ctx_num); 740 extern void GWContextPosition( 741 gw_display_struct *display, int x, int y 742 ); 743 extern void GWContextSize( 744 gw_display_struct *display, int width, int height 745 ); 746 extern Boolean GWContextIsFullScreen(gw_display_struct *display); 747 extern int GWContextFullScreen(gw_display_struct *display, Boolean state); 748 749 /* Buffer IO */ 750 extern void GWPostRedraw(gw_display_struct *display); 751 extern void GWSwapBuffer(gw_display_struct *display); 752 753 /* Set up gl projection matrix for 2d drawing */ 754 extern void GWOrtho2D(gw_display_struct *display); 755 extern void GWOrtho2DCoord( 756 gw_display_struct *display, 757 float left, float right, float top, float bottom 758 ); 759 760 /* Keyboard */ 761 extern void GWKeyboardAutoRepeat(gw_display_struct *display, Boolean b); 762 763 /* Video modes */ 764 extern gw_vidmode_struct *GWVidModesGet( 765 gw_display_struct *display, int *n 766 ); 767 extern void GWVidModesFree(gw_vidmode_struct *vidmode, int n); 768 769 /* Accelerator keys */ 770 extern gw_accelerator_struct *GWAcceleratorNew( 771 int key, int modifier 772 ); 773 extern void GWAcceleratorDelete(gw_accelerator_struct *a); 774 extern int GWAcceleratorListAdd( 775 gw_accelerator_struct ***a, int *total, 776 int key, int modifier 777 ); 778 extern void GWAcceleratorListDelete( 779 gw_accelerator_struct ***a, int *total 780 ); 781 extern Boolean GWAcceleratorListCheck( 782 gw_accelerator_struct **a, int total, 783 int key, int modifier 784 ); 785 786 /* GW pointer cursor */ 787 #ifdef X_H 788 extern void *GWCursorNew( 789 gw_display_struct *display, 790 int width, int height, /* In pixels */ 791 int hot_x, int hot_y, /* In pixels */ 792 int bpl, /* Bytes per line, 0 for autocalc */ 793 const void *data /* RGBA data (4 bytes per pixel) */ 794 ); 795 extern void GWCursorSet(gw_display_struct *display, void *cursor_ptr); 796 extern void GWCursorDelete(gw_display_struct *display, void *cursor_ptr); 797 #endif /* X_H */ 798 extern void GWSetPointerCursor( 799 gw_display_struct *display, gw_pointer_cursor cursor 800 ); 801 extern void GWShowCursor(gw_display_struct *display); 802 extern void GWHideCursor(gw_display_struct *display); 803 extern Boolean GWIsCursorShown(gw_display_struct *display); 804 extern void GWSetInputBusy(gw_display_struct *display); 805 extern void GWSetInputReady(gw_display_struct *display); 806 807 /* GW font IO */ 808 extern void GWSetFont(gw_display_struct *display, GWFont *font); 809 extern int GWGetFontSize( 810 GWFont *font, 811 int *width, int *height, 812 int *character_spacing, int *line_spacing 813 ); 814 815 /* GW string drawing */ 816 extern void GWDrawString( 817 gw_display_struct *display, 818 int x, int y, 819 const char *string 820 ); 821 extern void GWDrawCharacter( 822 gw_display_struct *display, 823 int x, int y, 824 char c 825 ); 826 827 /* GW image IO */ 828 extern int GWImageLoadHeaderFromData( 829 gw_display_struct *display, 830 int *width, int *height, int *bpl, int *bpp, 831 const void *data 832 ); 833 extern u_int8_t *GWImageLoadFromDataRGB( 834 gw_display_struct *display, 835 int *width, int *height, int *bpl, 836 const void *data 837 ); 838 extern const u_int8_t *GWImageLoadFromDataSharedRGB( 839 gw_display_struct *display, 840 int *width, int *height, int *bpl, 841 const void *data 842 ); 843 extern u_int8_t *GWImageLoadFromDataRGBA( 844 gw_display_struct *display, 845 int *width, int *height, int *bpl, 846 const void *data 847 ); 848 extern const u_int8_t *GWImageLoadFromDataSharedRGBA( 849 gw_display_struct *display, 850 int *width, int *height, int *bpl, 851 const void *data 852 ); 853 extern void GWImageDrawFromDataRGB( 854 gw_display_struct *display, const void *data, 855 int x, int y, int width, int height 856 ); 857 extern void GWImageDrawFromDataRGBA( 858 gw_display_struct *display, const void *data, 859 int x, int y, int width, int height 860 ); 861 862 863 #ifdef X_H 864 /* In gwx_dialog.c */ 865 /* Widgets */ 866 extern void GWXWidgetSetFlags( 867 gw_display_struct *display, gwx_widget_struct *widget, 868 gwx_widget_flags flags 869 ); 870 extern void GWXWidgetUnsetFlags( 871 gw_display_struct *display, gwx_widget_struct *widget, 872 gwx_widget_flags flags 873 ); 874 extern void GWXWidgetMapRaise( 875 gw_display_struct *display, gwx_widget_struct *widget 876 ); 877 extern void GWXWidgetMap( 878 gw_display_struct *display, gwx_widget_struct *widget 879 ); 880 extern void GWXWidgetUnmap( 881 gw_display_struct *display, gwx_widget_struct *widget 882 ); 883 extern void GWXWidgetFocus( 884 gw_display_struct *display, gwx_widget_struct *widget 885 ); 886 extern void GWXWidgetUnfocus( 887 gw_display_struct *display, gwx_widget_struct *widget 888 ); 889 extern void GWXWidgetGrabDefault( 890 gw_display_struct *display, gwx_widget_struct *widget 891 ); 892 extern void GWXWidgetUngrabDefault( 893 gw_display_struct *display, gwx_widget_struct *widget 894 ); 895 extern void GWXWidgetSetSensitive( 896 gw_display_struct *display, gwx_widget_struct *widget, 897 Boolean sensitive 898 ); 899 /* Push Buttons */ 900 extern int GWXButtonCreate( 901 gw_display_struct *display, gwx_button_struct *btn, 902 void *dialog, /* Parent gwx_dialog_struct */ 903 Window parent, 904 int x, int y, 905 unsigned int width, unsigned int height, 906 const char *label, 907 void *client_data, 908 void (*func_cb)(void *, void *) 909 ); 910 extern void GWXButtonUpdateSize( 911 gw_display_struct *display, gwx_button_struct *btn 912 ); 913 extern void GWXButtonResize( 914 gw_display_struct *display, gwx_button_struct *btn 915 ); 916 extern void GWXButtonDraw( 917 gw_display_struct *display, gwx_button_struct *btn 918 ); 919 extern int GWXButtonManage( 920 gw_display_struct *display, 921 gwx_button_struct *btn, 922 XEvent *event 923 ); 924 extern void GWXButtonDestroy( 925 gw_display_struct *display, gwx_button_struct *btn 926 ); 927 /* Dialogs */ 928 extern void GWXDialogLoadIcon( 929 gw_display_struct *display, gwx_dialog_struct *md, 930 gwx_icon icon_code 931 ); 932 extern int GWXDialogCreate( 933 gw_display_struct *display, gwx_dialog_struct *md, 934 gwx_dialog_type type 935 ); 936 extern void GWXDialogUpdateSize( 937 gw_display_struct *display, gwx_dialog_struct *md 938 ); 939 extern void GWXDialogResize( 940 gw_display_struct *display, gwx_dialog_struct *md 941 ); 942 extern void GWXDialogDraw( 943 gw_display_struct *display, gwx_dialog_struct *md 944 ); 945 extern int GWXDialogManage( 946 gw_display_struct *display, gwx_dialog_struct *md, 947 XEvent *event 948 ); 949 extern void GWXDialogDestroy( 950 gw_display_struct *display, gwx_dialog_struct *md 951 ); 952 /* Dialog Callbacks */ 953 extern void GWXDialogNoBtnCB(void *object, void *client_data); 954 extern void GWXDialogYesBtnCB(void *object, void *client_data); 955 extern void GWXDialogCancelBtnCB(void *object, void *client_data); 956 extern void GWXDialogOKBtnCB(void *object, void *client_data); 957 extern void GWXDialogSetMesg( 958 gw_display_struct *display, gwx_dialog_struct *md, 959 const char *title, 960 const char *mesg, 961 const char *details 962 ); 963 extern void GWXDialogMap( 964 gw_display_struct *display, gwx_dialog_struct *md 965 ); 966 extern int GWXDoBlockUntilConf(gw_display_struct *display); 967 #endif /* X_H */ 968 969 970 971 972 973 #ifdef NOMANGLE 974 # undef NOMANGLE 975 } 976 #endif /* NOMANGLE */ 977 978 #endif /* GW_H */ 979