1 /* 2 Hatari 3 4 This file is distributed under the GNU Public License, version 2 or at 5 your option any later version. Read the file gpl.txt for details. 6 7 Header for the tiny graphical user interface for Hatari. 8 */ 9 10 #ifndef _SDLGUI_H 11 #define _SDLGUI_H 12 13 #include "host.h" 14 15 #include "SDL_compat.h" 16 17 class HostSurface; 18 class Dialog; 19 20 enum 21 { 22 SGBOX, 23 SGTEXT, 24 SGEDITFIELD, 25 SGBUTTON, 26 SGRADIOBUT, 27 SGCHECKBOX, 28 SGPOPUP, 29 SGSCROLLBAR 30 }; 31 32 33 /* Object flags: */ 34 #define SG_TOUCHEXIT 0x0001 /* Exit immediately when mouse button is pressed down */ 35 #define SG_EXIT 0x0002 /* Exit when mouse button has been pressed (and released) */ 36 #define SG_BUTTON_RIGHT 0x0004 /* Text is aligned right */ 37 #define SG_DEFAULT 0x0008 /* Marks a default button, selectable with Enter & Return keys */ 38 #define SG_CANCEL 0x0010 /* Marks a cancel button, selectable with ESC key */ 39 #define SG_SHORTCUT 0x0020 /* Marks a shortcut button, selectable with masked letter */ 40 #define SG_SELECTABLE 0x0100 41 #define SG_BACKGROUND 0x0200 42 #define SG_RADIO 0x0400 43 #define SG_SMALLTEXT 0x0800 44 45 /* Object states: */ 46 #define SG_SELECTED 0x0001 47 #define SG_MOUSEDOWN 0x0002 48 #define SG_FOCUSED 0x0004 /* Marks an object that has selection focus */ 49 #define SG_WASFOCUSED 0x0008 /* Marks an object that had selection focus & its bg needs redraw */ 50 #define SG_HIDDEN 0x0100 51 #define SG_DISABLED 0x0200 52 53 /* special shortcut keys, something that won't conflict with text shortcuts */ 54 #define SG_SHORTCUT_LEFT '<' 55 #define SG_SHORTCUT_RIGHT '>' 56 #define SG_SHORTCUT_UP '^' 57 #define SG_SHORTCUT_DOWN '|' 58 59 /* Special characters: */ 60 #define SGARROWUP 1 61 #define SGARROWDOWN 2 62 #define SGFOLDER 5 63 64 65 typedef struct 66 { 67 int type; /* What type of object */ 68 int flags; /* Object flags */ 69 int state; /* Object state */ 70 int x, y; /* The offset to the upper left corner */ 71 unsigned int w, h; /* Width and height (for scrollbar : height and position) */ 72 const char *txt; /* Text string */ 73 int shortcut; /* shortcut key */ 74 } SGOBJ; 75 76 typedef struct 77 { 78 int object; 79 int position; 80 Uint32 blink_counter; 81 bool blink_state; 82 } cursor_state; 83 84 enum 85 { 86 SG_FIRST_EDITFIELD, 87 SG_PREVIOUS_EDITFIELD, 88 SG_NEXT_EDITFIELD, 89 SG_LAST_EDITFIELD 90 }; 91 92 bool SDLGui_Init(void); 93 int SDLGui_UnInit(void); 94 int SDLGui_DoDialog(SGOBJ *dlg); 95 int SDLGui_PrepareFont(void); 96 void SDLGui_FreeFont(void); 97 int SDLGui_FileSelect(char *path_and_name, bool bAllowNew); 98 SDL_Rect *SDLGui_GetFirstBackgroundRect(void); 99 SDL_Rect *SDLGui_GetNextBackgroundRect(void); 100 101 #define STATUS_REBOOT 1 102 #define STATUS_SHUTDOWN 2 103 int GUImainDlg(); 104 105 typedef enum { ALERT_OK, ALERT_OKCANCEL } alert_type; 106 extern bool SDLGui_Alert(const char *, alert_type type); 107 108 void SDLGui_setGuiPos(int guix, int guiy); 109 HostSurface *SDLGui_getSurface(void); 110 111 /* dlgHotkeys.cpp */ 112 113 /* stuff needed by dialog.cpp */ 114 int SDLGui_FindEditField(SGOBJ *dlg, int objnum, int mode); 115 void SDLGui_DrawDialog(SGOBJ *dlg); 116 int SDLGui_FindObj(SGOBJ *dlg, int fx, int fy); 117 bool SDLGui_UpdateObjState(SGOBJ *dlg, int clicked_obj, int original_state, 118 int x, int y); 119 void SDLGui_SelectRadioObject(SGOBJ *dlg, int clicked_obj); 120 void SDLGui_ClickEditField(SGOBJ *dlg, cursor_state *cursor, int clicked_obj, int x); 121 void SDLGui_DrawObject(SGOBJ *dlg, int objnum); 122 void SDLGui_RefreshObj(SGOBJ *dlg, int objnum); 123 int SDLGui_FindDefaultObj(SGOBJ *dlg); 124 void SDLGui_MoveCursor(SGOBJ *dlg, cursor_state *cursor, int mode); 125 void SDLGui_DeselectButtons(SGOBJ *dlg); 126 void SDLGui_DeselectAndRedraw(SGOBJ *dlg, int obj); 127 int SDLGui_TextLen(const char *txt); 128 int SDLGui_ByteLen(const char *txt, int pos); 129 130 int SDLGui_DoEvent(const SDL_Event &event); 131 void SDLGui_Open(Dialog *new_dlg); 132 void SDLGui_Close(void); 133 bool SDLGui_isClosed(void); 134 135 #endif /* _SDLGUI_H */ 136