commit 3d512a29e74d89d4eb5c01fdfd8c145701e61b0f
parent c44d3dce68c0741eca7db3bf641070172cbc2459
Author: cfillion <cfillion@users.noreply.github.com>
Date: Sat, 30 Jan 2016 20:29:22 -0500
mild refactoring of Win32 code
Diffstat:
6 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/dialog.cpp b/src/dialog.cpp
@@ -78,7 +78,7 @@ WDL_DLGRET Dialog::Proc(HWND handle, UINT msg, WPARAM wParam, LPARAM lParam)
Dialog::Dialog(const int templateId)
: m_template(templateId), m_isVisible(false),
- m_parent(nullptr), m_handle(nullptr)
+ m_instance(nullptr), m_parent(nullptr), m_handle(nullptr)
{
// can't call reimplemented virtual methods here during object construction
}
@@ -91,6 +91,7 @@ Dialog::~Dialog()
INT_PTR Dialog::init(REAPER_PLUGIN_HINSTANCE inst, HWND parent, Modality mode)
{
+ m_instance = inst;
m_parent = parent;
switch(mode) {
@@ -163,7 +164,7 @@ void Dialog::setEnabled(const bool enabled, HWND handle)
EnableWindow(handle, enabled);
}
-HWND Dialog::getItem(const int idc)
+HWND Dialog::getControl(const int idc)
{
return GetDlgItem(m_handle, idc);
}
diff --git a/src/dialog.hpp b/src/dialog.hpp
@@ -56,6 +56,8 @@ public:
INT_PTR init(REAPER_PLUGIN_HINSTANCE, HWND, const Modality);
+ REAPER_PLUGIN_HINSTANCE instance() const { return m_instance; }
+ HWND parent() const { return m_parent; }
HWND handle() const { return m_handle; }
bool isVisible() const { return m_isVisible; }
@@ -77,7 +79,7 @@ protected:
Dialog(const int templateId);
virtual ~Dialog();
- HWND getItem(const int idc);
+ HWND getControl(const int idc);
virtual void onInit() = 0;
virtual void onShow();
@@ -95,6 +97,7 @@ private:
const int m_template;
bool m_isVisible;
+ REAPER_PLUGIN_HINSTANCE m_instance;
HWND m_parent;
HWND m_handle;
};
diff --git a/src/listview.cpp b/src/listview.cpp
@@ -27,24 +27,24 @@ ListView::ListView(const Columns &columns, HWND handle)
: m_handle(handle), m_columnSize(0), m_rowSize(0)
{
for(const Column &col : columns)
- addColumn(col.first, col.second);
+ addColumn(col);
// For some reason FULLROWSELECT doesn't work from the resource file
ListView_SetExtendedListViewStyleEx(m_handle,
LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
}
-void ListView::addColumn(const auto_string &text, const int width)
+void ListView::addColumn(const Column &col)
{
- LVCOLUMN col{};
+ LVCOLUMN item{};
- col.mask |= LVCF_WIDTH;
- col.cx = width;
+ item.mask |= LVCF_WIDTH;
+ item.cx = col.width;
- col.mask |= LVCF_TEXT;
- col.pszText = const_cast<auto_char *>(text.c_str());
+ item.mask |= LVCF_TEXT;
+ item.pszText = const_cast<auto_char *>(col.text.c_str());
- ListView_InsertColumn(m_handle, m_columnSize++, &col);
+ ListView_InsertColumn(m_handle, m_columnSize++, &item);
}
int ListView::addRow(const Row &content)
diff --git a/src/listview.hpp b/src/listview.hpp
@@ -31,7 +31,7 @@
class ListView {
public:
- typedef std::pair<auto_string, int> Column;
+ struct Column { auto_string text; int width; };
typedef std::vector<Column> Columns;
typedef std::vector<auto_string> Row;
@@ -55,7 +55,7 @@ public:
void onNotify(LPNMHDR, LPARAM);
private:
- void addColumn(const auto_string &text, const int width);
+ void addColumn(const Column &);
HWND m_handle;
int m_columnSize;
diff --git a/src/manager.cpp b/src/manager.cpp
@@ -51,7 +51,7 @@ void Manager::onInit()
{AUTO_STR("Name"), 110},
{AUTO_STR("URL"), URL_WIDTH},
{AUTO_STR("State"), 60},
- }, getItem(IDC_LIST));
+ }, getControl(IDC_LIST));
}
void Manager::onCommand(const int id)
diff --git a/src/progress.cpp b/src/progress.cpp
@@ -51,7 +51,7 @@ void Progress::setTransaction(Transaction *t)
void Progress::onInit()
{
- m_label = getItem(IDC_LABEL);
+ m_label = getControl(IDC_LABEL);
m_progress = GetDlgItem(handle(), IDC_PROGRESS);
}