void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle) { Style & style = getCurrentStyler(); if (style._fontStyle == -1) style._fontStyle = 0; int fontStyle = FONTSTYLE_UNDERLINE; HWND hWnd = _hCheckUnderline; if (whitchStyle == BOLD_STATUS) { fontStyle = FONTSTYLE_BOLD; hWnd = _hCheckBold; } if (whitchStyle == ITALIC_STATUS) { fontStyle = FONTSTYLE_ITALIC; hWnd = _hCheckItalic; } int isChecked = ::SendMessage(hWnd, BM_GETCHECK, 0, 0); if (isChecked != BST_INDETERMINATE) { if (isChecked == BST_CHECKED) style._fontStyle |= fontStyle; else style._fontStyle &= ~fontStyle; } }
void WordStyleDlg::updateFontName() { Style & style = getCurrentStyler(); int iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0); TCHAR *fnStr = (TCHAR *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0); style._fontName = fnStr; }
void WordStyleDlg::updateUserKeywords() { Style & style = getCurrentStyler(); //const int NB_MAX = 2048; //TCHAR kw[NB_MAX]; int len = ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXTLENGTH, 0, 0); len +=1; TCHAR *kw = new TCHAR[len]; ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXT, len, (LPARAM)kw); style.setKeywords(kw); delete [] kw; }
void WordStyleDlg::updateColour(bool which) { Style & style = getCurrentStyler(); if (which == C_FOREGROUND) { style._fgColor = _pFgColour->getColour(); if (_pFgColour->isEnabled()) style._colorStyle |= COLORSTYLE_FOREGROUND; else style._colorStyle &= ~COLORSTYLE_FOREGROUND; } else //(which == C_BACKGROUND) { style._bgColor = _pBgColour->getColour(); if (_pBgColour->isEnabled()) style._colorStyle |= COLORSTYLE_BACKGROUND; else style._colorStyle &= ~COLORSTYLE_BACKGROUND; } }
void WordStyleDlg::updateFontSize() { Style & style = getCurrentStyler(); int iFontSizeSel = ::SendMessage(_hFontSizeCombo, CB_GETCURSEL, 0, 0); TCHAR intStr[5]; if (iFontSizeSel != 0) { ::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr); if ((!intStr) || (!intStr[0])) style._fontSize = -1; else { TCHAR *finStr; style._fontSize = generic_strtol(intStr, &finStr, 10); if (*finStr != '\0') style._fontSize = -1; } } else style._fontSize = 0; }
void WordStyleDlg::setVisualFromStyleList() { showGlobalOverrideCtrls(false); Style & style = getCurrentStyler(); // Global override style if (style._styleDesc == TEXT("Global override")) { showGlobalOverrideCtrls(true); } //--Warning text //bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; COLORREF color = RGB(0x00, 0x00, 0xFF); TCHAR str[256]; str[0] = '\0'; int i = ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_GETTEXT, i, (LPARAM)str); i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; TCHAR styleName[64]; ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); lstrcat(lstrcat(str, TEXT(" : ")), styleName); // PAD for fix a display glitch lstrcat(str, TEXT(" ")); _colourHooker->setColour(color); ::SetWindowText(_hStyleInfoStaticText, str); //-- 2 couleurs : fg et bg bool isEnable = false; if (HIBYTE(HIWORD(style._fgColor)) != 0xFF) { assert(_pFgColour); _pFgColour->setColour(style._fgColor); _pFgColour->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0); isEnable = true; } enableFg(isEnable); isEnable = false; if (HIBYTE(HIWORD(style._bgColor)) != 0xFF) { assert(_pBgColour); _pBgColour->setColour(style._bgColor); _pBgColour->setEnabled((style._colorStyle & COLORSTYLE_BACKGROUND) != 0); isEnable = true; } enableBg(isEnable); //-- font name isEnable = true; int iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, (LPARAM)style._fontName.c_str()); if (iFontName == CB_ERR) iFontName = 0; ::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0); enableFontName(isEnable); //-- font size isEnable = false; TCHAR intStr[5] = TEXT(""); int iFontSize = 0; if (style._fontSize != -1) { wsprintf(intStr, TEXT("%d"), style._fontSize); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr); isEnable = true; } ::SendMessage(_hFontSizeCombo, CB_SETCURSEL, iFontSize, 0); enableFontSize(isEnable); //-- font style : bold et italic isEnable = false; int isBold, isItalic, isUnderline; if (style._fontStyle != -1) { isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED; ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); isEnable = true; } else // -1 est comme 0 { ::SendMessage(_hCheckBold, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, BST_UNCHECKED, 0); } enableFontStyle(isEnable); //-- Default Keywords bool shouldBeDisplayed = style._keywordClass != -1; if (shouldBeDisplayed) { LexerStyler & lexerStyler = _lsArray.getLexerFromIndex(_currentLexerIndex - 1); LangType lType = NppParameters::getLangIDFromStr(lexerStyler.getLexerName()); if (lType == L_TXT) { generic_string str = lexerStyler.getLexerName(); str += TEXT(" is not defined in NppParameters::getLangIDFromStr()"); printStr(str.c_str()); } NppParameters *pNppParams = NppParameters::getInstance(); const TCHAR *kws = pNppParams->getWordList(lType, style._keywordClass); if (!kws) kws = TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_DEF_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(kws)); const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr)); } int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE; ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_EDIT), showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_EDIT),showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_KEYWORDS_STATIC), showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_KEYWORDS_STATIC),showOption); ::ShowWindow(::GetDlgItem(_hSelf, IDC_PLUSSYMBOL_STATIC),showOption); redraw(); }