Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch

This commit is contained in:
Eric House 2011-01-19 09:10:51 -08:00
commit 4202ea5fac
16 changed files with 384 additions and 127 deletions

View file

@ -25,6 +25,7 @@
<string name="key_tile_back">key_clr_tile_back</string> <string name="key_tile_back">key_clr_tile_back</string>
<string name="key_empty">key_clr_empty</string> <string name="key_empty">key_clr_empty</string>
<string name="key_clr_crosshairs">key_clr_crosshairs</string> <string name="key_clr_crosshairs">key_clr_crosshairs</string>
<string name="key_board_theme">key_board_theme</string>
<string name="key_relay_host">key_relay_host</string> <string name="key_relay_host">key_relay_host</string>
<string name="key_relay_port">key_relay_port2</string> <string name="key_relay_port">key_relay_port2</string>
<string name="key_proxy_port">key_proxy_port</string> <string name="key_proxy_port">key_proxy_port</string>
@ -54,6 +55,7 @@
<string name="key_notagain_conndfirst">key_notagain_conndfirst</string> <string name="key_notagain_conndfirst">key_notagain_conndfirst</string>
<string name="key_notagain_conndmid">key_notagain_conndmid</string> <string name="key_notagain_conndmid">key_notagain_conndmid</string>
<string name="key_notagain_dicts">key_notagain_dicts</string> <string name="key_notagain_dicts">key_notagain_dicts</string>
<string name="key_notagain_arrow">key_notagain_arrow</string>
<string name="relayids_extra">org.eehouse.android.xw4.relayids_extra</string> <string name="relayids_extra">org.eehouse.android.xw4.relayids_extra</string>
@ -80,6 +82,11 @@
<item>@string/robot_smart</item> <item>@string/robot_smart</item>
</string-array> </string-array>
<string-array name="board_themes">
<item>@string/black_on_white</item>
<item>@string/white_on_black</item>
</string-array>
<string-array name="connect_frequencies"> <string-array name="connect_frequencies">
<item>@string/connect_thirty_seconds</item> <item>@string/connect_thirty_seconds</item>
<item>@string/connect_five_mins</item> <item>@string/connect_five_mins</item>

View file

@ -268,7 +268,7 @@
<string name="manage_dicts">Choose</string> <string name="manage_dicts">Choose</string>
<string name="prefs_colors">Colors</string> <string name="prefs_colors">Individual colors</string>
<string name="prefs_colors_summary">Edit colors used on the board</string> <string name="prefs_colors_summary">Edit colors used on the board</string>
<string name="player0">First player</string> <string name="player0">First player</string>
<string name="player1">Second player</string> <string name="player1">Second player</string>
@ -287,6 +287,10 @@
<string name="tile_back">Tile background</string> <string name="tile_back">Tile background</string>
<string name="empty">Empty cell/background</string> <string name="empty">Empty cell/background</string>
<string name="clr_crosshairs">Crosshairs color</string> <string name="clr_crosshairs">Crosshairs color</string>
<string name="board_themes">Board color schemes</string>
<string name="white_on_black">Dark background</string>
<string name="black_on_white">Light background</string>
<string name="advanced">Advanced</string> <string name="advanced">Advanced</string>
<string name="advanced_summary">You may never need these...</string> <string name="advanced_summary">You may never need these...</string>
<string name="relay_host">Relay address</string> <string name="relay_host">Relay address</string>
@ -488,6 +492,14 @@
here. Email me at eehouse@eehouse.org for information on building here. Email me at eehouse@eehouse.org for information on building
and installing your own dictionaries.</string> and installing your own dictionaries.</string>
<string name="not_again_arrow">Moving tiles to the board:\nYou can
drag tiles between the rack and the board, or you can tap an
empty square to place the board arrow. Rack tiles you tap will
replace the arrow (moving it one square in the direction it
points.) Tap the arrow once to change its orientation; a second
time, to hide it. A checkbox in the Appearance section of
Settings will hide it permanently.</string>
<string name="relay_game_explainf">To start a basic networked two-player <string name="relay_game_explainf">To start a basic networked two-player
game in %s:</string> game in %s:</string>

View file

@ -49,11 +49,11 @@
<PreferenceScreen android:title="@string/prefs_appearance" <PreferenceScreen android:title="@string/prefs_appearance"
android:summary="@string/prefs_appearance_summary" android:summary="@string/prefs_appearance_summary"
> >
<CheckBoxPreference android:key="@string/key_color_tiles" <!-- <CheckBoxPreference android:key="@string/key_color_tiles" -->
android:title="@string/color_tiles" <!-- android:title="@string/color_tiles" -->
android:summary="@string/color_tiles_summary" <!-- android:summary="@string/color_tiles_summary" -->
android:defaultValue="true" <!-- android:defaultValue="true" -->
/> <!-- /> -->
<CheckBoxPreference android:key="@string/key_show_arrow" <CheckBoxPreference android:key="@string/key_show_arrow"
android:title="@string/show_arrow" android:title="@string/show_arrow"
android:summary="@string/show_arrow_summary" android:summary="@string/show_arrow_summary"
@ -69,6 +69,13 @@
android:summary="@string/show_bonussum_summary" android:summary="@string/show_bonussum_summary"
android:defaultValue="true" android:defaultValue="true"
/> />
<ListPreference android:key="@string/key_board_theme"
android:title="@string/board_themes"
android:entries="@array/board_themes"
android:entryValues="@array/board_themes"
android:defaultValue="@string/white_on_black"
/>
<PreferenceScreen android:title="@string/prefs_colors" <PreferenceScreen android:title="@string/prefs_colors"
android:summary="@string/prefs_colors_summary" android:summary="@string/prefs_colors_summary"
> >
@ -112,16 +119,17 @@
android:title="@string/bonus_w3x" android:title="@string/bonus_w3x"
android:defaultValue="0xAFAFAF" android:defaultValue="0xAFAFAF"
/> />
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_tile_back"
android:title="@string/tile_back"
android:defaultValue="0xFFFF99"
/>
<org.eehouse.android.xw4.EditColorPreference <org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_clr_crosshairs" android:key="@string/key_clr_crosshairs"
android:title="@string/clr_crosshairs" android:title="@string/clr_crosshairs"
android:defaultValue="0x7070FF" android:defaultValue="0x7070FF"
/> />
<org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_tile_back"
android:title="@string/tile_back"
android:defaultValue="0xFFFF99"
/>
<org.eehouse.android.xw4.EditColorPreference <org.eehouse.android.xw4.EditColorPreference
android:key="@string/key_empty" android:key="@string/key_empty"
android:title="@string/empty" android:title="@string/empty"

View file

@ -252,7 +252,8 @@ public class BoardActivity extends XWActivity implements UtilCtxt {
break; break;
default: default:
Assert.assertTrue( false ); // just drop it; super.onCreateDialog likely failed
break;
} }
} }
return dialog; return dialog;
@ -830,7 +831,7 @@ public class BoardActivity extends XWActivity implements UtilCtxt {
} ); } );
m_jniThread.start(); m_jniThread.start();
m_view.startHandling( m_jniThread, m_jniGamePtr, m_gi ); m_view.startHandling( this, m_jniThread, m_jniGamePtr, m_gi );
if ( null != m_xport ) { if ( null != m_xport ) {
m_xport.setReceiver( m_jniThread ); m_xport.setReceiver( m_jniThread );
} }

View file

@ -26,6 +26,7 @@ import android.graphics.Paint;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.*;
@ -63,9 +64,14 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private Rect m_letterRect; private Rect m_letterRect;
private Drawable m_rightArrow; private Drawable m_rightArrow;
private Drawable m_downArrow; private Drawable m_downArrow;
private boolean m_blackArrow;
// m_backgroundUsed: alpha not set ensures inequality
private int m_backgroundUsed = 0x00000000;
private boolean m_darkOnLight;
private Drawable m_origin; private Drawable m_origin;
private int m_left, m_top; private int m_left, m_top;
private JNIThread m_jniThread; private JNIThread m_jniThread;
private XWActivity m_parent;
private String[][] m_scores; private String[][] m_scores;
private String[] m_dictChars; private String[] m_dictChars;
private Rect m_boundsScratch; private Rect m_boundsScratch;
@ -110,6 +116,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private static final int BLACK = 0xFF000000; private static final int BLACK = 0xFF000000;
private static final int WHITE = 0xFFFFFFFF; private static final int WHITE = 0xFFFFFFFF;
private static final int FRAME_GREY = 0xFF101010;
private static final int GREY = 0xFF7F7F7F; private static final int GREY = 0xFF7F7F7F;
private int[] m_bonusColors; private int[] m_bonusColors;
private int[] m_playerColors; private int[] m_playerColors;
@ -171,7 +178,6 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_strokePaint.setStyle( Paint.Style.STROKE ); m_strokePaint.setStyle( Paint.Style.STROKE );
m_tileStrokePaint = new Paint(); m_tileStrokePaint = new Paint();
m_tileStrokePaint.setStyle( Paint.Style.STROKE ); m_tileStrokePaint.setStyle( Paint.Style.STROKE );
Utils.logf( "stroke starts at " + m_tileStrokePaint.getStrokeWidth() );
float curWidth = m_tileStrokePaint.getStrokeWidth(); float curWidth = m_tileStrokePaint.getStrokeWidth();
curWidth *= 2; curWidth *= 2;
if ( curWidth < 2 ) { if ( curWidth < 2 ) {
@ -180,8 +186,6 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_tileStrokePaint.setStrokeWidth( curWidth ); m_tileStrokePaint.setStrokeWidth( curWidth );
Resources res = getResources(); Resources res = getResources();
m_rightArrow = res.getDrawable( R.drawable.rightarrow );
m_downArrow = res.getDrawable( R.drawable.downarrow );
m_origin = res.getDrawable( R.drawable.origin ); m_origin = res.getDrawable( R.drawable.origin );
m_boundsScratch = new Rect(); m_boundsScratch = new Rect();
@ -286,8 +290,10 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
} // layoutBoardOnce } // layoutBoardOnce
// BoardHandler interface implementation // BoardHandler interface implementation
public void startHandling( JNIThread thread, int gamePtr, CurGameInfo gi ) public void startHandling( XWActivity parent, JNIThread thread,
int gamePtr, CurGameInfo gi )
{ {
m_parent = parent;
m_jniThread = thread; m_jniThread = thread;
m_jniGamePtr = gamePtr; m_jniGamePtr = gamePtr;
m_gi = gi; m_gi = gi;
@ -312,7 +318,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
synchronized( this ) { synchronized( this ) {
if ( null != m_canvas ) { if ( null != m_canvas ) {
if ( 0 == resID ) { if ( 0 == resID ) {
clearToBack( rect ); fillRect( rect, m_otherColors[CommonPrefs.COLOR_BKGND] );
} else { } else {
Drawable icon = getResources().getDrawable( resID ); Drawable icon = getResources().getDrawable( resID );
icon.setBounds( rect ); icon.setBounds( rect );
@ -326,7 +332,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
public boolean scoreBegin( Rect rect, int numPlayers, int[] scores, public boolean scoreBegin( Rect rect, int numPlayers, int[] scores,
int remCount, int dfs ) int remCount, int dfs )
{ {
clearToBack( rect ); fillRect( rect, WHITE );
m_canvas.save( Canvas.CLIP_SAVE_FLAG ); m_canvas.save( Canvas.CLIP_SAVE_FLAG );
m_canvas.clipRect(rect); m_canvas.clipRect(rect);
m_scores = new String[numPlayers][]; m_scores = new String[numPlayers][];
@ -434,7 +440,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
String time = String.format( "%s%d:%02d", negSign, secondsLeft/60, String time = String.format( "%s%d:%02d", negSign, secondsLeft/60,
secondsLeft%60 ); secondsLeft%60 );
clearToBack( rect ); fillRect( rect, WHITE );
m_fillPaint.setColor( m_playerColors[player] ); m_fillPaint.setColor( m_playerColors[player] );
Rect shorter = new Rect( rect ); Rect shorter = new Rect( rect );
@ -472,8 +478,13 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
} }
} }
} else if ( pending ) { } else if ( pending ) {
backColor = BLACK; if ( darkOnLight() ) {
foreColor = WHITE; foreColor = WHITE;
backColor = BLACK;
} else {
foreColor = BLACK;
backColor = WHITE;
}
} else { } else {
backColor = m_otherColors[CommonPrefs.COLOR_TILE_BACK]; backColor = m_otherColors[CommonPrefs.COLOR_TILE_BACK];
} }
@ -498,7 +509,9 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
if ( (CELL_ISBLANK & flags) != 0 ) { if ( (CELL_ISBLANK & flags) != 0 ) {
markBlank( rect, pending ); markBlank( rect, pending );
} }
// frame the cell // frame the cell
m_strokePaint.setColor( FRAME_GREY );
m_canvas.drawRect( rect, m_strokePaint ); m_canvas.drawRect( rect, m_strokePaint );
drawCrosshairs( rect, flags ); drawCrosshairs( rect, flags );
@ -506,13 +519,44 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
return true; return true;
} // drawCell } // drawCell
private boolean m_arrowHintShown = false;
public void drawBoardArrow( Rect rect, int bonus, boolean vert, public void drawBoardArrow( Rect rect, int bonus, boolean vert,
int hintAtts, int flags ) int hintAtts, int flags )
{ {
// figure out if the background is more dark than light
boolean useDark = darkOnLight();
if ( m_blackArrow != useDark ) {
m_blackArrow = useDark;
m_downArrow = m_rightArrow = null;
}
Drawable arrow;
if ( vert ) {
if ( null == m_downArrow ) {
m_downArrow = loadAndRecolor( R.drawable.downarrow, useDark );
}
arrow = m_downArrow;
} else {
if ( null == m_rightArrow ) {
m_rightArrow = loadAndRecolor( R.drawable.rightarrow, useDark );
}
arrow = m_rightArrow;
}
rect.inset( 2, 2 ); rect.inset( 2, 2 );
Drawable arrow = vert? m_downArrow : m_rightArrow;
arrow.setBounds( rect ); arrow.setBounds( rect );
arrow.draw( m_canvas ); arrow.draw( m_canvas );
if ( !m_arrowHintShown ) {
m_arrowHintShown = true;
m_viewHandler.post( new Runnable() {
public void run() {
m_parent.
showNotAgainDlgThen( R.string.not_again_arrow,
R.string.key_notagain_arrow,
null );
}
} );
}
} }
public boolean trayBegin ( Rect rect, int owner, int dfs ) public boolean trayBegin ( Rect rect, int owner, int dfs )
@ -617,7 +661,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
public void drawMiniWindow( String text, Rect rect ) public void drawMiniWindow( String text, Rect rect )
{ {
clearToBack( rect ); fillRect( rect, WHITE );
m_fillPaint.setTextSize( k_miniTextSize ); m_fillPaint.setTextSize( k_miniTextSize );
m_fillPaint.setTextAlign( Paint.Align.CENTER ); m_fillPaint.setTextAlign( Paint.Align.CENTER );
@ -679,16 +723,16 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_canvas.clipRect( rect ); m_canvas.clipRect( rect );
if ( clearBack ) { if ( clearBack ) {
clearToBack( rect ); fillRect( rect, WHITE );
} }
if ( isCursor || notEmpty ) { if ( isCursor || notEmpty ) {
int color = m_otherColors[isCursor? CommonPrefs.COLOR_FOCUS
if ( clearBack ) { : CommonPrefs.COLOR_TILE_BACK];
int indx = isCursor? CommonPrefs.COLOR_FOCUS if ( !clearBack ) {
: CommonPrefs.COLOR_TILE_BACK; color &= 0x7FFFFFFF; // translucent if being dragged.
fillRect( rect, m_otherColors[indx] );
} }
fillRect( rect, color );
m_fillPaint.setColor( m_playerColors[m_trayOwner] ); m_fillPaint.setColor( m_playerColors[m_trayOwner] );
@ -802,11 +846,6 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_canvas.drawRect( rect, m_fillPaint ); m_canvas.drawRect( rect, m_fillPaint );
} }
private void clearToBack( Rect rect )
{
fillRect( rect, m_otherColors[CommonPrefs.COLOR_BKGND] );
}
private void figureFontDims() private void figureFontDims()
{ {
if ( null == m_fontDims ) { if ( null == m_fontDims ) {
@ -891,4 +930,41 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_strokePaint.setColor( curColor ); m_strokePaint.setColor( curColor );
} }
} }
}
private boolean darkOnLight()
{
int background = m_otherColors[ CommonPrefs.COLOR_BKGND ];
if ( background != m_backgroundUsed ) {
m_backgroundUsed = background;
int sum = 0;
for ( int ii = 0; ii < 3; ++ii ) {
sum += background & 0xFF;
background >>= 8;
}
m_darkOnLight = sum > (127*3);
}
return m_darkOnLight;
}
private Drawable loadAndRecolor( int resID, boolean useDark )
{
Resources res = getResources();
Drawable arrow = res.getDrawable( resID );
if ( !useDark ) {
Bitmap src = ((BitmapDrawable)arrow).getBitmap();
Bitmap bitmap = src.copy( Bitmap.Config.ARGB_8888, true );
for ( int xx = 0; xx < bitmap.getWidth(); ++xx ) {
for( int yy = 0; yy < bitmap.getHeight(); ++yy ) {
if ( BLACK == bitmap.getPixel( xx, yy ) ) {
bitmap.setPixel( xx, yy, WHITE );
}
}
}
arrow = new BitmapDrawable(bitmap);
}
return arrow;
}
}

View file

@ -27,6 +27,7 @@ import android.database.Cursor;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import android.content.ContentValues; import android.content.ContentValues;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import junit.framework.Assert; import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.*;
@ -356,7 +357,8 @@ public class DBUtils {
} }
} }
public static void saveGame( Context context, String path, byte[] bytes ) public static void saveGame( Context context, String path, byte[] bytes,
boolean setCreate )
{ {
initDB( context ); initDB( context );
synchronized( s_dbHelper ) { synchronized( s_dbHelper ) {
@ -366,6 +368,12 @@ public class DBUtils {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put( DBHelper.SNAPSHOT, bytes ); values.put( DBHelper.SNAPSHOT, bytes );
long timestamp = new Date().getTime();
if ( setCreate ) {
values.put( DBHelper.CREATE_TIME, timestamp );
}
values.put( DBHelper.LASTPLAY_TIME, timestamp );
int result = db.update( DBHelper.TABLE_NAME_SUM, int result = db.update( DBHelper.TABLE_NAME_SUM,
values, selection, null ); values, selection, null );
if ( 0 == result ) { if ( 0 == result ) {

View file

@ -37,7 +37,7 @@ public class GameConverter {
Utils.logf( "GameConverter::convert() converting %s", Utils.logf( "GameConverter::convert() converting %s",
game ); game );
byte[] bytes = savedGame( context, game ); byte[] bytes = savedGame( context, game );
DBUtils.saveGame( context, game, bytes ); DBUtils.saveGame( context, game, bytes, true );
context.deleteFile( game ); context.deleteFile( game );
} }
} }

View file

@ -79,7 +79,7 @@ public class GameUtils {
if ( null != addr ) { if ( null != addr ) {
XwJNI.comms_setAddr( gamePtr, addr ); XwJNI.comms_setAddr( gamePtr, addr );
} }
saveGame( context, gamePtr, gi, pathOut ); saveGame( context, gamePtr, gi, pathOut, true );
GameSummary summary = new GameSummary( gi ); GameSummary summary = new GameSummary( gi );
XwJNI.game_summarize( gamePtr, summary ); XwJNI.game_summarize( gamePtr, summary );
@ -142,27 +142,29 @@ public class GameUtils {
} }
public static void saveGame( Context context, int gamePtr, public static void saveGame( Context context, int gamePtr,
CurGameInfo gi, String path ) CurGameInfo gi, String path,
boolean setCreate )
{ {
byte[] stream = XwJNI.game_saveToStream( gamePtr, gi ); byte[] stream = XwJNI.game_saveToStream( gamePtr, gi );
saveGame( context, stream, path ); saveGame( context, stream, path, setCreate );
} }
public static void saveGame( Context context, int gamePtr, public static void saveGame( Context context, int gamePtr,
CurGameInfo gi ) CurGameInfo gi )
{ {
saveGame( context, gamePtr, gi, newName( context ) ); saveGame( context, gamePtr, gi, newName( context ), false );
} }
public static void saveGame( Context context, byte[] bytes, String path ) public static void saveGame( Context context, byte[] bytes,
String path, boolean setCreate )
{ {
DBUtils.saveGame( context, path, bytes ); DBUtils.saveGame( context, path, bytes, setCreate );
} }
public static String saveGame( Context context, byte[] bytes ) public static String saveGame( Context context, byte[] bytes )
{ {
String name = newName( context ); String name = newName( context );
saveGame( context, bytes, name ); saveGame( context, bytes, name, false );
return name; return name;
} }
@ -372,7 +374,7 @@ public class GameUtils {
CommonPrefs.get( context ) ); CommonPrefs.get( context ) );
gi.dictName = dict; gi.dictName = dict;
saveGame( context, gamePtr, gi, path ); saveGame( context, gamePtr, gi, path, false );
GameSummary summary = new GameSummary( gi ); GameSummary summary = new GameSummary( gi );
XwJNI.game_summarize( gamePtr, summary ); XwJNI.game_summarize( gamePtr, summary );
@ -415,7 +417,7 @@ public class GameUtils {
XwJNI.comms_setAddr( gamePtr, car ); XwJNI.comms_setAddr( gamePtr, car );
} }
GameUtils.saveGame( context, gamePtr, gi, path ); saveGame( context, gamePtr, gi, path, false );
GameSummary summary = new GameSummary( gi ); GameSummary summary = new GameSummary( gi );
XwJNI.game_summarize( gamePtr, summary ); XwJNI.game_summarize( gamePtr, summary );

View file

@ -134,7 +134,7 @@ public class GamesList extends XWListActivity
}); });
break; break;
default: default:
Assert.fail(); // just drop it; super.onCreateDialog likely failed
break; break;
} }
} }

View file

@ -31,6 +31,7 @@ import android.preference.PreferenceManager;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MenuInflater; import android.view.MenuInflater;
import java.util.HashSet;
public class PrefsActivity extends PreferenceActivity public class PrefsActivity extends PreferenceActivity
implements SharedPreferences.OnSharedPreferenceChangeListener { implements SharedPreferences.OnSharedPreferenceChangeListener {
@ -38,7 +39,11 @@ public class PrefsActivity extends PreferenceActivity
private static final int REVERT_COLORS = 1; private static final int REVERT_COLORS = 1;
private static final int REVERT_ALL = 2; private static final int REVERT_ALL = 2;
private String[] m_keys; private HashSet<String> m_keys;
private String m_boardThemeKey;
private String m_keyEmpty;
private String m_whiteOnBlack;
private String m_blackOnWhite;
@Override @Override
protected Dialog onCreateDialog( int id ) protected Dialog onCreateDialog( int id )
@ -118,17 +123,22 @@ public class PrefsActivity extends PreferenceActivity
R.string.key_initial_player_minutes, R.string.key_initial_player_minutes,
R.string.key_default_dict, R.string.key_default_dict,
R.string.key_default_phonies, R.string.key_default_phonies,
R.string.key_board_theme,
}; };
SharedPreferences sp SharedPreferences sp
= PreferenceManager.getDefaultSharedPreferences( this ); = PreferenceManager.getDefaultSharedPreferences( this );
m_keys = new String[ textKeyIds.length ]; m_keys = new HashSet<String>( textKeyIds.length );
for ( int ii = 0; ii < textKeyIds.length; ++ii ) { for ( int ii = 0; ii < textKeyIds.length; ++ii ) {
int id = textKeyIds[ii]; int id = textKeyIds[ii];
String key = getString( id ); String key = getString( id );
setSummary( sp, key ); setSummary( sp, key );
m_keys[ii] = key; m_keys.add( key );
} }
m_boardThemeKey = getString( R.string.key_board_theme );
m_keyEmpty = getString( R.string.key_empty );
m_whiteOnBlack = getString( R.string.white_on_black );
m_blackOnWhite = getString( R.string.black_on_white );
} }
@Override @Override
@ -149,11 +159,28 @@ public class PrefsActivity extends PreferenceActivity
public void onSharedPreferenceChanged( SharedPreferences sp, String key ) public void onSharedPreferenceChanged( SharedPreferences sp, String key )
{ {
for ( String akey : m_keys ) { if ( m_keys.contains( key ) ) {
if ( akey.equals( key ) ) { setSummary( sp, key );
setSummary( sp, key ); }
// Change those color elements that follow the "themes" --
// currently only key_empty
while ( m_boardThemeKey.equals( key ) ) { // while allows break
String newValue = sp.getString( key, "" );
int color;
if ( m_whiteOnBlack.equals( newValue ) ) {
color = 0xFF000000;
} else if ( m_blackOnWhite.equals( newValue ) ) {
color = 0xFFFFFFFF;
} else {
break; break;
} }
SharedPreferences.Editor editor = sp.edit();
editor.putInt( m_keyEmpty, color );
editor.commit();
break;
} }
} }

View file

@ -1,3 +1,4 @@
/* -*- compile-command: "cd ../../../../../../; ant install"; -*- */
/* /*
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
* rights reserved. * rights reserved.
@ -19,8 +20,11 @@
package org.eehouse.android.xw4.jni; package org.eehouse.android.xw4.jni;
import org.eehouse.android.xw4.XWActivity;
public interface BoardHandler { public interface BoardHandler {
void startHandling( JNIThread thread, int gamePtr, CurGameInfo gi ); void startHandling( XWActivity parent, JNIThread thread,
int gamePtr, CurGameInfo gi );
} }

View file

@ -262,7 +262,7 @@ public class JNIThread extends Thread {
GameSummary summary = new GameSummary( m_gi ); GameSummary summary = new GameSummary( m_gi );
XwJNI.game_summarize( m_jniGamePtr, summary ); XwJNI.game_summarize( m_jniGamePtr, summary );
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null ); byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
GameUtils.saveGame( m_context, state, m_path ); GameUtils.saveGame( m_context, state, m_path, false );
DBUtils.saveSummary( m_context, m_path, summary ); DBUtils.saveSummary( m_context, m_path, summary );
break; break;

View file

@ -1689,7 +1689,7 @@ server_setGameOverListener( ServerCtxt* server, GameOverListener gol,
{ {
server->vol.gameOverListener = gol; server->vol.gameOverListener = gol;
server->vol.gameOverData = data; server->vol.gameOverData = data;
} /* server_setTurnChangeListener */ } /* server_setGameOverListener */
static XP_Bool static XP_Bool
storeBadWords( XP_UCHAR* word, void* closure ) storeBadWords( XP_UCHAR* word, void* closure )

View file

@ -37,6 +37,7 @@ ifdef CURSES_SMALL_SCREEN
DO_CURSES += -DCURSES_SMALL_SCREEN DO_CURSES += -DCURSES_SMALL_SCREEN
endif endif
DO_GTK = -DPLATFORM_GTK DO_GTK = -DPLATFORM_GTK
# DO_GTK += -DUSE_CAIRO
# uncomment for standalone build # uncomment for standalone build
# STANDALONE = -DXWFEATURE_STANDALONE_ONLY # STANDALONE = -DXWFEATURE_STANDALONE_ONLY
@ -178,8 +179,8 @@ endif
ifneq (,$(findstring DPLATFORM_GTK,$(DEFINES))) ifneq (,$(findstring DPLATFORM_GTK,$(DEFINES)))
LIBS += `pkg-config --libs gtk+-2.0` LIBS += `pkg-config --libs gtk+-2.0`
CFLAGS += `pkg-config --cflags gtk+-2.0` \ CFLAGS += `pkg-config --cflags gtk+-2.0`
-DGDK_DISABLE_DEPRECATED # CFLAGS += -DGDK_DISABLE_DEPRECATED
POINTER_SUPPORT = -DPOINTER_SUPPORT POINTER_SUPPORT = -DPOINTER_SUPPORT
endif endif

View file

@ -22,8 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#undef GDK_DISABLE_DEPRECATED
#include <gdk/gdkdrawable.h> #include <gdk/gdkdrawable.h>
#include "gtkmain.h" #include "gtkmain.h"
@ -64,31 +62,75 @@ gtkInsetRect( XP_Rect* r, short i )
#define GTKMIN_W_HT 12 #define GTKMIN_W_HT 12
#ifdef USE_CAIRO
# define XP_UNUSED_CAIRO(var) UNUSED__ ## var __attribute__((unused))
#else
# define XP_UNUSED_CAIRO(var) var
#endif
static void
draw_rectangle( const GtkDrawCtx* dctx,
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 );
/* } else { */
cairo_stroke( dctx->cr );
/* } */
fill = fill;
#else
dctx = dctx;
gdk_draw_rectangle( drawable, gc, fill, left, top, width, height );
#endif
}
static void static void
gtkFillRect( GtkDrawCtx* dctx, const XP_Rect* rect, const GdkColor* color ) gtkFillRect( GtkDrawCtx* dctx, const XP_Rect* rect, const GdkColor* color )
{ {
#ifdef USE_CAIRO
color = color;
//gdk_cairo_set_source_color( dctx->cr, color );
#else
gdk_gc_set_foreground( dctx->drawGC, color ); gdk_gc_set_foreground( dctx->drawGC, color );
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, #endif
TRUE, draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
rect->left, rect->top, rect->width, rect->left, rect->top, rect->width,
rect->height ); rect->height );
}
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 );
} }
static void static void
gtkEraseRect( const GtkDrawCtx* dctx, const XP_Rect* rect ) gtkEraseRect( const GtkDrawCtx* dctx, const XP_Rect* rect )
{ {
gdk_draw_rectangle( DRAW_WHAT(dctx), set_color_cairo( dctx, 0xFFFF, 0xFFFF, 0xFFFF );
dctx->drawing_area->style->white_gc, draw_rectangle( dctx, DRAW_WHAT(dctx),
TRUE, rect->left, rect->top, dctx->drawing_area->style->white_gc,
rect->width, rect->height ); TRUE, rect->left, rect->top,
rect->width, rect->height );
} /* gtkEraseRect */ } /* gtkEraseRect */
static void static void
frameRect( GtkDrawCtx* dctx, const XP_Rect* rect ) frameRect( GtkDrawCtx* dctx, const XP_Rect* rect )
{ {
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC,
dctx->drawGC, FALSE, rect->left, rect->top, FALSE, rect->left, rect->top,
rect->width, rect->height ); rect->width, rect->height );
} /* frameRect */ } /* frameRect */
#ifdef DRAW_WITH_PRIMITIVES #ifdef DRAW_WITH_PRIMITIVES
@ -225,9 +267,14 @@ draw_string_at( GtkDrawCtx* dctx, PangoLayout* layout,
} }
} }
#ifdef USE_CAIRO
frground = frground;
bkgrnd = bkgrnd;
#else
gdk_draw_layout_with_colors( DRAW_WHAT(dctx), dctx->drawGC, gdk_draw_layout_with_colors( DRAW_WHAT(dctx), dctx->drawGC,
xx, yy, layout, xx, yy, layout,
frground, bkgrnd ); frground, bkgrnd );
#endif
} /* draw_string_at */ } /* draw_string_at */
static void static void
@ -248,8 +295,8 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
pm = gdk_pixmap_new( DRAW_WHAT(dctx), nCols, nRows, -1 ); pm = gdk_pixmap_new( DRAW_WHAT(dctx), nCols, nRows, -1 );
gdk_draw_rectangle( pm, dctx->drawing_area->style->white_gc, TRUE, draw_rectangle( dctx, pm, dctx->drawing_area->style->white_gc, TRUE,
0, 0, nCols, nRows ); 0, 0, nCols, nRows );
x = 0; x = 0;
y = 0; y = 0;
@ -259,7 +306,10 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
for ( i = 0; i < 8; ++i ) { for ( i = 0; i < 8; ++i ) {
XP_Bool draw = ((byte & 0x80) != 0); XP_Bool draw = ((byte & 0x80) != 0);
if ( draw ) { if ( draw ) {
#ifdef USE_CAIRO
#else
gdk_draw_point( pm, dctx->drawing_area->style->black_gc, x, y ); gdk_draw_point( pm, dctx->drawing_area->style->black_gc, x, y );
#endif
} }
byte <<= 1; byte <<= 1;
if ( ++x == nCols ) { if ( ++x == nCols ) {
@ -273,6 +323,9 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
XP_ASSERT( nBytes == -1 ); /* else we're out of sync */ XP_ASSERT( nBytes == -1 ); /* else we're out of sync */
#ifdef USE_CAIRO
rect = rect;
#else
gdk_draw_drawable( DRAW_WHAT(dctx), gdk_draw_drawable( DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
(GdkDrawable*)pm, 0, 0, (GdkDrawable*)pm, 0, 0,
@ -280,7 +333,7 @@ drawBitmapFromLBS( GtkDrawCtx* dctx, const XP_Bitmap bm, const XP_Rect* rect )
rect->top+2, rect->top+2,
lbs->nCols, lbs->nCols,
lbs->nRows ); lbs->nRows );
#endif
g_object_unref( pm ); g_object_unref( pm );
} /* drawBitmapFromLBS */ } /* drawBitmapFromLBS */
@ -299,10 +352,10 @@ gtk_draw_destroyCtxt( DrawCtx* p_dctx )
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
GtkAllocation* alloc = &dctx->drawing_area->allocation; GtkAllocation* alloc = &dctx->drawing_area->allocation;
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawing_area->style->white_gc, dctx->drawing_area->style->white_gc,
TRUE, TRUE,
0, 0, alloc->width, alloc->height ); 0, 0, alloc->width, alloc->height );
g_list_foreach( dctx->fontsPerSize, freer, NULL ); g_list_foreach( dctx->fontsPerSize, freer, NULL );
g_list_free( dctx->fontsPerSize ); g_list_free( dctx->fontsPerSize );
@ -328,7 +381,11 @@ gtk_draw_boardBegin( DrawCtx* p_dctx, const XP_Rect* rect,
dctx->cellWidth = width; dctx->cellWidth = width;
dctx->cellHeight = height; dctx->cellHeight = height;
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
gdkrect = *(GdkRectangle*)rect; gdkrect = *(GdkRectangle*)rect;
++gdkrect.width; ++gdkrect.width;
@ -364,6 +421,9 @@ gtk_draw_vertScrollBoard( DrawCtx* p_dctx, XP_Rect* rect,
ysrc = ydest + dist; ysrc = ydest + dist;
} }
#ifdef USE_CAIRO
dctx = dctx;
#else
gdk_draw_drawable( DRAW_WHAT(dctx), gdk_draw_drawable( DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
DRAW_WHAT(dctx), DRAW_WHAT(dctx),
@ -373,7 +433,7 @@ gtk_draw_vertScrollBoard( DrawCtx* p_dctx, XP_Rect* rect,
ydest, ydest,
rect->width, rect->width,
rect->height - dist ); rect->height - dist );
#endif
if ( !down ) { if ( !down ) {
rect->top += rect->height - dist; rect->top += rect->height - dist;
} }
@ -391,33 +451,37 @@ drawHintBorders( GtkDrawCtx* dctx, const XP_Rect* rect, HintAtts hintAtts)
XP_Rect lrect = *rect; XP_Rect lrect = *rect;
gtkInsetRect( &lrect, 1 ); gtkInsetRect( &lrect, 1 );
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
#endif
if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) { if ( (hintAtts & HINT_BORDER_LEFT) != 0 ) {
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
FALSE, lrect.left, lrect.top, FALSE, lrect.left, lrect.top,
0, lrect.height); 0, lrect.height);
} }
if ( (hintAtts & HINT_BORDER_TOP) != 0 ) { if ( (hintAtts & HINT_BORDER_TOP) != 0 ) {
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
FALSE, lrect.left, lrect.top, FALSE, lrect.left, lrect.top,
lrect.width, 0/*rectInset.height*/); lrect.width, 0/*rectInset.height*/);
} }
if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) { if ( (hintAtts & HINT_BORDER_RIGHT) != 0 ) {
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
FALSE, lrect.left+lrect.width, FALSE, lrect.left+lrect.width,
lrect.top, lrect.top,
0, lrect.height); 0, lrect.height);
} }
if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) { if ( (hintAtts & HINT_BORDER_BOTTOM) != 0 ) {
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
FALSE, lrect.left, FALSE, lrect.left,
lrect.top+lrect.height, lrect.top+lrect.height,
lrect.width, 0 ); lrect.width, 0 );
} }
} }
} }
@ -462,12 +526,16 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
gtkInsetRect( &rectInset, 1 ); gtkInsetRect( &rectInset, 1 );
if ( showGrid ) { if ( showGrid ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
gdk_draw_rectangle( DRAW_WHAT(dctx), #endif
dctx->drawGC, draw_rectangle( dctx, DRAW_WHAT(dctx),
FALSE, dctx->drawGC,
rect->left, rect->top, rect->width, FALSE,
rect->height ); rect->left, rect->top, rect->width,
rect->height );
} }
/* We draw just an empty, potentially colored, square IFF there's nothing /* We draw just an empty, potentially colored, square IFF there's nothing
@ -483,10 +551,14 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
foreground = NULL; foreground = NULL;
} }
if ( !!foreground ) { if ( !!foreground ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, foreground );
#else
gdk_gc_set_foreground( dctx->drawGC, foreground ); gdk_gc_set_foreground( dctx->drawGC, foreground );
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, TRUE, #endif
rectInset.left, rectInset.top, draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
rectInset.width+1, rectInset.height+1 ); rectInset.left, rectInset.top,
rectInset.width+1, rectInset.height+1 );
} }
} }
if ( (flags & CELL_ISSTAR) != 0 ) { if ( (flags & CELL_ISSTAR) != 0 ) {
@ -499,13 +571,21 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
XP_Bool isBlank = (flags & CELL_ISBLANK) != 0; XP_Bool isBlank = (flags & CELL_ISBLANK) != 0;
GdkColor* foreground; GdkColor* foreground;
if ( cursor ) { if ( cursor ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, cursor );
#else
gdk_gc_set_foreground( dctx->drawGC, cursor ); gdk_gc_set_foreground( dctx->drawGC, cursor );
#endif
} else if ( !highlight ) { } else if ( !highlight ) {
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->tileBack );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->tileBack ); gdk_gc_set_foreground( dctx->drawGC, &dctx->tileBack );
#endif
} }
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, TRUE, draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC, TRUE,
rectInset.left, rectInset.top, rectInset.left, rectInset.top,
rectInset.width+1, rectInset.height+1 ); rectInset.width+1, rectInset.height+1 );
if ( isBlank && 0 == strcmp("_",letter ) ) { if ( isBlank && 0 == strcmp("_",letter ) ) {
letter = "?"; letter = "?";
@ -517,6 +597,8 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
XP_GTK_JUST_CENTER, foreground, cursor ); XP_GTK_JUST_CENTER, foreground, cursor );
if ( isBlank ) { if ( isBlank ) {
#ifdef USE_CAIRO
#else
gdk_draw_arc( DRAW_WHAT(dctx), dctx->drawGC, gdk_draw_arc( DRAW_WHAT(dctx), dctx->drawGC,
0, /* filled */ 0, /* filled */
rect->left, /* x */ rect->left, /* x */
@ -524,6 +606,7 @@ gtk_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* letter,
rect->width,/*width, */ rect->width,/*width, */
rect->height,/*width, */ rect->height,/*width, */
0, 360*64 ); 0, 360*64 );
#endif
} }
} }
@ -547,7 +630,7 @@ gtk_draw_invertCell( DrawCtx* XP_UNUSED(p_dctx),
/* gdk_gc_set_function( dctx->drawGC, GDK_INVERT ); */ /* gdk_gc_set_function( dctx->drawGC, GDK_INVERT ); */
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */ /* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rect ); */
/* gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, */ /* draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, */
/* TRUE, rect->left, rect->top, */ /* TRUE, rect->left, rect->top, */
/* rect->width, rect->height ); */ /* rect->width, rect->height ); */
@ -617,19 +700,23 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
} }
/* frame the tile */ /* frame the tile */
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
gdk_draw_rectangle( DRAW_WHAT(dctx), #endif
dctx->drawGC, draw_rectangle( dctx, DRAW_WHAT(dctx),
FALSE, dctx->drawGC,
insetR.left, insetR.top, insetR.width, FALSE,
insetR.height ); insetR.left, insetR.top, insetR.width,
insetR.height );
if ( (flags & CELL_HIGHLIGHT) != 0 ) { if ( (flags & CELL_HIGHLIGHT) != 0 ) {
gtkInsetRect( &insetR, 1 ); gtkInsetRect( &insetR, 1 );
gdk_draw_rectangle( DRAW_WHAT(dctx), draw_rectangle( dctx, DRAW_WHAT(dctx),
dctx->drawGC, dctx->drawGC,
FALSE, insetR.left, insetR.top, FALSE, insetR.left, insetR.top,
insetR.width, insetR.height); insetR.width, insetR.height);
} }
} }
} /* gtkDrawTileImpl */ } /* gtkDrawTileImpl */
@ -693,11 +780,15 @@ gtk_draw_drawTrayDivider( DrawCtx* p_dctx, const XP_Rect* rect,
--r.height; --r.height;
} }
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
gdk_draw_rectangle( DRAW_WHAT(dctx), #endif
dctx->drawGC, draw_rectangle( dctx, DRAW_WHAT(dctx),
!selected, dctx->drawGC,
r.left, r.top, r.width, r.height); !selected,
r.left, r.top, r.width, r.height);
} /* gtk_draw_drawTrayDivider */ } /* gtk_draw_drawTrayDivider */
@ -940,7 +1031,11 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
gtkFillRect( dctx, rOuter, cursor ); gtkFillRect( dctx, rOuter, cursor );
} }
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->playerColors[playerNum] );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[playerNum] ); gdk_gc_set_foreground( dctx->drawGC, &dctx->playerColors[playerNum] );
#endif
if ( dsi->selected ) { if ( dsi->selected ) {
XP_Rect selRect = *rOuter; XP_Rect selRect = *rOuter;
@ -960,9 +1055,9 @@ gtk_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner,
} }
} }
gdk_draw_rectangle( DRAW_WHAT(dctx), dctx->drawGC, draw_rectangle( dctx, DRAW_WHAT(dctx), dctx->drawGC,
TRUE, selRect.left, selRect.top, TRUE, selRect.left, selRect.top,
selRect.width, selRect.height ); selRect.width, selRect.height );
if ( hasCursor ) { if ( hasCursor ) {
gtkFillRect( dctx, rInner, cursor ); gtkFillRect( dctx, rInner, cursor );
} }
@ -1099,8 +1194,11 @@ gtk_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text,
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Rect localR = *rect; XP_Rect localR = *rect;
#ifdef USE_CAIRO
//gdk_cairo_set_source_color( dctx->cr, &dctx->black );
#else
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)&localR ); */ #endif
/* play some skanky games to get the shadow drawn under and to the /* play some skanky games to get the shadow drawn under and to the
right... */ right... */
@ -1227,7 +1325,16 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkAppGlobals* globals )
} else { } else {
window = GTK_WIDGET(drawing_area)->window; window = GTK_WIDGET(drawing_area)->window;
} }
window = GTK_WIDGET(drawing_area)->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 );
#else
dctx->drawGC = gdk_gc_new( window ); dctx->drawGC = gdk_gc_new( window );
#endif
} }
map = gdk_colormap_get_system(); map = gdk_colormap_get_system();

View file

@ -47,7 +47,11 @@ typedef struct GtkDrawCtx {
GtkWidget* drawing_area; GtkWidget* drawing_area;
struct GtkAppGlobals* globals; struct GtkAppGlobals* globals;
#ifdef USE_CAIRO
cairo_t* cr;
#else
GdkGC* drawGC; GdkGC* drawGC;
#endif
GdkColor black; GdkColor black;
GdkColor white; GdkColor white;