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:
ehouse 2006-02-16 03:31:44 +00:00
parent d601ba3488
commit 7dccae2d3c
2 changed files with 34 additions and 27 deletions

View file

@ -225,7 +225,7 @@ myChooseColor( CEAppGlobals* globals, HWND hwnd, COLORREF* cref )
XP_LOGF( "setting up IDD_COLOREDITDLG" ); 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 ); (DLGPROC)EditColorsDlg, (long)&state );
XP_LOGF( "DialogBoxParam=>%d", result ); XP_LOGF( "DialogBoxParam=>%d", result );
@ -266,7 +266,6 @@ initColorData( ColorsDlgState* cState, HWND hDlg )
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) { for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
COLORREF ref = cState->inColors[i]; COLORREF ref = cState->inColors[i];
cState->colors[i] = ref; cState->colors[i] = ref;
XP_LOGF( "ref[%d] = 0x%lx", i, (unsigned long)ref );
cState->brushes[i] = CreateSolidBrush( ref ); cState->brushes[i] = CreateSolidBrush( ref );
cState->buttons[i] = GetDlgItem( hDlg, FIRST_BUTTON + i ); cState->buttons[i] = GetDlgItem( hDlg, FIRST_BUTTON + i );
} }
@ -305,6 +304,8 @@ wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
cState->colors[index] = clrref; cState->colors[index] = clrref;
DeleteObject( cState->brushes[index] ); DeleteObject( cState->brushes[index] );
cState->brushes[index] = CreateSolidBrush( clrref ); cState->brushes[index] = CreateSolidBrush( clrref );
XP_LOGF( "%s: may need to invalidate the button since color's changed",
__FUNCTION__ );
} }
#else #else
CHOOSECOLOR ccs; CHOOSECOLOR ccs;
@ -336,11 +337,20 @@ wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
#endif #endif
} /* wrapChooseColor */ } /* 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 LRESULT CALLBACK
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{ {
ColorsDlgState* cState; ColorsDlgState* cState;
XP_U16 wid; XP_U16 wid;
BOOL result = FALSE;
if ( message == WM_INITDIALOG ) { if ( message == WM_INITDIALOG ) {
SetWindowLong( hDlg, GWL_USERDATA, lParam ); SetWindowLong( hDlg, GWL_USERDATA, lParam );
@ -349,7 +359,7 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
cState->cancelled = XP_TRUE; cState->cancelled = XP_TRUE;
cState->inited = XP_FALSE; cState->inited = XP_FALSE;
return TRUE; result = TRUE;
} else { } else {
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA ); cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
if ( !!cState ) { if ( !!cState ) {
@ -361,15 +371,10 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
switch (message) { switch (message) {
case WM_CTLCOLORBTN: { case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
HDC hdcButton = (HDC)wParam; ceDrawColorButton( cState, (DRAWITEMSTRUCT*)lParam );
HWND hwndButton = (HWND)lParam; result = TRUE;
HBRUSH brush = brushForButton( cState, hwndButton ); break;
/* if ( !!brush ) { */
/* SetSysColors( hdcButton ) */
/* } */
return (BOOL)brush;
}
case WM_COMMAND: case WM_COMMAND:
wid = LOWORD(wParam); wid = LOWORD(wParam);
@ -382,25 +387,27 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
case IDCANCEL: case IDCANCEL:
deleteButtonBrushes( cState ); deleteButtonBrushes( cState );
EndDialog(hDlg, wid); EndDialog(hDlg, wid);
return TRUE; result = TRUE;
break;
default: default:
/* it's one of the color buttons. Set up with the /* it's one of the color buttons. Set up with the
appropriate color and launch ChooseColor */ appropriate color and launch ChooseColor */
wrapChooseColor( cState, hDlg, wid ); wrapChooseColor( cState, hDlg, wid );
return TRUE; result = TRUE;
break;
} }
} }
} }
} }
return FALSE; return result;
} /* ColorsDlg */ } /* ColorsDlg */
XP_Bool XP_Bool
ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors ) ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors )
{ {
#if 1 #ifdef _WIN32_WCE
MessageBox( globals->hWnd, MessageBox( globals->hWnd,
L"Color selection will be fixed in the next Beta.", L"Color selection will be fixed in the next Beta.",
L"Sorry...", MB_OK ); L"Sorry...", MB_OK );

View file

@ -425,45 +425,45 @@ FONT 8, "System"
BEGIN BEGIN
LTEXT "Dbl letter:",DLBLTR_LABEL,CLR_COL_1,CLR_ROW_1, LTEXT "Dbl letter:",DLBLTR_LABEL,CLR_COL_1,CLR_ROW_1,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Dbl word:",DBLWRD_LABEL,CLR_COL_3,CLR_ROW_1,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Triple letter:",TPLLTR_LABEL,CLR_COL_1,CLR_ROW_2,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Triple word:",TPLWRD_LABEL,CLR_COL_3,CLR_ROW_2,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Empty cell:",EMPTYCELL_LABEL,CLR_COL_1,CLR_ROW_3,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Tile bkgnd:",TILEBACK_LABEL,CLR_COL_3,CLR_ROW_3,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Player 1:",PLAYER1_LABEL,CLR_COL_1,CLR_ROW_4,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Player 2:",PLAYER2_LABEL,CLR_COL_3,CLR_ROW_4,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Player 3:",PLAYER3_LABEL,CLR_COL_1,CLR_ROW_5,
CLR_LAB_WIDTH,CLR_LAB_HT 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, LTEXT "Player 4:",PLAYER4_LABEL,CLR_COL_3,CLR_ROW_5,
CLR_LAB_WIDTH,CLR_LAB_HT 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 DEFPUSHBUTTON "OK",IDOK,15,BUTTON_ROW,28,14