mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
make color buttons owner-draw, and draw them. This fixes bug where
all are the background color, and seems to fix win32 build altogether. Wince build still needs to respond to the buttons being pressed.
This commit is contained in:
parent
d601ba3488
commit
7dccae2d3c
2 changed files with 34 additions and 27 deletions
|
@ -225,7 +225,7 @@ myChooseColor( CEAppGlobals* globals, HWND hwnd, COLORREF* cref )
|
|||
|
||||
XP_LOGF( "setting up IDD_COLOREDITDLG" );
|
||||
|
||||
result = DH(DialogBoxParam)( globals->hInst, (LPCTSTR)IDD_COLOREDITDLG, hwnd,
|
||||
result = DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLOREDITDLG, hwnd,
|
||||
(DLGPROC)EditColorsDlg, (long)&state );
|
||||
|
||||
XP_LOGF( "DialogBoxParam=>%d", result );
|
||||
|
@ -266,7 +266,6 @@ initColorData( ColorsDlgState* cState, HWND hDlg )
|
|||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
COLORREF ref = cState->inColors[i];
|
||||
cState->colors[i] = ref;
|
||||
XP_LOGF( "ref[%d] = 0x%lx", i, (unsigned long)ref );
|
||||
cState->brushes[i] = CreateSolidBrush( ref );
|
||||
cState->buttons[i] = GetDlgItem( hDlg, FIRST_BUTTON + i );
|
||||
}
|
||||
|
@ -305,6 +304,8 @@ wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
|
|||
cState->colors[index] = clrref;
|
||||
DeleteObject( cState->brushes[index] );
|
||||
cState->brushes[index] = CreateSolidBrush( clrref );
|
||||
XP_LOGF( "%s: may need to invalidate the button since color's changed",
|
||||
__FUNCTION__ );
|
||||
}
|
||||
#else
|
||||
CHOOSECOLOR ccs;
|
||||
|
@ -336,11 +337,20 @@ wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
|
|||
#endif
|
||||
} /* wrapChooseColor */
|
||||
|
||||
static void
|
||||
ceDrawColorButton( ColorsDlgState* cState, DRAWITEMSTRUCT* dis )
|
||||
{
|
||||
HBRUSH brush = brushForButton( cState, dis->hwndItem );
|
||||
XP_ASSERT( !!brush );
|
||||
FillRect( dis->hDC, &dis->rcItem, brush );
|
||||
} /* ceDrawColorButton */
|
||||
|
||||
LRESULT CALLBACK
|
||||
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
ColorsDlgState* cState;
|
||||
XP_U16 wid;
|
||||
BOOL result = FALSE;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
@ -349,7 +359,7 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
cState->cancelled = XP_TRUE;
|
||||
cState->inited = XP_FALSE;
|
||||
|
||||
return TRUE;
|
||||
result = TRUE;
|
||||
} else {
|
||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
if ( !!cState ) {
|
||||
|
@ -361,15 +371,10 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
|
||||
switch (message) {
|
||||
|
||||
case WM_CTLCOLORBTN: {
|
||||
HDC hdcButton = (HDC)wParam;
|
||||
HWND hwndButton = (HWND)lParam;
|
||||
HBRUSH brush = brushForButton( cState, hwndButton );
|
||||
/* if ( !!brush ) { */
|
||||
/* SetSysColors( hdcButton ) */
|
||||
/* } */
|
||||
return (BOOL)brush;
|
||||
}
|
||||
case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
|
||||
ceDrawColorButton( cState, (DRAWITEMSTRUCT*)lParam );
|
||||
result = TRUE;
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
wid = LOWORD(wParam);
|
||||
|
@ -382,25 +387,27 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|||
case IDCANCEL:
|
||||
deleteButtonBrushes( cState );
|
||||
EndDialog(hDlg, wid);
|
||||
return TRUE;
|
||||
result = TRUE;
|
||||
break;
|
||||
default:
|
||||
/* it's one of the color buttons. Set up with the
|
||||
appropriate color and launch ChooseColor */
|
||||
wrapChooseColor( cState, hDlg, wid );
|
||||
return TRUE;
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return result;
|
||||
} /* ColorsDlg */
|
||||
|
||||
XP_Bool
|
||||
ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors )
|
||||
{
|
||||
#if 1
|
||||
#ifdef _WIN32_WCE
|
||||
MessageBox( globals->hWnd,
|
||||
L"Color selection will be fixed in the next Beta.",
|
||||
L"Sorry...", MB_OK );
|
||||
|
|
|
@ -425,45 +425,45 @@ FONT 8, "System"
|
|||
BEGIN
|
||||
LTEXT "Dbl letter:",DLBLTR_LABEL,CLR_COL_1,CLR_ROW_1,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",DLBLTR_BUTTON,CLR_COL_2,CLR_ROW_1,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",DLBLTR_BUTTON,CLR_COL_2,CLR_ROW_1,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Dbl word:",DBLWRD_LABEL,CLR_COL_3,CLR_ROW_1,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",DBLWRD_BUTTON,CLR_COL_4,CLR_ROW_1,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",DBLWRD_BUTTON,CLR_COL_4,CLR_ROW_1,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Triple letter:",TPLLTR_LABEL,CLR_COL_1,CLR_ROW_2,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",TPLLTR_BUTTON,CLR_COL_2,CLR_ROW_2,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",TPLLTR_BUTTON,CLR_COL_2,CLR_ROW_2,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Triple word:",TPLWRD_LABEL,CLR_COL_3,CLR_ROW_2,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",TPLWRD_BUTTON,CLR_COL_4,CLR_ROW_2,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",TPLWRD_BUTTON,CLR_COL_4,CLR_ROW_2,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
|
||||
LTEXT "Empty cell:",EMPTYCELL_LABEL,CLR_COL_1,CLR_ROW_3,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",EMPCELL_BUTTON,CLR_COL_2,CLR_ROW_3,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",EMPCELL_BUTTON,CLR_COL_2,CLR_ROW_3,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Tile bkgnd:",TILEBACK_LABEL,CLR_COL_3,CLR_ROW_3,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",TBACK_BUTTON,CLR_COL_4,CLR_ROW_3,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",TBACK_BUTTON,CLR_COL_4,CLR_ROW_3,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
|
||||
LTEXT "Player 1:",PLAYER1_LABEL,CLR_COL_1,CLR_ROW_4,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",PLAYER1_BUTTON,CLR_COL_2,CLR_ROW_4,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",PLAYER1_BUTTON,CLR_COL_2,CLR_ROW_4,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Player 2:",PLAYER2_LABEL,CLR_COL_3,CLR_ROW_4,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",PLAYER2_BUTTON,CLR_COL_4,CLR_ROW_4,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",PLAYER2_BUTTON,CLR_COL_4,CLR_ROW_4,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Player 3:",PLAYER3_LABEL,CLR_COL_1,CLR_ROW_5,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",PLAYER3_BUTTON,CLR_COL_2,CLR_ROW_5,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",PLAYER3_BUTTON,CLR_COL_2,CLR_ROW_5,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
LTEXT "Player 4:",PLAYER4_LABEL,CLR_COL_3,CLR_ROW_5,
|
||||
CLR_LAB_WIDTH,CLR_LAB_HT
|
||||
PUSHBUTTON "",PLAYER4_BUTTON,CLR_COL_4,CLR_ROW_5,CLR_BUT_WIDTH,CLR_BUT_HT
|
||||
PUSHBUTTON "",PLAYER4_BUTTON,CLR_COL_4,CLR_ROW_5,CLR_BUT_WIDTH,CLR_BUT_HT,BS_OWNERDRAW
|
||||
|
||||
|
||||
DEFPUSHBUTTON "OK",IDOK,15,BUTTON_ROW,28,14
|
||||
|
|
Loading…
Reference in a new issue