[BUG_FIXED] refine the "cancel" feature in styler configurator.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@22 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2007-09-04 18:37:45 +00:00
parent 93a47c6d70
commit 7175d376d3
2 changed files with 30 additions and 15 deletions

View File

@ -54,7 +54,17 @@ BOOL CALLBACK ColourStaticTextHooker::colourStaticProc(HWND hwnd, UINT Message,
} }
return ::CallWindowProc(_oldProc, hwnd, Message, wParam, lParam); return ::CallWindowProc(_oldProc, hwnd, Message, wParam, lParam);
} }
void WordStyleDlg::updateGlobalOverrideCtrls()
{
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FG_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFg, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_BG_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableBg, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FONT_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFont, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FONTSIZE_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFontSize, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_BOLD_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableBold, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_ITALIC_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableItalic, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableUnderLine, 0);
}
BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{ {
@ -128,14 +138,8 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
enableDlgTheme(_hSelf, ETDT_ENABLETAB); enableDlgTheme(_hSelf, ETDT_ENABLETAB);
redraw(); redraw();
} }
const NppGUI & nppGUI = pNppParam->getNppGUI();
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FG_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFg, 0); updateGlobalOverrideCtrls();
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_BG_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableBg, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FONT_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFont, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_FONTSIZE_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableFontSize, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_BOLD_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableBold, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_ITALIC_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableItalic, 0);
::SendDlgItemMessage(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK, BM_SETCHECK, nppGUI._globalOverride.enableUnderLine, 0);
goToCenter(); goToCenter();
return TRUE; return TRUE;
@ -195,9 +199,11 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
//::MessageBox(NULL, "dirty", "", MB_OK); //::MessageBox(NULL, "dirty", "", MB_OK);
LexerStylerArray & lsArray = (NppParameters::getInstance())->getLStylerArray(); LexerStylerArray & lsArray = (NppParameters::getInstance())->getLStylerArray();
StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers(); StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers();
GlobalOverride & gOverride = (NppParameters::getInstance())->getGlobalOverrideStyle();
globalStyles = _globalStyles = _gstyles2restored; globalStyles = _globalStyles = _gstyles2restored;
lsArray = _lsArray = _styles2restored; lsArray = _lsArray = _styles2restored;
gOverride = _gOverride2restored;
_isDirty = false; _isDirty = false;
setVisualFromStyleList(); setVisualFromStyleList();

View File

@ -76,20 +76,22 @@ public :
if (!isCreated()) if (!isCreated())
{ {
create(IDD_STYLER_DLG, isRTL); create(IDD_STYLER_DLG, isRTL);
_styles2restored = (NppParameters::getInstance())->getLStylerArray(); prepare2Cancel();
_gstyles2restored = (NppParameters::getInstance())->getGlobalStylers();
//::MessageBox(NULL, "", "gogogogo", MB_OK);
} }
if (!::IsWindowVisible(_hSelf)) if (!::IsWindowVisible(_hSelf))
{ {
_styles2restored = (NppParameters::getInstance())->getLStylerArray(); prepare2Cancel();
_gstyles2restored = (NppParameters::getInstance())->getGlobalStylers();
//::MessageBox(NULL, "", "gogogogo", MB_OK);
} }
display(); display();
}; };
void prepare2Cancel() {
_styles2restored = (NppParameters::getInstance())->getLStylerArray();
_gstyles2restored = (NppParameters::getInstance())->getGlobalStylers();
_gOverride2restored = (NppParameters::getInstance())->getGlobalOverrideStyle();
};
virtual void redraw() const { virtual void redraw() const {
_pFgColour->redraw(); _pFgColour->redraw();
_pBgColour->redraw(); _pBgColour->redraw();
@ -125,6 +127,7 @@ private :
LexerStylerArray _styles2restored; LexerStylerArray _styles2restored;
StyleArray _gstyles2restored; StyleArray _gstyles2restored;
GlobalOverride _gOverride2restored;
ColourStaticTextHooker colourHooker; ColourStaticTextHooker colourHooker;
@ -187,8 +190,14 @@ private :
void setStyleListFromLexer(int index); void setStyleListFromLexer(int index);
void setVisualFromStyleList(); void setVisualFromStyleList();
void updateGlobalOverrideCtrls();
void showGlobalOverrideCtrls(bool show) void showGlobalOverrideCtrls(bool show)
{ {
if (show)
{
updateGlobalOverrideCtrls();
}
::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FG_CHECK), show?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FG_CHECK), show?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_BG_CHECK), show?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_BG_CHECK), show?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FONT_CHECK), show?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FONT_CHECK), show?SW_SHOW:SW_HIDE);