?? wordstyledlg.cpp.dockable
字號:
}
default :
return FALSE;
}
return FALSE;
}
void WordStyleDlg::updateColour(bool which)
{
Style & style = getCurrentStyler();
if (which == C_FOREGROUND)
{
style._fgColor = _pFgColour->getColour();
}
else //(which == C_BACKGROUND)
{
style._bgColor = _pBgColour->getColour();
}
}
void WordStyleDlg::updateFontSize()
{
Style & style = getCurrentStyler();
int iFontSizeSel = ::SendMessage(_hFontSizeCombo, CB_GETCURSEL, 0, 0);
char intStr[5];
if (iFontSizeSel != 0)
{
::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr);
if ((!intStr) || (!intStr[0]))
style._fontSize = -1;
else
{
char *finStr;
style._fontSize = strtol(intStr, &finStr, 10);
if (*finStr != '\0')
style._fontSize = -1;
}
}
else
style._fontSize = 0;
}
void WordStyleDlg::updateExtension()
{
const int NB_MAX = 256;
char ext[NB_MAX];
::SendDlgItemMessage(_hSelf, IDC_USER_EXT_EDIT, WM_GETTEXT, NB_MAX, (LPARAM)ext);
_lsArray.getLexerFromIndex(_currentLexerIndex - 1).setLexerUserExt(ext);
}
void WordStyleDlg::updateUserKeywords()
{
Style & style = getCurrentStyler();
//const int NB_MAX = 2048;
//char kw[NB_MAX];
int len = ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXTLENGTH, 0, 0);
char *kw = new char[len];
::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXT, len, (LPARAM)kw);
style.setKeywords(kw);
delete [] kw;
}
void WordStyleDlg::updateFontName()
{
Style & style = getCurrentStyler();
int iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0);
char *fnStr = (char *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0);
style._fontName = fnStr;
}
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::setStyleListFromLexer(int index)
{
_currentLexerIndex = index;
// Fill out Styles listbox
// Before filling out, we clean it
::SendMessage(_hStyleList, LB_RESETCONTENT, 0, 0);
if (index)
{
const char *langName = _lsArray.getLexerNameFromIndex(index - 1);
const char *ext = NppParameters::getInstance()->getLangExtFromName(langName);
const char *userExt = (_lsArray.getLexerStylerByName(langName))->getLexerUserExt();
::SendDlgItemMessage(_hSelf, IDC_DEF_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(ext));
::SendDlgItemMessage(_hSelf, IDC_USER_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(userExt));
//::SetWindowText(::GetDlgItem(_hSelf, IDC_USER_EXT_EDIT), userExt);
}
::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_EXT_EDIT), index?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_DEF_EXT_STATIC), index?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_EXT_EDIT), index?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_USER_EXT_STATIC), index?SW_SHOW:SW_HIDE);
::ShowWindow(::GetDlgItem(_hSelf, IDC_PLUSSYMBOL2_STATIC), index?SW_SHOW:SW_HIDE);
StyleArray & lexerStyler = index?_lsArray.getLexerFromIndex(index-1):_globalStyles;
for (int i = 0 ; i < lexerStyler.getNbStyler() ; i++)
{
Style & style = lexerStyler.getStyler(i);
::SendMessage(_hStyleList, LB_ADDSTRING, 0, (LPARAM)style._styleDesc);
}
::SendMessage(_hStyleList, LB_SETCURSEL, 0, 0);
setVisualFromStyleList();
}
void WordStyleDlg::setVisualFromStyleList()
{
Style & style = getCurrentStyler();
//--Warning text
bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE;
COLORREF c = RGB(0xFF, 0x00, 0x00);
char str[256];
strcpy(str, _originalWarning);
if (!showWarning)
{
if (!_originalWarning[0])
// Get the original text for the usage afterward
::GetWindowText(_hStyleInfoStaticText, _originalWarning, sizeof(_originalWarning));
str[0] = '\0';
c = RGB(0x00, 0x00, 0xFF);
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;
char styleName[64];
::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName);
strcat(strcat(str, " : "), styleName);
}
else
{
if (!str[0])
{
::GetWindowText(_hStyleInfoStaticText, _originalWarning, sizeof(_originalWarning));
strcpy(str, _originalWarning);
}
}
colourHooker.setColour(c);
::SetWindowText(_hStyleInfoStaticText, str);
//::InvalidateRect(hColourTextStatic, NULL, TRUE);
//::UpdateWindow(hColourTextStatic);
//::ShowWindow(_hStyleInfoStaticText, showWarning);
//-- 2 couleurs : fg et bg
bool isEnable = false;
if (HIBYTE(HIWORD(style._fgColor)) != 0xFF)
{
_pFgColour->setColour(style._fgColor);
isEnable = true;
}
enableFg(isEnable);
isEnable = false;
if (HIBYTE(HIWORD(style._bgColor)) != 0xFF)
{
_pBgColour->setColour(style._bgColor);
isEnable = true;
}
enableBg(isEnable);
//-- font name
isEnable = false;
int iFontName;
if (style._fontName != NULL)
{
iFontName = ::SendMessage(_hFontNameCombo, CB_FINDSTRING, 1, (LPARAM)style._fontName);
if (iFontName == CB_ERR)
iFontName = 0;
isEnable = true;
}
else
{
iFontName = 0;
}
::SendMessage(_hFontNameCombo, CB_SETCURSEL, iFontName, 0);
enableFontName(isEnable);
//-- font size
isEnable = false;
char intStr[5] = "";
int iFontSize = 0;
if (style._fontSize != -1)
{
sprintf(intStr, "%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);
NppParameters *pNppParams = NppParameters::getInstance();
LangType lType = pNppParams->getLangIDFromStr(lexerStyler.getLexerName());
if (lType == L_TXT)
{
string str = lexerStyler.getLexerName();
str += " is not defined in NppParameters::getLangIDFromStr()";
printStr(str.c_str());
}
const char *kws = pNppParams->getWordList(lType, style._keywordClass);
if (!kws)
kws = "";
::SendDlgItemMessage(_hSelf, IDC_DEF_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(kws));
const char *ckwStr = (style._keywords)?style._keywords->c_str():"";
::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();
}
void WordStyleDlg::create(tTbData * data, bool isRTL)
{
DockingDlgInterface::create(data, isRTL);
if ((NppParameters::getInstance())->isTransparentAvailable())
{
::ShowWindow(::GetDlgItem(_hSelf, IDC_SC_TRANSPARENT_CHECK), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER), SW_SHOW);
::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200));
::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, 150);
if (!(BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_SC_PERCENTAGE_SLIDER, BM_GETCHECK, 0, 0)))
::EnableWindow(::GetDlgItem(_hSelf, IDC_SC_PERCENTAGE_SLIDER), FALSE);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -