[NEW_FEATURE] Add style transparency feature, rightclick on color to enable.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@170 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
11333a7ec3
commit
12a2f16042
@ -192,7 +192,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
// returned value : TRUE if tab bar is hidden, otherwise FALSE
|
||||
|
||||
#define NPPM_CHECKDOCSTATUS (NPPMSG + 53)
|
||||
// VOID NPPM_CHECKDOCSTATUS(TRUE, 0)
|
||||
// VOID NPPM_CHECKDOCSTATUS(BOOL, 0)
|
||||
|
||||
#define NPPM_ENABLECHECKDOCOPT (NPPMSG + 54)
|
||||
// VOID NPPM_ENABLECHECKDOCOPT(OPT, 0)
|
||||
@ -209,6 +209,11 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
#define NPPM_GETEXTPART (RUNCOMMAND_USER + EXT_PART)
|
||||
#define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD)
|
||||
#define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY)
|
||||
// BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, char *str)
|
||||
// where str is the allocated char array,
|
||||
// strLen is the allocated array size
|
||||
// The return value is TRUE when get string operation success
|
||||
// Otherwise (allocated array size is too small) FALSE
|
||||
|
||||
#define VAR_NOT_RECOGNIZED 0
|
||||
#define FULL_CURRENT_PATH 1
|
||||
|
@ -2421,21 +2421,24 @@ void Notepad_plus::addHotSpot(bool docIsModifing)
|
||||
int activeFG = 0xFF0000;
|
||||
|
||||
char fontName[256];
|
||||
Style hotspotStyle;
|
||||
|
||||
_pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontName);
|
||||
int fg = _pEditView->execute(SCI_STYLEGETFORE, idStyle);
|
||||
int bg = _pEditView->execute(SCI_STYLEGETBACK, idStyle);
|
||||
int fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle);
|
||||
hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle);
|
||||
hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle);
|
||||
hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle);
|
||||
|
||||
int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyle);
|
||||
int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyle);
|
||||
int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle);
|
||||
hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0);
|
||||
|
||||
int fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0);
|
||||
int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL;
|
||||
if (urlAction == 2)
|
||||
fontStyle |= FONTSTYLE_UNDERLINE;
|
||||
hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE;
|
||||
|
||||
_pEditView->setStyle(style_hotspot, fg, bg, fontName, fontStyle, fontSize);
|
||||
_pEditView->setStyle(hotspotStyle);
|
||||
|
||||
_pEditView->execute(SCI_STYLESETHOTSPOT, style_hotspot, TRUE);
|
||||
_pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG);
|
||||
@ -6801,6 +6804,17 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
else if (Message == NPPM_GETEXTPART)
|
||||
fileStr = PathFindExtension(str);
|
||||
|
||||
// For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough.
|
||||
// otherwise we check if the string buffer size is enough for the string to copy.
|
||||
if (wParam != 0)
|
||||
{
|
||||
if (strlen(fileStr) >= wParam)
|
||||
{
|
||||
::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM error", MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char *)lParam, fileStr);
|
||||
return TRUE;
|
||||
}
|
||||
@ -6815,6 +6829,18 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
_pEditView->expandWordSelection();
|
||||
|
||||
_pEditView->getSelectedText(str, strSize, true);
|
||||
|
||||
// For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough.
|
||||
// otherwise we check if the string buffer size is enough for the string to copy.
|
||||
if (wParam != 0)
|
||||
{
|
||||
if (strlen(str) >= wParam)
|
||||
{
|
||||
::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETCURRENTWORD error", MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char *)lParam, str);
|
||||
return TRUE;
|
||||
}
|
||||
@ -6826,6 +6852,18 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
::GetModuleFileName(NULL, str, strSize);
|
||||
PathRemoveFileSpec(str);
|
||||
|
||||
// For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough.
|
||||
// otherwise we check if the string buffer size is enough for the string to copy.
|
||||
if (wParam != 0)
|
||||
{
|
||||
if (strlen(str) >= wParam)
|
||||
{
|
||||
::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETNPPDIRECTORY error", MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy((char *)lParam, str);
|
||||
return TRUE;
|
||||
}
|
||||
@ -8313,3 +8351,4 @@ winVer getWindowsVersion()
|
||||
return WV_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1846,6 +1846,12 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode)
|
||||
_styleArray[_nbStyler]._bgColor = (RGB((result >> 16) & 0xFF, (result >> 8) & 0xFF, result & 0xFF)) | (result & 0xFF000000);
|
||||
}
|
||||
|
||||
str = element->Attribute("colorStyle");
|
||||
if (str)
|
||||
{
|
||||
_styleArray[_nbStyler]._colorStyle = decStrVal(str);
|
||||
}
|
||||
|
||||
str = element->Attribute("fontName");
|
||||
_styleArray[_nbStyler]._fontName = str;
|
||||
|
||||
@ -3804,6 +3810,11 @@ void NppParameters::writeStyle2Element(Style & style2Wite, Style & style2Sync, T
|
||||
element->SetAttribute("bgColor", bgStr);
|
||||
}
|
||||
|
||||
if (style2Wite._colorStyle != COLORSTYLE_ALL)
|
||||
{
|
||||
element->SetAttribute("colorStyle", style2Wite._colorStyle);
|
||||
}
|
||||
|
||||
if (style2Wite._fontName)
|
||||
{
|
||||
const char *oldFontName = element->Attribute("fontName");
|
||||
@ -3898,6 +3909,11 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user
|
||||
styleElement->SetAttribute("bgColor", bgStr);
|
||||
}
|
||||
|
||||
if (style2Wite._colorStyle != COLORSTYLE_ALL)
|
||||
{
|
||||
styleElement->SetAttribute("colorStyle", style2Wite._colorStyle);
|
||||
}
|
||||
|
||||
if (style2Wite._fontName)
|
||||
{
|
||||
styleElement->SetAttribute("fontName", style2Wite._fontName);
|
||||
@ -4013,3 +4029,4 @@ void NppParameters::addScintillaModifiedIndex(int index)
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -236,6 +236,10 @@ const int FONTSTYLE_BOLD = 1;
|
||||
const int FONTSTYLE_ITALIC = 2;
|
||||
const int FONTSTYLE_UNDERLINE = 4;
|
||||
|
||||
const int COLORSTYLE_FOREGROUND = 0x01;
|
||||
const int COLORSTYLE_BACKGROUND = 0x02;
|
||||
const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND;
|
||||
|
||||
struct Style
|
||||
{
|
||||
int _styleID;
|
||||
@ -243,6 +247,7 @@ struct Style
|
||||
|
||||
COLORREF _fgColor;
|
||||
COLORREF _bgColor;
|
||||
int _colorStyle;
|
||||
const char *_fontName;
|
||||
int _fontStyle;
|
||||
int _fontSize;
|
||||
@ -250,7 +255,7 @@ struct Style
|
||||
int _keywordClass;
|
||||
string *_keywords;
|
||||
|
||||
Style():_styleID(-1), _fgColor(COLORREF(-1)), _bgColor(COLORREF(-1)), _fontName(NULL), _fontStyle(-1), _fontSize(-1), _keywordClass(-1), _keywords(NULL){};
|
||||
Style():_styleID(-1), _fgColor(COLORREF(-1)), _bgColor(COLORREF(-1)), _colorStyle(COLORSTYLE_ALL), _fontName(NULL), _fontStyle(-1), _fontSize(-1), _keywordClass(-1), _keywords(NULL){};
|
||||
|
||||
~Style(){
|
||||
if (_keywords)
|
||||
@ -263,6 +268,7 @@ struct Style
|
||||
_styleDesc = style._styleDesc;
|
||||
_fgColor = style._fgColor;
|
||||
_bgColor = style._bgColor;
|
||||
_colorStyle = style._colorStyle;
|
||||
_fontName = style._fontName;
|
||||
_fontSize = style._fontSize;
|
||||
_fontStyle = style._fontStyle;
|
||||
@ -280,6 +286,7 @@ struct Style
|
||||
this->_styleDesc = style._styleDesc;
|
||||
this->_fgColor = style._fgColor;
|
||||
this->_bgColor = style._bgColor;
|
||||
this->_colorStyle = style._colorStyle;
|
||||
this->_fontName = style._fontName;
|
||||
this->_fontSize = style._fontSize;
|
||||
this->_fontStyle = style._fontStyle;
|
||||
|
@ -1247,7 +1247,8 @@ void Finder::setFinderStyle()
|
||||
if (iStyleDefault != -1)
|
||||
{
|
||||
Style & styleDefault = stylers.getStyler(iStyleDefault);
|
||||
_scintView.setStyle(styleDefault._styleID, styleDefault._fgColor, styleDefault._bgColor, styleDefault._fontName, styleDefault._fontStyle, styleDefault._fontSize);
|
||||
styleDefault._colorStyle = COLORSTYLE_ALL; //All colors set
|
||||
_scintView.setStyle(styleDefault);
|
||||
}
|
||||
|
||||
_scintView.execute(SCI_STYLECLEARALL);
|
||||
|
@ -191,35 +191,35 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
|
||||
}
|
||||
return _callWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam);
|
||||
}
|
||||
void ScintillaEditView::setSpecialStyle(int styleID, COLORREF fgColour, COLORREF bgColour, const char *fontName, int fontStyle, int fontSize)
|
||||
void ScintillaEditView::setSpecialStyle(Style & styleToSet)
|
||||
{
|
||||
if (!((fgColour >> 24) & 0xFF))
|
||||
execute(SCI_STYLESETFORE, styleID, fgColour);
|
||||
int styleID = styleToSet._styleID;
|
||||
if ( styleToSet._colorStyle & COLORSTYLE_FOREGROUND )
|
||||
execute(SCI_STYLESETFORE, styleID, styleToSet._fgColor);
|
||||
|
||||
if (!((bgColour >> 24) & 0xFF))
|
||||
execute(SCI_STYLESETBACK, styleID, bgColour);
|
||||
if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND )
|
||||
execute(SCI_STYLESETBACK, styleID, styleToSet._bgColor);
|
||||
|
||||
if ((!fontName)||(strcmp(fontName, "")))
|
||||
execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)fontName);
|
||||
if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, "")))
|
||||
execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)styleToSet._fontName);
|
||||
|
||||
int fontStyle = styleToSet._fontStyle;
|
||||
if (fontStyle != -1)
|
||||
{
|
||||
execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD);
|
||||
execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC);
|
||||
execute(SCI_STYLESETUNDERLINE, (WPARAM)styleID, fontStyle & FONTSTYLE_UNDERLINE);
|
||||
execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD);
|
||||
execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC);
|
||||
execute(SCI_STYLESETUNDERLINE, (WPARAM)styleID, fontStyle & FONTSTYLE_UNDERLINE);
|
||||
}
|
||||
|
||||
if (fontSize > 0)
|
||||
execute(SCI_STYLESETSIZE, styleID, fontSize);
|
||||
if (styleToSet._fontSize > 0)
|
||||
execute(SCI_STYLESETSIZE, styleID, styleToSet._fontSize);
|
||||
}
|
||||
|
||||
void ScintillaEditView::setStyle(int styleID, COLORREF fgColour, COLORREF bgColour, const char *fontName, int fontStyle, int fontSize)
|
||||
void ScintillaEditView::setStyle(Style styleToSet)
|
||||
{
|
||||
GlobalOverride & go = _pParameter->getGlobalOverrideStyle();
|
||||
//go.enableBg = true;
|
||||
|
||||
const char *localFn = fontName;
|
||||
|
||||
if (go.isEnable())
|
||||
{
|
||||
StyleArray & stylers = _pParameter->getMiscStylerArray();
|
||||
@ -228,42 +228,62 @@ void ScintillaEditView::setStyle(int styleID, COLORREF fgColour, COLORREF bgColo
|
||||
{
|
||||
Style & style = stylers.getStyler(i);
|
||||
|
||||
if (go.enableFg)
|
||||
fgColour = style._fgColor;
|
||||
if (go.enableBg)
|
||||
bgColour = style._bgColor;
|
||||
if (go.enableFg) {
|
||||
if (style._colorStyle & COLORSTYLE_FOREGROUND) {
|
||||
styleToSet._colorStyle |= COLORSTYLE_FOREGROUND;
|
||||
styleToSet._fgColor = style._fgColor;
|
||||
} else {
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) { //if global is set to transparent, use default style color
|
||||
styleToSet._colorStyle |= COLORSTYLE_FOREGROUND;
|
||||
} else {
|
||||
styleToSet._colorStyle &= ~COLORSTYLE_FOREGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (go.enableBg) {
|
||||
if (style._colorStyle & COLORSTYLE_BACKGROUND) {
|
||||
styleToSet._colorStyle |= COLORSTYLE_BACKGROUND;
|
||||
styleToSet._bgColor = style._bgColor;
|
||||
} else {
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) { //if global is set to transparent, use default style color
|
||||
styleToSet._colorStyle |= COLORSTYLE_BACKGROUND;
|
||||
} else {
|
||||
styleToSet._colorStyle &= ~COLORSTYLE_BACKGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (go.enableFont && style._fontName && style._fontName[0])
|
||||
localFn = style._fontName;
|
||||
styleToSet._fontName = style._fontName;
|
||||
if (go.enableFontSize && (style._fontSize > 0))
|
||||
fontSize = style._fontSize;
|
||||
styleToSet._fontSize = style._fontSize;
|
||||
|
||||
if (style._fontStyle != -1)
|
||||
{
|
||||
if (go.enableBold)
|
||||
{
|
||||
if (style._fontStyle & FONTSTYLE_BOLD)
|
||||
fontStyle |= FONTSTYLE_BOLD;
|
||||
styleToSet._fontStyle |= FONTSTYLE_BOLD;
|
||||
else
|
||||
fontStyle &= ~FONTSTYLE_BOLD;
|
||||
styleToSet._fontStyle &= ~FONTSTYLE_BOLD;
|
||||
}
|
||||
if (go.enableItalic)
|
||||
{
|
||||
if (style._fontStyle & FONTSTYLE_ITALIC)
|
||||
fontStyle |= FONTSTYLE_ITALIC;
|
||||
styleToSet._fontStyle |= FONTSTYLE_ITALIC;
|
||||
else
|
||||
fontStyle &= ~FONTSTYLE_ITALIC;
|
||||
styleToSet._fontStyle &= ~FONTSTYLE_ITALIC;
|
||||
}
|
||||
if (go.enableUnderLine)
|
||||
{
|
||||
if (style._fontStyle & FONTSTYLE_UNDERLINE)
|
||||
fontStyle |= FONTSTYLE_UNDERLINE;
|
||||
styleToSet._fontStyle |= FONTSTYLE_UNDERLINE;
|
||||
else
|
||||
fontStyle &= ~FONTSTYLE_UNDERLINE;
|
||||
styleToSet._fontStyle &= ~FONTSTYLE_UNDERLINE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
setSpecialStyle(styleID, fgColour, bgColour, localFn, fontStyle, fontSize);
|
||||
setSpecialStyle(styleToSet);
|
||||
}
|
||||
|
||||
|
||||
@ -361,7 +381,7 @@ void ScintillaEditView::setUserLexer()
|
||||
for (int i = 0 ; i < userLangContainer._styleArray.getNbStyler() ; i++)
|
||||
{
|
||||
Style & style = userLangContainer._styleArray.getStyler(i);
|
||||
setStyle(style._styleID, style._fgColor, style._bgColor, style._fontName, style._fontStyle, style._fontSize);
|
||||
setStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,7 +407,7 @@ void ScintillaEditView::setUserLexer(const char *userLangName)
|
||||
for (int i = 0 ; i < userLangContainer._styleArray.getNbStyler() ; i++)
|
||||
{
|
||||
Style & style = userLangContainer._styleArray.getStyler(i);
|
||||
setStyle(style._styleID, style._fgColor, style._bgColor, style._fontName, style._fontStyle, style._fontSize);
|
||||
setStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
@ -404,7 +424,7 @@ void ScintillaEditView::setExternalLexer(LangType typeDoc)
|
||||
{
|
||||
Style & style = pStyler->getStyler(i);
|
||||
|
||||
setStyle(style._styleID, style._fgColor, style._bgColor, style._fontName, style._fontStyle, style._fontSize);
|
||||
setStyle(style);
|
||||
|
||||
if (style._keywordClass >= 0 && style._keywordClass <= KEYWORDSET_MAX)
|
||||
{
|
||||
@ -473,7 +493,7 @@ void ScintillaEditView::setCppLexer(LangType langType)
|
||||
{
|
||||
for (int i = 0 ; i < pStyler->getNbStyler() ; i++)
|
||||
{
|
||||
Style & style = pStyler->getStyler(i);
|
||||
Style style = pStyler->getStyler(i); //not by reference, but copy
|
||||
int cppID = style._styleID;
|
||||
switch (style._styleID)
|
||||
{
|
||||
@ -489,7 +509,8 @@ void ScintillaEditView::setCppLexer(LangType langType)
|
||||
case SCE_HJ_SINGLESTRING : cppID = SCE_C_CHARACTER; break;
|
||||
case SCE_HJ_REGEX : cppID = SCE_C_REGEX; break;
|
||||
}
|
||||
setStyle(cppID, style._fgColor, style._bgColor, style._fontName, style._fontStyle, style._fontSize);
|
||||
style._styleID = cppID;
|
||||
setStyle(style);
|
||||
}
|
||||
}
|
||||
execute(SCI_STYLESETEOLFILLED, SCE_C_DEFAULT, true);
|
||||
@ -617,7 +638,8 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
if (iStyleDefault != -1)
|
||||
{
|
||||
Style & styleDefault = stylers.getStyler(iStyleDefault);
|
||||
setStyle(styleDefault._styleID, styleDefault._fgColor, styleDefault._bgColor, styleDefault._fontName, styleDefault._fontStyle, styleDefault._fontSize);
|
||||
styleDefault._colorStyle = COLORSTYLE_ALL; //override transparency
|
||||
setStyle(styleDefault);
|
||||
}
|
||||
|
||||
execute(SCI_STYLECLEARALL);
|
||||
@ -626,21 +648,21 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
if (iFind != -1)
|
||||
{
|
||||
Style & styleFind = stylers.getStyler(iFind);
|
||||
setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);
|
||||
setSpecialStyle(styleFind);
|
||||
}
|
||||
|
||||
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||
if (iFind != -1)
|
||||
{
|
||||
Style & styleFind = stylers.getStyler(iFind);
|
||||
setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);
|
||||
setSpecialStyle(styleFind);
|
||||
}
|
||||
|
||||
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE);
|
||||
if (iFind != -1)
|
||||
{
|
||||
Style & styleFind = stylers.getStyler(iFind);
|
||||
setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);
|
||||
setSpecialStyle(styleFind);
|
||||
}
|
||||
|
||||
int caretWidth = 1;
|
||||
@ -703,18 +725,22 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName("nfo");
|
||||
COLORREF bg = black;
|
||||
COLORREF fg = liteGrey;
|
||||
Style nfoStyle;
|
||||
nfoStyle._styleID = STYLE_DEFAULT;
|
||||
nfoStyle._fontName = "MS LineDraw";
|
||||
if (pStyler)
|
||||
{
|
||||
int i = pStyler->getStylerIndexByName("DEFAULT");
|
||||
if (i != -1)
|
||||
{
|
||||
Style & style = pStyler->getStyler(i);
|
||||
bg = style._bgColor;
|
||||
fg = style._fgColor;
|
||||
nfoStyle._bgColor = style._bgColor;
|
||||
nfoStyle._fgColor = style._fgColor;
|
||||
nfoStyle._colorStyle = style._colorStyle;
|
||||
}
|
||||
}
|
||||
|
||||
setStyle(STYLE_DEFAULT, fg, bg, "MS LineDraw");
|
||||
setStyle(nfoStyle);
|
||||
execute(SCI_STYLECLEARALL);
|
||||
}
|
||||
break;
|
||||
@ -821,14 +847,14 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
if (indexOfIndentGuide != -1)
|
||||
{
|
||||
static Style & styleIG = stylers.getStyler(indexOfIndentGuide);
|
||||
setStyle(styleIG._styleID, styleIG._fgColor, styleIG._bgColor, styleIG._fontName, styleIG._fontStyle, styleIG._fontSize);
|
||||
setStyle(styleIG);
|
||||
}
|
||||
|
||||
static int indexOfBraceLight = stylers.getStylerIndexByID(STYLE_BRACELIGHT);
|
||||
if (indexOfBraceLight != -1)
|
||||
{
|
||||
static Style & styleBL = stylers.getStyler(indexOfBraceLight);
|
||||
setStyle(styleBL._styleID, styleBL._fgColor, styleBL._bgColor, styleBL._fontName, styleBL._fontStyle, styleBL._fontSize);
|
||||
setStyle(styleBL);
|
||||
}
|
||||
//setStyle(STYLE_CONTROLCHAR, liteGrey);
|
||||
|
||||
@ -836,14 +862,14 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
||||
if (indexBadBrace != -1)
|
||||
{
|
||||
static Style & styleBB = stylers.getStyler(indexBadBrace);
|
||||
setStyle(styleBB._styleID, styleBB._fgColor, styleBB._bgColor, styleBB._fontName, styleBB._fontStyle, styleBB._fontSize);
|
||||
setStyle(styleBB);
|
||||
}
|
||||
|
||||
static int indexLineNumber = stylers.getStylerIndexByID(STYLE_LINENUMBER);
|
||||
if (indexLineNumber != -1)
|
||||
{
|
||||
static Style & styleLN = stylers.getStyler(indexLineNumber);
|
||||
setSpecialStyle(styleLN._styleID, styleLN._fgColor, styleLN._bgColor, styleLN._fontName, styleLN._fontStyle, styleLN._fontSize);
|
||||
setSpecialStyle(styleLN);
|
||||
}
|
||||
|
||||
execute(SCI_SETTABWIDTH, ((NppParameters::getInstance())->getNppGUI())._tabSize);
|
||||
@ -1273,7 +1299,7 @@ void ScintillaEditView::makeStyle(const char *lexerName, const char **keywordArr
|
||||
for (int i = 0 ; i < pStyler->getNbStyler() ; i++)
|
||||
{
|
||||
Style & style = pStyler->getStyler(i);
|
||||
setStyle(style._styleID, style._fgColor, style._bgColor, style._fontName, style._fontStyle, style._fontSize);
|
||||
setStyle(style);
|
||||
if (keywordArray)
|
||||
{
|
||||
if ((style._keywordClass != -1) && (style._keywords))
|
||||
|
@ -665,9 +665,9 @@ protected:
|
||||
|
||||
bool _wrapRestoreNeeded;
|
||||
|
||||
void setStyle(int styleID, COLORREF fgColor, COLORREF bgColor = -1, const char *fontName = NULL, int fontStyle = -1, int fontSize = 0);
|
||||
void setSpecialStyle(int styleID, COLORREF fgColor, COLORREF bgColor = -1, const char *fontName = NULL, int fontStyle = -1, int fontSize = 0);
|
||||
void setCppLexer(LangType type);
|
||||
void setStyle(Style styleToSet); //NOT by reference (style edited)
|
||||
void setSpecialStyle(Style & styleToSet); //by reference
|
||||
void setCppLexer(LangType type);
|
||||
void setXmlLexer(LangType type);
|
||||
void setUserLexer();
|
||||
void setUserLexer(const char *userLangName);
|
||||
|
@ -92,8 +92,10 @@ void SharedParametersDialog::styleUpdate(const Style & style, ColourPicker *pFgC
|
||||
int fontComboId, int fontSizeComboId, int boldCheckId, int italicCheckId, int underlineCheckId)
|
||||
{
|
||||
pFgColourPicker->setColour((style._fgColor == COLORREF(-1))?black:style._fgColor);
|
||||
pFgColourPicker->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0);
|
||||
pFgColourPicker->redraw();
|
||||
pBgColourPicker->setColour((style._bgColor == COLORREF(-1))?white:style._bgColor);
|
||||
pBgColourPicker->setEnabled((style._colorStyle & COLORSTYLE_BACKGROUND) != 0);
|
||||
pBgColourPicker->redraw();
|
||||
|
||||
HWND hFontCombo = ::GetDlgItem(_hSelf, fontComboId);
|
||||
@ -217,12 +219,20 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L
|
||||
if (index != -1)
|
||||
{
|
||||
Style & style = _pUserLang->_styleArray.getStyler(index);
|
||||
if (isFG)
|
||||
style._fgColor = pCP->getColour();
|
||||
else
|
||||
style._bgColor = pCP->getColour();
|
||||
}
|
||||
|
||||
if (isFG) {
|
||||
style._fgColor = pCP->getColour();
|
||||
if (pCP->isEnabled())
|
||||
style._colorStyle |= COLORSTYLE_FOREGROUND;
|
||||
else
|
||||
style._colorStyle &= ~COLORSTYLE_FOREGROUND;
|
||||
} else {
|
||||
style._bgColor = pCP->getColour();
|
||||
if (pCP->isEnabled())
|
||||
style._colorStyle |= COLORSTYLE_BACKGROUND;
|
||||
else
|
||||
style._colorStyle &= ~COLORSTYLE_BACKGROUND;
|
||||
}
|
||||
}
|
||||
// A cause de "#define CPN_COLOURPICKED (BN_CLICKED)"
|
||||
// Nous sommes obligés de mettre ce bloc ici !!!
|
||||
// A modifier !!!
|
||||
|
@ -48,17 +48,46 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
||||
|
||||
}
|
||||
|
||||
void ColourPicker::drawSelf(HDC hDC)
|
||||
void ColourPicker::drawBackground(HDC hDC)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
RECT rc;
|
||||
HBRUSH hbrush;
|
||||
|
||||
if(!hDC)
|
||||
return;
|
||||
|
||||
HDC hdc = hDC?hDC:(::BeginPaint(_hSelf, &ps));
|
||||
getClientRect(rc);
|
||||
HBRUSH hbrush = ::CreateSolidBrush(_currentColour);
|
||||
FillRect(hdc, &rc, hbrush);
|
||||
hbrush = ::CreateSolidBrush(_currentColour);
|
||||
HGDIOBJ oldObj = ::SelectObject(hDC, hbrush);
|
||||
::Rectangle(hDC, 0, 0, rc.right, rc.bottom);
|
||||
::SelectObject(hDC, oldObj);
|
||||
//FillRect(hDC, &rc, hbrush);
|
||||
::DeleteObject(hbrush);
|
||||
::EndPaint(_hSelf, &ps);
|
||||
}
|
||||
|
||||
void ColourPicker::drawForeground(HDC hDC)
|
||||
{
|
||||
RECT rc;
|
||||
HBRUSH hbrush;
|
||||
|
||||
if(!hDC || _isEnabled)
|
||||
return;
|
||||
|
||||
int oldMode = ::SetBkMode(hDC, TRANSPARENT);
|
||||
getClientRect(rc);
|
||||
COLORREF strikeOut = RGB(0,0,0);
|
||||
if ((((_currentColour ) & 0xFF) +
|
||||
((_currentColour >> 8) & 0xFF) +
|
||||
((_currentColour >> 16) & 0xFF)) < 200) //check if the color is too dark, if so, use white strikeout
|
||||
strikeOut = RGB(0xFF,0xFF,0xFF);
|
||||
if (!_isEnabled)
|
||||
hbrush = ::CreateHatchBrush(HS_FDIAGONAL, strikeOut);
|
||||
HGDIOBJ oldObj = ::SelectObject(hDC, hbrush);
|
||||
::Rectangle(hDC, 0, 0, rc.right, rc.bottom);
|
||||
::SelectObject(hDC, oldObj);
|
||||
//FillRect(hDC, &rc, hbrush);
|
||||
::DeleteObject(hbrush);
|
||||
::SetBkMode(hDC, oldMode);
|
||||
}
|
||||
|
||||
LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
@ -85,10 +114,28 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
_isEnabled = !_isEnabled;
|
||||
redraw();
|
||||
::SendMessage(_hParent, WM_COMMAND, MAKELONG(0, CPN_COLOURPICKED), (LPARAM)_hSelf);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
HDC dc = (HDC)wParam;
|
||||
drawBackground(dc);
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_PAINT :
|
||||
{
|
||||
drawSelf((HDC)wParam);
|
||||
PAINTSTRUCT ps;
|
||||
HDC dc = ::BeginPaint(_hSelf, &ps);
|
||||
drawForeground(dc);
|
||||
::EndPaint(_hSelf, &ps);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
class ColourPicker : public Window
|
||||
{
|
||||
public :
|
||||
ColourPicker() : Window(), _currentColour(RGB(0xFF, 0x00, 0x00)), _pColourPopup(NULL){};
|
||||
ColourPicker() : Window(), _currentColour(RGB(0xFF, 0x00, 0x00)), _pColourPopup(NULL), _isEnabled(true) {};
|
||||
~ColourPicker(){};
|
||||
virtual void init(HINSTANCE hInst, HWND parent);
|
||||
virtual void destroy() {
|
||||
@ -42,16 +42,21 @@ public :
|
||||
|
||||
COLORREF getColour() const {return _currentColour;};
|
||||
|
||||
bool isEnabled() {return _isEnabled;};
|
||||
void setEnabled(bool enabled) {_isEnabled = enabled;};
|
||||
|
||||
private :
|
||||
COLORREF _currentColour;
|
||||
WNDPROC _buttonDefaultProc;
|
||||
ColourPopup *_pColourPopup;
|
||||
bool _isEnabled;
|
||||
|
||||
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
|
||||
return (((ColourPicker *)(::GetWindowLong(hwnd, GWL_USERDATA)))->runProc(Message, wParam, lParam));
|
||||
};
|
||||
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
inline void drawSelf(HDC hDC);
|
||||
void drawForeground(HDC hDC);
|
||||
void drawBackground(HDC hDC);
|
||||
};
|
||||
|
||||
#endif // COLOUR_PICKER_H
|
||||
|
@ -400,10 +400,18 @@ void WordStyleDlg::updateColour(bool which)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -581,6 +589,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
||||
if (HIBYTE(HIWORD(style._fgColor)) != 0xFF)
|
||||
{
|
||||
_pFgColour->setColour(style._fgColor);
|
||||
_pFgColour->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0);
|
||||
isEnable = true;
|
||||
}
|
||||
enableFg(isEnable);
|
||||
@ -589,6 +598,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
||||
if (HIBYTE(HIWORD(style._bgColor)) != 0xFF)
|
||||
{
|
||||
_pBgColour->setColour(style._bgColor);
|
||||
_pBgColour->setEnabled((style._colorStyle & COLORSTYLE_BACKGROUND) != 0);
|
||||
isEnable = true;
|
||||
}
|
||||
enableBg(isEnable);
|
||||
|
Loading…
Reference in New Issue
Block a user