snapshot toward building with gtk3

Board renders, but only when touched. Tray and scoreboard skipped for
now. Lots of changed still to go, and some asserts added where I didn't
want to stop to solve a compile problem.
This commit is contained in:
Eric House 2016-08-03 15:19:12 -07:00
parent 2ade75158b
commit b57e50a255
15 changed files with 296 additions and 191 deletions

View file

@ -53,7 +53,7 @@ DO_CURSES += -DCURSES_SMALL_SCREEN
endif
DO_GTK = -DPLATFORM_GTK
DO_GTK += -DXWFEATURE_BOARDWORDS
# DO_GTK += -DUSE_CAIRO
DO_GTK += -DUSE_CAIRO
# uncomment for standalone build
# STANDALONE = -DXWFEATURE_STANDALONE_ONLY
@ -239,8 +239,8 @@ LIBS += -lbluetooth
endif
ifneq (,$(findstring DPLATFORM_GTK,$(DEFINES)))
LIBS += `pkg-config --libs gtk+-2.0`
CFLAGS += `pkg-config --cflags gtk+-2.0`
LIBS += `pkg-config --libs gtk+-3.0`
CFLAGS += `pkg-config --cflags gtk+-3.0`
# CFLAGS += -DGDK_DISABLE_DEPRECATED
POINTER_SUPPORT = -DPOINTER_SUPPORT
endif

View file

@ -95,7 +95,7 @@ gtkaskdict( GSList* dicts, gchar* buf, gint buflen )
}
GtkWidget* button = gtk_button_new_with_label( "Ok" );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(on_clicked), NULL );
gtk_box_pack_start( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
button, FALSE, TRUE, 0 );

View file

@ -50,7 +50,7 @@ gtkaskm( const gchar* message, AskMInfo* infos, int nInfos )
gtk_window_set_title( GTK_WINDOW(dialog), message );
int ii;
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );//gtk_vbox_new
for ( ii = 0; ii < nInfos; ++ii ) {
AskMInfo* info = &infos[ii];
GtkWidget* row = makeLabeledField( info->label, &fields[ii], *info->result );
@ -58,19 +58,21 @@ gtkaskm( const gchar* message, AskMInfo* infos, int nInfos )
gtk_widget_show( row );
}
GtkWidget* hbox = gtk_hbox_new( FALSE, 0 );
GtkWidget* hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
state.okButton = gtk_button_new_with_label( "Ok" );
g_signal_connect( GTK_OBJECT(state.okButton), "clicked",
g_signal_connect( state.okButton, "clicked",
G_CALLBACK(button_clicked), &state );
gtk_box_pack_start( GTK_BOX(hbox), state.okButton, FALSE, TRUE, 0 );
state.cancelButton = gtk_button_new_with_label( "Cancel" );
g_signal_connect( GTK_OBJECT(state.cancelButton), "clicked",
g_signal_connect( state.cancelButton, "clicked",
G_CALLBACK(button_clicked), &state );
gtk_box_pack_start( GTK_BOX(hbox), state.cancelButton, FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))),
vbox);
/* gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), */
/* vbox); */
XP_LOGF( "%s(): not adding vbox!!!", __func__ );
XP_ASSERT(0);
gtk_widget_show_all( dialog );
gtk_main();

View file

@ -482,7 +482,8 @@ addDropChecks( GtkGameGlobals* globals )
datum->typ = typ;
datum->comms = comms;
GtkWidget* hbox = gtk_hbox_new( FALSE, 0 );
GtkWidget* hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
gchar buf[32];
snprintf( buf, sizeof(buf), "Drop %s messages",
ConnType2Str( typ ) );
@ -494,7 +495,7 @@ addDropChecks( GtkGameGlobals* globals )
if ( comms_getAddrDisabled( comms, typ, XP_FALSE ) ) {
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(widget), TRUE );
}
g_signal_connect( GTK_OBJECT(widget), "toggled", G_CALLBACK(drop_msg_toggle),
g_signal_connect( widget, "toggled", G_CALLBACK(drop_msg_toggle),
datum );
gtk_box_pack_start( GTK_BOX(hbox), widget, FALSE, TRUE, 0);
gtk_widget_show( widget );
@ -503,7 +504,7 @@ addDropChecks( GtkGameGlobals* globals )
if ( comms_getAddrDisabled( comms, typ, XP_TRUE ) ) {
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(widget), TRUE );
}
g_signal_connect( GTK_OBJECT(widget), "toggled", G_CALLBACK(drop_msg_toggle),
g_signal_connect( widget, "toggled", G_CALLBACK(drop_msg_toggle),
(void*)(((long)datum) | 1) );
gtk_box_pack_start( GTK_BOX(hbox), widget, FALSE, TRUE, 0);
gtk_widget_show( widget );
@ -1262,8 +1263,8 @@ createAddItem( GtkWidget* parent, gchar* label,
/* g_print( "createAddItem called with label %s\n", label ); */
if ( handlerFunc != NULL ) {
g_signal_connect( GTK_OBJECT(item), "activate",
G_CALLBACK(handlerFunc), globals );
g_signal_connect( item, "activate", G_CALLBACK(handlerFunc),
globals );
}
gtk_menu_shell_append( GTK_MENU_SHELL(parent), item );
@ -1581,8 +1582,8 @@ handle_hide_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
gtk_adjustment_set_page_size( globals->adjustment, nRows );
gtk_adjustment_set_value( globals->adjustment, 0.0 );
g_signal_emit_by_name( GTK_OBJECT(globals->adjustment), "changed" );
gtk_adjustment_value_changed( GTK_ADJUSTMENT(globals->adjustment) );
g_signal_emit_by_name( globals->adjustment, "changed" );
// gtk_adjustment_value_changed( GTK_ADJUSTMENT(globals->adjustment) );
}
board = globals->cGlobals.game.board;
@ -1794,7 +1795,7 @@ setCtrlsForTray( GtkGameGlobals* XP_UNUSED(globals) )
globals->adjustment->value =
board_getYOffset( globals->cGlobals.game.board );
gtk_signal_emit_by_name( GTK_OBJECT(globals->adjustment), "changed" );
gtk_signal_emit_by_name( globals->adjustment, "changed" );
}
#endif
} /* setCtrlsForTray */
@ -1817,7 +1818,7 @@ gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 maxOffset,
gint nRows = globals->cGlobals.gi->boardSize;
gtk_adjustment_set_page_size(globals->adjustment, nRows - maxOffset);
gtk_adjustment_set_value(globals->adjustment, newOffset);
gtk_adjustment_value_changed( globals->adjustment );
// gtk_adjustment_value_changed( globals->adjustment );
}
} /* gtk_util_yOffsetChange */
@ -2332,7 +2333,7 @@ makeShowButtonFromBitmap( void* closure, const gchar* filename,
gtk_widget_show (button);
if ( func != NULL ) {
g_signal_connect( GTK_OBJECT(button), "clicked", func, closure );
g_signal_connect( button, "clicked", func, closure );
}
return button;
@ -2344,7 +2345,7 @@ makeVerticalBar( GtkGameGlobals* globals, GtkWidget* XP_UNUSED(window) )
GtkWidget* vbox;
GtkWidget* button;
vbox = gtk_vbutton_box_new();
vbox = gtk_button_box_new( GTK_ORIENTATION_VERTICAL );
button = makeShowButtonFromBitmap( globals, "../flip.xpm", "f",
G_CALLBACK(handle_flip_button) );
@ -2421,7 +2422,7 @@ addButton( GtkWidget* hbox, gchar* label, GCallback func, GtkGameGlobals* global
{
GtkWidget* button = gtk_button_new_with_label( label );
gtk_widget_show( button );
g_signal_connect( GTK_OBJECT(button), "clicked", G_CALLBACK(func), globals );
g_signal_connect( button, "clicked", G_CALLBACK(func), globals );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0);
return button;
}
@ -2429,7 +2430,7 @@ addButton( GtkWidget* hbox, gchar* label, GCallback func, GtkGameGlobals* global
static GtkWidget*
makeButtons( GtkGameGlobals* globals )
{
GtkWidget* hbox = gtk_hbox_new( FALSE, 0 );
GtkWidget* hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
globals->buttons_hbox = hbox;
(void)addButton( hbox, "Grid", G_CALLBACK(handle_grid_button), globals );
@ -2652,6 +2653,16 @@ initGlobalsNoDraw( GtkGameGlobals* globals, LaunchParams* params,
setupGtkUtilCallbacks( globals, globals->cGlobals.util );
}
static gboolean
on_draw_event( GtkWidget *widget, cairo_t* cr, gpointer user_data )
{
LOG_FUNC();
XP_USE(user_data);
XP_USE(widget);
XP_USE(cr);
return FALSE;
}
void
initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
{
@ -2676,21 +2687,21 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
gtk_window_set_title( GTK_WINDOW(window), params->fileName );
}
vbox = gtk_vbox_new (FALSE, 0);
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
gtk_container_add( GTK_CONTAINER(window), vbox );
gtk_widget_show( vbox );
g_signal_connect( G_OBJECT (window), "destroy",
G_CALLBACK( destroy_board_window ), globals );
g_signal_connect( window, "destroy", G_CALLBACK(destroy_board_window),
globals );
XP_ASSERT( !!globals );
g_signal_connect( G_OBJECT (window), "show",
G_CALLBACK( on_board_window_shown ), globals );
g_signal_connect( window, "show", G_CALLBACK( on_board_window_shown ),
globals );
menubar = makeMenus( globals );
gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
#if ! defined XWFEATURE_STANDALONE_ONLY && defined DEBUG
globals->drop_checks_vbox = gtk_vbox_new( FALSE, 0 );
globals->drop_checks_vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
gtk_box_pack_start( GTK_BOX(vbox), globals->drop_checks_vbox,
FALSE, TRUE, 0 );
#endif
@ -2698,6 +2709,8 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
gtk_box_pack_start( GTK_BOX(vbox), makeButtons( globals ), FALSE, TRUE, 0);
drawing_area = gtk_drawing_area_new();
g_signal_connect(G_OBJECT(drawing_area), "draw", G_CALLBACK(on_draw_event), globals);
globals->drawing_area = drawing_area;
gtk_widget_show( drawing_area );
@ -2712,7 +2725,7 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
gtk_widget_set_size_request( GTK_WIDGET(drawing_area), width, height );
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX (hbox), drawing_area, TRUE, TRUE, 0);
/* install scrollbar even if not needed -- since zooming can make it
@ -2722,8 +2735,8 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
globals->adjustment = (GtkAdjustment*)
gtk_adjustment_new( 0, 0, nRows, 1, 2,
nRows - params->nHidden );
vscrollbar = gtk_vscrollbar_new( globals->adjustment );
g_signal_connect( GTK_OBJECT(globals->adjustment), "value_changed",
vscrollbar = gtk_scrollbar_new( GTK_ORIENTATION_VERTICAL, globals->adjustment );
g_signal_connect( globals->adjustment, "value_changed",
G_CALLBACK(scroll_value_changed), globals );
gtk_widget_show( vscrollbar );
gtk_box_pack_start( GTK_BOX(hbox), vscrollbar, TRUE, TRUE, 0 );
@ -2735,25 +2748,25 @@ initGlobals( GtkGameGlobals* globals, LaunchParams* params, CurGameInfo* gi )
gtk_box_pack_start( GTK_BOX(vbox), hbox/* drawing_area */, TRUE, TRUE, 0);
g_signal_connect( GTK_OBJECT(drawing_area), "expose_event",
g_signal_connect( drawing_area, "expose_event",
G_CALLBACK(expose_event), globals );
g_signal_connect( GTK_OBJECT(drawing_area),"configure_event",
g_signal_connect( drawing_area,"configure_event",
G_CALLBACK(configure_event), globals );
g_signal_connect( GTK_OBJECT(drawing_area), "button_press_event",
g_signal_connect( drawing_area, "button_press_event",
G_CALLBACK(button_press_event), globals );
g_signal_connect( GTK_OBJECT(drawing_area), "motion_notify_event",
g_signal_connect( drawing_area, "motion_notify_event",
G_CALLBACK(motion_notify_event), globals );
g_signal_connect( GTK_OBJECT(drawing_area), "button_release_event",
g_signal_connect( drawing_area, "button_release_event",
G_CALLBACK(button_release_event), globals );
setOneSecondTimer( cGlobals );
#ifdef KEY_SUPPORT
# ifdef KEYBOARD_NAV
g_signal_connect( GTK_OBJECT(window), "key_press_event",
g_signal_connect( window, "key_press_event",
G_CALLBACK(key_press_event), globals );
# endif
g_signal_connect( GTK_OBJECT(window), "key_release_event",
g_signal_connect( window, "key_release_event",
G_CALLBACK(key_release_event), globals );
#endif

View file

@ -48,19 +48,19 @@ typedef struct GtkDrawCtx {
struct GtkGameGlobals* globals;
#ifdef USE_CAIRO
cairo_t* cr;
cairo_t* _cairo;
#else
GdkGC* drawGC;
#endif
GdkColor black;
GdkColor white;
GdkColor grey;
GdkColor red; /* for pending tiles */
GdkColor tileBack; /* for pending tiles */
GdkColor cursor;
GdkColor bonusColors[4];
GdkColor playerColors[MAX_NUM_PLAYERS];
GdkRGBA black;
GdkRGBA white;
GdkRGBA grey;
GdkRGBA red; /* for pending tiles */
GdkRGBA tileBack; /* for pending tiles */
GdkRGBA cursor;
GdkRGBA bonusColors[4];
GdkRGBA playerColors[MAX_NUM_PLAYERS];
/* new for gtk 2.0 */
PangoContext* pangoContext;

View file

@ -27,7 +27,7 @@ gtkGetChatMessage( GtkGameGlobals* XP_UNUSED(globals) )
gchar* result = NULL;
GtkWidget* dialog = gtk_dialog_new_with_buttons( "message text", NULL, //GtkWindow *parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK,
"Ok",
GTK_RESPONSE_ACCEPT,
NULL );

View file

@ -183,13 +183,12 @@ boxWithUseCheck( GtkConnsState* state, PageData* data )
XP_Bool set = addr_hasType( state->addr, data->pageType );
data->doUse = set;
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
gchar buf[32];
snprintf( buf, sizeof(buf), "Connect via %s", data->labelText );
GtkWidget* check = gtk_check_button_new_with_label( buf );
g_signal_connect( GTK_OBJECT(check),
"toggled", G_CALLBACK(useCheckToggled), data );
g_signal_connect( check, "toggled", G_CALLBACK(useCheckToggled), data );
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(check), set );
gtk_box_pack_start( GTK_BOX(vbox), check, FALSE, TRUE, 0);
@ -378,7 +377,7 @@ gtkConnsDlg( GtkGameGlobals* globals, CommsAddrRec* addr, DeviceRole role,
data->label );
#endif
vbox = gtk_vbox_new( FALSE, 0 );
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
gtk_box_pack_start( GTK_BOX(vbox), state.notebook, FALSE, TRUE, 0 );
/* Set page to the first we actually have */
@ -392,7 +391,7 @@ gtkConnsDlg( GtkGameGlobals* globals, CommsAddrRec* addr, DeviceRole role,
gtk_widget_show( state.notebook );
/* buttons at the bottom */
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX(hbox),
makeButton( "Ok", (GCallback)handle_ok, &state ),
FALSE, TRUE, 0 );
@ -408,7 +407,7 @@ gtkConnsDlg( GtkGameGlobals* globals, CommsAddrRec* addr, DeviceRole role,
dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox );
gtk_dialog_add_action_widget( GTK_DIALOG(dialog), vbox, 0 );
gtk_widget_show_all( dialog );
gtk_main();

View file

@ -47,6 +47,7 @@ typedef struct FontPerSize {
static void gtk_draw_measureScoreText( DrawCtx* p_dctx, const XP_Rect* bounds,
const DrawScoreInfo* dsi,
XP_U16* widthP, XP_U16* heightP );
static gdouble figureColor( int in );
/* static GdkGC* newGCForColor( GdkWindow* window, XP_Color* newC ); */
static void
@ -71,27 +72,64 @@ gtkInsetRect( XP_Rect* r, short i )
#ifdef USE_CAIRO
# define XP_UNUSED_CAIRO(var) UNUSED__ ## var __attribute__((unused))
# define GDKDRAWABLE void
# define GDKGC void
# define GDKCOLORMAP void
#define LOG_CAIRO_PENDING() XP_LOGF( "%s(): CAIRO work pending", __func__ )
#else
# define XP_UNUSED_CAIRO(var) var
# define GDKCOLORMAP GdkColormap
#endif
static void
initCairo( GtkDrawCtx* dctx )
{
LOG_FUNC();
XP_ASSERT( !dctx->_cairo );
dctx->_cairo = gdk_cairo_create( gtk_widget_get_window(dctx->drawing_area) );
XP_LOGF( "dctx->cairo=%p", dctx->_cairo );
cairo_set_line_width( dctx->_cairo, 1.0 );
cairo_set_line_cap( dctx->_cairo, CAIRO_LINE_CAP_SQUARE );
// cairo_set_source_rgb( dctx->_cairo, 0, 0, 0 );
}
static void
destroyCairo( GtkDrawCtx* dctx )
{
LOG_FUNC();
XP_ASSERT( !!dctx->_cairo );
cairo_destroy(dctx->_cairo);
dctx->_cairo = NULL;
}
static cairo_t*
getCairo( const GtkDrawCtx* dctx )
{
XP_ASSERT( !!dctx->_cairo );
return dctx->_cairo;
}
static void
draw_rectangle( const GtkDrawCtx* dctx,
GdkDrawable* XP_UNUSED_CAIRO(drawable),
GdkGC* XP_UNUSED_CAIRO(gc),
GDKDRAWABLE* XP_UNUSED_CAIRO(drawable),
GDKGC* XP_UNUSED_CAIRO(gc),
gboolean fill, gint left, gint top, gint width,
gint height )
{
#ifdef USE_CAIRO
cairo_rectangle( dctx->cr, left, top, width, height );
cairo_stroke_preserve( dctx->cr );
cairo_set_source_rgb( dctx->cr, 1, 1, 1 );
/* if ( fill ) { */
cairo_fill( dctx->cr );
cairo_t *cr = getCairo( dctx );
cairo_rectangle( cr, left, top, width, height );
cairo_stroke_preserve( cr );
if ( fill ) {
cairo_fill( cr );
} else {
cairo_stroke( cr );
}
/* } else { */
cairo_stroke( dctx->cr );
/* cairo_stroke( dctx->cairo ); */
/* } */
fill = fill;
#else
dctx = dctx;
gdk_draw_rectangle( drawable, gc, fill, left, top, width, height );
@ -99,15 +137,14 @@ draw_rectangle( const GtkDrawCtx* dctx,
}
static void
gtkFillRect( GtkDrawCtx* dctx, const XP_Rect* rect, const GdkColor* color )
gtkFillRect( GtkDrawCtx* dctx, const XP_Rect* rect, const GdkRGBA* color )
{
#ifdef USE_CAIRO
color = color;
//gdk_cairo_set_source_color( dctx->cr, color );
gdk_cairo_set_source_rgba( getCairo(dctx), color );
#else
gdk_gc_set_foreground( dctx->drawGC, color );
#endif
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
draw_rectangle( dctx, DRAW_WHAT(dctx), NULL, TRUE,
rect->left, rect->top, rect->width,
rect->height );
}
@ -116,18 +153,19 @@ static void
set_color_cairo( const GtkDrawCtx* dctx, unsigned short red,
unsigned short green, unsigned short blue )
{
GdkColor color = { red, green, blue };
color = color;
dctx = dctx;
//gdk_cairo_set_source_color( dctx->cr, &color );
GdkRGBA color = { figureColor(red),
figureColor(green),
figureColor(blue),
1.0 };
gdk_cairo_set_source_rgba( getCairo(dctx), &color );
}
static void
gtkEraseRect( const GtkDrawCtx* dctx, const XP_Rect* rect )
{
set_color_cairo( dctx, 0xFFFF, 0xFFFF, 0xFFFF );
const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
draw_rectangle( dctx, DRAW_WHAT(dctx), style->white_gc,
// const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
draw_rectangle( dctx, DRAW_WHAT(dctx), NULL, //style->white_gc,
TRUE, rect->left, rect->top,
rect->width, rect->height );
} /* gtkEraseRect */
@ -235,13 +273,28 @@ static void
draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
const XP_UCHAR* str, XP_U16 fontHt,
const XP_Rect* where, XP_GTK_JUST just,
const GdkColor* frground, const GdkColor* bkgrnd )
const GdkRGBA* frground,
const GdkRGBA* bkgrnd )
{
XP_LOGF( "%s(%s)", __func__, str );
gint xx = where->left;
gint yy = where->top;
#ifdef USE_CAIRO
cairo_t* cr = getCairo( dctx );
#endif
if ( !layout ) {
#ifdef USE_CAIRO
gdk_cairo_set_source_rgba( cr, frground );
layout = pango_cairo_create_layout( cr );
gchar buf[32];
sprintf( buf, "Sans Bold %d", (fontHt * 2) / 3 );
PangoFontDescription* desc = pango_font_description_from_string( buf );
pango_layout_set_font_description( layout, desc );
pango_font_description_free( desc );
#else
layout = layout_for_ht( dctx, fontHt );
#endif
}
pango_layout_set_text( layout, (char*)str, XP_STRLEN(str) );
@ -267,35 +320,41 @@ draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
}
#ifdef USE_CAIRO
frground = frground;
bkgrnd = bkgrnd;
XP_USE(bkgrnd);
cairo_save( cr );
cairo_translate( cr, xx, yy );
pango_cairo_show_layout( cr, layout );
cairo_restore( cr );
#else
gdk_draw_layout_with_colors( DRAW_WHAT(dctx), dctx->drawGC,
xx, yy, layout,
frground, bkgrnd );
#endif
g_object_unref(layout);
} /* draw_string_at */
static void
drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
{
GdkPixmap* pm;
LinuxBMStruct* lbs = (LinuxBMStruct*)bm;
gint x, y;
XP_U8* bp;
XP_U16 i;
XP_S16 nBytes;
XP_U16 nCols, nRows;
const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
nCols = lbs->nCols;
nRows = lbs->nRows;
bp = (XP_U8*)(lbs + 1); /* point to the bitmap data */
nBytes = lbs->nBytes;
pm = gdk_pixmap_new( DRAW_WHAT(dctx), nCols, nRows, -1 );
draw_rectangle( dctx, pm, style->white_gc, TRUE,
0, 0, nCols, nRows );
#ifdef USE_CAIRO
draw_rectangle( dctx, NULL, NULL, TRUE, 0, 0, nCols, nRows );
#else
const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
GdkPixmap* pm = gdk_pixmap_new( DRAW_WHAT(dctx), nCols, nRows, -1 );
draw_rectangle( dctx, pm, style->white_gc, TRUE, 0, 0, nCols, nRows );
#endif
x = 0;
y = 0;
@ -306,6 +365,7 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
XP_Bool draw = ((byte & 0x80) != 0);
if ( draw ) {
#ifdef USE_CAIRO
LOG_CAIRO_PENDING();
#else
gdk_draw_point( pm, style->black_gc, x, y );
#endif
@ -324,6 +384,7 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
#ifdef USE_CAIRO
rect = rect;
LOG_CAIRO_PENDING();
#else
gdk_draw_drawable( DRAW_WHAT(dctx),
dctx->drawGC,
@ -332,8 +393,8 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
rect->top+2,
lbs->nCols,
lbs->nRows );
#endif
g_object_unref( pm );
#endif
} /* drawBitmapFromLBS */
static void
@ -351,10 +412,15 @@ gtk_draw_destroyCtxt( DrawCtx* p_dctx )
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
GtkAllocation alloc;
gtk_widget_get_allocation( dctx->drawing_area, &alloc );
const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
#ifdef USE_CAIRO
draw_rectangle( dctx, NULL, NULL, TRUE,
0, 0, alloc.width, alloc.height );
#else
const GtkStyle* style = gtk_widget_get_style( dctx->drawing_area );
draw_rectangle( dctx, DRAW_WHAT(dctx), style->white_gc, TRUE,
0, 0, alloc.width, alloc.height );
#endif
g_list_foreach( dctx->fontsPerSize, freer, NULL );
g_list_free( dctx->fontsPerSize );
@ -382,7 +448,8 @@ gtk_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect,
dctx->cellHeight = height;
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
initCairo( dctx );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
@ -392,15 +459,20 @@ gtk_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect,
++gdkrect.height;
/* gdk_gc_set_clip_rectangle( dctx->drawGC, &gdkrect ); */
LOG_RETURN_VOID();
return XP_TRUE;
} /* draw_finish */
} /* gtk_draw_boardBegin */
static void
gtk_draw_objFinished( DrawCtx* XP_UNUSED(p_dctx),
BoardObjectType XP_UNUSED(typ),
gtk_draw_objFinished( DrawCtx* p_dctx,
BoardObjectType typ,
const XP_Rect* XP_UNUSED(rect),
DrawFocusState XP_UNUSED(dfs) )
{
if ( OBJ_BOARD == typ ) {
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
destroyCairo( dctx );
}
} /* draw_finished */
@ -452,34 +524,30 @@ drawHintBorders( GtkDrawCtx* dctx, const XP_Rect* rect, HintAtts hintAtts)
gtkInsetRect( &lrect, 1 );
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) {
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
FALSE, lrect.left, lrect.top,
NULL, FALSE, lrect.left, lrect.top,
0, lrect.height);
}
if ( (hintAtts & HINT_BORDER_TOP) != 0 ) {
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
FALSE, lrect.left, lrect.top,
NULL, FALSE, lrect.left, lrect.top,
lrect.width, 0/*rectInset.height*/);
}
if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) {
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
FALSE, lrect.left+lrect.width,
NULL, FALSE, lrect.left+lrect.width,
lrect.top,
0, lrect.height);
}
if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) {
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
FALSE, lrect.left,
NULL, FALSE, lrect.left,
lrect.top+lrect.height,
lrect.width, 0 );
}
@ -519,21 +587,25 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
GtkGameGlobals* globals = dctx->globals;
XP_Bool showGrid = globals->gridOn;
XP_Bool highlight = (flags & CELL_HIGHLIGHT) != 0;
GdkColor* cursor =
GdkRGBA* cursor =
((flags & CELL_ISCURSOR) != 0) ? &dctx->cursor : NULL;
gtkEraseRect( dctx, rect );
gtkInsetRect( &rectInset, 1 );
#ifdef USE_CAIRO
cairo_t* cr = getCairo( dctx );
#endif
if ( showGrid ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
cairo_set_source_rgb( cr, 0, 0, 0 );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
NULL,
FALSE,
rect->left, rect->top, rect->width,
rect->height );
@ -543,23 +615,24 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
in the cell or if CELL_DRAGSRC is set */
if ( (flags & (CELL_DRAGSRC|CELL_ISEMPTY)) != 0 ) {
if ( !!cursor || bonus != BONUS_NONE ) {
GdkColor* foreground;
GdkRGBA* foreground;
if ( !!cursor ) {
foreground = cursor;
} else if ( bonus != BONUS_NONE ) {
foreground = &dctx->bonusColors[bonus-1];
} else {
foreground = NULL;
foreground = &dctx->white;
}
if ( !!foreground ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, foreground );
gtkFillRect( dctx, &rectInset, foreground );
// gdk_cairo_set_source_rgba( cr, foreground );
#else
gdk_gc_set_foreground( dctx->drawGC, foreground );
#endif
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
draw_rectangle( dctx, DRAW_WHAT(dctx), NULL, TRUE,
rectInset.left, rectInset.top,
rectInset.width+1, rectInset.height+1 );
#endif
}
}
if ( (flags & CELL_ISSTAR) != 0 ) {
@ -570,21 +643,21 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
drawBitmapFromLBS( dctx, bitmaps->bmps[0], rect );
} else if ( !!letter ) {
XP_Bool isBlank = (flags & CELL_ISBLANK) != 0;
GdkColor* foreground;
GdkRGBA* foreground;
if ( cursor ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, cursor );
//gdk_cairo_set_source_color( dctx->cairo, cursor );
#else
gdk_gc_set_foreground( dctx->drawGC, cursor );
#endif
} else if ( !highlight ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->tileBack );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->tileBack );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->tileBack );
#endif
}
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
draw_rectangle( dctx, DRAW_WHAT(dctx), NULL, TRUE,
rectInset.left, rectInset.top,
rectInset.width+1, rectInset.height+1 );
@ -643,9 +716,12 @@ gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
XP_U16 owner, XP_S16 XP_UNUSED(owner),
DrawFocusState XP_UNUSED(dfs) )
{
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
dctx->trayOwner = owner;
return XP_TRUE;
XP_USE( p_dctx );
XP_USE( owner );
return XP_FALSE;
/* GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; */
/* dctx->trayOwner = owner; */
/* return XP_TRUE; */
} /* gtk_draw_trayBegin */
static XP_Bool
@ -665,7 +741,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
}
if ( isCursor || notEmpty ) {
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
GdkRGBA* foreground = &dctx->playerColors[dctx->trayOwner];
XP_Rect formatRect = insetR;
gtkInsetRect( &insetR, 1 );
@ -701,12 +777,12 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
/* frame the tile */
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
NULL,
FALSE,
insetR.left, insetR.top, insetR.width,
insetR.height );
@ -714,7 +790,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
gtkInsetRect( &insetR, 1 );
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
NULL,
FALSE, insetR.left, insetR.top,
insetR.width, insetR.height);
}
@ -782,12 +858,12 @@ gtk_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
}
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC,
NULL,
!selected,
r.left, r.top, r.width, r.height);
@ -828,12 +904,15 @@ gtk_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect,
XP_S16 XP_UNUSED(remCount),
DrawFocusState XP_UNUSED(dfs) )
{
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_USE( p_dctx );
XP_USE( rect );
return XP_FALSE;
/* GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; */
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */
gtkEraseRect( dctx, rect );
dctx->scoreIsVertical = rect->height > rect->width;
return XP_TRUE;
/* /\* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); *\/ */
/* gtkEraseRect( dctx, rect ); */
/* dctx->scoreIsVertical = rect->height > rect->width; */
/* return XP_TRUE; */
} /* gtk_draw_scoreBegin */
static PangoLayout*
@ -893,7 +972,7 @@ gtkDrawDrawRemText( DrawCtx* p_dctx, const XP_Rect* rect, XP_S16 nTilesLeft,
*widthP = width;
*heightP = height;
} else {
const GdkColor* cursor = NULL;
const GdkRGBA* cursor = NULL;
if ( focussed ) {
cursor = &dctx->cursor;
gtkFillRect( dctx, rect, cursor );
@ -911,7 +990,7 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
{
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Bool hasCursor = (dsi->flags & CELL_ISCURSOR) != 0;
GdkColor* cursor = NULL;
GdkRGBA* cursor = NULL;
XP_U16 playerNum = dsi->playerNum;
const XP_UCHAR* scoreBuf = dctx->scoreCache[playerNum].str;
XP_U16 fontHt = dctx->scoreCache[playerNum].fontHt;
@ -922,7 +1001,7 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
}
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->playerColors[playerNum] );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->playerColors[playerNum] );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[playerNum] );
#endif
@ -945,7 +1024,7 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
}
}
draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC,
draw_rectangle( dctx, DRAW_WHAT(dctx), NULL,
TRUE, selRect.left, selRect.top,
selRect.width, selRect.height );
if ( hasCursor ) {
@ -1133,9 +1212,9 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
XP_UCHAR buf[5];
XP_U16 ht;
XP_Rect localR;
GdkColor* cursor = ((flags & CELL_ISCURSOR) != 0)
GdkRGBA* cursor = ((flags & CELL_ISCURSOR) != 0)
? &dctx->cursor : NULL;
GdkColor* txtColor;
GdkRGBA* txtColor;
if ( score >= 0 ) {
XP_SNPRINTF( buf, VSIZE(buf), "%.3d", score );
@ -1253,7 +1332,7 @@ gtk_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
XP_Rect localR = *rect;
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
//gdk_cairo_set_source_color( dctx->cairo, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
@ -1288,11 +1367,28 @@ draw_doNothing( DrawCtx* XP_UNUSED(dctx), ... )
{
} /* draw_doNothing */
static gdouble
figureColor( int in )
{
gdouble asDouble = (gdouble)in;
gdouble result = asDouble / 0xFFFF;
// XP_LOGF( "%s(%d): asDouble: %lf; result: %lf", __func__, in, asDouble, result );
XP_ASSERT( result >= 0 && result <= 1.0 );
return result;
}
static void
allocAndSet( GdkColormap* map, GdkColor* color, unsigned short red,
allocAndSet( GDKCOLORMAP* map, GdkRGBA* color, unsigned short red,
unsigned short green, unsigned short blue )
{
#ifdef USE_CAIRO
XP_USE( map );
color->red = figureColor(red);
color->green = figureColor(green);
color->blue = figureColor(blue);
color->alpha = 1.0;
#else
color->red = red;
color->green = green;
@ -1305,13 +1401,13 @@ allocAndSet( GdkColormap* map, GdkColor* color, unsigned short red,
TRUE, /* writeable */
TRUE ); /* best-match */
XP_ASSERT( success );
#endif
} /* allocAndSet */
DrawCtx*
gtkDrawCtxtMake( GtkWidget* drawing_area, GtkGameGlobals* globals )
{
GtkDrawCtx* dctx = g_malloc0( sizeof(GtkDrawCtx) );
GdkColormap* map;
short ii;
@ -1377,30 +1473,22 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkGameGlobals* globals )
dctx->drawing_area = drawing_area;
dctx->globals = globals;
{
// GdkWindow *window = NULL;
/* if ( GTK_WIDGET_FLAGS(GTK_WIDGET(drawing_area)) & GTK_NO_WINDOW ) { */
/* /\* XXX I'm not sure about this function because I never used it. */
/* * (the name seems to indicate what you want though). */
/* *\/ */
/* window = gtk_widget_get_parent_window( GTK_WIDGET(drawing_area) ); */
/* } else { */
/* window = GTK_WIDGET(drawing_area)->window; */
/* } */
GdkWindow* window = gtk_widget_get_window(drawing_area);
XP_ASSERT( !!window );
GdkWindow* window = gtk_widget_get_window(drawing_area);
XP_ASSERT( !!window );
#ifdef USE_CAIRO
dctx->cr = gdk_cairo_create( window );
XP_LOGF( "dctx->cr=%p", dctx->cr );
cairo_set_line_width( dctx->cr, 1.0 );
cairo_set_line_cap( dctx->cr, CAIRO_LINE_CAP_SQUARE );
cairo_set_source_rgb( dctx->cr, 0, 0, 0 );
/* dctx->cairo = gdk_cairo_create( window ); */
/* XP_LOGF( "dctx->cairo=%p", dctx->cairo ); */
/* cairo_set_line_width( dctx->cairo, 1.0 ); */
/* cairo_set_line_cap( dctx->cairo, CAIRO_LINE_CAP_SQUARE ); */
/* cairo_set_source_rgb( dctx->cairo, 0, 0, 0 ); */
#else
dctx->drawGC = gdk_gc_new( window );
dctx->drawGC = gdk_gc_new( window );
#endif
}
GDKCOLORMAP* map = NULL;
#ifndef USE_CAIRO
map = gdk_colormap_get_system();
#endif
allocAndSet( map, &dctx->black, 0x0000, 0x0000, 0x0000 );
allocAndSet( map, &dctx->grey, 0x7FFF, 0x7FFF, 0x7FFF );

View file

@ -168,7 +168,7 @@ makeRelayPage( GtkInviteState* state, PageData* data )
{
data->okButtonTxt = "Invite via Relay";
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
GtkWidget* hbox;
hbox = makeLabeledField( "Invitee DeviceID", &state->devID, NULL );
@ -185,7 +185,7 @@ makeBTPage( GtkInviteState* state, PageData* data )
{
data->okButtonTxt = "Invite via Bluetooth";
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
GtkWidget* hbox = makeLabeledField( "Invitee device", &state->bthost, NULL );
if ( addr_hasType( state->addr, data->pageType ) ) {
@ -234,7 +234,7 @@ makeSMSPage( GtkInviteState* state, PageData* data )
{
data->okButtonTxt = "Invite via SMS";
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
XP_Bool hasSMS = addr_hasType( state->addr, data->pageType );
const gchar* phone = hasSMS ?
state->addr->u.sms.phone : state->globals->cGlobals.params->connInfo.sms.phone;
@ -290,9 +290,9 @@ gtkInviteDlg( GtkGameGlobals* globals, CommsAddrRec* addr,
GtkWidget* dialog;
GtkWidget* hbox;
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
GtkWidget* label = gtk_label_new( "Invite how many:" );
gtk_box_pack_start( GTK_BOX(hbox), label, FALSE, TRUE, 0 );
@ -308,7 +308,7 @@ gtkInviteDlg( GtkGameGlobals* globals, CommsAddrRec* addr,
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
state.notebook = gtk_notebook_new();
g_signal_connect( GTK_OBJECT(state.notebook), "switch-page",
g_signal_connect( state.notebook, "switch-page",
G_CALLBACK(onPageChanged), &state );
PageData* data;
@ -351,7 +351,7 @@ gtkInviteDlg( GtkGameGlobals* globals, CommsAddrRec* addr,
gtk_widget_show( state.notebook );
/* buttons at the bottom */
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
state.okButton = makeButton( state.pageData[0].okButtonTxt,
(GCallback)handle_ok, &state );
gtk_box_pack_start( GTK_BOX(hbox), state.okButton, FALSE, TRUE, 0 );
@ -365,7 +365,8 @@ gtkInviteDlg( GtkGameGlobals* globals, CommsAddrRec* addr,
dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox );
// gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox );
XP_ASSERT(0);
gtk_widget_show_all( dialog );
gtk_main();

View file

@ -58,17 +58,17 @@ gtkletterask( const PickInfo* pi, XP_Bool forTray, const XP_UCHAR* name,
XP_MEMSET( results, XP_FALSE, sizeof(results) );
vbox = gtk_vbox_new( FALSE, 0 );
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
for ( ii = 0; ii < nTiles; ++ii ) {
if ( ii % BUTTONS_PER_ROW == 0 ) {
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
}
button = gtk_button_new_with_label( texts[ii] );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(set_bool_and_quit), &results[ii] );
gtk_widget_show( button );
@ -79,16 +79,16 @@ gtkletterask( const PickInfo* pi, XP_Bool forTray, const XP_UCHAR* name,
}
#ifdef FEATURE_TRAY_EDIT
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
button = gtk_button_new_with_label( "Just pick em!" );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(abort_button_event), NULL );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
gtk_widget_show( button );
button = gtk_button_new_with_label( "Back up" );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(set_bool_and_quit), &backedUp );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
gtk_widget_show( button );
@ -128,7 +128,8 @@ gtkletterask( const PickInfo* pi, XP_Bool forTray, const XP_UCHAR* name,
curTilesLabel );
}
gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox);
// gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox);
XP_ASSERT(0);
gtk_widget_show_all( dialog );
gtk_main();

View file

@ -418,7 +418,7 @@ addButton( gchar* label, GtkWidget* parent, GCallback proc, void* closure )
{
GtkWidget* button = gtk_button_new_with_label( label );
gtk_container_add( GTK_CONTAINER(parent), button );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(proc), closure );
gtk_widget_show( button );
return button;
@ -459,7 +459,7 @@ makeGamesWindow( GtkAppGlobals* apg )
setWindowTitle( apg );
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add( GTK_CONTAINER(window), vbox );
gtk_widget_show( vbox );
GtkWidget* list = init_games_list( apg );
@ -477,7 +477,7 @@ makeGamesWindow( GtkAppGlobals* apg )
g_slist_free( games );
}
GtkWidget* hbox = gtk_hbox_new( FALSE, 0 );
GtkWidget* hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_widget_show( hbox );
gtk_container_add( GTK_CONTAINER(vbox), hbox );

View file

@ -218,10 +218,10 @@ makeNewGameDialog( GtkNewGameState* state )
dialog = gtk_dialog_new();
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
vbox = gtk_vbox_new( FALSE, 0 );
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
#ifndef XWFEATURE_STANDALONE_ONLY
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Role:"),
FALSE, TRUE, 0 );
roleCombo = gtk_combo_box_text_new();
@ -232,7 +232,7 @@ makeNewGameDialog( GtkNewGameState* state )
roles[ii] );
}
gtk_box_pack_start( GTK_BOX(hbox), roleCombo, FALSE, TRUE, 0 );
g_signal_connect( GTK_OBJECT(roleCombo), "changed",
g_signal_connect( roleCombo, "changed",
G_CALLBACK(role_combo_changed), state );
state->settingsButton = makeButton( "Settings...",
@ -244,7 +244,7 @@ makeNewGameDialog( GtkNewGameState* state )
#endif
/* NPlayers menu */
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
state->nPlayersLabel = gtk_label_new("");
gtk_box_pack_start( GTK_BOX(hbox), state->nPlayersLabel, FALSE, TRUE, 0 );
@ -261,7 +261,7 @@ makeNewGameDialog( GtkNewGameState* state )
gtk_widget_show( nPlayersCombo );
gtk_box_pack_start( GTK_BOX(hbox), nPlayersCombo, FALSE, TRUE, 0 );
g_signal_connect( GTK_OBJECT(nPlayersCombo), "changed",
g_signal_connect( nPlayersCombo, "changed",
G_CALLBACK(nplayers_menu_changed), state );
state->juggleButton = makeButton( "Juggle",
@ -283,13 +283,13 @@ makeNewGameDialog( GtkNewGameState* state )
GtkWidget* robotCheck = gtk_check_button_new_with_label( "Robot" );
#ifndef XWFEATURE_STANDALONE_ONLY
g_signal_connect( GTK_OBJECT(remoteCheck), "toggled",
g_signal_connect( remoteCheck, "toggled",
(GCallback)handle_remote_toggled, state );
#endif
g_signal_connect( GTK_OBJECT(robotCheck), "toggled",
g_signal_connect( robotCheck, "toggled",
(GCallback)handle_robot_toggled, state );
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
#ifndef XWFEATURE_STANDALONE_ONLY
gtk_box_pack_start( GTK_BOX(hbox), remoteCheck, FALSE, TRUE, 0 );
@ -323,7 +323,7 @@ makeNewGameDialog( GtkNewGameState* state )
}
/* board size choices */
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Board size"),
FALSE, TRUE, 0 );
@ -342,7 +342,7 @@ makeNewGameDialog( GtkNewGameState* state )
}
}
g_signal_connect( GTK_OBJECT(boardSizeCombo), "changed",
g_signal_connect( boardSizeCombo, "changed",
G_CALLBACK(size_combo_changed), state );
gtk_widget_show( boardSizeCombo );
@ -351,7 +351,7 @@ makeNewGameDialog( GtkNewGameState* state )
gtk_box_pack_start( GTK_BOX(hbox), gtk_label_new("Dictionary: "),
FALSE, TRUE, 0 );
dictCombo = gtk_combo_box_text_new();
g_signal_connect( GTK_OBJECT(dictCombo), "changed",
g_signal_connect( dictCombo, "changed",
G_CALLBACK(dict_combo_changed), state );
gtk_widget_show( dictCombo );
gtk_box_pack_start( GTK_BOX(hbox), dictCombo, FALSE, TRUE, 0 );
@ -376,7 +376,7 @@ makeNewGameDialog( GtkNewGameState* state )
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
/* buttons at the bottom */
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX(hbox),
makeButton( "Ok", (GCallback)handle_ok, state ),
FALSE, TRUE, 0 );
@ -395,7 +395,7 @@ makeNewGameDialog( GtkNewGameState* state )
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
gtk_widget_show( vbox );
gtk_container_add( GTK_CONTAINER( gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox);
gtk_dialog_add_action_widget( GTK_DIALOG(dialog), vbox, 0 );
gtk_widget_show_all (dialog);

View file

@ -51,7 +51,7 @@ askNTiles( XP_U16 max, XP_U16 deflt )
gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
label );
hbox = gtk_hbox_new( FALSE, 0 );
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
for ( i = 0; i < max; ++i ) {
XP_UCHAR buf[3];
@ -59,7 +59,7 @@ askNTiles( XP_U16 max, XP_U16 deflt )
button = gtk_button_new_with_label( buf );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(button_event),
&results[i] );
gtk_widget_show( button );
@ -72,7 +72,7 @@ askNTiles( XP_U16 max, XP_U16 deflt )
sprintf( defbuf, "Default (%d)", deflt );
button = gtk_button_new_with_label( defbuf );
gtk_box_pack_start( GTK_BOX(dlgVBox), button, FALSE, TRUE, 0 );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(button_event),
&results[deflt-1] );
gtk_widget_show( button );

View file

@ -56,17 +56,17 @@ gtkpasswdask( const char* name, char* outbuf, XP_U16* buflen )
label);
/* we need a text field and two buttons as well */
vbox = gtk_vbox_new(FALSE, 0);
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
entry = gtk_entry_new();
gtk_widget_show( entry );
gtk_box_pack_start( GTK_BOX(vbox), entry, FALSE, TRUE, 0 );
hbox = gtk_hbox_new(FALSE, 0);
hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0);
for ( i = 0; i < 2; ++i ) {
GtkWidget* button = gtk_button_new_with_label( labels[i] );
g_signal_connect( GTK_OBJECT(button), "clicked",
g_signal_connect( button, "clicked",
G_CALLBACK(button_event),
boolps[i] );
gtk_box_pack_start( GTK_BOX(hbox), button, FALSE, TRUE, 0 );
@ -75,7 +75,8 @@ gtkpasswdask( const char* name, char* outbuf, XP_U16* buflen )
gtk_box_pack_start( GTK_BOX(vbox), hbox, FALSE, TRUE, 0 );
gtk_container_add( GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox);
// gtk_container_add( GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(dialog))), vbox);
XP_ASSERT(0);
gtk_widget_show_all( dialog );

View file

@ -27,7 +27,7 @@ GtkWidget*
makeButton( const char* text, GCallback func, gpointer data )
{
GtkWidget* button = gtk_button_new_with_label( text );
g_signal_connect( GTK_OBJECT(button), "clicked", func, data );
g_signal_connect( button, "clicked", func, data );
gtk_widget_show( button );
return button;
@ -47,7 +47,7 @@ makeLabeledField( const char* labelText, GtkWidget** field,
gtk_entry_set_text( GTK_ENTRY(*field), initialVal );
}
GtkWidget* hbox = gtk_hbox_new( FALSE, 0 );
GtkWidget* hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 0 );
gtk_box_pack_start( GTK_BOX(hbox), label, FALSE, TRUE, 0 );
gtk_box_pack_start( GTK_BOX(hbox), *field, FALSE, TRUE, 0 );
return hbox;