1 /* 2 * sdlgui.h - Header for the tiny graphical user interface for the SDL library. 3 * 4 * This file is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This file is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * (http://www.gnu.org/licenses/) for more details. 13 */ 14 15 #ifndef SDLGUI_H 16 #define SDLGUI_H 17 18 #include <SDL.h> 19 20 enum 21 { 22 SGBOX, 23 SGTEXT, 24 SGEDITFIELD, 25 SGBUTTON, 26 SGRADIOBUT, 27 SGCHECKBOX, 28 SGPOPUP, 29 SGSCROLLBAR, 30 SGUSER 31 }; 32 33 34 /* Object flags: */ 35 #define SG_TOUCHEXIT 1 /* Exit immediately when mouse button is pressed down */ 36 #define SG_EXIT 2 /* Exit when mouse button has been pressed (and released) */ 37 #define SG_DEFAULT 4 /* Marks a default button, selectable with return key */ 38 #define SG_CANCEL 8 /* Marks a cancel button, selectable with ESC key */ 39 40 /* Object states: */ 41 #define SG_SELECTED 1 42 #define SG_MOUSEDOWN 16 43 #define SG_MOUSEUP (((int)-1) - SG_MOUSEDOWN) 44 45 /* Special characters: */ 46 #define SGRADIOBUTTON_NORMAL 12 47 #define SGRADIOBUTTON_SELECTED 13 48 #define SGCHECKBOX_NORMAL 14 49 #define SGCHECKBOX_SELECTED 15 50 #define SGARROWUP 1 51 #define SGARROWDOWN 2 52 #define SGFOLDER 5 53 54 #define SGARROWLEFTSTR "\x04" 55 #define SGARROWRIGHTSTR "\x03" 56 57 /* Return codes: */ 58 #define SDLGUI_ERROR -1 59 #define SDLGUI_QUIT -2 60 #define SDLGUI_UNKNOWNEVENT -3 61 62 63 typedef struct 64 { 65 int type; /* What type of object */ 66 int flags; /* Object flags */ 67 int state; /* Object state */ 68 int x, y; /* The offset to the upper left corner */ 69 int w, h; /* Width and height (for scrollbar : height and position) */ 70 char *txt; /* Text string */ 71 } SGOBJ; 72 73 extern int sdlgui_fontwidth; /* Width of the actual font */ 74 extern int sdlgui_fontheight; /* Height of the actual font */ 75 76 extern int SDLGui_Init(void); 77 extern int SDLGui_UnInit(void); 78 extern int SDLGui_SetScreen(SDL_Surface *pScrn); 79 extern void SDLGui_GetFontSize(int *width, int *height); 80 extern void SDLGui_Text(int x, int y, const char *txt); 81 extern void SDLGui_DrawDialog(const SGOBJ *dlg); 82 extern int SDLGui_DoDialog(SGOBJ *dlg, SDL_Event *pEventOut); 83 extern void SDLGui_CenterDlg(SGOBJ *dlg); 84 void SDLGui_DrawButton(const SGOBJ *bdlg, int objnum); 85 86 #endif 87