From 6613345b8d2a3aaf95cb1947863496bb91bdebc4 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 25 Jun 2015 09:23:44 +0000 Subject: MirLua: added open button in script list git-svn-id: http://svn.miranda-ng.org/main/trunk@14373 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_options.cpp | 51 +++++++++++++++++++++++++++++++++++-- plugins/MirLua/src/mlua_options.h | 20 +++++++++++++-- plugins/MirLua/src/resource.h | 6 ++--- 3 files changed, 69 insertions(+), 8 deletions(-) (limited to 'plugins/MirLua/src') diff --git a/plugins/MirLua/src/mlua_options.cpp b/plugins/MirLua/src/mlua_options.cpp index bd8234ed9a..9c59e246e3 100644 --- a/plugins/MirLua/src/mlua_options.cpp +++ b/plugins/MirLua/src/mlua_options.cpp @@ -1,9 +1,28 @@ #include "stdafx.h" +CCtrlScriptList::CCtrlScriptList(CDlgBase* dlg, int ctrlId) + : CCtrlListView(dlg, ctrlId) +{ +} + +BOOL CCtrlScriptList::OnNotify(int idCtrl, NMHDR *pnmh) +{ + if (pnmh->code == NM_CLICK) + { + TEventInfo evt = { this, pnmh }; + OnClick(&evt); + return TRUE; + } + return CCtrlListView::OnNotify(idCtrl, pnmh); +} + +/****************************************/ + CLuaOptions::CLuaOptions(int idDialog) : CDlgBase(g_hInstance, idDialog), m_scripts(this, IDC_SCRIPTS), isScriptListInit(false), m_reload(this, IDC_RELOAD) { + m_scripts.OnClick = Callback(this, &CLuaOptions::OnScriptListClick); m_reload.OnClick = Callback(this, &CLuaOptions::OnReload); } @@ -45,6 +64,7 @@ void CLuaOptions::LoadScripts(const TCHAR *scriptDir, int iGroup) int iItem = m_scripts.AddItem(fd.cFileName, -1, NULL, iGroup); if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1)) m_scripts.SetCheckState(iItem, TRUE); + m_scripts.SetItem(iItem, 1, _T(""), 0); } } while (FindNextFile(hFind, &fd)); FindClose(hFind); @@ -71,9 +91,14 @@ void CLuaOptions::OnInitDialog() { CDlgBase::OnInitDialog(); - m_scripts.SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); + m_scripts.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); m_scripts.EnableGroupView(TRUE); - m_scripts.AddColumn(0, _T("Script"), 300); + m_scripts.AddColumn(0, _T("Script"), 440); + m_scripts.AddColumn(1, NULL, 32 - GetSystemMetrics(SM_CXVSCROLL)); + + HIMAGELIST hImageList = m_scripts.CreateImageList(LVSIL_SMALL); + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OPEN)); + ImageList_AddIcon(hImageList, icon); LoadScripts(); @@ -117,6 +142,28 @@ INT_PTR CLuaOptions::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) return CDlgBase::DlgProc(msg, wParam, lParam); } +void CLuaOptions::OnScriptListClick(CCtrlListView::TEventInfo *evt) +{ + LVITEM lvi = { 0 }; + lvi.iItem = evt->nmlvia->iItem; + if (lvi.iItem == -1) return; + lvi.pszText = (LPTSTR)mir_calloc(MAX_PATH * sizeof(TCHAR)); + lvi.cchTextMax = MAX_PATH; + lvi.mask = LVIF_GROUPID | LVIF_TEXT; + evt->treeviewctrl->GetItem(&lvi); + lvi.iSubItem = evt->nmlvia->iSubItem; + if (lvi.iSubItem == 1) + { + TCHAR path[MAX_PATH]; + if (lvi.iGroupId == 0) + FoldersGetCustomPathT(g_hCommonFolderPath, path, _countof(path), VARST(COMMON_SCRIPTS_PATHT)); + else + FoldersGetCustomPathT(g_hCustomFolderPath, path, _countof(path), VARST(CUSTOM_SCRIPTS_PATHT)); + ShellExecute(m_hwnd, NULL, lvi.pszText, NULL, path, SW_SHOWNORMAL); + } + mir_free(lvi.pszText); +} + void CLuaOptions::OnReload(CCtrlBase*) { isScriptListInit = false; diff --git a/plugins/MirLua/src/mlua_options.h b/plugins/MirLua/src/mlua_options.h index 4972656260..f6fd0db164 100644 --- a/plugins/MirLua/src/mlua_options.h +++ b/plugins/MirLua/src/mlua_options.h @@ -1,11 +1,26 @@ #ifndef _LUA_OPTIONS_H_ #define _LUA_OPTIONS_H_ +class CCtrlScriptList : public CCtrlListView +{ +private: + typedef CCtrlListView CSuper; + +protected: + BOOL OnNotify(int idCtrl, NMHDR *pnmh); + +public: + CCtrlScriptList(CDlgBase* dlg, int ctrlId); + + CCallback OnClick; +}; + + class CLuaOptions : public CDlgBase { private: bool isScriptListInit; - CCtrlListView m_scripts; + CCtrlScriptList m_scripts; CCtrlButton m_reload; void LoadScripts(const TCHAR *scriptDir, int iGroup = -1); @@ -15,6 +30,7 @@ protected: void OnInitDialog(); void OnApply(); + void OnScriptListClick(CCtrlListView::TEventInfo *evt); void OnReload(CCtrlBase*); INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); @@ -33,7 +49,7 @@ public: ctrl.CreateDbLink(new CMOptionLink(option)); } - static CDlgBase *CreateOptionsPage() { return new CLuaOptions(IDD_OPTIONS_MAIN); } + static CDlgBase *CreateOptionsPage() { return new CLuaOptions(IDD_OPTIONS); } }; #endif //_LUA_OPTIONS_H_ \ No newline at end of file diff --git a/plugins/MirLua/src/resource.h b/plugins/MirLua/src/resource.h index 612051cbad..6e93d57ad5 100644 --- a/plugins/MirLua/src/resource.h +++ b/plugins/MirLua/src/resource.h @@ -3,18 +3,16 @@ // Used by d:\Projects\MirandaNG\plugins\MirLua\res\resource.rc // #define IDI_ICON 100 -#define IDD_OPTIONS_MAIN 106 +#define IDI_OPEN 105 #define IDD_OPTIONS 106 -#define IDC_LIST1 1011 #define IDC_SCRIPTS 1011 -#define IDC_BUTTON1 1012 #define IDC_RELOAD 1012 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1013 #define _APS_NEXT_SYMED_VALUE 101 -- cgit v1.2.3