1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

5 commits

Author SHA1 Message Date
Gwenhael Le Moine
8bbfba569d
re-enable Alt for α 2024-10-24 15:45:09 +02:00
Gwenhael Le Moine
d8f623938f
disable making buttons look clicked when using keyboard. Not syre how to re-implement it without using the private GtkButton->in_button field 2024-10-24 15:41:27 +02:00
Gwenhael Le Moine
e1f34098c4
prettify code 2024-10-24 15:41:14 +02:00
Gwenhael Le Moine
d300afe3c7
[gtk] use accessor functions to get values
as part of modernizing gtk code before upgrading gtk
2024-10-24 15:39:41 +02:00
Gwenhael Le Moine
c09f925e32
prettify code 2024-10-24 15:35:28 +02:00
5 changed files with 182 additions and 185 deletions

View file

@ -13,7 +13,7 @@ DEBUG_CFLAGS = -g # -pg
OPTIM = 2
# GTK
GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0)
GTK_CFLAGS = $(shell pkg-config --cflags gtk+-2.0) -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE
GTK_LDLIBS = $(shell pkg-config --libs gtk+-2.0) -lz -lm
# Embedded qemu

View file

@ -29,7 +29,6 @@ void config_init( char* progname, int argc, char* argv[] )
opt.model = MODEL_50G;
opt.name = NULL;
const char* optstring = "hrc:D:df:Fn:";
struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
@ -42,11 +41,11 @@ void config_init( char* progname, int argc, char* argv[] )
{"reflash-full", no_argument, NULL, 'F'},
{"reboot", no_argument, NULL, 'r'},
{"50g", no_argument, NULL, 506},
{"50g-newrpl", no_argument, NULL, 507},
{"49gp", no_argument, NULL, 496},
{"49gp-newrpl", no_argument, NULL, 497},
{"name", required_argument, NULL, 'n'},
{"50g", no_argument, NULL, 506},
{"50g-newrpl", no_argument, NULL, 507},
{"49gp", no_argument, NULL, 496},
{"49gp-newrpl", no_argument, NULL, 497},
{"name", required_argument, NULL, 'n'},
{0, 0, 0, 0 }
};
@ -84,80 +83,78 @@ void config_init( char* progname, int argc, char* argv[] )
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname, DEFAULT_GDBSTUB_PORT, progname );
exit( EXIT_SUCCESS );
break;
case 'r':
if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY )
opt.reinit = X49GP_REINIT_REBOOT_ONLY;
break;
case 'c':
opt.config = strdup( optarg );
break;
case 'D':
do_enable_debugger = true;
break;
case 'd':
do_start_debugger = true;
break;
case 'f':
do_reflash = true;
break;
case 'F':
do_reflash_full = true;
break;
case 496:
opt.model = MODEL_49GP;
break;
case 497:
opt.model = MODEL_49GP_NEWRPL;
break;
case 506:
opt.model = MODEL_50G;
break;
case 507:
opt.model = MODEL_50G_NEWRPL;
break;
case 'n':
opt.name = strdup( optarg );
break;
default:
break;
case 'r':
if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY )
opt.reinit = X49GP_REINIT_REBOOT_ONLY;
break;
case 'c':
opt.config = strdup( optarg );
break;
case 'D':
do_enable_debugger = true;
break;
case 'd':
do_start_debugger = true;
break;
case 'f':
do_reflash = true;
break;
case 'F':
do_reflash_full = true;
break;
case 496:
opt.model = MODEL_49GP;
break;
case 497:
opt.model = MODEL_49GP_NEWRPL;
break;
case 506:
opt.model = MODEL_50G;
break;
case 507:
opt.model = MODEL_50G_NEWRPL;
break;
case 'n':
opt.name = strdup( optarg );
break;
default:
break;
}
}
if ( do_enable_debugger ) {
char* end;
int port;
char* end;
int port;
if ( optarg == NULL && opt.debug_port == 0 )
opt.debug_port = DEFAULT_GDBSTUB_PORT;
if ( optarg == NULL && opt.debug_port == 0 )
opt.debug_port = DEFAULT_GDBSTUB_PORT;
port = strtoul( optarg, &end, 0 );
if ( ( end == optarg ) || ( *end != '\0' ) ) {
fprintf( stderr, "Invalid port \"%s\", using default\n", optarg );
if ( opt.debug_port == 0 )
opt.debug_port = DEFAULT_GDBSTUB_PORT;
}
port = strtoul( optarg, &end, 0 );
if ( ( end == optarg ) || ( *end != '\0' ) ) {
fprintf( stderr, "Invalid port \"%s\", using default\n", optarg );
if ( opt.debug_port == 0 )
opt.debug_port = DEFAULT_GDBSTUB_PORT;
}
if ( opt.debug_port != 0 && opt.debug_port != DEFAULT_GDBSTUB_PORT )
fprintf( stderr,
"Additional debug port \"%s\" specified, overriding\n",
optarg );
opt.debug_port = port;
if ( opt.debug_port != 0 && opt.debug_port != DEFAULT_GDBSTUB_PORT )
fprintf( stderr, "Additional debug port \"%s\" specified, overriding\n", optarg );
opt.debug_port = port;
opt.start_debugger = do_start_debugger;
opt.start_debugger = do_start_debugger;
}
if ( do_reflash ) {
if ( opt.reinit < X49GP_REINIT_FLASH )
opt.reinit = X49GP_REINIT_FLASH;
if ( opt.reinit < X49GP_REINIT_FLASH )
opt.reinit = X49GP_REINIT_FLASH;
if ( opt.firmware != NULL )
fprintf( stderr,
"Additional firmware file \"%s\" specified,"
" overriding\n",
optarg );
opt.firmware = optarg;
if ( opt.firmware != NULL )
fprintf( stderr,
"Additional firmware file \"%s\" specified,"
" overriding\n",
optarg );
opt.firmware = optarg;
if ( do_reflash_full )
opt.reinit = X49GP_REINIT_FLASH_FULL;
if ( do_reflash_full )
opt.reinit = X49GP_REINIT_FLASH_FULL;
}
if ( opt.config == NULL ) {

View file

@ -110,12 +110,12 @@ void x49gp_lcd_update( x49gp_t* x49gp )
int color, x, y;
if ( !( lcd->lcdcon1 & 1 ) ) {
gdk_draw_drawable( ui->lcd_pixmap, ui->window->style->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0,
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( ui->window )->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0,
ui->lcd_width, ui->lcd_height );
goto done;
}
gdk_draw_drawable( ui->lcd_pixmap, ui->window->style->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0,
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( ui->window )->bg_gc[ 0 ], ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0,
ui->lcd_width, ui->lcd_height );
color = x49gp_get_pixel_color( lcd, 131, 0 );
@ -142,7 +142,7 @@ void x49gp_lcd_update( x49gp_t* x49gp )
gdk_gc_set_rgb_fg_color( ui->ann_busy_gc, &( ui->colors[ UI_COLOR_GRAYSCALE_0 + color ] ) );
gdk_draw_rectangle( ui->lcd_pixmap, ui->ann_busy_gc, TRUE, 191, 0, 15, 12 );
gc = gdk_gc_new( ui->lcd_canvas->window );
gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
for ( y = 0; y < ( ui->lcd_height - ui->lcd_top_margin ) / 2; y++ ) {
for ( x = 0; x < ui->lcd_width / 2; x++ ) {
@ -160,7 +160,7 @@ done:
rect.width = ui->lcd_width;
rect.height = ui->lcd_height;
gdk_window_invalidate_rect( ui->lcd_canvas->window, &rect, false );
gdk_window_invalidate_rect( gtk_widget_get_window( ui->lcd_canvas ), &rect, false );
}
static uint32_t s3c2410_lcd_read( void* opaque, target_phys_addr_t offset )

222
src/ui.c
View file

@ -1602,7 +1602,7 @@ static int x49gp_ui_button_pixmaps_init( x49gp_t* x49gp, x49gp_ui_button_t* butt
x49gp_ui_style_init( style, button->button, &ui->colors[ button->key->color ], &ui->colors[ UI_COLOR_BLACK ] );
for ( int i = 0; i < 5; i++ ) {
style->bg_pixmap[ i ] = gdk_pixmap_new( ui->window->window, button->key->width, button->key->height, -1 );
style->bg_pixmap[ i ] = gdk_pixmap_new( gtk_widget_get_window( ui->window ), button->key->width, button->key->height, -1 );
if ( i == GTK_STATE_ACTIVE ) {
if ( color == UI_COLOR_SILVER ) {
@ -1625,7 +1625,7 @@ static int x49gp_ui_button_pixmaps_init( x49gp_t* x49gp, x49gp_ui_button_t* butt
src = gdk_pixbuf_new_subpixbuf( ui->bg_pixbuf, ui->kb_x_offset + button->key->x, ui->kb_y_offset + button->key->y,
button->key->width, button->key->height );
gdk_draw_pixbuf( style->bg_pixmap[ i ], ui->window->style->black_gc, src, 0, 0, 0, 0, button->key->width, button->key->height,
gdk_draw_pixbuf( style->bg_pixmap[ i ], gtk_widget_get_style( ui->window )->black_gc, src, 0, 0, 0, 0, button->key->width, button->key->height,
GDK_RGB_DITHER_NORMAL, 0, 0 );
g_object_unref( src );
@ -2365,18 +2365,18 @@ static void x49gp_release_single_button( x49gp_ui_button_t* button, x49gp_ui_but
const x49gp_ui_key_t* key;
GtkButton* gtkbutton;
/* #ifdef DEBUG_X49GP_UI */
/* printf( "%s: button %u: col %u, row %u, eint %u\n", __FUNCTION__, event->button, button->key->column, button->key->row, */
/* button->key->eint ); */
/* #endif */
/* #ifdef DEBUG_X49GP_UI */
/* printf( "%s: button %u: col %u, row %u, eint %u\n", __FUNCTION__, event->button, button->key->column, button->key->row, */
/* button->key->eint ); */
/* #endif */
button->down = false;
button->hold = false;
gtkbutton = GTK_BUTTON( button->button );
if ( button != cause )
gtkbutton->in_button = false;
/* if ( button != cause ) */
/* gtkbutton->in_button = false; */
gtk_button_released( gtkbutton );
key = button->key;
@ -2476,10 +2476,13 @@ static gboolean x49gp_ui_focus_lost( GtkWidget* widget, GdkEventFocus* event, gp
static void x49gp_ui_popup_at_widget( GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer user_data )
{
GtkWidget* widget = GTK_WIDGET( user_data );
GtkAllocation widget_allocation;
gdk_window_get_origin( widget->window, x, y );
*x += widget->allocation.x;
*y += widget->allocation.y;
gtk_widget_get_allocation( widget, &widget_allocation);
gdk_window_get_origin( gtk_widget_get_window( widget ), x, y );
*x += widget_allocation.x;
*y += widget_allocation.y;
}
static void x49gp_ui_mount_sd_folder( GtkMenuItem* menuitem, gpointer user_data )
@ -2527,7 +2530,7 @@ static gboolean x49gp_ui_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
x49gp_ui_t* ui = x49gp->ui;
x49gp_ui_button_t* button;
GdkEventButton bev;
gboolean save_in;
/* gboolean save_in; */
int index;
guint keyval;
@ -2660,8 +2663,8 @@ static gboolean x49gp_ui_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
index = 31;
break;
#ifndef __APPLE__
// case GDK_KEY_Alt_L: case GDK_KEY_Alt_R:
// case GDK_KEY_Meta_L: case GDK_KEY_Meta_R:
case GDK_KEY_Alt_L: case GDK_KEY_Alt_R:
case GDK_KEY_Meta_L: case GDK_KEY_Meta_R:
case GDK_KEY_Mode_switch:
index = 31;
break;
@ -2801,21 +2804,21 @@ static gboolean x49gp_ui_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
bev.button = 1;
bev.state = event->state;
save_in = GTK_BUTTON( button->button )->in_button;
/* save_in = GTK_BUTTON( button->button )->in_button; */
switch ( event->type ) {
case GDK_KEY_PRESS:
bev.type = GDK_BUTTON_PRESS;
x49gp_ui_button_press( button->button, &bev, button );
GTK_BUTTON( button->button )->in_button = true;
/* GTK_BUTTON( button->button )->in_button = true; */
gtk_button_pressed( GTK_BUTTON( button->button ) );
GTK_BUTTON( button->button )->in_button = save_in;
/* GTK_BUTTON( button->button )->in_button = save_in; */
break;
case GDK_KEY_RELEASE:
bev.type = GDK_BUTTON_RELEASE;
GTK_BUTTON( button->button )->in_button = true;
/* GTK_BUTTON( button->button )->in_button = true; */
gtk_button_released( GTK_BUTTON( button->button ) );
GTK_BUTTON( button->button )->in_button = save_in;
/* GTK_BUTTON( button->button )->in_button = save_in; */
x49gp_ui_button_release( button->button, &bev, button );
break;
default:
@ -2828,15 +2831,18 @@ static gboolean x49gp_ui_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
static int x49gp_button_expose_event( GtkWidget* widget, GdkEventExpose* event, gpointer user_data )
{
x49gp_ui_button_t* button = user_data;
GtkAllocation widget_allocation;
int x = widget->allocation.x;
int y = widget->allocation.y;
gtk_widget_get_allocation( widget, &widget_allocation);
if ( GTK_WIDGET_STATE( widget ) == GTK_STATE_ACTIVE )
int x = widget_allocation.x;
int y = widget_allocation.y;
if ( gtk_widget_get_state( widget ) == GTK_STATE_ACTIVE )
y -= 1;
gdk_draw_drawable( widget->window, widget->style->black_gc, button->pixmap, 0, 0, x, y, widget->allocation.width,
widget->allocation.height );
gdk_draw_drawable( gtk_widget_get_window( widget ), gtk_widget_get_style( widget )->black_gc, button->pixmap, 0, 0, x, y, widget_allocation.width,
widget_allocation.height );
return false;
}
@ -2850,15 +2856,18 @@ static void x49gp_button_realize( GtkWidget* widget, gpointer user_data )
double xoff, yoff, width, height, ascent, descent;
unsigned int w, h;
int xoffset, yoffset, x, y;
GtkAllocation widget_allocation;
xoffset = widget->allocation.x;
yoffset = widget->allocation.y;
w = widget->allocation.width;
h = widget->allocation.height;
gtk_widget_get_allocation( widget, &widget_allocation);
button->pixmap = gdk_pixmap_new( widget->style->bg_pixmap[ 0 ], w, h, -1 );
xoffset = widget_allocation.x;
yoffset = widget_allocation.y;
w = widget_allocation.width;
h = widget_allocation.height;
gdk_draw_drawable( button->pixmap, widget->style->black_gc, widget->style->bg_pixmap[ 0 ], xoffset, yoffset, 0, 0, button->key->width,
button->pixmap = gdk_pixmap_new( gtk_widget_get_style( widget )->bg_pixmap[ 0 ], w, h, -1 );
gdk_draw_drawable( button->pixmap, gtk_widget_get_style( widget )->black_gc, gtk_widget_get_style( widget )->bg_pixmap[ 0 ], xoffset, yoffset, 0, 0, button->key->width,
button->key->height );
xoffset += 2;
@ -2871,14 +2880,14 @@ static void x49gp_button_realize( GtkWidget* widget, gpointer user_data )
cairo_set_line_join( cr, CAIRO_LINE_JOIN_MITER );
#if DEBUG_LAYOUT /* Layout Debug */
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, xoffset, yoffset);
cairo_line_to(cr, xoffset + w - 1, yoffset);
cairo_line_to(cr, xoffset + w - 1, yoffset + h - 1);
cairo_line_to(cr, xoffset, yoffset + h - 1);
cairo_close_path(cr);
cairo_stroke(cr);
cairo_set_source_rgb( cr, 1.0, 1.0, 1.0 );
cairo_set_line_width( cr, 1.0 );
cairo_move_to( cr, xoffset, yoffset );
cairo_line_to( cr, xoffset + w - 1, yoffset );
cairo_line_to( cr, xoffset + w - 1, yoffset + h - 1 );
cairo_line_to( cr, xoffset, yoffset + h - 1 );
cairo_close_path( cr );
cairo_stroke( cr );
#endif
if ( key->letter ) {
@ -2913,7 +2922,7 @@ static void x49gp_button_realize( GtkWidget* widget, gpointer user_data )
x = ( int )floor( ( w - 1.0 - width ) / 2.0 - xoff + 0.5 );
y = ( int )floor( ( h - 1.0 + ascent ) / 2.0 + 0.5 );
x49gp_ui_draw_text( cr, &widget->style->text[ 0 ], X49GP_UI_NORMAL_FONT, key->font_size, 0.0, x + xoffset, y + yoffset, 1,
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->text[ 0 ], X49GP_UI_NORMAL_FONT, key->font_size, 0.0, x + xoffset, y + yoffset, 1,
CAIRO_FONT_SLANT_NORMAL, key->font_weight, key->label );
cairo_destroy( cr );
@ -2928,7 +2937,7 @@ static int x49gp_lcd_expose_event( GtkWidget* widget, GdkEventExpose* event, gpo
gdk_region_get_rectangles( event->region, &rects, &n );
for ( int i = 0; i < n; i++ ) {
gdk_draw_drawable( widget->window, widget->style->black_gc, ui->lcd_pixmap, rects[ i ].x, rects[ i ].y, rects[ i ].x, rects[ i ].y,
gdk_draw_drawable( gtk_widget_get_window(widget), gtk_widget_get_style( widget )->black_gc, ui->lcd_pixmap, rects[ i ].x, rects[ i ].y, rects[ i ].x, rects[ i ].y,
rects[ i ].width, rects[ i ].height );
}
@ -2945,71 +2954,68 @@ static int x49gp_lcd_configure_event( GtkWidget* widget, GdkEventConfigure* even
if ( NULL != ui->lcd_pixmap )
return false;
ui->ann_left = gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_left_bits, ann_left_width, ann_left_height );
ui->ann_right = gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_right_bits, ann_right_width, ann_right_height );
ui->ann_alpha = gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_alpha_bits, ann_alpha_width, ann_alpha_height );
ui->ann_left = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_left_bits, ann_left_width, ann_left_height );
ui->ann_right = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_right_bits, ann_right_width, ann_right_height );
ui->ann_alpha = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_alpha_bits, ann_alpha_width, ann_alpha_height );
ui->ann_battery =
gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_battery_bits, ann_battery_width, ann_battery_height );
ui->ann_busy = gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_busy_bits, ann_busy_width, ann_busy_height );
ui->ann_io = gdk_bitmap_create_from_data( ui->lcd_canvas->window, ( char* )ann_io_bits, ann_io_width, ann_io_height );
gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_battery_bits, ann_battery_width, ann_battery_height );
ui->ann_busy = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_busy_bits, ann_busy_width, ann_busy_height );
ui->ann_io = gdk_bitmap_create_from_data( gtk_widget_get_window( ui->lcd_canvas ), ( char* )ann_io_bits, ann_io_width, ann_io_height );
ui->ann_left_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_left_gc, widget->style->black_gc );
ui->ann_left_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_left_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_left_gc, 11, 0 );
gdk_gc_set_stipple( ui->ann_left_gc, ui->ann_left );
gdk_gc_set_fill( ui->ann_left_gc, GDK_STIPPLED );
ui->ann_right_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_right_gc, widget->style->black_gc );
ui->ann_right_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_right_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_right_gc, 56, 0 );
gdk_gc_set_stipple( ui->ann_right_gc, ui->ann_right );
gdk_gc_set_fill( ui->ann_right_gc, GDK_STIPPLED );
ui->ann_alpha_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_alpha_gc, widget->style->black_gc );
ui->ann_alpha_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_alpha_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_alpha_gc, 101, 0 );
gdk_gc_set_stipple( ui->ann_alpha_gc, ui->ann_alpha );
gdk_gc_set_fill( ui->ann_alpha_gc, GDK_STIPPLED );
ui->ann_battery_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_battery_gc, widget->style->black_gc );
ui->ann_battery_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_battery_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_battery_gc, 146, 0 );
gdk_gc_set_stipple( ui->ann_battery_gc, ui->ann_battery );
gdk_gc_set_fill( ui->ann_battery_gc, GDK_STIPPLED );
ui->ann_busy_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_busy_gc, widget->style->black_gc );
ui->ann_busy_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_busy_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_busy_gc, 191, 0 );
gdk_gc_set_stipple( ui->ann_busy_gc, ui->ann_busy );
gdk_gc_set_fill( ui->ann_busy_gc, GDK_STIPPLED );
ui->ann_io_gc = gdk_gc_new( ui->lcd_canvas->window );
gdk_gc_copy( ui->ann_io_gc, widget->style->black_gc );
ui->ann_io_gc = gdk_gc_new( gtk_widget_get_window( ui->lcd_canvas ) );
gdk_gc_copy( ui->ann_io_gc, gtk_widget_get_style( widget )->black_gc );
gdk_gc_set_ts_origin( ui->ann_io_gc, 236, 0 );
gdk_gc_set_stipple( ui->ann_io_gc, ui->ann_io );
gdk_gc_set_fill( ui->ann_io_gc, GDK_STIPPLED );
ui->lcd_pixmap = gdk_pixmap_new( ui->lcd_canvas->window, ui->lcd_width, ui->lcd_height, -1 );
ui->lcd_pixmap = gdk_pixmap_new( gtk_widget_get_window( ui->lcd_canvas ), ui->lcd_width, ui->lcd_height, -1 );
#if DEBUG_LAYOUT /* Debug Symbols on LCD screen ;) */
{
cairo_t *cr;
{
cairo_t* cr;
cr = gdk_cairo_create(ui->bg_pixmap);
cairo_set_line_cap(cr, CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
cr = gdk_cairo_create( ui->bg_pixmap );
cairo_set_line_cap( cr, CAIRO_LINE_CAP_BUTT );
cairo_set_line_join( cr, CAIRO_LINE_JOIN_MITER );
x49gp_ui_draw_text(cr, &widget->style->black,
X49GP_UI_NORMAL_FONT, 100.0, 1.0,
ui->lcd_x_offset + 10, ui->lcd_y_offset + 160,
1, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD,
"\\arrowleftdblfull");
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->black, X49GP_UI_NORMAL_FONT, 100.0, 1.0, ui->lcd_x_offset + 10, ui->lcd_y_offset + 160, 1,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD, "\\arrowleftdblfull" );
cairo_destroy(cr);
}
cairo_destroy( cr );
}
#endif
gdk_draw_drawable( ui->lcd_pixmap, widget->style->black_gc, ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0, ui->lcd_width,
gdk_draw_drawable( ui->lcd_pixmap, gtk_widget_get_style( widget )->black_gc, ui->bg_pixmap, ui->lcd_x_offset, ui->lcd_y_offset, 0, 0, ui->lcd_width,
ui->lcd_height );
return false;
@ -3032,9 +3038,9 @@ static int x49gp_window_configure_event( GtkWidget* widget, GdkEventConfigure* e
if ( NULL != ui->bg_pixmap )
return false;
ui->bg_pixmap = gdk_pixmap_new( widget->window, ui->width, ui->height, -1 );
ui->bg_pixmap = gdk_pixmap_new( gtk_widget_get_window( widget ), ui->width, ui->height, -1 );
gdk_draw_pixbuf( ui->bg_pixmap, widget->style->black_gc, ui->bg_pixbuf, 0, 0, 0, 0, ui->width, ui->height, GDK_RGB_DITHER_NORMAL, 0,
gdk_draw_pixbuf( ui->bg_pixmap, gtk_widget_get_style( widget )->black_gc, ui->bg_pixbuf, 0, 0, 0, 0, ui->width, ui->height, GDK_RGB_DITHER_NORMAL, 0,
0 );
cr = gdk_cairo_create( ui->bg_pixmap );
@ -3044,14 +3050,14 @@ static int x49gp_window_configure_event( GtkWidget* widget, GdkEventConfigure* e
switch ( ui->calculator ) {
case UI_CALCULATOR_HP49GP:
case UI_CALCULATOR_HP49GP_NEWRPL:
x49gp_ui_draw_text( cr, &widget->style->black, X49GP_UI_NORMAL_FONT, 15.0, 0.0, 14 /* 38 */, 20 /* 42 */, 2,
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->black, X49GP_UI_NORMAL_FONT, 15.0, 0.0, 14 /* 38 */, 20 /* 42 */, 2,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD, "hp", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL,
" 49g+" );
x49gp_ui_draw_text( cr, &widget->style->black, X49GP_UI_NORMAL_FONT, 13.0, 0.0, 14 /* 38 */, 34 /* 56 */, 1,
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->black, X49GP_UI_NORMAL_FONT, 13.0, 0.0, 14 /* 38 */, 34 /* 56 */, 1,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, "graphing calculator" );
x49gp_ui_draw_symbol( cr, &widget->style->black, 10.0, 0.0, true, 114 /* 138 */, 8 /* 25 */,
x49gp_ui_draw_symbol( cr, &gtk_widget_get_style( widget )->black, 10.0, 0.0, true, 114 /* 138 */, 8 /* 25 */,
symbol_get_by_name( "triangleup" ) );
left_color = UI_COLOR_GREEN;
@ -3065,14 +3071,14 @@ static int x49gp_window_configure_event( GtkWidget* widget, GdkEventConfigure* e
case UI_CALCULATOR_HP50G:
case UI_CALCULATOR_HP50G_NEWRPL:
x49gp_ui_draw_text( cr, &widget->style->white, X49GP_UI_NORMAL_FONT, 15.0, 0.0, 14 /* 38 */, 20 /* 42 */, 2,
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->white, X49GP_UI_NORMAL_FONT, 15.0, 0.0, 14 /* 38 */, 20 /* 42 */, 2,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, "HP", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL,
" 50g" );
x49gp_ui_draw_text( cr, &widget->style->white, X49GP_UI_NORMAL_FONT, 13.0, 0.0, 14 /* 38 */, 34 /* 56 */, 1,
x49gp_ui_draw_text( cr, &gtk_widget_get_style( widget )->white, X49GP_UI_NORMAL_FONT, 13.0, 0.0, 14 /* 38 */, 34 /* 56 */, 1,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL, "Graphing Calculator" );
x49gp_ui_draw_symbol( cr, &widget->style->white, 10.0, 0.0, true, 134 /* 168 */, 8 /* 25 */,
x49gp_ui_draw_symbol( cr, &gtk_widget_get_style( widget )->white, 10.0, 0.0, true, 134 /* 168 */, 8 /* 25 */,
symbol_get_by_name( "triangleup" ) );
left_color = UI_COLOR_WHITE;
@ -3129,15 +3135,12 @@ static int x49gp_window_configure_event( GtkWidget* widget, GdkEventConfigure* e
}
#if DEBUG_LAYOUT /* Debug Button Layout */
gdk_draw_rectangle(ui->bg_pixmap, ui->window->style->white_gc,
false,
ui->kb_x_offset + key->x,
ui->kb_y_offset + key->y,
key->width, key->height);
gdk_draw_rectangle( ui->bg_pixmap, gtk_widget_get_style( ui->window )->white_gc, false, ui->kb_x_offset + key->x, ui->kb_y_offset + key->y,
key->width, key->height );
#endif
}
gdk_window_set_back_pixmap( widget->window, ui->bg_pixmap, false );
gdk_window_set_back_pixmap( gtk_widget_get_window( widget ), ui->bg_pixmap, false );
return false;
}
@ -3148,8 +3151,8 @@ static gboolean x49gp_window_button_press( GtkWidget* widget, GdkEventButton* ev
fprintf( stderr, "%s:%u: type %u, button %u\n", __FUNCTION__, __LINE__, event->type, event->button );
#endif
gdk_window_focus( widget->window, event->time );
gdk_window_raise( widget->window );
gdk_window_focus( gtk_widget_get_window( widget ), event->time );
gdk_window_raise( gtk_widget_get_window( widget ) );
if ( event->type != GDK_BUTTON_PRESS )
return false;
@ -3157,7 +3160,7 @@ static gboolean x49gp_window_button_press( GtkWidget* widget, GdkEventButton* ev
if ( event->button != 1 )
return false;
gdk_window_begin_move_drag( widget->window, event->button, event->x_root, event->y_root, event->time );
gdk_window_begin_move_drag( gtk_widget_get_window( widget ), event->button, event->x_root, event->y_root, event->time );
return false;
}
@ -3221,23 +3224,23 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
int fd;
switch ( opt.model ) {
case MODEL_50G_NEWRPL:
ui->calculator = UI_CALCULATOR_HP50G_NEWRPL;
ui->name = opt.name != NULL ? opt.name : "HP 50g / newRPL";
break;
case MODEL_49GP:
ui->calculator = UI_CALCULATOR_HP49GP;
ui->name = opt.name != NULL ? opt.name : "HP 49g+";
break;
case MODEL_49GP_NEWRPL:
ui->calculator = UI_CALCULATOR_HP49GP_NEWRPL;
ui->name = "opt.name != NULL ? opt.name : HP 49g+ / newRPL";
break;
case MODEL_50G:
default:
ui->calculator = UI_CALCULATOR_HP50G;
ui->name = opt.name != NULL ? opt.name : "HP 50g";
break;
case MODEL_50G_NEWRPL:
ui->calculator = UI_CALCULATOR_HP50G_NEWRPL;
ui->name = opt.name != NULL ? opt.name : "HP 50g / newRPL";
break;
case MODEL_49GP:
ui->calculator = UI_CALCULATOR_HP49GP;
ui->name = opt.name != NULL ? opt.name : "HP 49g+";
break;
case MODEL_49GP_NEWRPL:
ui->calculator = UI_CALCULATOR_HP49GP_NEWRPL;
ui->name = "opt.name != NULL ? opt.name : HP 49g+ / newRPL";
break;
case MODEL_50G:
default:
ui->calculator = UI_CALCULATOR_HP50G;
ui->name = opt.name != NULL ? opt.name : "HP 50g";
break;
}
fd = x49gp_module_open_rodata( module,
@ -3367,7 +3370,7 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
if ( key->label ) {
button->label = gtk_label_new( "" );
gtk_widget_set_style( button->label, button->button->style );
gtk_widget_set_style( button->label, gtk_widget_get_style( button->button ) );
gtk_container_add( GTK_CONTAINER( button->button ), button->label );
g_signal_connect( G_OBJECT( button->label ), "expose-event", G_CALLBACK( x49gp_button_expose_event ), button );
@ -3448,10 +3451,7 @@ static int gui_load( x49gp_module_t* module, GKeyFile* keyfile )
return 0;
}
static int gui_save( x49gp_module_t* module, GKeyFile* keyfile )
{
return 0;
}
static int gui_save( x49gp_module_t* module, GKeyFile* keyfile ) { return 0; }
int x49gp_ui_init( x49gp_t* x49gp )
{

View file

@ -7,7 +7,7 @@
#include <stdint.h>
#include <time.h>
# include "list.h"
#include "list.h"
#include "x49gp_types.h"
#define X49GP_TIMER_VIRTUAL 0