mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-30 10:26:58 +01:00
first cut at color picking using MS's ChooseColor
This commit is contained in:
parent
aa1d398ec4
commit
d640d4d301
9 changed files with 796 additions and 0 deletions
190
wince/ceclrsel.c
Normal file
190
wince/ceclrsel.c
Normal file
|
@ -0,0 +1,190 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
||||
|
||||
#include <Windowsx.h>
|
||||
#include "stdafx.h"
|
||||
#include <commdlg.h>
|
||||
|
||||
#include "ceclrsel.h"
|
||||
|
||||
typedef struct ColorsDlgState {
|
||||
|
||||
CEAppGlobals* globals;
|
||||
|
||||
COLORREF colors[NUM_EDITABLE_COLORS];
|
||||
HBRUSH brushes[NUM_EDITABLE_COLORS];
|
||||
HWND buttons[NUM_EDITABLE_COLORS];
|
||||
|
||||
XP_Bool cancelled;
|
||||
XP_Bool inited;
|
||||
} ColorsDlgState;
|
||||
|
||||
#define FIRST_BUTTON DLBLTR_BUTTON
|
||||
#define LAST_BUTTON PLAYER4_BUTTON
|
||||
|
||||
static void
|
||||
initColorData( ColorsDlgState* cState, HWND hDlg )
|
||||
{
|
||||
CEAppGlobals* globals = cState->globals;
|
||||
XP_U16 i;
|
||||
|
||||
XP_ASSERT( (LAST_BUTTON - FIRST_BUTTON + 1) == NUM_EDITABLE_COLORS );
|
||||
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
COLORREF ref = globals->appPrefs.colors[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 );
|
||||
}
|
||||
} /* initColorData */
|
||||
|
||||
static HBRUSH
|
||||
brushForButton( ColorsDlgState* cState, HWND hwndButton )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
if ( cState->buttons[i] == hwndButton ) {
|
||||
return cState->brushes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* brushForButton */
|
||||
|
||||
static void
|
||||
deleteButtonBrushes( ColorsDlgState* cState )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
DeleteObject( cState->brushes[i] );
|
||||
}
|
||||
} /* deleteButtonBrushes */
|
||||
|
||||
static void
|
||||
wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
|
||||
{
|
||||
CHOOSECOLOR ccs;
|
||||
BOOL hitOk;
|
||||
COLORREF arr[16];
|
||||
XP_U16 index = button-FIRST_BUTTON;
|
||||
|
||||
XP_MEMSET( &ccs, 0, sizeof(ccs) );
|
||||
XP_MEMSET( &arr, 0, sizeof(arr) );
|
||||
|
||||
ccs.lStructSize = sizeof(ccs);
|
||||
ccs.hwndOwner = owner;
|
||||
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 );
|
||||
}
|
||||
} /* wrapChooseColor */
|
||||
|
||||
LRESULT CALLBACK
|
||||
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
ColorsDlgState* cState;
|
||||
XP_U16 wid;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
cState = (ColorsDlgState*)lParam;
|
||||
cState->cancelled = XP_TRUE;
|
||||
cState->inited = XP_FALSE;
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
|
||||
if ( !cState->inited ) {
|
||||
initColorData( cState, hDlg );
|
||||
cState->inited = XP_TRUE;
|
||||
}
|
||||
|
||||
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_COMMAND:
|
||||
wid = LOWORD(wParam);
|
||||
switch( wid ) {
|
||||
|
||||
case IDOK:
|
||||
cState->cancelled = XP_FALSE;
|
||||
/* fallthrough */
|
||||
|
||||
case IDCANCEL:
|
||||
deleteButtonBrushes( cState );
|
||||
EndDialog(hDlg, wid);
|
||||
return TRUE;
|
||||
default:
|
||||
/* it's one of the color buttons. Set up with the
|
||||
appropriate color and launch ChooseColor */
|
||||
wrapChooseColor( cState, hDlg, wid );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} /* ColorsDlg */
|
||||
|
||||
XP_Bool
|
||||
ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals )
|
||||
{
|
||||
ColorsDlgState state;
|
||||
int result;
|
||||
|
||||
XP_MEMSET( &state, 0, sizeof(state) );
|
||||
state.globals = globals;
|
||||
|
||||
result = DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLORSDLG, hwnd,
|
||||
(DLGPROC)ColorsDlg, (long)&state );
|
||||
|
||||
if ( !state.cancelled ) {
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
globals->appPrefs.colors[i] = state.colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
return !state.cancelled;
|
||||
} /* ceDoColorsEdit */
|
||||
|
||||
#endif
|
19
wince/ceclrsel.c.~1~
Normal file
19
wince/ceclrsel.c.~1~
Normal file
|
@ -0,0 +1,19 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2002 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
110
wince/ceclrsel.c.~2~
Normal file
110
wince/ceclrsel.c.~2~
Normal file
|
@ -0,0 +1,110 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
*/
|
||||
|
||||
static void
|
||||
initColorData( ColorsDlgState* cState )
|
||||
{
|
||||
CEAppGlobals* globals = cState->globals;
|
||||
|
||||
for ( i = 0; i < NUM_COLORS; ++i ) {
|
||||
COLORREF ref = globals->appPrefs.colors[i];
|
||||
cState->colors[i] = ref;
|
||||
cState->brushes[i] = CreateSolidBrush( ref );
|
||||
}
|
||||
} /* initColorData */
|
||||
|
||||
static HBRUSH
|
||||
brushForButton( ColorsDlgState* cState, HWND hwndButton )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_COLORS; ++i ) {
|
||||
if ( cState->buttons[i] == hwndButton ) {
|
||||
return cState->brushes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* brushForButton */
|
||||
|
||||
static void
|
||||
deleteButtonBrushes( ColorsDlgState* cState )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_COLORS; ++i ) {
|
||||
DeleteObject( cState->brushes[i] );
|
||||
}
|
||||
} /* deleteButtonBrushes */
|
||||
|
||||
LRESULT CALLBACK
|
||||
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
ColorsDlgState* cState;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
cState = (ColorsDlgState*)lParam;
|
||||
cState->cancelled = XP_TRUE;
|
||||
cState->inited = XP_FALSE;
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
|
||||
if ( !cState->inited ) {
|
||||
initColorData( cState );
|
||||
cState->inited = XP_TRUE;
|
||||
}
|
||||
|
||||
switch (message) {
|
||||
|
||||
case WM_CTLCOLORBTN: {
|
||||
HDC hdcButton = (HDC)wParam;
|
||||
HWND hwndButton = (HWND)lParam;
|
||||
HBRUSH brush = brushForButton( cState, hwndButton );
|
||||
return (BOOL)brush;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
switch( LOWORD(wParam) ) {
|
||||
|
||||
case IDOK:
|
||||
ceControlsToPrefs( hDlg, &cState->prefsPrefs );
|
||||
cState->cancelled = XP_FALSE;
|
||||
/* fallthrough */
|
||||
|
||||
case IDCANCEL:
|
||||
deleteButtonBrushes( cState );
|
||||
EndDialog(hDlg, id);
|
||||
return TRUE;
|
||||
default:
|
||||
/* it's one of the color buttons. Set up with the
|
||||
appropriate color and launch ChooseColor */
|
||||
BOOL hitOk = ChooseColor( &ccs );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
} /* ColorsDlg */
|
171
wince/ceclrsel.c.~3~
Normal file
171
wince/ceclrsel.c.~3~
Normal file
|
@ -0,0 +1,171 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
||||
|
||||
#include <Windowsx.h>
|
||||
//#include <commdlg.h>
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "ceclrsel.h"
|
||||
|
||||
typedef struct ColorsDlgState {
|
||||
|
||||
CEAppGlobals* globals;
|
||||
|
||||
COLORREF colors[NUM_EDITABLE_COLORS];
|
||||
HBRUSH brushes[NUM_EDITABLE_COLORS];
|
||||
HWND buttons[NUM_EDITABLE_COLORS];
|
||||
|
||||
XP_Bool cancelled;
|
||||
} ColorsDlgState;
|
||||
|
||||
#define FIRST_BUTTON PLAYER1_BUTTON
|
||||
#define LAST_BUTTON TBACK_BUTTON
|
||||
|
||||
static void
|
||||
initColorData( ColorsDlgState* cState, HWND hDlg )
|
||||
{
|
||||
CEAppGlobals* globals = cState->globals;
|
||||
XP_U16 i;
|
||||
|
||||
XP_ASSERT( (LAST_BUTTON - FIRST_BUTTON + 1) == NUM_EDITABLE_COLORS );
|
||||
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
COLORREF ref = globals->appPrefs.colors[i];
|
||||
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;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
if ( cState->buttons[i] == hwndButton ) {
|
||||
return cState->brushes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* brushForButton */
|
||||
|
||||
static void
|
||||
deleteButtonBrushes( ColorsDlgState* cState )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
DeleteObject( cState->brushes[i] );
|
||||
}
|
||||
} /* deleteButtonBrushes */
|
||||
|
||||
static void
|
||||
wrapChooseColor( ColorsDlgState* cState )
|
||||
{
|
||||
CHOOSECOLOR ccs;
|
||||
|
||||
XP_MEMSET( &ccs, 0, sizeof(ccs) );
|
||||
|
||||
BOOL hitOk = ChooseColor( &ccs );
|
||||
} /* wrapChooseColor */
|
||||
|
||||
LRESULT CALLBACK
|
||||
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
ColorsDlgState* cState;
|
||||
XP_U16 wid;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
cState = (ColorsDlgState*)lParam;
|
||||
cState->cancelled = XP_TRUE;
|
||||
cState->inited = XP_FALSE;
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
|
||||
if ( !cState->inited ) {
|
||||
initColorData( cState, hDlg );
|
||||
cState->inited = XP_TRUE;
|
||||
}
|
||||
|
||||
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_COMMAND:
|
||||
wid = LOWORD(wParam);
|
||||
switch( wid ) {
|
||||
|
||||
case IDOK:
|
||||
ceControlsToPrefs( hDlg, &cState->prefsPrefs );
|
||||
cState->cancelled = XP_FALSE;
|
||||
/* fallthrough */
|
||||
|
||||
case IDCANCEL:
|
||||
deleteButtonBrushes( cState );
|
||||
EndDialog(hDlg, id);
|
||||
return TRUE;
|
||||
default:
|
||||
/* it's one of the color buttons. Set up with the
|
||||
appropriate color and launch ChooseColor */
|
||||
wrapChooseColor( cState );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} /* ColorsDlg */
|
||||
|
||||
XP_Bool
|
||||
ceDoColorsEdit( HWND hDlg, CEAppGlobals* globals )
|
||||
{
|
||||
ColorsDlgState state;
|
||||
XP_MEMSET( &state, 0, sizeof(state) );
|
||||
|
||||
state.globals = globals;
|
||||
|
||||
DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLORSDLG, hDlg,
|
||||
(DLGPROC)ColorsDlg, (long)&state );
|
||||
|
||||
if ( !state.cancelled ) {
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
globals->appPrefs.colors[i] = state.colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
return !state.cancelled;
|
||||
} /* ceDoColorsEdit */
|
||||
|
||||
#endif
|
187
wince/ceclrsel.c.~4~
Normal file
187
wince/ceclrsel.c.~4~
Normal file
|
@ -0,0 +1,187 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
||||
|
||||
#include <Windowsx.h>
|
||||
#include "stdafx.h"
|
||||
#include <commdlg.h>
|
||||
|
||||
#include "ceclrsel.h"
|
||||
|
||||
typedef struct ColorsDlgState {
|
||||
|
||||
CEAppGlobals* globals;
|
||||
|
||||
COLORREF colors[NUM_EDITABLE_COLORS];
|
||||
HBRUSH brushes[NUM_EDITABLE_COLORS];
|
||||
HWND buttons[NUM_EDITABLE_COLORS];
|
||||
|
||||
XP_Bool cancelled;
|
||||
XP_Bool inited;
|
||||
} ColorsDlgState;
|
||||
|
||||
#define FIRST_BUTTON PLAYER1_BUTTON
|
||||
#define LAST_BUTTON TBACK_BUTTON
|
||||
|
||||
static void
|
||||
initColorData( ColorsDlgState* cState, HWND hDlg )
|
||||
{
|
||||
CEAppGlobals* globals = cState->globals;
|
||||
XP_U16 i;
|
||||
|
||||
XP_ASSERT( (LAST_BUTTON - FIRST_BUTTON + 1) == NUM_EDITABLE_COLORS );
|
||||
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
COLORREF ref = globals->appPrefs.colors[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 );
|
||||
}
|
||||
} /* initColorData */
|
||||
|
||||
static HBRUSH
|
||||
brushForButton( ColorsDlgState* cState, HWND hwndButton )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
if ( cState->buttons[i] == hwndButton ) {
|
||||
return cState->brushes[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
} /* brushForButton */
|
||||
|
||||
static void
|
||||
deleteButtonBrushes( ColorsDlgState* cState )
|
||||
{
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
DeleteObject( cState->brushes[i] );
|
||||
}
|
||||
} /* deleteButtonBrushes */
|
||||
|
||||
static void
|
||||
wrapChooseColor( ColorsDlgState* cState, HWND owner, XP_U16 button )
|
||||
{
|
||||
CHOOSECOLOR ccs;
|
||||
BOOL hitOk;
|
||||
COLORREF arr[16];
|
||||
|
||||
XP_MEMSET( &ccs, 0, sizeof(ccs) );
|
||||
XP_MEMSET( &arr, 0, sizeof(arr) );
|
||||
|
||||
ccs.lStructSize = sizeof(ccs);
|
||||
ccs.hwndOwner = owner;
|
||||
ccs.rgbResult = cState->colors[button-FIRST_BUTTON];
|
||||
ccs.lpCustColors = arr;
|
||||
|
||||
ccs.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN;
|
||||
|
||||
hitOk = ChooseColor( &ccs );
|
||||
|
||||
if ( hitOk ) {
|
||||
cState->colors[button-FIRST_BUTTON] = ccs.rgbResult;
|
||||
}
|
||||
} /* wrapChooseColor */
|
||||
|
||||
LRESULT CALLBACK
|
||||
ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
ColorsDlgState* cState;
|
||||
XP_U16 wid;
|
||||
|
||||
if ( message == WM_INITDIALOG ) {
|
||||
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
||||
|
||||
cState = (ColorsDlgState*)lParam;
|
||||
cState->cancelled = XP_TRUE;
|
||||
cState->inited = XP_FALSE;
|
||||
|
||||
return TRUE;
|
||||
} else {
|
||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||
|
||||
if ( !cState->inited ) {
|
||||
initColorData( cState, hDlg );
|
||||
cState->inited = XP_TRUE;
|
||||
}
|
||||
|
||||
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_COMMAND:
|
||||
wid = LOWORD(wParam);
|
||||
switch( wid ) {
|
||||
|
||||
case IDOK:
|
||||
cState->cancelled = XP_FALSE;
|
||||
/* fallthrough */
|
||||
|
||||
case IDCANCEL:
|
||||
deleteButtonBrushes( cState );
|
||||
EndDialog(hDlg, wid);
|
||||
return TRUE;
|
||||
default:
|
||||
/* it's one of the color buttons. Set up with the
|
||||
appropriate color and launch ChooseColor */
|
||||
wrapChooseColor( cState, hDlg, wid );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
} /* ColorsDlg */
|
||||
|
||||
XP_Bool
|
||||
ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals )
|
||||
{
|
||||
ColorsDlgState state;
|
||||
int result;
|
||||
|
||||
XP_MEMSET( &state, 0, sizeof(state) );
|
||||
state.globals = globals;
|
||||
|
||||
result = DialogBoxParam( globals->hInst, (LPCTSTR)IDD_COLORSDLG, hwnd,
|
||||
(DLGPROC)ColorsDlg, (long)&state );
|
||||
|
||||
if ( !state.cancelled ) {
|
||||
XP_U16 i;
|
||||
for ( i = 0; i < NUM_EDITABLE_COLORS; ++i ) {
|
||||
globals->appPrefs.colors[i] = state.colors[i];
|
||||
}
|
||||
}
|
||||
|
||||
return !state.cancelled;
|
||||
} /* ceDoColorsEdit */
|
||||
|
||||
#endif
|
32
wince/ceclrsel.h
Normal file
32
wince/ceclrsel.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CECLRSEL_H_
|
||||
#define _CECLRSEL_H_
|
||||
|
||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
||||
|
||||
#include "xptypes.h"
|
||||
#include "cemain.h"
|
||||
|
||||
XP_Bool ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
18
wince/ceclrsel.h.~1~
Normal file
18
wince/ceclrsel.h.~1~
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
37
wince/ceclrsel.h.~2~
Normal file
37
wince/ceclrsel.h.~2~
Normal file
|
@ -0,0 +1,37 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CECLRSEL_H_
|
||||
#define _CECLRSEL_H_
|
||||
|
||||
typedef struct ColorsDlgState {
|
||||
|
||||
COLORREF colors[NUM_COLORS];
|
||||
HBRUSH brushes[NUM_COLORS];
|
||||
HWND buttons[NUM_COLORS];
|
||||
|
||||
XP_Bool cancelled;
|
||||
} ColorsDlgState;
|
||||
|
||||
|
||||
LRESULT CALLBACK ColorsDlg( HWND hDlg, UINT message, WPARAM wParam,
|
||||
LPARAM lParam );
|
||||
|
||||
|
||||
#endif
|
32
wince/ceclrsel.h.~3~
Normal file
32
wince/ceclrsel.h.~3~
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2004 by Eric House (fixin@peak.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _CECLRSEL_H_
|
||||
#define _CECLRSEL_H_
|
||||
|
||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
||||
|
||||
#include "xptypes.h"
|
||||
#include "cemain.h"
|
||||
|
||||
XP_Bool ceDoColorsEdit( CEAppGlobals* globals );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue