factorize using opt_gx and sdl surfaces on/off

This commit is contained in:
Gwenhael Le Moine 2024-06-12 13:40:53 +02:00
parent 3f32b34947
commit 1eb4ac580f
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
4 changed files with 381 additions and 396 deletions

View file

@ -79,9 +79,11 @@ extern letter_t small_font[ 128 ];
extern color_t colors_sx[ NB_COLORS ]; extern color_t colors_sx[ NB_COLORS ];
extern color_t colors_gx[ NB_COLORS ]; extern color_t colors_gx[ NB_COLORS ];
#define COLORS ( opt_gx ? colors_gx : colors_sx )
extern button_t buttons_sx[ NB_KEYS ]; extern button_t buttons_sx[ NB_KEYS ];
extern button_t buttons_gx[ NB_KEYS ]; extern button_t buttons_gx[ NB_KEYS ];
#define BUTTONS ( opt_gx ? buttons_gx : buttons_sx )
extern ann_struct_t ann_tbl[ NB_ANNUNCIATORS ]; extern ann_struct_t ann_tbl[ NB_ANNUNCIATORS ];

View file

@ -17,8 +17,8 @@
#include "ui.h" #include "ui.h"
#include "ui_inner.h" #include "ui_inner.h"
#define _KEYBOARD_HEIGHT ( buttons_gx[ LAST_HPKEY ].y + buttons_gx[ LAST_HPKEY ].h ) #define _KEYBOARD_HEIGHT ( BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h )
#define _KEYBOARD_WIDTH ( buttons_gx[ LAST_HPKEY ].x + buttons_gx[ LAST_HPKEY ].w ) #define _KEYBOARD_WIDTH ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w )
#define _TOP_SKIP 65 #define _TOP_SKIP 65
#define _SIDE_SKIP 20 #define _SIDE_SKIP 20
@ -39,15 +39,10 @@
/***********/ /***********/
/* typedef */ /* typedef */
/***********/ /***********/
typedef struct sdl_button_t { typedef struct sdl_surfaces_on_off_struct_t {
SDL_Surface* surfaceup;
SDL_Surface* surfacedown;
} sdl_button_t;
typedef struct sdl_ann_struct_t {
SDL_Surface* surfaceon; SDL_Surface* surfaceon;
SDL_Surface* surfaceoff; SDL_Surface* surfaceoff;
} sdl_ann_struct_t; } sdl_surfaces_on_off_struct_t;
/*************/ /*************/
/* variables */ /* variables */
@ -58,68 +53,67 @@ static unsigned KEYBOARD_HEIGHT, KEYBOARD_WIDTH, TOP_SKIP, SIDE_SKIP, BOTTOM_SKI
static unsigned int ARGBColors[ NB_COLORS ]; static unsigned int ARGBColors[ NB_COLORS ];
static button_t* buttons = 0; static sdl_surfaces_on_off_struct_t sdl_buttons[ NB_KEYS ] = {
static sdl_button_t sdl_buttons[ NB_KEYS ] = { {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceup = 0, .surfacedown = 0}, {.surfaceon = 0, .surfaceoff = 0},
}; };
static sdl_ann_struct_t sdl_ann_tbl[] = { static sdl_surfaces_on_off_struct_t sdl_ann_tbl[] = {
{.surfaceon = 0, .surfaceoff = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceon = 0, .surfaceoff = 0}, {.surfaceon = 0, .surfaceoff = 0},
{.surfaceon = 0, .surfaceoff = 0}, {.surfaceon = 0, .surfaceoff = 0},
@ -497,7 +491,7 @@ static void _draw_bezel( unsigned int cut, unsigned int offset_y, int keypad_wid
lineColor( sdlwindow, 0, keypad_height - 2, 0, cut, bgra2argb( ARGBColors[ PAD_BOT ] ) ); lineColor( sdlwindow, 0, keypad_height - 2, 0, cut, bgra2argb( ARGBColors[ PAD_BOT ] ) );
lineColor( sdlwindow, 1, keypad_height - 3, 1, cut, bgra2argb( ARGBColors[ PAD_BOT ] ) ); lineColor( sdlwindow, 1, keypad_height - 3, 1, cut, bgra2argb( ARGBColors[ PAD_BOT ] ) );
// lower the menu buttons // lower the menu BUTTONS
// bottom lines // bottom lines
lineColor( sdlwindow, 3, keypad_height - 3, keypad_width - 3, keypad_height - 3, bgra2argb( ARGBColors[ PAD_TOP ] ) ); lineColor( sdlwindow, 3, keypad_height - 3, keypad_width - 3, keypad_height - 3, bgra2argb( ARGBColors[ PAD_TOP ] ) );
@ -697,159 +691,159 @@ static void __create_buttons( void )
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
// Create surfaces for each button // Create surfaces for each button
if ( !sdl_buttons[ i ].surfaceup ) if ( !sdl_buttons[ i ].surfaceon )
sdl_buttons[ i ].surfaceup = sdl_buttons[ i ].surfaceon =
SDL_CreateRGBSurface( SDL_SWSURFACE, buttons[ i ].w, buttons[ i ].h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 ); SDL_CreateRGBSurface( SDL_SWSURFACE, BUTTONS[ i ].w, BUTTONS[ i ].h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
if ( !sdl_buttons[ i ].surfacedown ) if ( !sdl_buttons[ i ].surfaceoff )
sdl_buttons[ i ].surfacedown = sdl_buttons[ i ].surfaceoff =
SDL_CreateRGBSurface( SDL_SWSURFACE, buttons[ i ].w, buttons[ i ].h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 ); SDL_CreateRGBSurface( SDL_SWSURFACE, BUTTONS[ i ].w, BUTTONS[ i ].h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
// Use alpha channel // Use alpha channel
pixel = 0x00000000; pixel = 0x00000000;
// pixel = 0xffff0000; // pixel = 0xffff0000;
// Fill the button and outline // Fill the button and outline
SDL_FillRect( sdl_buttons[ i ].surfaceup, 0, pixel ); SDL_FillRect( sdl_buttons[ i ].surfaceon, 0, pixel );
SDL_FillRect( sdl_buttons[ i ].surfacedown, 0, pixel ); SDL_FillRect( sdl_buttons[ i ].surfaceoff, 0, pixel );
SDL_Rect rect; SDL_Rect rect;
rect.x = 1; rect.x = 1;
rect.y = 1; rect.y = 1;
rect.w = buttons[ i ].w - 2; rect.w = BUTTONS[ i ].w - 2;
rect.h = buttons[ i ].h - 2; rect.h = BUTTONS[ i ].h - 2;
SDL_FillRect( sdl_buttons[ i ].surfaceup, &rect, ARGBColors[ BUTTON ] ); SDL_FillRect( sdl_buttons[ i ].surfaceon, &rect, ARGBColors[ BUTTON ] );
SDL_FillRect( sdl_buttons[ i ].surfacedown, &rect, ARGBColors[ BUTTON ] ); SDL_FillRect( sdl_buttons[ i ].surfaceoff, &rect, ARGBColors[ BUTTON ] );
// draw the released button // draw the released button
// draw edge of button // draw edge of button
lineColor( sdl_buttons[ i ].surfaceup, 1, buttons[ i ].h - 2, 1, 1, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 1, BUTTONS[ i ].h - 2, 1, 1, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 2, buttons[ i ].h - 3, 2, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 2, BUTTONS[ i ].h - 3, 2, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 3, buttons[ i ].h - 4, 3, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 3, BUTTONS[ i ].h - 4, 3, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 1, 1, buttons[ i ].w - 2, 1, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 1, 1, BUTTONS[ i ].w - 2, 1, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 2, 2, buttons[ i ].w - 3, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 2, 2, BUTTONS[ i ].w - 3, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 3, 3, buttons[ i ].w - 4, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 3, 3, BUTTONS[ i ].w - 4, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 4, 4, buttons[ i ].w - 5, 4, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 4, 4, BUTTONS[ i ].w - 5, 4, bgra2argb( ARGBColors[ BUT_TOP ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, 4, 5, bgra2argb( ARGBColors[ BUT_TOP ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, 4, 5, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 3, buttons[ i ].h - 2, buttons[ i ].w - 2, buttons[ i ].h - 2, lineColor( sdl_buttons[ i ].surfaceon, 3, BUTTONS[ i ].h - 2, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 4, buttons[ i ].h - 3, buttons[ i ].w - 3, buttons[ i ].h - 3, lineColor( sdl_buttons[ i ].surfaceon, 4, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 2, buttons[ i ].h - 2, buttons[ i ].w - 2, 3, lineColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2, BUTTONS[ i ].w - 2, 3,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 3, buttons[ i ].h - 3, buttons[ i ].w - 3, 4, lineColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 3, 4,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 4, buttons[ i ].h - 4, buttons[ i ].w - 4, 5, lineColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 4, BUTTONS[ i ].h - 4, BUTTONS[ i ].w - 4, 5,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 5, buttons[ i ].h - 4, bgra2argb( ARGBColors[ BUT_BOT ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 5, BUTTONS[ i ].h - 4, bgra2argb( ARGBColors[ BUT_BOT ] ) );
// draw frame around button // draw frame around button
lineColor( sdl_buttons[ i ].surfaceup, 0, buttons[ i ].h - 3, 0, 2, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 0, BUTTONS[ i ].h - 3, 0, 2, bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 2, 0, buttons[ i ].w - 3, 0, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 2, 0, BUTTONS[ i ].w - 3, 0, bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfaceup, 2, buttons[ i ].h - 1, buttons[ i ].w - 3, buttons[ i ].h - 1, lineColor( sdl_buttons[ i ].surfaceon, 2, BUTTONS[ i ].h - 1, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 1,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 1, buttons[ i ].h - 3, buttons[ i ].w - 1, 2, lineColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 1, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 1, 2,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
lineColor( sdl_buttons[ i ].surfaceup, 1, 1, buttons[ 1 ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceon, 1, 1, BUTTONS[ 1 ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, 1, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, 1, 2, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 2, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 2, 2, bgra2argb( ARGBColors[ FRAME ] ) );
} else { } else {
pixelColor( sdl_buttons[ i ].surfaceup, 1, 1, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, 1, 1, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) );
} }
pixelColor( sdl_buttons[ i ].surfaceup, 1, buttons[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, 1, BUTTONS[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfaceup, buttons[ i ].w - 2, buttons[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceon, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) );
// draw the depressed button // draw the depressed button
// draw edge of button // draw edge of button
lineColor( sdl_buttons[ i ].surfacedown, 2, buttons[ i ].h - 4, 2, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 2, BUTTONS[ i ].h - 4, 2, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 3, buttons[ i ].h - 5, 3, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 3, BUTTONS[ i ].h - 5, 3, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 2, 2, buttons[ i ].w - 4, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 2, 2, BUTTONS[ i ].w - 4, 2, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 3, 3, buttons[ i ].w - 5, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 3, 3, BUTTONS[ i ].w - 5, 3, bgra2argb( ARGBColors[ BUT_TOP ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, 4, 4, bgra2argb( ARGBColors[ BUT_TOP ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 4, 4, bgra2argb( ARGBColors[ BUT_TOP ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 3, buttons[ i ].h - 3, buttons[ i ].w - 3, buttons[ i ].h - 3, lineColor( sdl_buttons[ i ].surfaceoff, 3, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 4, buttons[ i ].h - 4, buttons[ i ].w - 4, buttons[ i ].h - 4, lineColor( sdl_buttons[ i ].surfaceoff, 4, BUTTONS[ i ].h - 4, BUTTONS[ i ].w - 4, BUTTONS[ i ].h - 4,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 3, buttons[ i ].h - 3, buttons[ i ].w - 3, 3, lineColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 3, 3,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
lineColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 4, buttons[ i ].h - 4, buttons[ i ].w - 4, 4, lineColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 4, BUTTONS[ i ].h - 4, BUTTONS[ i ].w - 4, 4,
bgra2argb( ARGBColors[ BUT_BOT ] ) ); bgra2argb( ARGBColors[ BUT_BOT ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 5, buttons[ i ].h - 5, bgra2argb( ARGBColors[ BUT_BOT ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 5, BUTTONS[ i ].h - 5, bgra2argb( ARGBColors[ BUT_BOT ] ) );
// draw frame around button // draw frame around button
lineColor( sdl_buttons[ i ].surfacedown, 0, buttons[ i ].h - 3, 0, 2, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 0, BUTTONS[ i ].h - 3, 0, 2, bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 2, 0, buttons[ i ].w - 3, 0, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 2, 0, BUTTONS[ i ].w - 3, 0, bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfacedown, 2, buttons[ i ].h - 1, buttons[ i ].w - 3, buttons[ i ].h - 1, lineColor( sdl_buttons[ i ].surfaceoff, 2, BUTTONS[ i ].h - 1, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 1,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
lineColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 1, buttons[ i ].h - 3, buttons[ i ].w - 1, 2, lineColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 1, BUTTONS[ i ].h - 3, BUTTONS[ i ].w - 1, 2,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
lineColor( sdl_buttons[ i ].surfacedown, 1, 1, buttons[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) ); lineColor( sdl_buttons[ i ].surfaceoff, 1, 1, BUTTONS[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, 1, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 1, 2, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 2, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 2, 2, bgra2argb( ARGBColors[ FRAME ] ) );
} else { } else {
pixelColor( sdl_buttons[ i ].surfacedown, 1, 1, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 1, 1, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 2, 1, bgra2argb( ARGBColors[ FRAME ] ) );
} }
pixelColor( sdl_buttons[ i ].surfacedown, 1, buttons[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 1, BUTTONS[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 2, buttons[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2, bgra2argb( ARGBColors[ FRAME ] ) );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
rectangleColor( sdl_buttons[ i ].surfacedown, 1, 2, 1 + buttons[ i ].w - 3, 2 + buttons[ i ].h - 4, rectangleColor( sdl_buttons[ i ].surfaceoff, 1, 2, 1 + BUTTONS[ i ].w - 3, 2 + BUTTONS[ i ].h - 4,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, 2, 3, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 2, 3, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 3, 3, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 3, 3, bgra2argb( ARGBColors[ FRAME ] ) );
} else { } else {
rectangleColor( sdl_buttons[ i ].surfacedown, 1, 1, 1 + buttons[ i ].w - 3, 1 + buttons[ i ].h - 3, rectangleColor( sdl_buttons[ i ].surfaceoff, 1, 1, 1 + BUTTONS[ i ].w - 3, 1 + BUTTONS[ i ].h - 3,
bgra2argb( ARGBColors[ FRAME ] ) ); bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, 2, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 2, 2, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 3, 2, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 3, 2, bgra2argb( ARGBColors[ FRAME ] ) );
} }
pixelColor( sdl_buttons[ i ].surfacedown, 2, buttons[ i ].h - 3, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, 2, BUTTONS[ i ].h - 3, bgra2argb( ARGBColors[ FRAME ] ) );
pixelColor( sdl_buttons[ i ].surfacedown, buttons[ i ].w - 3, buttons[ i ].h - 3, bgra2argb( ARGBColors[ FRAME ] ) ); pixelColor( sdl_buttons[ i ].surfaceoff, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3, bgra2argb( ARGBColors[ FRAME ] ) );
if ( buttons[ i ].label != ( char* )0 ) { if ( BUTTONS[ i ].label != ( char* )0 ) {
// Todo: use SDL_ttf to print "nice" fonts // Todo: use SDL_ttf to print "nice" fonts
// for the time being use SDL_gfxPrimitives' font // for the time being use SDL_gfxPrimitives' font
x = ( buttons[ i ].w - strlen( buttons[ i ].label ) * 8 ) / 2; x = ( BUTTONS[ i ].w - strlen( BUTTONS[ i ].label ) * 8 ) / 2;
y = ( buttons[ i ].h + 1 ) / 2 - 4; y = ( BUTTONS[ i ].h + 1 ) / 2 - 4;
stringColor( sdl_buttons[ i ].surfaceup, x, y, buttons[ i ].label, 0xffffffff ); stringColor( sdl_buttons[ i ].surfaceon, x, y, BUTTONS[ i ].label, 0xffffffff );
stringColor( sdl_buttons[ i ].surfacedown, x, y, buttons[ i ].label, 0xffffffff ); stringColor( sdl_buttons[ i ].surfaceoff, x, y, BUTTONS[ i ].label, 0xffffffff );
} }
// Pixmap centered in button // Pixmap centered in button
if ( buttons[ i ].lw != 0 ) { if ( BUTTONS[ i ].lw != 0 ) {
// If there's a bitmap, try to plot this // If there's a bitmap, try to plot this
unsigned colorbg = ARGBColors[ BUTTON ]; unsigned colorbg = ARGBColors[ BUTTON ];
unsigned colorfg = ARGBColors[ buttons[ i ].lc ]; unsigned colorfg = ARGBColors[ BUTTONS[ i ].lc ];
// Blit the label surface to the button // Blit the label surface to the button
SDL_Surface* surf; SDL_Surface* surf;
surf = bitmap_to_surface( buttons[ i ].lw, buttons[ i ].lh, buttons[ i ].lb, colorfg, colorbg ); surf = bitmap_to_surface( BUTTONS[ i ].lw, BUTTONS[ i ].lh, BUTTONS[ i ].lb, colorfg, colorbg );
// Draw the surface on the center of the button // Draw the surface on the center of the button
x = ( 1 + buttons[ i ].w - buttons[ i ].lw ) / 2; x = ( 1 + BUTTONS[ i ].w - BUTTONS[ i ].lw ) / 2;
y = ( 1 + buttons[ i ].h - buttons[ i ].lh ) / 2 + 1; y = ( 1 + BUTTONS[ i ].h - BUTTONS[ i ].lh ) / 2 + 1;
SDL_Rect srect; SDL_Rect srect;
SDL_Rect drect; SDL_Rect drect;
srect.x = 0; srect.x = 0;
srect.y = 0; srect.y = 0;
srect.w = buttons[ i ].lw; srect.w = BUTTONS[ i ].lw;
srect.h = buttons[ i ].lh; srect.h = BUTTONS[ i ].lh;
drect.x = x; drect.x = x;
drect.y = y; drect.y = y;
drect.w = buttons[ i ].lw; drect.w = BUTTONS[ i ].lw;
drect.h = buttons[ i ].lh; drect.h = BUTTONS[ i ].lh;
SDL_BlitSurface( surf, &srect, sdl_buttons[ i ].surfacedown, &drect ); SDL_BlitSurface( surf, &srect, sdl_buttons[ i ].surfaceoff, &drect );
SDL_BlitSurface( surf, &srect, sdl_buttons[ i ].surfaceup, &drect ); SDL_BlitSurface( surf, &srect, sdl_buttons[ i ].surfaceon, &drect );
SDL_FreeSurface( surf ); SDL_FreeSurface( surf );
} }
} }
@ -863,22 +857,22 @@ static void __draw_buttons( void )
// Blit the button surface to the screen // Blit the button surface to the screen
srect.x = 0; srect.x = 0;
srect.y = 0; srect.y = 0;
srect.w = buttons[ i ].w; srect.w = BUTTONS[ i ].w;
srect.h = buttons[ i ].h; srect.h = BUTTONS[ i ].h;
drect.x = KEYBOARD_OFFSET_X + buttons[ i ].x; drect.x = KEYBOARD_OFFSET_X + BUTTONS[ i ].x;
drect.y = KEYBOARD_OFFSET_Y + buttons[ i ].y; drect.y = KEYBOARD_OFFSET_Y + BUTTONS[ i ].y;
drect.w = buttons[ i ].w; drect.w = BUTTONS[ i ].w;
drect.h = buttons[ i ].h; drect.h = BUTTONS[ i ].h;
if ( keyboard[ i ].pressed ) if ( keyboard[ i ].pressed )
SDL_BlitSurface( sdl_buttons[ i ].surfacedown, &srect, sdlwindow, &drect ); SDL_BlitSurface( sdl_buttons[ i ].surfaceoff, &srect, sdlwindow, &drect );
else else
SDL_BlitSurface( sdl_buttons[ i ].surfaceup, &srect, sdlwindow, &drect ); SDL_BlitSurface( sdl_buttons[ i ].surfaceon, &srect, sdlwindow, &drect );
} }
// Always update immediately buttons // Always update immediately BUTTONS
SDL_UpdateRect( sdlwindow, KEYBOARD_OFFSET_X + buttons[ 0 ].x, KEYBOARD_OFFSET_Y + buttons[ 0 ].y, SDL_UpdateRect( sdlwindow, KEYBOARD_OFFSET_X + BUTTONS[ 0 ].x, KEYBOARD_OFFSET_Y + BUTTONS[ 0 ].y,
buttons[ LAST_HPKEY ].x + buttons[ LAST_HPKEY ].w - buttons[ 0 ].x, BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w - BUTTONS[ 0 ].x,
buttons[ LAST_HPKEY ].y + buttons[ LAST_HPKEY ].h - buttons[ 0 ].y ); BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h - BUTTONS[ 0 ].y );
} }
static void _draw_keypad( void ) static void _draw_keypad( void )
@ -896,7 +890,7 @@ static void _draw_keypad( void )
// SDLDrawKeyMenu(); // SDLDrawKeyMenu();
for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) { for ( i = FIRST_HPKEY; i <= LAST_HPKEY; i++ ) {
if ( buttons[ i ].is_menu ) { if ( BUTTONS[ i ].is_menu ) {
// draw the dark shade under the label // draw the dark shade under the label
pw = opt_gx ? 58 : 44; pw = opt_gx ? 58 : 44;
ph = opt_gx ? 48 : 9; ph = opt_gx ? 48 : 9;
@ -905,11 +899,11 @@ static void _draw_keypad( void )
// Set the coordinates to absolute // Set the coordinates to absolute
if ( opt_gx ) { if ( opt_gx ) {
x = offset_x + buttons[ i ].x - 6; x = offset_x + BUTTONS[ i ].x - 6;
y = offset_y + buttons[ i ].y - small_ascent - small_descent - 6; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6;
} else { } else {
x = offset_x + buttons[ i ].x + ( buttons[ i ].w - pw ) / 2; x = offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2;
y = offset_y + buttons[ i ].y - small_ascent - small_descent; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent;
} }
rect.x = x; rect.x = x;
@ -926,119 +920,119 @@ static void _draw_keypad( void )
colorbg = ARGBColors[ PAD ]; colorbg = ARGBColors[ PAD ];
// Letter ( small character bottom right of key) // Letter ( small character bottom right of key)
if ( buttons[ i ].letter != ( char* )0 ) { if ( BUTTONS[ i ].letter != ( char* )0 ) {
if ( opt_gx ) { if ( opt_gx ) {
x = offset_x + buttons[ i ].x + buttons[ i ].w + 3; x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w + 3;
y = offset_y + buttons[ i ].y + buttons[ i ].h + 1; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + 1;
} else { } else {
x = offset_x + buttons[ i ].x + buttons[ i ].w - SmallTextWidth( buttons[ i ].letter, 1 ) / 2 + 5; x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].letter, 1 ) / 2 + 5;
y = offset_y + buttons[ i ].y + buttons[ i ].h - 2; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h - 2;
} }
write_text( x, y, buttons[ i ].letter, 1, 0xffffffff, colorbg ); write_text( x, y, BUTTONS[ i ].letter, 1, 0xffffffff, colorbg );
} }
// SDLDrawKeysLabelsBottom(); // SDLDrawKeysLabelsBottom();
// Bottom label: the only one is the cancel button // Bottom label: the only one is the cancel button
if ( buttons[ i ].sub != ( char* )0 ) { if ( BUTTONS[ i ].sub != ( char* )0 ) {
colorfg = ARGBColors[ WHITE ]; colorfg = ARGBColors[ WHITE ];
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].sub, strlen( buttons[ i ].sub ) ) ) / 2; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) ) ) / 2;
y = offset_y + buttons[ i ].y + buttons[ i ].h + small_ascent + 2; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + small_ascent + 2;
write_text( x, y, buttons[ i ].sub, strlen( buttons[ i ].sub ), colorfg, colorbg ); write_text( x, y, BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ), colorfg, colorbg );
} }
// SDLDrawKeysLabelsLeft(); // SDLDrawKeysLabelsLeft();
// Draw the left labels // Draw the left labels
if ( buttons[ i ].left != ( char* )0 ) { if ( BUTTONS[ i ].left != ( char* )0 ) {
if ( buttons[ i ].is_menu ) { if ( BUTTONS[ i ].is_menu ) {
// draw the dark shade under the label // draw the dark shade under the label
pw = opt_gx ? 58 : 46; pw = opt_gx ? 58 : 46;
colorbg = ARGBColors[ UNDERLAY ]; colorbg = ARGBColors[ UNDERLAY ];
colorfg = ARGBColors[ LEFT ]; colorfg = ARGBColors[ LEFT ];
x = ( pw + 1 - SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ) ) / 2; x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2;
y = opt_gx ? 14 : 9; y = opt_gx ? 14 : 9;
// Set the coordinates to absolute // Set the coordinates to absolute
if ( opt_gx ) { if ( opt_gx ) {
x += offset_x + buttons[ i ].x - 6; x += offset_x + BUTTONS[ i ].x - 6;
y += offset_y + buttons[ i ].y - small_ascent - small_descent - 6; y += offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6;
} else { } else {
x += offset_x + buttons[ i ].x + ( buttons[ i ].w - pw ) / 2; x += offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2;
y += offset_y + buttons[ i ].y - small_ascent - small_descent; y += offset_y + BUTTONS[ i ].y - small_ascent - small_descent;
} }
write_text( x, y, buttons[ i ].left, strlen( buttons[ i ].left ), colorfg, colorbg ); write_text( x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ), colorfg, colorbg );
} else // is_menu } else // is_menu
{ {
colorbg = ARGBColors[ BLACK ]; colorbg = ARGBColors[ BLACK ];
colorfg = ARGBColors[ LEFT ]; colorfg = ARGBColors[ LEFT ];
if ( buttons[ i ].right == ( char* )0 ) { if ( BUTTONS[ i ].right == ( char* )0 ) {
// centered label // centered label
x = offset_x + buttons[ i ].x + x = offset_x + BUTTONS[ i ].x +
( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ) ) / 2; ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2;
} else { } else {
// label to the left // label to the left
wl = SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ); wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
wr = SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ); wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
ws = SmallTextWidth( " ", 1 ); ws = SmallTextWidth( " ", 1 );
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - ( wl + wr + ws ) ) / 2; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2;
} }
y = offset_y + buttons[ i ].y - small_descent; y = offset_y + BUTTONS[ i ].y - small_descent;
write_text( x, y, buttons[ i ].left, strlen( buttons[ i ].left ), colorfg, colorbg ); write_text( x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ), colorfg, colorbg );
} // is_menu } // is_menu
} }
// SDLDrawKeysLabelsRight(); // SDLDrawKeysLabelsRight();
// draw the right labels // draw the right labels
if ( buttons[ i ].right != ( char* )0 ) { if ( BUTTONS[ i ].right != ( char* )0 ) {
if ( buttons[ i ].is_menu ) { if ( BUTTONS[ i ].is_menu ) {
// draw the dark shade under the label // draw the dark shade under the label
pw = opt_gx ? 58 : 44; pw = opt_gx ? 58 : 44;
colorbg = ARGBColors[ UNDERLAY ]; colorbg = ARGBColors[ UNDERLAY ];
colorfg = ARGBColors[ RIGHT ]; colorfg = ARGBColors[ RIGHT ];
x = ( pw + 1 - SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ) ) / 2; x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2;
y = opt_gx ? 14 : 8; y = opt_gx ? 14 : 8;
// Set the coordinates to absolute // Set the coordinates to absolute
if ( opt_gx ) { if ( opt_gx ) {
x += offset_x + buttons[ i ].x - 6; x += offset_x + BUTTONS[ i ].x - 6;
y += offset_y + buttons[ i ].y - small_ascent - small_descent - 6; y += offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6;
} else { } else {
x += offset_x + buttons[ i ].x + ( buttons[ i ].w - pw ) / 2; x += offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2;
y += offset_y + buttons[ i ].y - small_ascent - small_descent; y += offset_y + BUTTONS[ i ].y - small_ascent - small_descent;
} }
write_text( x, y, buttons[ i ].right, strlen( buttons[ i ].right ), colorfg, colorbg ); write_text( x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ), colorfg, colorbg );
} // buttons[i].is_menu } // BUTTONS[i].is_menu
else { else {
colorbg = ARGBColors[ BLACK ]; colorbg = ARGBColors[ BLACK ];
colorfg = ARGBColors[ RIGHT ]; colorfg = ARGBColors[ RIGHT ];
if ( buttons[ i ].left == ( char* )0 ) { if ( BUTTONS[ i ].left == ( char* )0 ) {
// centered label // centered label
x = offset_x + buttons[ i ].x + x = offset_x + BUTTONS[ i ].x +
( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ) ) / 2; ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2;
} else { } else {
// label to the right // label to the right
wl = SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ); wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
wr = SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ); wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
ws = SmallTextWidth( " ", 1 ); ws = SmallTextWidth( " ", 1 );
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - ( wl + wr + ws ) ) / 2 + wl + ws; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2 + wl + ws;
} }
y = offset_y + buttons[ i ].y - small_descent; y = offset_y + BUTTONS[ i ].y - small_descent;
write_text( x, y, buttons[ i ].right, strlen( buttons[ i ].right ), colorfg, colorbg ); write_text( x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ), colorfg, colorbg );
} }
} }
} }
@ -1170,14 +1164,14 @@ static void _show_key( int hpkey )
return; return;
// Which surface to show // Which surface to show
ssurf = ( keyboard[ hpkey ].pressed ) ? sdl_buttons[ hpkey ].surfacedown : sdl_buttons[ hpkey ].surfaceup; ssurf = ( keyboard[ hpkey ].pressed ) ? sdl_buttons[ hpkey ].surfaceoff : sdl_buttons[ hpkey ].surfaceon;
// Background backup // Background backup
showkeylastsurf = SDL_CreateRGBSurface( SDL_SWSURFACE, ssurf->w, ssurf->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 ); showkeylastsurf = SDL_CreateRGBSurface( SDL_SWSURFACE, ssurf->w, ssurf->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 );
// Where to // Where to
x = KEYBOARD_OFFSET_X + buttons[ hpkey ].x - ( ssurf->w - ssurf->w + 1 ) / 2; x = KEYBOARD_OFFSET_X + BUTTONS[ hpkey ].x - ( ssurf->w - ssurf->w + 1 ) / 2;
y = KEYBOARD_OFFSET_Y + buttons[ hpkey ].y - ( ssurf->h - ssurf->h + 1 ) / 2; y = KEYBOARD_OFFSET_Y + BUTTONS[ hpkey ].y - ( ssurf->h - ssurf->h + 1 ) / 2;
// blitting does not clip to screen, so if we are out of the screen we // blitting does not clip to screen, so if we are out of the screen we
// shift the button to fit // shift the button to fit
if ( x < 0 ) if ( x < 0 )
@ -1330,7 +1324,7 @@ void sdl_get_event( void )
please_exit = true; please_exit = true;
break; break;
// Mouse move: react to state changes in the buttons that are // Mouse move: react to state changes in the BUTTONS that are
// pressed // pressed
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
hpkey = mouse_click_to_hpkey( event.motion.x, event.motion.y ); hpkey = mouse_click_to_hpkey( event.motion.x, event.motion.y );
@ -1590,8 +1584,8 @@ void init_sdl_ui( int argc, char** argv )
DISPLAY_OFFSET_X = 0; DISPLAY_OFFSET_X = 0;
DISPLAY_OFFSET_Y = 0; DISPLAY_OFFSET_Y = 0;
} else { } else {
width = ( buttons_gx[ LAST_HPKEY ].x + buttons_gx[ LAST_HPKEY ].w ) + 2 * SIDE_SKIP; width = ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w ) + 2 * SIDE_SKIP;
height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP + buttons_gx[ LAST_HPKEY ].y + buttons_gx[ LAST_HPKEY ].h + BOTTOM_SKIP; height = DISPLAY_OFFSET_Y + DISPLAY_HEIGHT + DISP_KBD_SKIP + BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h + BOTTOM_SKIP;
} }
uint32_t sdl_window_flags = SDL_SWSURFACE | SDL_RESIZABLE; uint32_t sdl_window_flags = SDL_SWSURFACE | SDL_RESIZABLE;
@ -1605,12 +1599,12 @@ void init_sdl_ui( int argc, char** argv )
exit( 1 ); exit( 1 );
} }
buttons = opt_gx ? buttons_gx : buttons_sx; /* BUTTONS = opt_gx ? BUTTONS_gx : BUTTONS_sx; */
colors_setup( opt_gx ? colors_gx : colors_sx ); colors_setup( COLORS );
if ( !config.hide_chrome ) { if ( !config.hide_chrome ) {
int cut = buttons[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19; int cut = BUTTONS[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19;
_draw_background( width, cut, width, height ); _draw_background( width, cut, width, height );
_draw_bezel( cut, KEYBOARD_OFFSET_Y, width, height ); _draw_bezel( cut, KEYBOARD_OFFSET_Y, width, height );

View file

@ -586,16 +586,15 @@ void init_text_ui( int argc, char** argv )
noecho(); noecho();
nonl(); /* tell curses not to do NL->CR/NL on output */ nonl(); /* tell curses not to do NL->CR/NL on output */
color_t* colors = opt_gx ? colors_gx : colors_sx;
if ( !config.mono && has_colors() ) { if ( !config.mono && has_colors() ) {
start_color(); start_color();
if ( config.gray ) { if ( config.gray ) {
init_color( LCD_COLOR_BG, colors[ LCD ].gray_rgb, colors[ LCD ].gray_rgb, colors[ LCD ].gray_rgb ); init_color( LCD_COLOR_BG, COLORS[ LCD ].gray_rgb, COLORS[ LCD ].gray_rgb, COLORS[ LCD ].gray_rgb );
init_color( LCD_COLOR_FG, colors[ PIXEL ].gray_rgb, colors[ PIXEL ].gray_rgb, colors[ PIXEL ].gray_rgb ); init_color( LCD_COLOR_FG, COLORS[ PIXEL ].gray_rgb, COLORS[ PIXEL ].gray_rgb, COLORS[ PIXEL ].gray_rgb );
} else { } else {
init_color( LCD_COLOR_BG, colors[ LCD ].r, colors[ LCD ].g, colors[ LCD ].b ); init_color( LCD_COLOR_BG, COLORS[ LCD ].r, COLORS[ LCD ].g, COLORS[ LCD ].b );
init_color( LCD_COLOR_FG, colors[ PIXEL ].r, colors[ PIXEL ].g, colors[ PIXEL ].b ); init_color( LCD_COLOR_FG, COLORS[ PIXEL ].r, COLORS[ PIXEL ].g, COLORS[ PIXEL ].b );
} }
init_pair( LCD_PIXEL_OFF, LCD_COLOR_BG, LCD_COLOR_BG ); init_pair( LCD_PIXEL_OFF, LCD_COLOR_BG, LCD_COLOR_BG );

View file

@ -26,8 +26,8 @@
#define UPDATE_MENU 1 #define UPDATE_MENU 1
#define UPDATE_DISP 2 #define UPDATE_DISP 2
#define KEYBOARD_HEIGHT ( buttons[ LAST_HPKEY ].y + buttons[ LAST_HPKEY ].h ) #define KEYBOARD_HEIGHT ( BUTTONS[ LAST_HPKEY ].y + BUTTONS[ LAST_HPKEY ].h )
#define KEYBOARD_WIDTH ( buttons[ LAST_HPKEY ].x + buttons[ LAST_HPKEY ].w ) #define KEYBOARD_WIDTH ( BUTTONS[ LAST_HPKEY ].x + BUTTONS[ LAST_HPKEY ].w )
#define TOP_SKIP 65 #define TOP_SKIP 65
#define SIDE_SKIP 20 #define SIDE_SKIP 20
@ -242,7 +242,6 @@ static XColor x11_colors[ NB_COLORS ] = {
{0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0}, {0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0},
{0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0}, {0, 0, 0, 0, DoRed | DoGreen | DoBlue, 0},
}; };
static color_t* colors;
static int CompletionType = -1; static int CompletionType = -1;
@ -277,7 +276,6 @@ static int icon_color_mode;
static char* res_name; static char* res_name;
static char* res_class; static char* res_class;
static button_t* buttons = 0;
static x11_button_t x11_buttons[ NB_KEYS ] = { static x11_button_t x11_buttons[ NB_KEYS ] = {
{.map = 0, .down = 0, .xwin = 0}, {.map = 0, .down = 0, .xwin = 0},
{.map = 0, .down = 0, .xwin = 0}, {.map = 0, .down = 0, .xwin = 0},
@ -571,19 +569,19 @@ static inline void colors_setup( void )
for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) { for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) {
switch ( color_mode ) { switch ( color_mode ) {
case COLOR_MODE_MONO: case COLOR_MODE_MONO:
x11_colors[ c ].red = colors[ c ].mono_rgb << 8; x11_colors[ c ].red = COLORS[ c ].mono_rgb << 8;
x11_colors[ c ].green = colors[ c ].mono_rgb << 8; x11_colors[ c ].green = COLORS[ c ].mono_rgb << 8;
x11_colors[ c ].blue = colors[ c ].mono_rgb << 8; x11_colors[ c ].blue = COLORS[ c ].mono_rgb << 8;
break; break;
case COLOR_MODE_GRAY: case COLOR_MODE_GRAY:
x11_colors[ c ].red = colors[ c ].gray_rgb << 8; x11_colors[ c ].red = COLORS[ c ].gray_rgb << 8;
x11_colors[ c ].green = colors[ c ].gray_rgb << 8; x11_colors[ c ].green = COLORS[ c ].gray_rgb << 8;
x11_colors[ c ].blue = colors[ c ].gray_rgb << 8; x11_colors[ c ].blue = COLORS[ c ].gray_rgb << 8;
break; break;
default: default:
x11_colors[ c ].red = colors[ c ].r << 8; x11_colors[ c ].red = COLORS[ c ].r << 8;
x11_colors[ c ].green = colors[ c ].g << 8; x11_colors[ c ].green = COLORS[ c ].g << 8;
x11_colors[ c ].blue = colors[ c ].b << 8; x11_colors[ c ].blue = COLORS[ c ].b << 8;
break; break;
} }
if ( direct_color ) { if ( direct_color ) {
@ -654,19 +652,19 @@ static inline void colors_setup( void )
for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) { for ( c = FIRST_COLOR; c <= LAST_COLOR; c++ ) {
switch ( color_mode ) { switch ( color_mode ) {
case COLOR_MODE_MONO: case COLOR_MODE_MONO:
x11_colors[ c ].red = colors[ c ].mono_rgb << 8; x11_colors[ c ].red = COLORS[ c ].mono_rgb << 8;
x11_colors[ c ].green = colors[ c ].mono_rgb << 8; x11_colors[ c ].green = COLORS[ c ].mono_rgb << 8;
x11_colors[ c ].blue = colors[ c ].mono_rgb << 8; x11_colors[ c ].blue = COLORS[ c ].mono_rgb << 8;
break; break;
case COLOR_MODE_GRAY: case COLOR_MODE_GRAY:
x11_colors[ c ].red = colors[ c ].gray_rgb << 8; x11_colors[ c ].red = COLORS[ c ].gray_rgb << 8;
x11_colors[ c ].green = colors[ c ].gray_rgb << 8; x11_colors[ c ].green = COLORS[ c ].gray_rgb << 8;
x11_colors[ c ].blue = colors[ c ].gray_rgb << 8; x11_colors[ c ].blue = COLORS[ c ].gray_rgb << 8;
break; break;
default: default:
x11_colors[ c ].red = colors[ c ].r << 8; x11_colors[ c ].red = COLORS[ c ].r << 8;
x11_colors[ c ].green = colors[ c ].g << 8; x11_colors[ c ].green = COLORS[ c ].g << 8;
x11_colors[ c ].blue = colors[ c ].b << 8; x11_colors[ c ].blue = COLORS[ c ].b << 8;
break; break;
} }
if ( dynamic_color && c == PIXEL ) { if ( dynamic_color && c == PIXEL ) {
@ -724,7 +722,7 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
if ( i < HPKEY_MTH ) if ( i < HPKEY_MTH )
pixel = COLOR( DISP_PAD ); pixel = COLOR( DISP_PAD );
else { else {
if ( opt_gx && buttons[ i ].is_menu ) if ( opt_gx && BUTTONS[ i ].is_menu )
pixel = COLOR( UNDERLAY ); pixel = COLOR( UNDERLAY );
else else
pixel = COLOR( PAD ); pixel = COLOR( PAD );
@ -733,7 +731,7 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
/* /*
* create the buttons subwindows * create the buttons subwindows
*/ */
x11_buttons[ i ].xwin = XCreateSimpleWindow( dpy, mainW, off_x + buttons[ i ].x, off_y + buttons[ i ].y, buttons[ i ].w, buttons[ i ].h, x11_buttons[ i ].xwin = XCreateSimpleWindow( dpy, mainW, off_x + BUTTONS[ i ].x, off_y + BUTTONS[ i ].y, BUTTONS[ i ].w, BUTTONS[ i ].h,
0, COLOR( BLACK ), pixel ); 0, COLOR( BLACK ), pixel );
XDefineCursor( dpy, x11_buttons[ i ].xwin, XCreateFontCursor( dpy, XC_hand1 ) ); XDefineCursor( dpy, x11_buttons[ i ].xwin, XCreateFontCursor( dpy, XC_hand1 ) );
@ -746,19 +744,19 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
/* /*
* draw the released button * draw the released button
*/ */
x11_buttons[ i ].map = XCreatePixmap( dpy, x11_buttons[ i ].xwin, buttons[ i ].w, buttons[ i ].h, depth ); x11_buttons[ i ].map = XCreatePixmap( dpy, x11_buttons[ i ].xwin, BUTTONS[ i ].w, BUTTONS[ i ].h, depth );
XSetForeground( dpy, gc, pixel ); XSetForeground( dpy, gc, pixel );
XFillRectangle( dpy, x11_buttons[ i ].map, gc, 0, 0, buttons[ i ].w, buttons[ i ].h ); XFillRectangle( dpy, x11_buttons[ i ].map, gc, 0, 0, BUTTONS[ i ].w, BUTTONS[ i ].h );
XSetForeground( dpy, gc, COLOR( BUTTON ) ); XSetForeground( dpy, gc, COLOR( BUTTON ) );
XFillRectangle( dpy, x11_buttons[ i ].map, gc, 1, 1, buttons[ i ].w - 2, buttons[ i ].h - 2 ); XFillRectangle( dpy, x11_buttons[ i ].map, gc, 1, 1, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2 );
if ( buttons[ i ].label != ( char* )0 ) { if ( BUTTONS[ i ].label != ( char* )0 ) {
/* /*
* set font size in gc * set font size in gc
*/ */
switch ( buttons[ i ].font_size ) { switch ( BUTTONS[ i ].font_size ) {
case 0: case 0:
finfo = f_small; finfo = f_small;
break; break;
@ -780,28 +778,28 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
* draw string centered in button * draw string centered in button
*/ */
XSetBackground( dpy, gc, COLOR( BUTTON ) ); XSetBackground( dpy, gc, COLOR( BUTTON ) );
XSetForeground( dpy, gc, COLOR( buttons[ i ].lc ) ); XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) );
XTextExtents( finfo, buttons[ i ].label, ( int )strlen( buttons[ i ].label ), &dir, &fa, &fd, &xchar ); XTextExtents( finfo, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ), &dir, &fa, &fd, &xchar );
x = ( buttons[ i ].w - xchar.width ) / 2; x = ( BUTTONS[ i ].w - xchar.width ) / 2;
y = ( 1 + buttons[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent + 1; y = ( 1 + BUTTONS[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent + 1;
XDrawImageString( dpy, x11_buttons[ i ].map, gc, x, y, buttons[ i ].label, ( int )strlen( buttons[ i ].label ) ); XDrawImageString( dpy, x11_buttons[ i ].map, gc, x, y, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ) );
XSetBackground( dpy, gc, COLOR( BLACK ) ); XSetBackground( dpy, gc, COLOR( BLACK ) );
} else if ( buttons[ i ].lw != 0 ) { } else if ( BUTTONS[ i ].lw != 0 ) {
/* /*
* draw pixmap centered in button * draw pixmap centered in button
*/ */
XSetBackground( dpy, gc, COLOR( BUTTON ) ); XSetBackground( dpy, gc, COLOR( BUTTON ) );
XSetForeground( dpy, gc, COLOR( buttons[ i ].lc ) ); XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) );
pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )buttons[ i ].lb, buttons[ i ].lw, buttons[ i ].lh ); pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )BUTTONS[ i ].lb, BUTTONS[ i ].lw, BUTTONS[ i ].lh );
x = ( 1 + buttons[ i ].w - buttons[ i ].lw ) / 2; x = ( 1 + BUTTONS[ i ].w - BUTTONS[ i ].lw ) / 2;
y = ( 1 + buttons[ i ].h - buttons[ i ].lh ) / 2 + 1; y = ( 1 + BUTTONS[ i ].h - BUTTONS[ i ].lh ) / 2 + 1;
XCopyPlane( dpy, pix, x11_buttons[ i ].map, gc, 0, 0, buttons[ i ].lw, buttons[ i ].lh, x, y, 1 ); XCopyPlane( dpy, pix, x11_buttons[ i ].map, gc, 0, 0, BUTTONS[ i ].lw, BUTTONS[ i ].lh, x, y, 1 );
XFreePixmap( dpy, pix ); XFreePixmap( dpy, pix );
@ -813,72 +811,72 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
*/ */
XSetForeground( dpy, gc, COLOR( BUT_TOP ) ); XSetForeground( dpy, gc, COLOR( BUT_TOP ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, ( int )( buttons[ i ].h - 2 ), 1, 1 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, ( int )( BUTTONS[ i ].h - 2 ), 1, 1 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( buttons[ i ].h - 3 ), 2, 2 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( BUTTONS[ i ].h - 3 ), 2, 2 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( buttons[ i ].h - 4 ), 3, 3 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( BUTTONS[ i ].h - 4 ), 3, 3 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( buttons[ i ].w - 2 ), 1 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 2, ( int )( buttons[ i ].w - 3 ), 2 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 2, ( int )( BUTTONS[ i ].w - 3 ), 2 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, 3, ( int )( buttons[ i ].w - 4 ), 3 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, 3, ( int )( BUTTONS[ i ].w - 4 ), 3 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, 4, ( int )( buttons[ i ].w - 5 ), 4 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, 4, ( int )( BUTTONS[ i ].w - 5 ), 4 );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, 4, 5 ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, 4, 5 );
XSetForeground( dpy, gc, COLOR( BUT_BOT ) ); XSetForeground( dpy, gc, COLOR( BUT_BOT ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( buttons[ i ].h - 2 ), ( int )( buttons[ i ].w - 2 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, 3, ( int )( BUTTONS[ i ].h - 2 ), ( int )( BUTTONS[ i ].w - 2 ),
( int )( buttons[ i ].h - 2 ) ); ( int )( BUTTONS[ i ].h - 2 ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, 4, ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ),
( int )( buttons[ i ].h - 3 ) ); ( int )( BUTTONS[ i ].h - 3 ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 2 ), ( int )( buttons[ i ].h - 2 ), ( int )( buttons[ i ].w - 2 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ), ( int )( BUTTONS[ i ].w - 2 ),
3 ); 3 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 3 ), ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ),
4 ); 4 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 4 ), ( int )( buttons[ i ].h - 4 ), ( int )( buttons[ i ].w - 4 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 4 ), ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ),
5 ); 5 );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 5 ), ( int )( buttons[ i ].h - 4 ) ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 5 ), ( int )( BUTTONS[ i ].h - 4 ) );
/* /*
* draw frame around button * draw frame around button
*/ */
XSetForeground( dpy, gc, COLOR( FRAME ) ); XSetForeground( dpy, gc, COLOR( FRAME ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 0, ( int )( buttons[ i ].h - 3 ), 0, 2 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 0, ( int )( BUTTONS[ i ].h - 3 ), 0, 2 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 0, ( int )( buttons[ i ].w - 3 ), 0 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, 0, ( int )( BUTTONS[ i ].w - 3 ), 0 );
XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( buttons[ i ].h - 1 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, 2, ( int )( BUTTONS[ i ].h - 1 ), ( int )( BUTTONS[ i ].w - 3 ),
( int )( buttons[ i ].h - 1 ) ); ( int )( BUTTONS[ i ].h - 1 ) );
XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 1 ), ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 1 ), XDrawLine( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 1 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 1 ),
2 ); 2 );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( buttons[ i ].w - 2 ), 1 ); XDrawLine( dpy, x11_buttons[ i ].map, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 2 ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 2 );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 2 ), 2 ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), 2 );
} else { } else {
XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 1 ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, 1 );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 2 ), 1 ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), 1 );
} }
XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, ( int )( buttons[ i ].h - 2 ) ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, 1, ( int )( BUTTONS[ i ].h - 2 ) );
XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( buttons[ i ].w - 2 ), ( int )( buttons[ i ].h - 2 ) ); XDrawPoint( dpy, x11_buttons[ i ].map, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ) );
/* /*
* draw the depressed button * draw the depressed button
*/ */
x11_buttons[ i ].down = XCreatePixmap( dpy, x11_buttons[ i ].xwin, buttons[ i ].w, buttons[ i ].h, depth ); x11_buttons[ i ].down = XCreatePixmap( dpy, x11_buttons[ i ].xwin, BUTTONS[ i ].w, BUTTONS[ i ].h, depth );
XSetForeground( dpy, gc, pixel ); XSetForeground( dpy, gc, pixel );
XFillRectangle( dpy, x11_buttons[ i ].down, gc, 0, 0, buttons[ i ].w, buttons[ i ].h ); XFillRectangle( dpy, x11_buttons[ i ].down, gc, 0, 0, BUTTONS[ i ].w, BUTTONS[ i ].h );
XSetForeground( dpy, gc, COLOR( BUTTON ) ); XSetForeground( dpy, gc, COLOR( BUTTON ) );
XFillRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, buttons[ i ].w - 2, buttons[ i ].h - 2 ); XFillRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, BUTTONS[ i ].w - 2, BUTTONS[ i ].h - 2 );
if ( buttons[ i ].label != ( char* )0 ) { if ( BUTTONS[ i ].label != ( char* )0 ) {
/* /*
* set small or big font in gc * set small or big font in gc
*/ */
switch ( buttons[ i ].font_size ) { switch ( BUTTONS[ i ].font_size ) {
case 0: case 0:
finfo = f_small; finfo = f_small;
break; break;
@ -900,12 +898,12 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
* draw string centered in button * draw string centered in button
*/ */
XSetBackground( dpy, gc, COLOR( BUTTON ) ); XSetBackground( dpy, gc, COLOR( BUTTON ) );
XSetForeground( dpy, gc, COLOR( buttons[ i ].lc ) ); XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) );
XTextExtents( finfo, buttons[ i ].label, ( int )strlen( buttons[ i ].label ), &dir, &fa, &fd, &xchar ); XTextExtents( finfo, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ), &dir, &fa, &fd, &xchar );
x = ( buttons[ i ].w - xchar.width ) / 2; x = ( BUTTONS[ i ].w - xchar.width ) / 2;
y = ( 1 + buttons[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent; y = ( 1 + BUTTONS[ i ].h - ( xchar.ascent + xchar.descent ) ) / 2 + xchar.ascent;
XDrawImageString( dpy, x11_buttons[ i ].down, gc, x, y, buttons[ i ].label, ( int )strlen( buttons[ i ].label ) ); XDrawImageString( dpy, x11_buttons[ i ].down, gc, x, y, BUTTONS[ i ].label, ( int )strlen( BUTTONS[ i ].label ) );
XSetBackground( dpy, gc, COLOR( BLACK ) ); XSetBackground( dpy, gc, COLOR( BLACK ) );
} else { } else {
@ -913,14 +911,14 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
* draw pixmap centered in button * draw pixmap centered in button
*/ */
XSetBackground( dpy, gc, COLOR( BUTTON ) ); XSetBackground( dpy, gc, COLOR( BUTTON ) );
XSetForeground( dpy, gc, COLOR( buttons[ i ].lc ) ); XSetForeground( dpy, gc, COLOR( BUTTONS[ i ].lc ) );
pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )buttons[ i ].lb, buttons[ i ].lw, buttons[ i ].lh ); pix = XCreateBitmapFromData( dpy, x11_buttons[ i ].xwin, ( char* )BUTTONS[ i ].lb, BUTTONS[ i ].lw, BUTTONS[ i ].lh );
x = ( 1 + buttons[ i ].w - buttons[ i ].lw ) / 2; x = ( 1 + BUTTONS[ i ].w - BUTTONS[ i ].lw ) / 2;
y = ( 1 + buttons[ i ].h - buttons[ i ].lh ) / 2; y = ( 1 + BUTTONS[ i ].h - BUTTONS[ i ].lh ) / 2;
XCopyPlane( dpy, pix, x11_buttons[ i ].down, gc, 0, 0, buttons[ i ].lw, buttons[ i ].lh, x, y, 1 ); XCopyPlane( dpy, pix, x11_buttons[ i ].down, gc, 0, 0, BUTTONS[ i ].lw, BUTTONS[ i ].lh, x, y, 1 );
XFreePixmap( dpy, pix ); XFreePixmap( dpy, pix );
@ -932,62 +930,62 @@ static inline void __create_button( int i, int off_x, int off_y, XFontStruct* f_
*/ */
XSetForeground( dpy, gc, COLOR( BUT_TOP ) ); XSetForeground( dpy, gc, COLOR( BUT_TOP ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( buttons[ i ].h - 4 ), 2, 2 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 4 ), 2, 2 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( buttons[ i ].h - 5 ), 3, 3 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( BUTTONS[ i ].h - 5 ), 3, 3 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 2, ( int )( buttons[ i ].w - 4 ), 2 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 2, ( int )( BUTTONS[ i ].w - 4 ), 2 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, 3, ( int )( buttons[ i ].w - 5 ), 3 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, 3, ( int )( BUTTONS[ i ].w - 5 ), 3 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 4, 4 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 4, 4 );
XSetForeground( dpy, gc, COLOR( BUT_BOT ) ); XSetForeground( dpy, gc, COLOR( BUT_BOT ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, 3, ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ),
( int )( buttons[ i ].h - 3 ) ); ( int )( BUTTONS[ i ].h - 3 ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 4, ( int )( buttons[ i ].h - 4 ), ( int )( buttons[ i ].w - 4 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, 4, ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ),
( int )( buttons[ i ].h - 4 ) ); ( int )( BUTTONS[ i ].h - 4 ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 3 ), ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 3 ),
3 ); 3 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 4 ), ( int )( buttons[ i ].h - 4 ), ( int )( buttons[ i ].w - 4 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 4 ), ( int )( BUTTONS[ i ].h - 4 ), ( int )( BUTTONS[ i ].w - 4 ),
4 ); 4 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 5 ), ( int )( buttons[ i ].h - 5 ) ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 5 ), ( int )( BUTTONS[ i ].h - 5 ) );
/* /*
* draw frame around button * draw frame around button
*/ */
XSetForeground( dpy, gc, COLOR( FRAME ) ); XSetForeground( dpy, gc, COLOR( FRAME ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 0, ( int )( buttons[ i ].h - 3 ), 0, 2 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 0, ( int )( BUTTONS[ i ].h - 3 ), 0, 2 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 0, ( int )( buttons[ i ].w - 3 ), 0 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, 0, ( int )( BUTTONS[ i ].w - 3 ), 0 );
XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( buttons[ i ].h - 1 ), ( int )( buttons[ i ].w - 3 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 1 ), ( int )( BUTTONS[ i ].w - 3 ),
( int )( buttons[ i ].h - 1 ) ); ( int )( BUTTONS[ i ].h - 1 ) );
XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 1 ), ( int )( buttons[ i ].h - 3 ), ( int )( buttons[ i ].w - 1 ), XDrawLine( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 1 ), ( int )( BUTTONS[ i ].h - 3 ), ( int )( BUTTONS[ i ].w - 1 ),
2 ); 2 );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
XDrawLine( dpy, x11_buttons[ i ].down, gc, 1, 1, ( int )( buttons[ i ].w - 2 ), 1 ); XDrawLine( dpy, x11_buttons[ i ].down, gc, 1, 1, ( int )( BUTTONS[ i ].w - 2 ), 1 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 2 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 2 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 2 ), 2 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), 2 );
} else { } else {
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 1 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, 1 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 2 ), 1 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), 1 );
} }
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, ( int )( buttons[ i ].h - 2 ) ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 1, ( int )( BUTTONS[ i ].h - 2 ) );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 2 ), ( int )( buttons[ i ].h - 2 ) ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 2 ), ( int )( BUTTONS[ i ].h - 2 ) );
if ( i == HPKEY_ON ) { if ( i == HPKEY_ON ) {
XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 2, buttons[ i ].w - 3, buttons[ i ].h - 4 ); XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 2, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 4 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 3 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 3 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 3 ), 3 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), 3 );
} else { } else {
XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, buttons[ i ].w - 3, buttons[ i ].h - 3 ); XDrawRectangle( dpy, x11_buttons[ i ].down, gc, 1, 1, BUTTONS[ i ].w - 3, BUTTONS[ i ].h - 3 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 2 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, 2 );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 3 ), 2 ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), 2 );
} }
XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, ( int )( buttons[ i ].h - 3 ) ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, 2, ( int )( BUTTONS[ i ].h - 3 ) );
XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( buttons[ i ].w - 3 ), ( int )( buttons[ i ].h - 3 ) ); XDrawPoint( dpy, x11_buttons[ i ].down, gc, ( int )( BUTTONS[ i ].w - 3 ), ( int )( BUTTONS[ i ].h - 3 ) );
} }
static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* local_keypad ) static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x, x11_keypad_t* local_keypad )
@ -1011,39 +1009,39 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
pixel = ( i < HPKEY_MTH ) ? COLOR( DISP_PAD ) : COLOR( PAD ); pixel = ( i < HPKEY_MTH ) ? COLOR( DISP_PAD ) : COLOR( PAD );
if ( buttons[ i ].letter != ( char* )0 ) { if ( BUTTONS[ i ].letter != ( char* )0 ) {
XSetBackground( dpy, gc, pixel ); XSetBackground( dpy, gc, pixel );
XSetForeground( dpy, gc, COLOR( WHITE ) ); XSetForeground( dpy, gc, COLOR( WHITE ) );
if ( opt_gx ) { if ( opt_gx ) {
x = offset_x + buttons[ i ].x + buttons[ i ].w + 3; x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w + 3;
y = offset_y + buttons[ i ].y + buttons[ i ].h + 1; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + 1;
} else { } else {
x = offset_x + buttons[ i ].x + buttons[ i ].w - SmallTextWidth( buttons[ i ].letter, 1 ) / 2 + 5; x = offset_x + BUTTONS[ i ].x + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].letter, 1 ) / 2 + 5;
y = offset_y + buttons[ i ].y + buttons[ i ].h - 2; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h - 2;
} }
__write_text( dpy, local_keypad->pixmap, gc, x, y, buttons[ i ].letter, 1 ); __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].letter, 1 );
} }
/* /*
* draw the bottom labels * draw the bottom labels
*/ */
if ( buttons[ i ].sub != ( char* )0 ) { if ( BUTTONS[ i ].sub != ( char* )0 ) {
XSetBackground( dpy, gc, pixel ); XSetBackground( dpy, gc, pixel );
XSetForeground( dpy, gc, COLOR( WHITE ) ); XSetForeground( dpy, gc, COLOR( WHITE ) );
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].sub, strlen( buttons[ i ].sub ) ) ) / 2; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) ) ) / 2;
y = offset_y + buttons[ i ].y + buttons[ i ].h + small_ascent + 2; y = offset_y + BUTTONS[ i ].y + BUTTONS[ i ].h + small_ascent + 2;
__write_text( dpy, local_keypad->pixmap, gc, x, y, buttons[ i ].sub, strlen( buttons[ i ].sub ) ); __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].sub, strlen( BUTTONS[ i ].sub ) );
} }
/* /*
* draw the left labels * draw the left labels
*/ */
if ( buttons[ i ].left != ( char* )0 ) { if ( BUTTONS[ i ].left != ( char* )0 ) {
if ( buttons[ i ].is_menu ) { if ( BUTTONS[ i ].is_menu ) {
/* /*
* draw the dark shade under the label * draw the dark shade under the label
*/ */
@ -1064,10 +1062,10 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
XSetBackground( dpy, gc, COLOR( UNDERLAY ) ); XSetBackground( dpy, gc, COLOR( UNDERLAY ) );
XSetForeground( dpy, gc, COLOR( LEFT ) ); XSetForeground( dpy, gc, COLOR( LEFT ) );
x = ( pw + 1 - SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ) ) / 2; x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2;
y = ( opt_gx ) ? 14 : 9; y = ( opt_gx ) ? 14 : 9;
__write_text( dpy, pix, gc, x, y, buttons[ i ].left, strlen( buttons[ i ].left ) ); __write_text( dpy, pix, gc, x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
XSetForeground( dpy, gc, pixel ); XSetForeground( dpy, gc, pixel );
@ -1079,11 +1077,11 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
} }
if ( opt_gx ) { if ( opt_gx ) {
x = offset_x + buttons[ i ].x - 6; x = offset_x + BUTTONS[ i ].x - 6;
y = offset_y + buttons[ i ].y - small_ascent - small_descent - 6; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6;
} else { } else {
x = offset_x + buttons[ i ].x + ( buttons[ i ].w - pw ) / 2; x = offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2;
y = offset_y + buttons[ i ].y - small_ascent - small_descent; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent;
} }
XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y ); XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y );
@ -1093,28 +1091,28 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
XSetBackground( dpy, gc, pixel ); XSetBackground( dpy, gc, pixel );
XSetForeground( dpy, gc, COLOR( LEFT ) ); XSetForeground( dpy, gc, COLOR( LEFT ) );
if ( buttons[ i ].right == ( char* )0 ) /* centered label */ if ( BUTTONS[ i ].right == ( char* )0 ) /* centered label */
x = offset_x + buttons[ i ].x + x = offset_x + BUTTONS[ i ].x +
( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ) ) / 2; ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) ) ) / 2;
else { /* label to the left */ else { /* label to the left */
wl = SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ); wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
wr = SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ); wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
ws = SmallTextWidth( " ", 1 ); ws = SmallTextWidth( " ", 1 );
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - ( wl + wr + ws ) ) / 2; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2;
} }
y = offset_y + buttons[ i ].y - small_descent; y = offset_y + BUTTONS[ i ].y - small_descent;
__write_text( dpy, local_keypad->pixmap, gc, x, y, buttons[ i ].left, strlen( buttons[ i ].left ) ); __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
} }
} }
/* /*
* draw the right labels * draw the right labels
*/ */
if ( buttons[ i ].right != ( char* )0 ) { if ( BUTTONS[ i ].right != ( char* )0 ) {
if ( buttons[ i ].is_menu ) { if ( BUTTONS[ i ].is_menu ) {
/* /*
* draw the dark shade under the label * draw the dark shade under the label
*/ */
@ -1135,10 +1133,10 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
XSetBackground( dpy, gc, COLOR( UNDERLAY ) ); XSetBackground( dpy, gc, COLOR( UNDERLAY ) );
XSetForeground( dpy, gc, COLOR( RIGHT ) ); XSetForeground( dpy, gc, COLOR( RIGHT ) );
x = ( pw + 1 - SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ) ) / 2; x = ( pw + 1 - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2;
y = ( opt_gx ) ? 14 : 8; y = ( opt_gx ) ? 14 : 8;
__write_text( dpy, pix, gc, x, y, buttons[ i ].right, strlen( buttons[ i ].right ) ); __write_text( dpy, pix, gc, x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
XSetForeground( dpy, gc, pixel ); XSetForeground( dpy, gc, pixel );
@ -1150,11 +1148,11 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
} }
if ( opt_gx ) { if ( opt_gx ) {
x = offset_x + buttons[ i ].x - 6; x = offset_x + BUTTONS[ i ].x - 6;
y = offset_y + buttons[ i ].y - small_ascent - small_descent - 6; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent - 6;
} else { } else {
x = offset_x + buttons[ i ].x + ( buttons[ i ].w - pw ) / 2; x = offset_x + BUTTONS[ i ].x + ( BUTTONS[ i ].w - pw ) / 2;
y = offset_y + buttons[ i ].y - small_ascent - small_descent; y = offset_y + BUTTONS[ i ].y - small_ascent - small_descent;
} }
XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y ); XCopyArea( dpy, pix, local_keypad->pixmap, gc, 0, 0, pw, ph, x, y );
@ -1164,20 +1162,20 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
XSetBackground( dpy, gc, pixel ); XSetBackground( dpy, gc, pixel );
XSetForeground( dpy, gc, COLOR( RIGHT ) ); XSetForeground( dpy, gc, COLOR( RIGHT ) );
if ( buttons[ i ].left == ( char* )0 ) /* centered label */ if ( BUTTONS[ i ].left == ( char* )0 ) /* centered label */
x = offset_x + buttons[ i ].x + x = offset_x + BUTTONS[ i ].x +
( 1 + buttons[ i ].w - SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ) ) / 2; ( 1 + BUTTONS[ i ].w - SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) ) ) / 2;
else { /* label to the right */ else { /* label to the right */
wl = SmallTextWidth( buttons[ i ].left, strlen( buttons[ i ].left ) ); wl = SmallTextWidth( BUTTONS[ i ].left, strlen( BUTTONS[ i ].left ) );
wr = SmallTextWidth( buttons[ i ].right, strlen( buttons[ i ].right ) ); wr = SmallTextWidth( BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
ws = SmallTextWidth( " ", 1 ); ws = SmallTextWidth( " ", 1 );
x = offset_x + buttons[ i ].x + ( 1 + buttons[ i ].w - ( wl + wr + ws ) ) / 2 + wl + ws; x = offset_x + BUTTONS[ i ].x + ( 1 + BUTTONS[ i ].w - ( wl + wr + ws ) ) / 2 + wl + ws;
} }
y = offset_y + buttons[ i ].y - small_descent; y = offset_y + BUTTONS[ i ].y - small_descent;
__write_text( dpy, local_keypad->pixmap, gc, x, y, buttons[ i ].right, strlen( buttons[ i ].right ) ); __write_text( dpy, local_keypad->pixmap, gc, x, y, BUTTONS[ i ].right, strlen( BUTTONS[ i ].right ) );
} }
} }
} }
@ -1196,9 +1194,9 @@ static inline void __create_keypad( unsigned int offset_y, unsigned int offset_x
pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )last_bitmap, last_width, last_height ); pix = XCreateBitmapFromData( dpy, local_keypad->pixmap, ( char* )last_bitmap, last_width, last_height );
x = offset_x + buttons[ HPKEY_1 ].x + buttons[ HPKEY_1 ].w + x = offset_x + BUTTONS[ HPKEY_1 ].x + BUTTONS[ HPKEY_1 ].w +
( buttons[ HPKEY_2 ].x - buttons[ HPKEY_1 ].x - buttons[ HPKEY_1 ].w ) / 2; ( BUTTONS[ HPKEY_2 ].x - BUTTONS[ HPKEY_1 ].x - BUTTONS[ HPKEY_1 ].w ) / 2;
y = offset_y + buttons[ HPKEY_5 ].y + buttons[ HPKEY_5 ].h + 2; y = offset_y + BUTTONS[ HPKEY_5 ].y + BUTTONS[ HPKEY_5 ].h + 2;
XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, last_width, last_height, x, y, 1 ); XCopyPlane( dpy, pix, local_keypad->pixmap, gc, 0, 0, last_width, last_height, x, y, 1 );
@ -1334,7 +1332,7 @@ static inline void _draw_bezel( unsigned int offset_y, x11_keypad_t* local_keypa
XDrawLine( dpy, local_keypad->pixmap, gc, 1, ( int )( local_keypad->height - 3 ), 1, cut ); XDrawLine( dpy, local_keypad->pixmap, gc, 1, ( int )( local_keypad->height - 3 ), 1, cut );
/* /*
* lower the menu buttons * lower the menu BUTTONS
*/ */
XSetForeground( dpy, gc, COLOR( PAD_TOP ) ); XSetForeground( dpy, gc, COLOR( PAD_TOP ) );
@ -1515,7 +1513,7 @@ static void draw_keypad( void ) { XCopyArea( dpy, keypad.pixmap, mainW, gc, 0, 0
static inline void draw_button( int i ) static inline void draw_button( int i )
{ {
XCopyArea( dpy, ( keyboard[ i ].pressed ) ? x11_buttons[ i ].down : x11_buttons[ i ].map, x11_buttons[ i ].xwin, gc, 0, 0, XCopyArea( dpy, ( keyboard[ i ].pressed ) ? x11_buttons[ i ].down : x11_buttons[ i ].map, x11_buttons[ i ].xwin, gc, 0, 0,
buttons[ i ].w, buttons[ i ].h, 0, 0 ); BUTTONS[ i ].w, BUTTONS[ i ].h, 0, 0 );
} }
static inline void _create_icon( void ) static inline void _create_icon( void )
@ -2185,25 +2183,17 @@ static bool create_window( int argc, char** argv )
int info, x, y, w, h; int info, x, y, w, h;
unsigned int width, height; unsigned int width, height;
if ( opt_gx ) { icon_maps = opt_gx ? icon_maps_gx : icon_maps_sx;
buttons = buttons_gx;
colors = colors_gx;
icon_maps = icon_maps_gx;
} else {
buttons = buttons_sx;
colors = colors_sx;
icon_maps = icon_maps_sx;
}
if ( config.netbook ) { if ( config.netbook ) {
int i; int i;
for ( i = 0; i < 6; i++ ) { for ( i = 0; i < 6; i++ ) {
buttons[ i ].x -= 3; BUTTONS[ i ].x -= 3;
buttons[ i ].y += 300; BUTTONS[ i ].y += 300;
} }
for ( ; i <= LAST_HPKEY; i++ ) { for ( ; i <= LAST_HPKEY; i++ ) {
buttons[ i ].x += 317; BUTTONS[ i ].x += 317;
buttons[ i ].y -= 3; BUTTONS[ i ].y -= 3;
} }
} }
@ -2419,7 +2409,7 @@ static bool create_window( int argc, char** argv )
* create the keypad * create the keypad
*/ */
/* /*
* draw the nice labels around the buttons * draw the nice labels around the BUTTONS
*/ */
keypad.width = width; keypad.width = width;
keypad.height = height; keypad.height = height;
@ -2428,11 +2418,11 @@ static bool create_window( int argc, char** argv )
int cut; int cut;
if ( config.netbook ) { if ( config.netbook ) {
cut = buttons[ HPKEY_MTH ].y - ( small_ascent + small_descent + 6 + 4 ); cut = BUTTONS[ HPKEY_MTH ].y - ( small_ascent + small_descent + 6 + 4 );
_draw_background( width / 2, height, width, height, &keypad ); _draw_background( width / 2, height, width, height, &keypad );
__create_keypad( -cut, KEYBOARD_OFFSET_X, &keypad ); __create_keypad( -cut, KEYBOARD_OFFSET_X, &keypad );
} else { } else {
cut = buttons[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19; cut = BUTTONS[ HPKEY_MTH ].y + KEYBOARD_OFFSET_Y - 19;
_draw_background( width, cut, width, height, &keypad ); _draw_background( width, cut, width, height, &keypad );
__create_keypad( KEYBOARD_OFFSET_Y, KEYBOARD_OFFSET_X, &keypad ); __create_keypad( KEYBOARD_OFFSET_Y, KEYBOARD_OFFSET_X, &keypad );
} }
@ -3053,15 +3043,15 @@ void x11_adjust_contrast( void )
case COLOR_MODE_MONO: case COLOR_MODE_MONO:
return; return;
case COLOR_MODE_GRAY: case COLOR_MODE_GRAY:
gray = ( 0x13 - contrast ) * ( colors[ LCD ].gray_rgb / 0x10 ); gray = ( 0x13 - contrast ) * ( COLORS[ LCD ].gray_rgb / 0x10 );
x11_colors[ PIXEL ].red = gray << 8; x11_colors[ PIXEL ].red = gray << 8;
x11_colors[ PIXEL ].green = gray << 8; x11_colors[ PIXEL ].green = gray << 8;
x11_colors[ PIXEL ].blue = gray << 8; x11_colors[ PIXEL ].blue = gray << 8;
break; break;
default: default:
r = ( 0x13 - contrast ) * ( colors[ LCD ].r / 0x10 ); r = ( 0x13 - contrast ) * ( COLORS[ LCD ].r / 0x10 );
g = ( 0x13 - contrast ) * ( colors[ LCD ].g / 0x10 ); g = ( 0x13 - contrast ) * ( COLORS[ LCD ].g / 0x10 );
b = 128 - ( ( 0x13 - contrast ) * ( ( 128 - colors[ LCD ].b ) / 0x10 ) ); b = 128 - ( ( 0x13 - contrast ) * ( ( 128 - COLORS[ LCD ].b ) / 0x10 ) );
x11_colors[ PIXEL ].red = r << 8; x11_colors[ PIXEL ].red = r << 8;
x11_colors[ PIXEL ].green = g << 8; x11_colors[ PIXEL ].green = g << 8;
x11_colors[ PIXEL ].blue = b << 8; x11_colors[ PIXEL ].blue = b << 8;
@ -3069,10 +3059,10 @@ void x11_adjust_contrast( void )
} }
if ( direct_color ) { if ( direct_color ) {
colors[ PIXEL ].gray_rgb = gray; COLORS[ PIXEL ].gray_rgb = gray;
colors[ PIXEL ].r = r; COLORS[ PIXEL ].r = r;
colors[ PIXEL ].g = g; COLORS[ PIXEL ].g = g;
colors[ PIXEL ].b = b; COLORS[ PIXEL ].b = b;
colors_setup(); colors_setup();