Skip to content

Commit cf0f849

Browse files
CFrankCFrank
authored andcommitted
implement colorchooser
1 parent 40bfaf2 commit cf0f849

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

PythonScript/res/PythonScript.rc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ BEGIN
100100
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,303,352,19
101101
LTEXT "This has the effect that the directories under Notepad++ that contain Python libraries are searched AFTER the standard Python directories. If in doubt, leave unchecked.",IDC_STATIC,22,321,348,19
102102
CONTROL "Add an additional end of line character for run statements and error messages to the console",IDC_CHECKADDEXTRALINETOOUTPUT,
103-
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,342,352,11
103+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,342,312,10
104104
CONTROL "Automatically open console on error",IDC_CHECKOPENCONSOLEONERROR,
105-
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,355,352,11
105+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,355,131,9
106106
CONTROL "Color output from run statements differently",IDC_CHECKCOLORIZEOUTPUT,
107-
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,368,157,11
107+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | BS_NOTIFY | WS_TABSTOP,11,368,157,11
108+
PUSHBUTTON "Chose a color...",IDC_COLORCHOOSER,169,365,62,14
108109
END
109110

110111
IDD_PROMPTDIALOG DIALOGEX 0, 0, 313, 105

PythonScript/res/resource.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@
4141
#define IDC_CHECKADDEXTRALINETOOUTPUT 1021
4242
#define IDC_CHECKOPENCONSOLEONERROR 1022
4343
#define IDC_CHECKCOLORIZEOUTPUT 1023
44+
#define IDC_COLORCHOOSER 1024
45+
#define IDC_PICTUREBOX 1028
4446

4547
// Next default values for new objects
4648
//
4749
#ifdef APSTUDIO_INVOKED
4850
#ifndef APSTUDIO_READONLY_SYMBOLS
4951
#define _APS_NEXT_RESOURCE_VALUE 120
5052
#define _APS_NEXT_COMMAND_VALUE 40001
51-
#define _APS_NEXT_CONTROL_VALUE 1021
53+
#define _APS_NEXT_CONTROL_VALUE 1029
5254
#define _APS_NEXT_SYMED_VALUE 101
5355
#endif
5456
#endif

PythonScript/src/ShortcutDlg.cpp

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ShortcutDlg::ShortcutDlg(HINSTANCE hInst, NppData& nppData, const TCHAR *scriptD
1212
m_hListMenuItems(NULL),
1313
m_hListToolbarItems(NULL),
1414
m_hComboInitialisation(NULL),
15+
m_hButtonColor(NULL),
1516
m_hImageList(NULL),
1617
m_hDefaultImageIndex(0),
1718
m_hIcons(NULL),
@@ -74,6 +75,19 @@ INT_PTR CALLBACK ShortcutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
7475
return TRUE;
7576

7677
case WM_COMMAND:
78+
switch (LOWORD(wParam))
79+
{
80+
case IDC_COLORCHOOSER:
81+
ctrlOnClick();
82+
break;
83+
case IDC_CHECKCOLORIZEOUTPUT:
84+
if (HIWORD(wParam) == BN_CLICKED)
85+
{
86+
size_t result = SendMessage(reinterpret_cast<HWND>(lParam), BM_GETCHECK, 0, 0);
87+
EnableWindow(m_hButtonColor, (result == BST_CHECKED) ? true : false);
88+
}
89+
break;
90+
}
7791
switch(wParam)
7892
{
7993
case IDOK:
@@ -208,6 +222,7 @@ void ShortcutDlg::onInitDialog()
208222
m_hListMenuItems = ::GetDlgItem(_hSelf, IDC_MENUITEMLIST);
209223
m_hListToolbarItems = ::GetDlgItem(_hSelf, IDC_TOOLBARITEMLIST2);
210224
m_hComboInitialisation = ::GetDlgItem(_hSelf, IDC_COMBOINITIALISATION);
225+
m_hButtonColor = ::GetDlgItem(_hSelf, IDC_COLORCHOOSER);
211226
InitCommonControls();
212227
HICON hIcon; // handle to icon
213228

@@ -507,7 +522,8 @@ void ShortcutDlg::populateCurrentItems()
507522
CheckDlgButton(_hSelf, IDC_CHECKADDEXTRALINETOOUTPUT, addExtraLine ? BST_CHECKED : BST_UNCHECKED);
508523

509524
bool colorOutput = (configFile->getSetting(_T("COLORIZEOUTPUT")) >= _T("0"));
510-
CheckDlgButton(_hSelf, IDC_CHECKCOLORIZEOUTPUT, colorOutput ? BST_CHECKED : BST_UNCHECKED);
525+
CheckDlgButton(_hSelf, IDC_CHECKCOLORIZEOUTPUT, colorOutput ? BST_CHECKED : BST_UNCHECKED);
526+
EnableWindow(m_hButtonColor, colorOutput);
511527

512528
bool openOnError = (configFile->getSetting(_T("OPENCONSOLEONERROR")) == _T("1"));
513529
CheckDlgButton(_hSelf, IDC_CHECKOPENCONSOLEONERROR, openOnError ? BST_CHECKED : BST_UNCHECKED);
@@ -544,7 +560,7 @@ void ShortcutDlg::saveConfig()
544560
configFile->setSetting(_T("ADDEXTRALINETOOUTPUT"), addExtraLine ? _T("1"): _T("0"));
545561

546562
bool colorOutput = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKCOLORIZEOUTPUT));
547-
configFile->setSetting(_T("COLORIZEOUTPUT"), colorOutput ? _T("1234567") : _T("-1"));
563+
configFile->setSetting(_T("COLORIZEOUTPUT"), colorOutput ? ConfigFile::getInstance()->getSetting(_T("COLORIZEOUTPUT")) : _T("-1"));
548564

549565
bool openOnError = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKOPENCONSOLEONERROR));
550566
configFile->setSetting(_T("OPENCONSOLEONERROR"), openOnError ? _T("1") : _T("0"));
@@ -595,3 +611,29 @@ void ShortcutDlg::toolbarSetIcon()
595611
}
596612
}
597613
}
614+
615+
void ShortcutDlg::ctrlOnClick()
616+
{
617+
CHOOSECOLOR cc;
618+
static COLORREF acrCustClr[16];
619+
for (int i = 0; i < 16; i++)
620+
{
621+
acrCustClr[i] = RGB(255,255,255);
622+
}
623+
const tstring strRGBCurrent = ConfigFile::getInstance()->getSetting(_T("COLORIZEOUTPUT"));
624+
static DWORD rgbCurrent = (strRGBCurrent == _T("-1")) ? RGB(135,214,18) : stoi(strRGBCurrent);
625+
626+
ZeroMemory(&cc, sizeof(cc));
627+
cc.lStructSize = sizeof(cc);
628+
cc.hwndOwner = _hSelf;
629+
cc.lpCustColors = (LPDWORD)acrCustClr;
630+
cc.rgbResult = rgbCurrent;
631+
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
632+
633+
if (ChooseColor(&cc) == TRUE)
634+
{
635+
rgbCurrent = cc.rgbResult;
636+
ConfigFile::getInstance()->setSetting(_T("COLORIZEOUTPUT"), std::to_wstring(rgbCurrent));
637+
}
638+
639+
}

PythonScript/src/ShortcutDlg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class ShortcutDlg : public StaticDialog
4545

4646
void saveConfig();
4747

48+
void ctrlOnClick();
49+
4850
HTREEITEM addTreeItem(HTREEITEM parent, HTREEITEM lastItem, TCHAR *fullPath, TCHAR *text, bool isDirectory);
4951

5052
tstring m_userScriptDir;
@@ -53,6 +55,7 @@ class ShortcutDlg : public StaticDialog
5355
HWND m_hListMenuItems;
5456
HWND m_hListToolbarItems;
5557
HWND m_hComboInitialisation;
58+
HWND m_hButtonColor;
5659

5760
HIMAGELIST m_hImageList;
5861
int m_hDefaultImageIndex;

0 commit comments

Comments
 (0)