mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
fix problems drawing focus so letters still visible on board.
This commit is contained in:
parent
b99aaa826b
commit
2d199f2a9c
1 changed files with 42 additions and 64 deletions
106
linux/gtkdraw.c
106
linux/gtkdraw.c
|
@ -44,7 +44,7 @@ typedef struct FontPerSize {
|
||||||
|
|
||||||
/* static GdkGC* newGCForColor( GdkWindow* window, XP_Color* newC ); */
|
/* static GdkGC* newGCForColor( GdkWindow* window, XP_Color* newC ); */
|
||||||
static void
|
static void
|
||||||
insetRect( XP_Rect* r, short i )
|
gtkInsetRect( XP_Rect* r, short i )
|
||||||
{
|
{
|
||||||
r->top += i;
|
r->top += i;
|
||||||
r->left += i;
|
r->left += i;
|
||||||
|
@ -52,7 +52,7 @@ insetRect( XP_Rect* r, short i )
|
||||||
|
|
||||||
r->width -= i;
|
r->width -= i;
|
||||||
r->height -= i;
|
r->height -= i;
|
||||||
} /* insetRect */
|
} /* gtkInsetRect */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define DRAW_WHAT(dc) ((dc)->globals->pixmap)
|
#define DRAW_WHAT(dc) ((dc)->globals->pixmap)
|
||||||
|
@ -62,6 +62,16 @@ insetRect( XP_Rect* r, short i )
|
||||||
|
|
||||||
#define GTKMIN_W_HT 12
|
#define GTKMIN_W_HT 12
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtkFillRect( GtkDrawCtx* dctx, const XP_Rect* rect, GdkColor* color )
|
||||||
|
{
|
||||||
|
gdk_gc_set_foreground( dctx->drawGC, color );
|
||||||
|
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC,
|
||||||
|
TRUE,
|
||||||
|
rect->left, rect->top, rect->width,
|
||||||
|
rect->height );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtkEraseRect( GtkDrawCtx* dctx, const XP_Rect* rect )
|
gtkEraseRect( GtkDrawCtx* dctx, const XP_Rect* rect )
|
||||||
{
|
{
|
||||||
|
@ -369,7 +379,7 @@ drawHintBorders( GtkDrawCtx* dctx, const XP_Rect* rect, HintAtts hintAtts)
|
||||||
{
|
{
|
||||||
if ( hintAtts != HINT_BORDER_NONE && hintAtts != HINT_BORDER_CENTER ) {
|
if ( hintAtts != HINT_BORDER_NONE && hintAtts != HINT_BORDER_CENTER ) {
|
||||||
XP_Rect lrect = *rect;
|
XP_Rect lrect = *rect;
|
||||||
insetRect( &lrect, 1 );
|
gtkInsetRect( &lrect, 1 );
|
||||||
|
|
||||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
||||||
|
|
||||||
|
@ -416,7 +426,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
|
|
||||||
gtkEraseRect( dctx, rect );
|
gtkEraseRect( dctx, rect );
|
||||||
|
|
||||||
insetRect( &rectInset, 1 );
|
gtkInsetRect( &rectInset, 1 );
|
||||||
|
|
||||||
if ( showGrid ) {
|
if ( showGrid ) {
|
||||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
||||||
|
@ -451,7 +461,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
&dctx->black, NULL );
|
&dctx->black, NULL );
|
||||||
}
|
}
|
||||||
} else if ( !!letter ) {
|
} else if ( !!letter ) {
|
||||||
GdkColor* foreground = cursor;
|
GdkColor* foreground;
|
||||||
if ( cursor ) {
|
if ( cursor ) {
|
||||||
gdk_gc_set_foreground( dctx->drawGC, cursor );
|
gdk_gc_set_foreground( dctx->drawGC, cursor );
|
||||||
} else if ( !highlight ) {
|
} else if ( !highlight ) {
|
||||||
|
@ -461,11 +471,9 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
|
||||||
rectInset.left, rectInset.top,
|
rectInset.left, rectInset.top,
|
||||||
rectInset.width+1, rectInset.height+1 );
|
rectInset.width+1, rectInset.height+1 );
|
||||||
|
|
||||||
if ( !foreground ) {
|
foreground = highlight? &dctx->white : &dctx->playerColors[owner];
|
||||||
foreground = highlight? &dctx->white : &dctx->playerColors[owner];
|
|
||||||
}
|
|
||||||
draw_string_at( dctx, letter, rectInset.height-2, &rectInset,
|
draw_string_at( dctx, letter, rectInset.height-2, &rectInset,
|
||||||
XP_GTK_JUST_CENTER, foreground, NULL );
|
XP_GTK_JUST_CENTER, foreground, cursor );
|
||||||
|
|
||||||
if ( (flags & CELL_ISBLANK) != 0 ) {
|
if ( (flags & CELL_ISBLANK) != 0 ) {
|
||||||
gdk_draw_arc( DRAW_WHAT(dctx), dctx->drawGC,
|
gdk_draw_arc( DRAW_WHAT(dctx), dctx->drawGC,
|
||||||
|
@ -535,16 +543,10 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||||
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
|
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
|
||||||
XP_Rect formatRect = insetR;
|
XP_Rect formatRect = insetR;
|
||||||
|
|
||||||
insetRect( &insetR, 1 );
|
gtkInsetRect( &insetR, 1 );
|
||||||
|
|
||||||
if ( clearBack ) {
|
if ( clearBack ) {
|
||||||
gdk_gc_set_foreground( dctx->drawGC,
|
gtkFillRect( dctx, &insetR, isCursor? &dctx->cursor:&dctx->tileBack );
|
||||||
isCursor? &dctx->cursor:&dctx->tileBack );
|
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
|
||||||
dctx->drawGC,
|
|
||||||
XP_TRUE,
|
|
||||||
insetR.left, insetR.top, insetR.width,
|
|
||||||
insetR.height );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( val >= 0 ) {
|
if ( val >= 0 ) {
|
||||||
|
@ -578,7 +580,7 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
|
||||||
insetR.height );
|
insetR.height );
|
||||||
|
|
||||||
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
|
||||||
insetRect( &insetR, 1 );
|
gtkInsetRect( &insetR, 1 );
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
||||||
dctx->drawGC,
|
dctx->drawGC,
|
||||||
FALSE, insetR.left, insetR.top,
|
FALSE, insetR.left, insetR.top,
|
||||||
|
@ -616,20 +618,12 @@ gtk_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
XP_Bool hasCursor = (flags & CELL_ISCURSOR) != 0;
|
XP_Bool hasCursor = (flags & CELL_ISCURSOR) != 0;
|
||||||
XP_Rect r = *rect;
|
XP_Rect r = *rect;
|
||||||
|
|
||||||
insetRect( &r, 1 );
|
gtkInsetRect( &r, 1 );
|
||||||
|
|
||||||
gdk_gc_set_foreground( dctx->drawGC,
|
gtkFillRect( dctx, &r, &dctx->playerColors[dctx->trayOwner] );
|
||||||
&dctx->playerColors[dctx->trayOwner] );
|
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
|
||||||
dctx->drawGC, TRUE,
|
|
||||||
r.left, r.top, r.width, r.height );
|
|
||||||
|
|
||||||
insetRect( &r, 1 );
|
gtkInsetRect( &r, 1 );
|
||||||
gdk_gc_set_foreground( dctx->drawGC,
|
gtkFillRect( dctx, &r, hasCursor? &dctx->cursor : &dctx->tileBack );
|
||||||
hasCursor? &dctx->cursor : &dctx->tileBack );
|
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
|
||||||
dctx->drawGC, TRUE,
|
|
||||||
r.left, r.top, r.width, r.height );
|
|
||||||
|
|
||||||
draw_string_at( dctx, "?", r.height,
|
draw_string_at( dctx, "?", r.height,
|
||||||
&r, XP_GTK_JUST_CENTER,
|
&r, XP_GTK_JUST_CENTER,
|
||||||
|
@ -648,11 +642,7 @@ gtk_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
|
|
||||||
gtkEraseRect( dctx, &r );
|
gtkEraseRect( dctx, &r );
|
||||||
|
|
||||||
gdk_gc_set_foreground( dctx->drawGC,
|
gtkFillRect( dctx, &r, isCursor? &dctx->cursor:&dctx->white );
|
||||||
isCursor? &dctx->cursor:&dctx->white );
|
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
|
||||||
dctx->drawGC, XP_TRUE,
|
|
||||||
r.left, r.top, r.width, r.height );
|
|
||||||
|
|
||||||
r.left += 2;
|
r.left += 2;
|
||||||
r.width -= 4;
|
r.width -= 4;
|
||||||
|
@ -668,26 +658,6 @@ gtk_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
|
|
||||||
} /* gtk_draw_drawTrayDivider */
|
} /* gtk_draw_drawTrayDivider */
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
gtk_draw_frameBoard( DrawCtx* p_dctx, XP_Rect* rect )
|
|
||||||
{
|
|
||||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
|
||||||
|
|
||||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
|
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx),
|
|
||||||
dctx->drawGC, FALSE,
|
|
||||||
rect->left, rect->top, rect->width, rect->height );
|
|
||||||
|
|
||||||
} /* gtk_draw_frameBoard */
|
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_draw_frameTray( DrawCtx* p_dctx, const XP_Rect* rect )
|
|
||||||
{
|
|
||||||
// GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
|
||||||
} /* gtk_draw_frameBoard */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP )
|
gtk_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP )
|
||||||
{
|
{
|
||||||
|
@ -850,18 +820,21 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
||||||
|
|
||||||
if ( hasCursor ) {
|
if ( hasCursor ) {
|
||||||
cursor = &dctx->cursor;
|
cursor = &dctx->cursor;
|
||||||
gdk_gc_set_foreground( dctx->drawGC, cursor );
|
gtkFillRect( dctx, rOuter, cursor );
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC,
|
|
||||||
TRUE, rOuter->left, rOuter->top,
|
|
||||||
rOuter->width, rOuter->height );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[dsi->playerNum] );
|
gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[dsi->playerNum] );
|
||||||
|
|
||||||
if ( dsi->selected ) {
|
if ( dsi->selected ) {
|
||||||
|
XP_Rect selRect = *rOuter;
|
||||||
|
XP_S16 diff = selRect.width - rInner->width;
|
||||||
|
if ( diff > 0 ) {
|
||||||
|
selRect.width -= diff>>1;
|
||||||
|
selRect.left += diff>>2;
|
||||||
|
}
|
||||||
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC,
|
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC,
|
||||||
TRUE, rOuter->left, rOuter->top,
|
TRUE, selRect.left, selRect.top,
|
||||||
rOuter->width, rOuter->height );
|
selRect.width, selRect.height );
|
||||||
gtkEraseRect( dctx, rInner );
|
gtkEraseRect( dctx, rInner );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -892,8 +865,13 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect,
|
||||||
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */
|
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */
|
||||||
|
|
||||||
localR = *rect;
|
localR = *rect;
|
||||||
insetRect( &localR, 1 );
|
gtkInsetRect( &localR, 1 );
|
||||||
gtkEraseRect( dctx, &localR );
|
|
||||||
|
if ( !!cursor ) {
|
||||||
|
gtkFillRect( dctx, &localR, cursor );
|
||||||
|
} else {
|
||||||
|
gtkEraseRect( dctx, &localR );
|
||||||
|
}
|
||||||
|
|
||||||
ht = localR.height >> 2;
|
ht = localR.height >> 2;
|
||||||
draw_string_at( dctx, "Pts:", ht,
|
draw_string_at( dctx, "Pts:", ht,
|
||||||
|
@ -992,7 +970,7 @@ gtk_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
|
||||||
right... */
|
right... */
|
||||||
gtkEraseRect( dctx, &localR );
|
gtkEraseRect( dctx, &localR );
|
||||||
|
|
||||||
insetRect( &localR, 1 );
|
gtkInsetRect( &localR, 1 );
|
||||||
--localR.width;
|
--localR.width;
|
||||||
--localR.height;
|
--localR.height;
|
||||||
frameRect( dctx, &localR );
|
frameRect( dctx, &localR );
|
||||||
|
|
Loading…
Add table
Reference in a new issue