2008-02-22 14:27:33 +01:00
|
|
|
/* -*- fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE" -*- */
|
2004-03-28 03:15:24 +02:00
|
|
|
/*
|
2008-02-22 14:27:33 +01:00
|
|
|
* Copyright 2004-2008 by Eric House (xwords@eehouse.org). All rights reserved.
|
2004-03-28 03:15:24 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2005-11-27 21:04:06 +01:00
|
|
|
#include <windowsx.h>
|
2004-03-28 03:15:24 +02:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include <commdlg.h>
|
|
|
|
|
|
|
|
#include "ceclrsel.h"
|
2004-04-03 17:29:34 +02:00
|
|
|
#include "ceutil.h"
|
2008-02-22 14:27:33 +01:00
|
|
|
#include "cedebug.h"
|
2006-01-28 20:03:10 +01:00
|
|
|
#include "debhacks.h"
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
#ifdef MY_COLOR_SEL
|
|
|
|
|
|
|
|
typedef struct ClrEditDlgState {
|
|
|
|
CEAppGlobals* globals;
|
|
|
|
|
|
|
|
RECT clrRect;
|
2008-02-26 14:31:36 +01:00
|
|
|
HWND parent;
|
|
|
|
XP_U16 labelID;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
XP_U8 r;
|
|
|
|
XP_U8 b;
|
|
|
|
XP_U8 g;
|
|
|
|
|
|
|
|
XP_Bool inited;
|
|
|
|
XP_Bool cancelled;
|
|
|
|
} ClrEditDlgState;
|
|
|
|
|
|
|
|
static void
|
|
|
|
drawColorRect( ClrEditDlgState* eState, HDC hdc )
|
|
|
|
{
|
|
|
|
COLORREF ref = RGB( eState->r, eState->g, eState->b );
|
|
|
|
HBRUSH brush = CreateSolidBrush( ref );
|
|
|
|
FillRect( hdc, &eState->clrRect, brush );
|
|
|
|
DeleteObject( brush );
|
|
|
|
} /* drawColorRect */
|
|
|
|
|
|
|
|
static void
|
|
|
|
initEditAndSlider( HWND hDlg, XP_U16 sliderID, XP_U8 val )
|
|
|
|
{
|
|
|
|
SendDlgItemMessage( hDlg, sliderID, TBM_SETRANGE, TRUE,
|
|
|
|
MAKELONG(0,255) );
|
|
|
|
SendDlgItemMessage( hDlg, sliderID, TBM_SETPOS, TRUE,
|
|
|
|
(long)val );
|
2004-04-14 06:05:00 +02:00
|
|
|
ceSetDlgItemNum( hDlg, sliderID+1, val );
|
2004-04-03 17:29:34 +02:00
|
|
|
} /* initEditAndSlider */
|
|
|
|
|
|
|
|
static void
|
|
|
|
initChooseColor( ClrEditDlgState* eState, HWND hDlg )
|
|
|
|
{
|
2004-04-15 04:18:13 +02:00
|
|
|
eState->clrRect.left = 162;
|
2004-04-09 04:36:48 +02:00
|
|
|
eState->clrRect.top = 5;
|
2004-04-15 04:18:13 +02:00
|
|
|
eState->clrRect.right = 193;
|
2004-04-09 04:36:48 +02:00
|
|
|
eState->clrRect.bottom = 90;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
InvalidateRect( hDlg, &eState->clrRect, FALSE );
|
|
|
|
|
|
|
|
initEditAndSlider( hDlg, CLREDT_SLIDER1, eState->r );
|
|
|
|
initEditAndSlider( hDlg, CLREDT_SLIDER2, eState->g );
|
|
|
|
initEditAndSlider( hDlg, CLREDT_SLIDER3, eState->b );
|
|
|
|
} /* initChooseColor */
|
|
|
|
|
2004-04-09 04:36:48 +02:00
|
|
|
static XP_U8*
|
|
|
|
colorForSlider( ClrEditDlgState* eState, XP_U16 sliderID )
|
2004-04-03 17:29:34 +02:00
|
|
|
{
|
2004-04-09 04:36:48 +02:00
|
|
|
switch( sliderID ) {
|
|
|
|
case CLREDT_SLIDER1:
|
|
|
|
return &eState->r;
|
|
|
|
case CLREDT_SLIDER2:
|
|
|
|
return &eState->g;
|
|
|
|
case CLREDT_SLIDER3:
|
|
|
|
return &eState->b;
|
|
|
|
default:
|
|
|
|
XP_LOGF( "huh???" );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} /* colorForSlider */
|
2004-04-03 17:29:34 +02:00
|
|
|
|
2004-04-09 04:36:48 +02:00
|
|
|
static void
|
|
|
|
updateForSlider( HWND hDlg, ClrEditDlgState* eState, XP_U16 sliderID )
|
|
|
|
{
|
2004-04-14 05:56:12 +02:00
|
|
|
XP_U8 newColor = (XP_U8)SendDlgItemMessage( hDlg, sliderID, TBM_GETPOS,
|
|
|
|
0, 0L );
|
2004-04-09 04:36:48 +02:00
|
|
|
XP_U8* colorPtr = colorForSlider( eState, sliderID );
|
|
|
|
if ( newColor != *colorPtr ) {
|
|
|
|
*colorPtr = newColor;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
2004-04-09 04:36:48 +02:00
|
|
|
ceSetDlgItemNum( hDlg, sliderID+1, (XP_S32)newColor );
|
|
|
|
|
|
|
|
InvalidateRect( hDlg, &eState->clrRect, FALSE );
|
|
|
|
}
|
|
|
|
} /* updateForSlider */
|
|
|
|
|
|
|
|
static void
|
|
|
|
updateForField( HWND hDlg, ClrEditDlgState* eState, XP_U16 fieldID )
|
|
|
|
{
|
|
|
|
XP_S32 newColor = ceGetDlgItemNum( hDlg, fieldID );
|
|
|
|
XP_U8* colorPtr = colorForSlider( eState, fieldID - 1 );
|
|
|
|
XP_Bool modified = XP_FALSE;;
|
|
|
|
|
|
|
|
if ( newColor > 255 ) {
|
|
|
|
newColor = 255;
|
|
|
|
modified = XP_TRUE;
|
|
|
|
} else if ( newColor < 0 ) {
|
|
|
|
newColor = 0;
|
|
|
|
modified = XP_TRUE;
|
|
|
|
}
|
|
|
|
if ( modified ) {
|
|
|
|
ceSetDlgItemNum( hDlg, fieldID, newColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( newColor != *colorPtr ) {
|
2004-04-14 05:56:12 +02:00
|
|
|
*colorPtr = (XP_U8)newColor;
|
2004-04-09 04:36:48 +02:00
|
|
|
|
|
|
|
SendDlgItemMessage( hDlg, fieldID-1, TBM_SETPOS, TRUE,
|
|
|
|
(long)newColor );
|
|
|
|
InvalidateRect( hDlg, &eState->clrRect, FALSE );
|
|
|
|
}
|
|
|
|
} /* updateForField */
|
2004-04-03 17:29:34 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
LRESULT CALLBACK
|
2004-04-03 17:29:34 +02:00
|
|
|
EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
ClrEditDlgState* eState;
|
|
|
|
XP_U16 wid;
|
2004-04-09 04:36:48 +02:00
|
|
|
XP_U16 notifyCode;
|
2004-04-03 17:29:34 +02:00
|
|
|
NMTOOLBAR* nmToolP;
|
|
|
|
|
|
|
|
if ( message == WM_INITDIALOG ) {
|
|
|
|
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
|
|
|
|
|
|
|
eState = (ClrEditDlgState*)lParam;
|
|
|
|
eState->cancelled = XP_TRUE;
|
|
|
|
eState->inited = XP_FALSE;
|
|
|
|
|
2006-05-28 00:19:30 +02:00
|
|
|
ceStackButtonsRight( eState->globals, hDlg );
|
|
|
|
|
2008-02-26 14:31:36 +01:00
|
|
|
wchar_t label[32];
|
|
|
|
XP_U16 len = SendDlgItemMessage( eState->parent, eState->labelID,
|
|
|
|
WM_GETTEXT, VSIZE(label),
|
|
|
|
(long)label );
|
|
|
|
if ( len > 0 ) {
|
|
|
|
label[len-1] = 0; /* hack: overwrite ':' */
|
|
|
|
}
|
|
|
|
wchar_t buf[64];
|
|
|
|
swprintf( buf, L"Edit color for %s", label );
|
|
|
|
SendMessage( hDlg, WM_SETTEXT, 0, buf );
|
|
|
|
|
2004-04-03 17:29:34 +02:00
|
|
|
return TRUE;
|
|
|
|
} else {
|
|
|
|
eState = (ClrEditDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
2004-05-26 06:46:57 +02:00
|
|
|
if ( !eState ) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
if ( !eState->inited ) {
|
|
|
|
/* set to true first! Messages will be generated by
|
|
|
|
initChooseColor call below */
|
|
|
|
eState->inited = XP_TRUE;
|
|
|
|
initChooseColor( eState, hDlg );
|
|
|
|
XP_LOGF( "initChooseColor done" );
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (message) {
|
|
|
|
|
|
|
|
case WM_PAINT: {
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc = BeginPaint( hDlg, &ps );
|
|
|
|
drawColorRect( eState, hdc );
|
|
|
|
EndPaint( hDlg, &ps );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-04-09 04:36:48 +02:00
|
|
|
case WM_NOTIFY:
|
|
|
|
nmToolP = (NMTOOLBAR*)lParam;
|
|
|
|
wid = nmToolP->hdr.idFrom;
|
|
|
|
switch ( wid ) {
|
|
|
|
case CLREDT_SLIDER1:
|
|
|
|
case CLREDT_SLIDER2:
|
|
|
|
case CLREDT_SLIDER3:
|
|
|
|
updateForSlider( hDlg, eState, wid );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
wid = LOWORD(wParam);
|
|
|
|
switch( wid ) {
|
2004-04-09 04:36:48 +02:00
|
|
|
case RED_EDIT:
|
|
|
|
case GREEN_EDIT:
|
|
|
|
case BLUE_EDIT:
|
|
|
|
notifyCode = HIWORD(wParam);
|
|
|
|
if ( notifyCode == EN_CHANGE ) {
|
|
|
|
updateForField( hDlg, eState, wid );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
case IDOK:
|
|
|
|
eState->cancelled = XP_FALSE;
|
|
|
|
/* fallthrough */
|
2004-04-09 04:36:48 +02:00
|
|
|
|
2004-04-03 17:29:34 +02:00
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, wid);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
} /* EditColorsDlg */
|
|
|
|
|
|
|
|
static XP_Bool
|
2008-02-26 14:31:36 +01:00
|
|
|
myChooseColor( CEAppGlobals* globals, HWND parent, XP_U16 labelID,
|
|
|
|
COLORREF* cref )
|
2004-04-03 17:29:34 +02:00
|
|
|
{
|
|
|
|
ClrEditDlgState state;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
XP_MEMSET( &state, 0, sizeof(state) );
|
|
|
|
state.globals = globals;
|
|
|
|
state.r = GetRValue(*cref);
|
|
|
|
state.g = GetGValue(*cref);
|
|
|
|
state.b = GetBValue(*cref);
|
2008-02-26 14:31:36 +01:00
|
|
|
state.labelID = labelID;
|
|
|
|
state.parent = parent;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
XP_LOGF( "setting up IDD_COLOREDITDLG" );
|
|
|
|
|
2008-02-26 14:31:36 +01:00
|
|
|
result = DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLOREDITDLG,
|
|
|
|
parent, (DLGPROC)EditColorsDlg, (long)&state );
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
XP_LOGF( "DialogBoxParam=>%d", result );
|
|
|
|
|
|
|
|
if ( !state.cancelled ) {
|
|
|
|
*cref = RGB( state.r, state.g, state.b );
|
|
|
|
}
|
|
|
|
|
|
|
|
return !state.cancelled;
|
|
|
|
} /* myChooseColor */
|
|
|
|
|
2006-02-14 05:52:31 +01:00
|
|
|
#endif /* MY_COLOR_SEL */
|
2004-03-28 03:15:24 +02:00
|
|
|
|
|
|
|
typedef struct ColorsDlgState {
|
|
|
|
|
|
|
|
CEAppGlobals* globals;
|
2004-04-14 05:56:12 +02:00
|
|
|
COLORREF* inColors;
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2007-01-19 07:43:52 +01:00
|
|
|
COLORREF colors[CE_NUM_EDITABLE_COLORS];
|
|
|
|
HBRUSH brushes[CE_NUM_EDITABLE_COLORS];
|
|
|
|
HWND buttons[CE_NUM_EDITABLE_COLORS];
|
2004-03-28 03:15:24 +02:00
|
|
|
|
|
|
|
XP_Bool cancelled;
|
|
|
|
XP_Bool inited;
|
|
|
|
} ColorsDlgState;
|
|
|
|
|
|
|
|
#define FIRST_BUTTON DLBLTR_BUTTON
|
|
|
|
#define LAST_BUTTON PLAYER4_BUTTON
|
|
|
|
|
|
|
|
static void
|
|
|
|
initColorData( ColorsDlgState* cState, HWND hDlg )
|
|
|
|
{
|
|
|
|
XP_U16 i;
|
|
|
|
|
2007-01-19 07:43:52 +01:00
|
|
|
XP_ASSERT( (LAST_BUTTON - FIRST_BUTTON + 1) == CE_NUM_EDITABLE_COLORS );
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2007-01-19 07:43:52 +01:00
|
|
|
for ( i = 0; i < CE_NUM_EDITABLE_COLORS; ++i ) {
|
2004-04-14 05:56:12 +02:00
|
|
|
COLORREF ref = cState->inColors[i];
|
2004-03-28 03:15:24 +02:00
|
|
|
cState->colors[i] = ref;
|
|
|
|
cState->brushes[i] = CreateSolidBrush( ref );
|
|
|
|
cState->buttons[i] = GetDlgItem( hDlg, FIRST_BUTTON + i );
|
|
|
|
}
|
|
|
|
} /* initColorData */
|
|
|
|
|
|
|
|
static HBRUSH
|
|
|
|
brushForButton( ColorsDlgState* cState, HWND hwndButton )
|
|
|
|
{
|
|
|
|
XP_U16 i;
|
2007-01-19 07:43:52 +01:00
|
|
|
for ( i = 0; i < CE_NUM_EDITABLE_COLORS; ++i ) {
|
2004-03-28 03:15:24 +02:00
|
|
|
if ( cState->buttons[i] == hwndButton ) {
|
|
|
|
return cState->brushes[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
} /* brushForButton */
|
|
|
|
|
|
|
|
static void
|
|
|
|
deleteButtonBrushes( ColorsDlgState* cState )
|
|
|
|
{
|
|
|
|
XP_U16 i;
|
2007-01-19 07:43:52 +01:00
|
|
|
for ( i = 0; i < CE_NUM_EDITABLE_COLORS; ++i ) {
|
2004-03-28 03:15:24 +02:00
|
|
|
DeleteObject( cState->brushes[i] );
|
|
|
|
}
|
|
|
|
} /* deleteButtonBrushes */
|
|
|
|
|
|
|
|
static void
|
2008-02-26 14:31:36 +01:00
|
|
|
wrapChooseColor( ColorsDlgState* cState, HWND parent, XP_U16 button )
|
2004-03-28 03:15:24 +02:00
|
|
|
{
|
2004-04-03 17:29:34 +02:00
|
|
|
XP_U16 index = button-FIRST_BUTTON;
|
2008-02-26 14:31:36 +01:00
|
|
|
XP_U16 labelID = button + CLRSEL_LABEL_OFFSET;
|
2004-04-03 17:29:34 +02:00
|
|
|
|
|
|
|
#ifdef MY_COLOR_SEL
|
|
|
|
COLORREF clrref = cState->colors[index];
|
|
|
|
|
2008-02-26 14:31:36 +01:00
|
|
|
if ( myChooseColor( cState->globals, parent, labelID, &clrref ) ) {
|
2004-04-03 17:29:34 +02:00
|
|
|
cState->colors[index] = clrref;
|
|
|
|
DeleteObject( cState->brushes[index] );
|
|
|
|
cState->brushes[index] = CreateSolidBrush( clrref );
|
2006-02-16 04:31:44 +01:00
|
|
|
XP_LOGF( "%s: may need to invalidate the button since color's changed",
|
2007-12-02 20:13:25 +01:00
|
|
|
__func__ );
|
2004-04-03 17:29:34 +02:00
|
|
|
}
|
|
|
|
#else
|
2004-03-28 03:15:24 +02:00
|
|
|
CHOOSECOLOR ccs;
|
|
|
|
BOOL hitOk;
|
|
|
|
COLORREF arr[16];
|
2004-04-03 17:29:34 +02:00
|
|
|
XP_U16 i;
|
2004-03-28 03:15:24 +02:00
|
|
|
|
|
|
|
XP_MEMSET( &ccs, 0, sizeof(ccs) );
|
|
|
|
XP_MEMSET( &arr, 0, sizeof(arr) );
|
|
|
|
|
2007-01-19 07:43:52 +01:00
|
|
|
for ( i = 0; i < CE_NUM_EDITABLE_COLORS; ++i ) {
|
2004-04-03 17:29:34 +02:00
|
|
|
arr[i] = cState->colors[i];
|
|
|
|
}
|
|
|
|
|
2004-03-28 03:15:24 +02:00
|
|
|
ccs.lStructSize = sizeof(ccs);
|
2008-02-26 14:31:36 +01:00
|
|
|
ccs.hwndOwner = parent;
|
2004-03-28 03:15:24 +02:00
|
|
|
ccs.rgbResult = cState->colors[index];
|
|
|
|
ccs.lpCustColors = arr;
|
|
|
|
|
|
|
|
ccs.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN;
|
|
|
|
|
|
|
|
hitOk = ChooseColor( &ccs );
|
|
|
|
|
|
|
|
if ( hitOk ) {
|
|
|
|
cState->colors[index] = ccs.rgbResult;
|
|
|
|
DeleteObject( cState->brushes[index] );
|
|
|
|
cState->brushes[index] = CreateSolidBrush( ccs.rgbResult );
|
|
|
|
}
|
2004-04-03 17:29:34 +02:00
|
|
|
#endif
|
2004-03-28 03:15:24 +02:00
|
|
|
} /* wrapChooseColor */
|
|
|
|
|
2008-02-22 14:27:33 +01:00
|
|
|
/* I'd prefer to use normal buttons, letting the OS draw them except for
|
|
|
|
* their background color, but MS docs don't seem to allow any way to do
|
|
|
|
* that. I'm either totally on my own drawing the button or they're all in
|
|
|
|
* the same color and so useless. So they're just rects with a black outer
|
|
|
|
* rect to show focus.
|
|
|
|
*/
|
2006-02-16 04:31:44 +01:00
|
|
|
static void
|
|
|
|
ceDrawColorButton( ColorsDlgState* cState, DRAWITEMSTRUCT* dis )
|
|
|
|
{
|
|
|
|
HBRUSH brush = brushForButton( cState, dis->hwndItem );
|
|
|
|
XP_ASSERT( !!brush );
|
2008-02-22 14:27:33 +01:00
|
|
|
|
|
|
|
RECT r = dis->rcItem;
|
|
|
|
XP_Bool hasFocus = ((dis->itemAction & ODA_FOCUS) != 0)
|
|
|
|
&& ((dis->itemState & ODS_FOCUS) != 0);
|
|
|
|
|
|
|
|
Rectangle( dis->hDC, r.left, r.top, r.right, r.bottom );
|
|
|
|
InsetRect( &r, 1, 1 );
|
|
|
|
if ( hasFocus ) {
|
|
|
|
Rectangle( dis->hDC, r.left, r.top, r.right, r.bottom );
|
|
|
|
}
|
|
|
|
InsetRect( &r, 1, 1 );
|
|
|
|
FillRect( dis->hDC, &r, brush );
|
2006-02-16 04:31:44 +01:00
|
|
|
} /* ceDrawColorButton */
|
|
|
|
|
2004-03-28 03:15:24 +02:00
|
|
|
LRESULT CALLBACK
|
|
|
|
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
ColorsDlgState* cState;
|
|
|
|
XP_U16 wid;
|
2006-02-16 04:31:44 +01:00
|
|
|
BOOL result = FALSE;
|
2004-03-28 03:15:24 +02:00
|
|
|
|
|
|
|
if ( message == WM_INITDIALOG ) {
|
|
|
|
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
|
|
|
|
|
|
|
cState = (ColorsDlgState*)lParam;
|
|
|
|
cState->cancelled = XP_TRUE;
|
|
|
|
cState->inited = XP_FALSE;
|
|
|
|
|
2006-05-28 00:19:30 +02:00
|
|
|
ceStackButtonsRight( cState->globals, hDlg );
|
|
|
|
|
2006-02-16 04:31:44 +01:00
|
|
|
result = TRUE;
|
2004-03-28 03:15:24 +02:00
|
|
|
} else {
|
|
|
|
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
2004-05-26 06:46:57 +02:00
|
|
|
if ( !!cState ) {
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
if ( !cState->inited ) {
|
|
|
|
initColorData( cState, hDlg );
|
|
|
|
cState->inited = XP_TRUE;
|
|
|
|
}
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2008-02-22 14:27:33 +01:00
|
|
|
/* XP_LOGF( "%s: event=%s (%d); wParam=0x%x; lParam=0x%lx", __func__, */
|
|
|
|
/* messageToStr(message), message, wParam, lParam ); */
|
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
switch (message) {
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2006-02-16 04:31:44 +01:00
|
|
|
case WM_DRAWITEM: /* passed when button has BS_OWNERDRAW style */
|
|
|
|
ceDrawColorButton( cState, (DRAWITEMSTRUCT*)lParam );
|
|
|
|
result = TRUE;
|
|
|
|
break;
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
wid = LOWORD(wParam);
|
|
|
|
switch( wid ) {
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
case IDOK:
|
|
|
|
cState->cancelled = XP_FALSE;
|
|
|
|
/* fallthrough */
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
case IDCANCEL:
|
|
|
|
deleteButtonBrushes( cState );
|
|
|
|
EndDialog(hDlg, wid);
|
2006-02-16 04:31:44 +01:00
|
|
|
result = TRUE;
|
|
|
|
break;
|
2004-05-26 06:46:57 +02:00
|
|
|
default:
|
|
|
|
/* it's one of the color buttons. Set up with the
|
|
|
|
appropriate color and launch ChooseColor */
|
|
|
|
wrapChooseColor( cState, hDlg, wid );
|
2006-02-16 04:31:44 +01:00
|
|
|
result = TRUE;
|
|
|
|
break;
|
2004-05-26 06:46:57 +02:00
|
|
|
}
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2004-05-26 06:46:57 +02:00
|
|
|
}
|
2004-03-28 03:15:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-16 04:31:44 +01:00
|
|
|
return result;
|
2004-03-28 03:15:24 +02:00
|
|
|
} /* ColorsDlg */
|
|
|
|
|
|
|
|
XP_Bool
|
2004-04-14 05:56:12 +02:00
|
|
|
ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors )
|
2004-03-28 03:15:24 +02:00
|
|
|
{
|
|
|
|
ColorsDlgState state;
|
|
|
|
|
|
|
|
XP_MEMSET( &state, 0, sizeof(state) );
|
|
|
|
state.globals = globals;
|
2004-04-14 05:56:12 +02:00
|
|
|
state.inColors = colors;
|
2004-03-28 03:15:24 +02:00
|
|
|
|
2006-03-04 16:56:31 +01:00
|
|
|
(void)DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLORSDLG, hwnd,
|
|
|
|
(DLGPROC)ColorsDlg, (long)&state );
|
2004-03-28 03:15:24 +02:00
|
|
|
|
|
|
|
if ( !state.cancelled ) {
|
|
|
|
XP_U16 i;
|
2007-01-19 07:43:52 +01:00
|
|
|
for ( i = 0; i < CE_NUM_EDITABLE_COLORS; ++i ) {
|
2004-04-14 05:56:12 +02:00
|
|
|
colors[i] = state.colors[i];
|
2004-03-28 03:15:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return !state.cancelled;
|
|
|
|
} /* ceDoColorsEdit */
|