2023-04-27 16:35:56 +02:00
|
|
|
#ifndef _X48_GUI_H
|
|
|
|
#define _X48_GUI_H 1
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2015-07-26 11:16:05 +02:00
|
|
|
#include <X11/Xlib.h>
|
2023-05-03 15:08:14 +02:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/keysym.h>
|
2022-03-24 13:41:22 +01:00
|
|
|
#include <X11/extensions/XShm.h>
|
2015-07-26 11:16:05 +02:00
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
2023-05-02 16:57:24 +02:00
|
|
|
#elif defined( GUI_IS_SDL1 )
|
2023-04-30 16:34:53 +02:00
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include <SDL/SDL_gfxPrimitives.h>
|
|
|
|
#include <SDL/SDL_rotozoom.h>
|
|
|
|
#endif
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-30 15:14:17 +02:00
|
|
|
// Colors
|
2022-03-24 13:41:22 +01:00
|
|
|
#define WHITE 0
|
|
|
|
#define LEFT 1
|
|
|
|
#define RIGHT 2
|
|
|
|
#define BUT_TOP 3
|
|
|
|
#define BUTTON 4
|
|
|
|
#define BUT_BOT 5
|
|
|
|
#define LCD 6
|
|
|
|
#define PIXEL 7
|
|
|
|
#define PAD_TOP 8
|
|
|
|
#define PAD 9
|
|
|
|
#define PAD_BOT 10
|
|
|
|
#define DISP_PAD_TOP 11
|
|
|
|
#define DISP_PAD 12
|
|
|
|
#define DISP_PAD_BOT 13
|
|
|
|
#define LOGO 14
|
|
|
|
#define LOGO_BACK 15
|
|
|
|
#define LABEL 16
|
|
|
|
#define FRAME 17
|
|
|
|
#define UNDERLAY 18
|
|
|
|
#define BLACK 19
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-30 16:34:53 +02:00
|
|
|
// Buttons
|
|
|
|
#define BUTTON_A 0
|
|
|
|
#define BUTTON_B 1
|
|
|
|
#define BUTTON_C 2
|
|
|
|
#define BUTTON_D 3
|
|
|
|
#define BUTTON_E 4
|
|
|
|
#define BUTTON_F 5
|
|
|
|
|
|
|
|
#define BUTTON_MTH 6
|
|
|
|
#define BUTTON_PRG 7
|
|
|
|
#define BUTTON_CST 8
|
|
|
|
#define BUTTON_VAR 9
|
|
|
|
#define BUTTON_UP 10
|
|
|
|
#define BUTTON_NXT 11
|
|
|
|
|
|
|
|
#define BUTTON_COLON 12
|
|
|
|
#define BUTTON_STO 13
|
|
|
|
#define BUTTON_EVAL 14
|
|
|
|
#define BUTTON_LEFT 15
|
|
|
|
#define BUTTON_DOWN 16
|
|
|
|
#define BUTTON_RIGHT 17
|
|
|
|
|
|
|
|
#define BUTTON_SIN 18
|
|
|
|
#define BUTTON_COS 19
|
|
|
|
#define BUTTON_TAN 20
|
|
|
|
#define BUTTON_SQRT 21
|
|
|
|
#define BUTTON_POWER 22
|
|
|
|
#define BUTTON_INV 23
|
|
|
|
|
|
|
|
#define BUTTON_ENTER 24
|
|
|
|
#define BUTTON_NEG 25
|
|
|
|
#define BUTTON_EEX 26
|
|
|
|
#define BUTTON_DEL 27
|
|
|
|
#define BUTTON_BS 28
|
|
|
|
|
|
|
|
#define BUTTON_ALPHA 29
|
|
|
|
#define BUTTON_7 30
|
|
|
|
#define BUTTON_8 31
|
|
|
|
#define BUTTON_9 32
|
|
|
|
#define BUTTON_DIV 33
|
|
|
|
|
|
|
|
#define BUTTON_SHL 34
|
|
|
|
#define BUTTON_4 35
|
|
|
|
#define BUTTON_5 36
|
|
|
|
#define BUTTON_6 37
|
|
|
|
#define BUTTON_MUL 38
|
|
|
|
|
|
|
|
#define BUTTON_SHR 39
|
|
|
|
#define BUTTON_1 40
|
|
|
|
#define BUTTON_2 41
|
|
|
|
#define BUTTON_3 42
|
|
|
|
#define BUTTON_MINUS 43
|
|
|
|
|
|
|
|
#define BUTTON_ON 44
|
|
|
|
#define BUTTON_0 45
|
|
|
|
#define BUTTON_PERIOD 46
|
|
|
|
#define BUTTON_SPC 47
|
|
|
|
#define BUTTON_PLUS 48
|
|
|
|
|
|
|
|
#define LAST_BUTTON 48
|
|
|
|
|
2023-05-03 16:22:05 +02:00
|
|
|
#define DISP_ROWS 64
|
|
|
|
#define NIBS_PER_BUFFER_ROW ( NIBBLES_PER_ROW + 2 )
|
|
|
|
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_SDL1 )
|
2023-04-30 16:34:53 +02:00
|
|
|
#define UPDATE_MENU 1
|
|
|
|
#define UPDATE_DISP 2
|
|
|
|
|
|
|
|
#define _KEYBOARD_HEIGHT \
|
|
|
|
( buttons_gx[ LAST_BUTTON ].y + buttons_gx[ LAST_BUTTON ].h )
|
|
|
|
#define _KEYBOARD_WIDTH \
|
|
|
|
( buttons_gx[ LAST_BUTTON ].x + buttons_gx[ LAST_BUTTON ].w )
|
|
|
|
|
|
|
|
#define _TOP_SKIP 65
|
|
|
|
#define _SIDE_SKIP 20
|
|
|
|
#define _BOTTOM_SKIP 25
|
|
|
|
#define _DISP_KBD_SKIP 65
|
|
|
|
#define _KBD_UPLINE 25
|
|
|
|
|
|
|
|
#define _DISPLAY_WIDTH ( 264 + 8 )
|
|
|
|
#define _DISPLAY_HEIGHT ( 128 + 16 + 8 )
|
|
|
|
#define _DISPLAY_OFFSET_X ( SIDE_SKIP + ( 286 - DISPLAY_WIDTH ) / 2 )
|
|
|
|
#define _DISPLAY_OFFSET_Y TOP_SKIP
|
|
|
|
|
|
|
|
#define _DISP_FRAME 8
|
|
|
|
|
|
|
|
#define _KEYBOARD_OFFSET_X SIDE_SKIP
|
|
|
|
#define _KEYBOARD_OFFSET_Y ( TOP_SKIP + DISPLAY_HEIGHT + DISP_KBD_SKIP )
|
2023-05-03 10:35:15 +02:00
|
|
|
#endif // SDL1
|
2023-04-30 16:34:53 +02:00
|
|
|
|
2015-07-26 11:16:05 +02:00
|
|
|
typedef struct color_t {
|
2023-04-30 16:34:53 +02:00
|
|
|
const char* name;
|
2023-04-27 12:15:59 +02:00
|
|
|
int r, g, b;
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-04-27 12:15:59 +02:00
|
|
|
int mono_rgb;
|
|
|
|
int gray_rgb;
|
|
|
|
XColor xcolor;
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2015-07-26 11:16:05 +02:00
|
|
|
} color_t;
|
|
|
|
|
2023-04-27 12:15:59 +02:00
|
|
|
extern color_t* colors;
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-05-03 15:08:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-04-27 12:15:59 +02:00
|
|
|
#define COLOR( c ) ( colors[ ( c ) ].xcolor.pixel )
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2022-03-24 13:41:22 +01:00
|
|
|
#define UPDATE_MENU 1
|
|
|
|
#define UPDATE_DISP 2
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct keypad_t {
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
2023-05-03 16:09:50 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
|
|
|
Pixmap pixmap;
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2023-05-03 16:09:50 +02:00
|
|
|
} keypad_t;
|
2015-07-26 11:16:05 +02:00
|
|
|
|
|
|
|
typedef struct disp_t {
|
2023-04-27 12:15:59 +02:00
|
|
|
unsigned int w, h;
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-04-27 12:15:59 +02:00
|
|
|
Window win;
|
|
|
|
GC gc;
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2023-04-27 12:15:59 +02:00
|
|
|
short mapped;
|
|
|
|
int offset;
|
|
|
|
int lines;
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-04-27 12:15:59 +02:00
|
|
|
int display_update;
|
|
|
|
XShmSegmentInfo disp_info;
|
|
|
|
XImage* disp_image;
|
|
|
|
XShmSegmentInfo menu_info;
|
|
|
|
XImage* menu_image;
|
2015-07-26 11:16:05 +02:00
|
|
|
#endif
|
|
|
|
} disp_t;
|
2023-05-03 16:32:40 +02:00
|
|
|
extern disp_t disp;
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2015-07-26 11:16:05 +02:00
|
|
|
|
|
|
|
extern int shm_flag;
|
|
|
|
|
2023-04-27 12:15:59 +02:00
|
|
|
extern Display* dpy;
|
2022-03-24 13:41:22 +01:00
|
|
|
extern int screen;
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-27 12:30:36 +02:00
|
|
|
extern int InitDisplay( int argc, char** argv );
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-04-27 12:30:36 +02:00
|
|
|
extern int CreateWindows( int argc, char** argv );
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct button_t {
|
|
|
|
const char* name;
|
|
|
|
short pressed;
|
|
|
|
short extra;
|
|
|
|
|
|
|
|
int code;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h;
|
|
|
|
|
|
|
|
int lc;
|
|
|
|
const char* label;
|
|
|
|
short font_size;
|
|
|
|
unsigned int lw, lh;
|
|
|
|
unsigned char* lb;
|
|
|
|
|
|
|
|
const char* letter;
|
|
|
|
|
|
|
|
const char* left;
|
|
|
|
short is_menu;
|
|
|
|
const char* right;
|
|
|
|
const char* sub;
|
|
|
|
|
2023-05-03 12:51:32 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
|
|
|
Pixmap map;
|
|
|
|
Pixmap down;
|
|
|
|
Window xwin;
|
|
|
|
#elif defined( GUI_IS_SDL1 )
|
|
|
|
SDL_Surface* surfaceup;
|
|
|
|
SDL_Surface* surfacedown;
|
|
|
|
int __dummy;
|
|
|
|
#endif
|
2023-04-30 16:34:53 +02:00
|
|
|
} button_t;
|
|
|
|
|
2023-05-03 12:51:32 +02:00
|
|
|
#if defined( GUI_IS_SDL1 )
|
2023-04-30 16:34:53 +02:00
|
|
|
// This mimicks the structure formerly lcd.c, except with SDL surfaces instead
|
|
|
|
// of Pixmaps.
|
|
|
|
typedef struct ann_struct {
|
|
|
|
int bit;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
unsigned char* bits;
|
|
|
|
|
|
|
|
SDL_Surface* surfaceon;
|
|
|
|
SDL_Surface* surfaceoff;
|
|
|
|
} ann_struct_t;
|
|
|
|
|
|
|
|
typedef struct SDLWINDOW {
|
|
|
|
SDL_Surface *oldsurf, *surf;
|
|
|
|
int x, y;
|
|
|
|
} SDLWINDOW_t;
|
|
|
|
|
|
|
|
extern ann_struct_t ann_tbl[];
|
|
|
|
extern button_t* buttons;
|
|
|
|
extern button_t buttons_sx[];
|
|
|
|
extern button_t buttons_gx[];
|
|
|
|
|
|
|
|
extern int InitDisplay( int argc, char** argv );
|
2023-05-03 14:23:09 +02:00
|
|
|
extern void SDLCreateHP( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
|
|
|
|
2023-05-03 14:23:09 +02:00
|
|
|
extern int get_ui_event( void );
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-27 12:30:36 +02:00
|
|
|
extern void adjust_contrast( int contrast );
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-05-03 14:23:09 +02:00
|
|
|
extern void refresh_icon( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-27 12:30:36 +02:00
|
|
|
extern void ShowConnections( char* w, char* i );
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-27 12:30:36 +02:00
|
|
|
extern void exit_x48( int tell_x11 );
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-05-02 16:57:24 +02:00
|
|
|
#if defined( GUI_IS_X11 )
|
2023-05-03 14:23:09 +02:00
|
|
|
extern void refresh_display( void );
|
2023-05-02 16:57:24 +02:00
|
|
|
#elif defined( GUI_IS_SDL1 )
|
2023-04-30 16:34:53 +02:00
|
|
|
extern unsigned int ARGBColors[ BLACK + 1 ];
|
|
|
|
|
|
|
|
extern SDL_Surface* sdlwindow;
|
|
|
|
extern SDL_Surface* sdlsurface;
|
|
|
|
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLInit( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
void SDLDrawAnnunc( char* annunc );
|
|
|
|
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLCreateAnnunc( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
void SDLDrawNibble( int nx, int ny, int val );
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLDrawKeypad( void );
|
|
|
|
void SDLDrawButtons( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
SDL_Surface* SDLCreateSurfFromData( unsigned int w, unsigned int h,
|
|
|
|
unsigned char* data, unsigned int coloron,
|
|
|
|
unsigned int coloroff );
|
|
|
|
SDL_Surface* SDLCreateARGBSurfFromData( unsigned int w, unsigned int h,
|
|
|
|
unsigned char* data,
|
|
|
|
unsigned int xpcolor );
|
|
|
|
void SDLDrawSmallString( int x, int y, const char* string, unsigned int length,
|
|
|
|
unsigned int coloron, unsigned int coloroff );
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLCreateColors( void );
|
|
|
|
void SDLDrawKeyLetter( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
unsigned SDLBGRA2ARGB( unsigned color );
|
|
|
|
void SDLDrawBezel( unsigned int width, unsigned int height,
|
|
|
|
unsigned int offset_y, unsigned int offset_x );
|
|
|
|
void SDLDrawMore( unsigned int w, unsigned int h, unsigned int cut,
|
|
|
|
unsigned int offset_y, unsigned int offset_x,
|
|
|
|
int keypad_width, int keypad_height );
|
|
|
|
void SDLDrawLogo( unsigned int w, unsigned int h, unsigned int cut,
|
|
|
|
unsigned int offset_y, unsigned int offset_x,
|
|
|
|
int keypad_width, int keypad_height );
|
|
|
|
void SDLDrawBackground( int width, int height, int w_top, int h_top );
|
|
|
|
void SDLUIShowKey( int hpkey );
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLUIHideKey( void );
|
|
|
|
void SDLUIFeedback( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
SDLWINDOW_t SDLCreateWindow( int x, int y, int w, int h, unsigned color,
|
|
|
|
int framewidth, int inverted );
|
|
|
|
void SDLShowWindow( SDLWINDOW_t* win );
|
|
|
|
void SDLSHideWindow( SDLWINDOW_t* win );
|
|
|
|
void SDLARGBTo( unsigned color, unsigned* a, unsigned* r, unsigned* g,
|
|
|
|
unsigned* b );
|
|
|
|
unsigned SDLToARGB( unsigned a, unsigned r, unsigned g, unsigned b );
|
|
|
|
void SDLMessageBox( int w, int h, const char* title, const char* text[],
|
|
|
|
unsigned color, unsigned colortext, int center );
|
2023-05-03 14:23:09 +02:00
|
|
|
void SDLEventWaitClickOrKey( void );
|
|
|
|
void SDLShowInformation( void );
|
2023-04-30 16:34:53 +02:00
|
|
|
#endif
|
2015-07-26 11:16:05 +02:00
|
|
|
|
2023-04-27 16:35:56 +02:00
|
|
|
#endif /* !_X48_GUI_H */
|