Skip to content

Commit

Permalink
remove some of mine dead code
Browse files Browse the repository at this point in the history
in the end there was no need to fetch the color info from scintilla
since npp expose that info via the NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR
and the NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR messages.
  • Loading branch information
kobilutil committed Feb 25, 2015
1 parent 0890623 commit 58e3341
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions Explorer/src/ExplorerDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,25 +2019,8 @@ bool ExplorerDialog::doPaste(LPCTSTR pszTo, LPDROPFILES hData, const DWORD & dwE

void ExplorerDialog::UpdateColors()
{
// i though this should have work but it doesn't
//COLORREF bgColor = ::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
//COLORREF fgColor = ::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, 0);

// get the bgcolor directly from scintilla.
// note that we assume that the bgcolor of style=0 if the default bgcolor of the document.
COLORREF bgColor = ::SendMessage(_nppData._scintillaMainHandle, SCI_STYLEGETBACK, 0, 0);

// try to estimate if the bgColor is light or dark
int h = 0;
if (GetRValue(bgColor) >= 128) ++h;
if (GetGValue(bgColor) >= 128) ++h;
if (GetBValue(bgColor) >= 128) ++h;

// if bgColor is light then pick a dark fgColor and vice versa
COLORREF fgColor = (h > 1) ? RGB(30, 30, 30) : RGB(200, 200, 200);

bgColor = ::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
fgColor = ::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, 0);
auto bgColor = (COLORREF)::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR, 0, 0);
auto fgColor = (COLORREF)::SendMessage(_nppData._nppHandle, NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR, 0, 0);

TreeView_SetBkColor(_hTreeCtrl, bgColor);
TreeView_SetTextColor(_hTreeCtrl, fgColor);
Expand Down

0 comments on commit 58e3341

Please sign in to comment.