mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
clean up dialog init
This commit is contained in:
parent
fa5bdc2457
commit
0a6a9de4cf
3 changed files with 87 additions and 89 deletions
|
@ -17,8 +17,6 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
|
||||||
|
|
||||||
#include <Windowsx.h>
|
#include <Windowsx.h>
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
|
@ -133,7 +131,7 @@ updateForField( HWND hDlg, ClrEditDlgState* eState, XP_U16 fieldID )
|
||||||
}
|
}
|
||||||
} /* updateForField */
|
} /* updateForField */
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
LRESULT CALLBACK
|
||||||
EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
{
|
{
|
||||||
ClrEditDlgState* eState;
|
ClrEditDlgState* eState;
|
||||||
|
@ -151,6 +149,9 @@ EditColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
eState = (ClrEditDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
eState = (ClrEditDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||||
|
if ( !eState ) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !eState->inited ) {
|
if ( !eState->inited ) {
|
||||||
/* set to true first! Messages will be generated by
|
/* set to true first! Messages will be generated by
|
||||||
|
@ -350,44 +351,45 @@ ColorsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
cState = (ColorsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||||
|
if ( !!cState ) {
|
||||||
|
|
||||||
if ( !cState->inited ) {
|
if ( !cState->inited ) {
|
||||||
initColorData( cState, hDlg );
|
initColorData( cState, hDlg );
|
||||||
cState->inited = XP_TRUE;
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,5 +417,3 @@ ceDoColorsEdit( HWND hwnd, CEAppGlobals* globals, COLORREF* colors )
|
||||||
|
|
||||||
return !state.cancelled;
|
return !state.cancelled;
|
||||||
} /* ceDoColorsEdit */
|
} /* ceDoColorsEdit */
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -109,10 +109,8 @@ loadStateFromCurPrefs( const CEAppPrefs* appPrefs, const CurGameInfo* gi,
|
||||||
prefsPrefs->showColors = appPrefs->showColors;
|
prefsPrefs->showColors = appPrefs->showColors;
|
||||||
|
|
||||||
XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) );
|
XP_MEMCPY( &prefsPrefs->cp, &appPrefs->cp, sizeof(prefsPrefs->cp) );
|
||||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
|
||||||
XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors,
|
XP_MEMCPY( &prefsPrefs->colors, &appPrefs->colors,
|
||||||
sizeof(prefsPrefs->colors) );
|
sizeof(prefsPrefs->colors) );
|
||||||
#endif
|
|
||||||
} /* loadStateFromCurPrefs */
|
} /* loadStateFromCurPrefs */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -130,10 +128,8 @@ loadCurPrefsFromState( CEAppPrefs* appPrefs, CurGameInfo* gi,
|
||||||
appPrefs->showColors = prefsPrefs->showColors;
|
appPrefs->showColors = prefsPrefs->showColors;
|
||||||
|
|
||||||
XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) );
|
XP_MEMCPY( &appPrefs->cp, &prefsPrefs->cp, sizeof(appPrefs->cp) );
|
||||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
|
||||||
XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors,
|
XP_MEMCPY( &appPrefs->colors, &prefsPrefs->colors,
|
||||||
sizeof(prefsPrefs->colors) );
|
sizeof(prefsPrefs->colors) );
|
||||||
#endif
|
|
||||||
} /* loadCurPrefsFromState */
|
} /* loadCurPrefsFromState */
|
||||||
|
|
||||||
/* Reflect local state into the controls user will see.
|
/* Reflect local state into the controls user will see.
|
||||||
|
@ -231,37 +227,37 @@ PrefsDlg(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
} else {
|
} else {
|
||||||
XP_Bool timerOn;
|
XP_Bool timerOn;
|
||||||
pState = (CePrefsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
pState = (CePrefsDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||||
globals = pState->globals;
|
if ( !!pState ) {
|
||||||
|
globals = pState->globals;
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
id = LOWORD(wParam);
|
id = LOWORD(wParam);
|
||||||
switch( id ) {
|
switch( id ) {
|
||||||
|
|
||||||
case IDC_RADIOGLOBAL:
|
case IDC_RADIOGLOBAL:
|
||||||
case IDC_RADIOLOCAL:
|
case IDC_RADIOLOCAL:
|
||||||
pState->globals->doGlobalPrefs = id == IDC_RADIOGLOBAL;
|
pState->globals->doGlobalPrefs = id == IDC_RADIOGLOBAL;
|
||||||
adjustForChoice( hDlg, pState );
|
adjustForChoice( hDlg, pState );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIMER_CHECK:
|
case TIMER_CHECK:
|
||||||
timerOn = SendDlgItemMessage( hDlg, TIMER_CHECK, BM_GETCHECK,
|
timerOn = SendDlgItemMessage( hDlg, TIMER_CHECK, BM_GETCHECK,
|
||||||
0, 0 );
|
0, 0 );
|
||||||
setTimerCtls( hDlg, timerOn );
|
setTimerCtls( hDlg, timerOn );
|
||||||
break;
|
break;
|
||||||
#ifdef XWFEATURE_CE_EDITCOLORS
|
case IDC_PREFCOLORS:
|
||||||
case IDC_PREFCOLORS:
|
pState->colorsChanged =
|
||||||
pState->colorsChanged =
|
ceDoColorsEdit( hDlg, pState->globals,
|
||||||
ceDoColorsEdit( hDlg, pState->globals,
|
pState->prefsPrefs.colors );
|
||||||
pState->prefsPrefs.colors );
|
break;
|
||||||
break;
|
case IDOK:
|
||||||
#endif
|
ceControlsToPrefs( hDlg, &pState->prefsPrefs );
|
||||||
case IDOK:
|
case IDCANCEL:
|
||||||
ceControlsToPrefs( hDlg, &pState->prefsPrefs );
|
EndDialog(hDlg, id);
|
||||||
case IDCANCEL:
|
pState->userCancelled = id == IDCANCEL;
|
||||||
EndDialog(hDlg, id);
|
return TRUE;
|
||||||
pState->userCancelled = id == IDCANCEL;
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,24 +77,26 @@ StrBox(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
} else {
|
} else {
|
||||||
init = (StrBoxInit*)GetWindowLong( hDlg, GWL_USERDATA );
|
init = (StrBoxInit*)GetWindowLong( hDlg, GWL_USERDATA );
|
||||||
|
|
||||||
switch (message) {
|
if ( !!init ) {
|
||||||
|
switch (message) {
|
||||||
|
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if ( !init->textIsSet ) {
|
if ( !init->textIsSet ) {
|
||||||
stuffTextInField( hDlg, init );
|
stuffTextInField( hDlg, init );
|
||||||
init->textIsSet = XP_TRUE;
|
init->textIsSet = XP_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = LOWORD(wParam);
|
||||||
|
switch( id ) {
|
||||||
|
|
||||||
|
case IDOK:
|
||||||
|
case IDCANCEL:
|
||||||
|
init->result = id;
|
||||||
|
EndDialog(hDlg, id);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
id = LOWORD(wParam);
|
|
||||||
switch( id ) {
|
|
||||||
|
|
||||||
case IDOK:
|
|
||||||
case IDCANCEL:
|
|
||||||
init->result = id;
|
|
||||||
EndDialog(hDlg, id);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in a new issue