diff --git a/src/SciCall.h b/src/SciCall.h index ced506e88..01f7b2bbd 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -207,10 +207,8 @@ DeclareSciCallV2(SetElementColour, SETELEMENTCOLOUR, int, element, COLORALPHAREF DeclareSciCallR1(GetElementColour, GETELEMENTCOLOUR, COLORALPHAREF, int, element); DeclareSciCallR1(GetElementBaseColour, GETELEMENTBASECOLOUR, COLORALPHAREF, int, element); DeclareSciCallV1(ResetElementColour, RESETELEMENTCOLOUR, int, element); -//SCI_GETELEMENTISSET(int element) → bool -//SCI_GETELEMENTALLOWSTRANSLUCENT(int element) → bool -//SCI_GETELEMENTBASECOLOUR(int element) → colouralpha - +DeclareSciCallR1(GetElementIsSet, GETELEMENTISSET, bool, int, element); +DeclareSciCallR1(GetElementAllowsTranslucent, GETELEMENTALLOWSTRANSLUCENT, bool, int, element); // Selection, positions and information DeclareSciCallR0(GetReadOnly, GETREADONLY, bool); diff --git a/src/Styles.c b/src/Styles.c index 6d89ce6fa..8a4553b49 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1477,17 +1477,22 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) SciCall_SetElementColour(SC_ELEMENT_SELECTION_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); } else { - SciCall_SetElementColour(SC_ELEMENT_SELECTION_TEXT, RGBxA(0, SC_ALPHA_OPAQUE)); - SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, RGBxA(0, SC_ALPHA_OPAQUE)); + SciCall_ResetElementColour(SC_ELEMENT_SELECTION_TEXT); + SciCall_ResetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT); } rgb = RGB(0xC0, 0xC0, 0xC0); - Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, BACKGROUND_LAYER, &rgb, true); // selection back - iValue = SC_ALPHA_OPAQUE; - Style_StrGetAlpha(pCurrentStandard->Styles[STY_SEL_TXT].szValue, &iValue, true); - SciCall_SetSelectionLayer(SC_LAYER_UNDER_TEXT); - SciCall_SetElementColour(SC_ELEMENT_SELECTION_BACK, RGBxA(rgb, iValue)); - SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, RGBxA(rgb, iValue*2/3)); + SciCall_SetSelectionLayer(SC_LAYER_UNDER_TEXT); // selection back + if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, BACKGROUND_LAYER, &rgb, true)) { + iValue = SC_ALPHA_OPAQUE; + Style_StrGetAlpha(pCurrentStandard->Styles[STY_SEL_TXT].szValue, &iValue, true); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_BACK, RGBxA(rgb, iValue)); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, RGBxA(rgb, iValue * 2 / 3)); + } + else { + SciCall_ResetElementColour(SC_ELEMENT_SELECTION_BACK); + SciCall_ResetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK); + } // selection eolfilled bFlag = Style_StrHasAttribute(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FontEffects[FE_EOLFILLED]); @@ -1495,11 +1500,24 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // whitespace colors rgb = RGB(0, 0, 0); - Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, false); - SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE, RGBxA(rgb, SC_ALPHA_OPAQUE/2)); + if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, false)) { + iValue = SC_ALPHA_OPAQUE; + Style_StrGetAlpha(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &iValue, true); + SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE, RGBxA(rgb, iValue)); + } + else { + SciCall_ResetElementColour(SC_ELEMENT_WHITE_SPACE); + } - Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, true); - SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE_BACK, RGBxA(rgb, SC_ALPHA_OPAQUE)); + rgb = RGB(0, 0, 0); + if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, true)) { + //iValue = SC_ALPHA_TRANSPARENT; + //~Style_StrGetAlpha(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &iValue, false); ~ always opaque, no translucency possible in Win32 + SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE_BACK, RGBxA(rgb, SC_ALPHA_OPAQUE)); + } + else { + SciCall_ResetElementColour(SC_ELEMENT_WHITE_SPACE_BACK); + } // whitespace dot size iValue = 2; diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 00b7bef98..f041a0492 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -104,8 +104,8 @@ extern WININFO g_DefWinInfo; //-typedef DWORD COLORREF; typedef int COLORALPHAREF; //-#define RGB(r, g, b) ((COLORREF)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16))) -#define RGBA(r, g, b, a) ((COLORALPHAREF)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16) | (((DWORD)(BYTE)(a)) << 24))) -#define RGBxA(rgb, a) ((COLORALPHAREF)(((DWORD)(rgb)&0xffffff) | (((DWORD)(BYTE)(a)) << 24))) +#define RGBA(r, g, b, a) ((COLORALPHAREF)(((BYTE)(((r)&0xff)) | ((WORD)((BYTE)((g)&0xff)) << 8)) | (((DWORD)(BYTE)((b)&0xff)) << 16) | (((DWORD)(BYTE)((a)&0xff)) << 24))) +#define RGBxA(rgb, a) ((COLORALPHAREF)(((DWORD)((rgb)&0xffffff)) | (((DWORD)(BYTE)((a)&0xff)) << 24))) //-#define GetRValue(rgba) (LOBYTE(rgba)) //-#define GetGValue(rgba) (LOBYTE(((WORD)(rgba)) >> 8)) //-#define GetBValue(rgba) (LOBYTE((rgba) >> 16))