forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDialogNewSkin.h
163 lines (129 loc) · 4.17 KB
/
DialogNewSkin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/* Copyright (C) 2011 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#ifndef __DIALOGNEWSKIN_H__
#define __DIALOGNEWSKIN_H__
#include "../Common/Dialog.h"
#include "Logger.h"
#include "Skin.h"
class DialogNewSkin : public Dialog
{
public:
DialogNewSkin();
virtual ~DialogNewSkin();
DialogNewSkin(const DialogNewSkin& other) = delete;
DialogNewSkin& operator=(DialogNewSkin other) = delete;
static Dialog* GetDialog() { return c_Dialog; }
static void Open(const WCHAR* tabName, const WCHAR* parent);
static void Open(const WCHAR* name);
static void Open(int tab = 0);
static void ShowNewSkinDialog();
static void CloseDialog() { if (c_Dialog) c_Dialog->HandleMessage(WM_CLOSE, 0, 0); }
protected:
virtual INT_PTR HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnInitDialog(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
private:
// NewSkin tab
class TabNew : public Tab
{
public:
enum Id
{
Id_ParentPathLabel = 100,
Id_ItemsTreeView,
Id_AddFolderButton,
Id_AddResourcesButton,
Id_AddSkinButton,
Id_TemplateDropDownList
};
TabNew();
~TabNew();
void Create(HWND owner);
virtual void Initialize();
std::wstring& GetParentFolder() { return m_ParentFolder; }
void SetParentFolder(const WCHAR* folder);
std::wstring& GetSelectedTemplate() { return m_SelectedTemplate; }
static void SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR name);
protected:
virtual INT_PTR HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
INT_PTR OnNotify(WPARAM wParam, LPARAM lParam);
private:
// Helper struct for sorting treeview items
struct SortInfo
{
bool type;
std::wstring name;
SortInfo(bool t, std::wstring n) : type(t), name(n) {}
};
void DestroyImageList();
void UpdateParentPathLabel();
void UpdateParentPathTT(bool update);
void AddTreeItem(bool isFolder);
bool DoesNodeExist(HTREEITEM item, LPCWSTR text, bool isFolder);
static UINT GetChildSkinCount(HWND tree, HTREEITEM item);
static int CALLBACK TreeViewSortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
static std::wstring GetTreeSelectionPath(HWND tree, bool allItems);
static int PopulateTree(HWND tree, TVINSERTSTRUCT& tvi, int index, bool isParentFolder);
static LRESULT CALLBACK TreeEditSubclass(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam, UINT_PTR uId, DWORD_PTR data);
std::wstring m_ParentFolder;
std::wstring m_SelectedTemplate;
bool m_IsRoot;
bool m_CanAddResourcesFolder;
bool m_InRenameMode;
HWND m_TreeEdit;
HWND m_ParentPathTT;
HIMAGELIST m_ImageList;
static std::vector<SortInfo> s_SortInfo;
};
// Template tab
class TabTemplate : public Tab
{
public:
enum Id
{
Id_NewEdit = 100,
Id_SaveButton,
Id_TemplateListBox,
Id_EditButton,
Id_DeleteButton
};
TabTemplate();
void Create(HWND owner);
virtual void Initialize();
static void CreateTemplateMenu(HMENU menu, std::wstring selected);
static void CreateTemplate(std::wstring& file);
protected:
virtual INT_PTR HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR OnCommand(WPARAM wParam, LPARAM lParam);
private:
static void PopulateTemplates();
};
enum Id
{
Id_CloseButton = IDCLOSE,
Id_Tab = 100
};
struct CloseType
{
bool rootFolder;
UINT skins; // Not inc files
};
Tab& GetActiveTab();
static const std::wstring& GetTemplateFolder();
static void LoadTemplates();
static void ValidateSelectedTemplate();
TabNew m_TabNew;
TabTemplate m_TabTemplate;
static CloseType c_CloseAction;
static std::vector<std::wstring> c_Templates;
static WINDOWPLACEMENT c_WindowPlacement;
static DialogNewSkin* c_Dialog;
};
#endif