forked from wangjun7121/npp-task-list
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathTaskListDlg.h
101 lines (83 loc) · 2.81 KB
/
TaskListDlg.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
//this file is part of notepad++
//Copyright (C)2003 Don HO ( [email protected] )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#ifndef TASKLIST_DLG_H
#define TASKLIST_DLG_H
#include "DockingDlgInterface.h"
#include "Sci_Position.h"
#include "PluginDefinition.h"
#include "../resources/resource.h"
#include "PluginDefinition.h"
#include <codecvt>
typedef struct
{
char* text;
HWND hScintilla;
Sci_PositionCR startPosition;
Sci_PositionCR endPosition;
} TodoItem;
#include <list>
#include <vector>
class TaskListDlg : public DockingDlgInterface
{
public :
TaskListDlg() : DockingDlgInterface(IDD_TODOLIST_DIALOG){};
virtual void display(bool toShow = true) const {
DockingDlgInterface::display(toShow);
if (toShow)
::SetFocus(::GetDlgItem(_hSelf, ID_GOLINE_EDIT));
};
void setParent(HWND parent2set){
_hParent = parent2set;
};
std::string itemsFingerprint(const std::list<TodoItem>& itemList)
{
// Create an empty string to store the concatenated content.
std::string concatenatedText;
// Iterate through the sorted list and concatenate the 'text' members.
for (const TodoItem& item : itemList) {
concatenatedText += item.text;
}
return concatenatedText;
}
std::string todoItemsFingerprint;
void SetList(const std::list<TodoItem>& items)
{
todoItemsFingerprint = itemsFingerprint(items);
HWND _hList = ::GetDlgItem( _hSelf, ID_TODO_LIST );
if ( !_hList )
return;
//clear list LB_RESETCONTENT
::SendMessage( _hList, LB_RESETCONTENT, NULL, NULL );
todoItems.clear();
//add list items LB_ADDSTRING
for (const auto &it : items)
{
::SendMessage( _hList, LB_ADDSTRING, NULL, (LPARAM)converterX.from_bytes(it.text).c_str());
todoItems.push_back(it);
}
};
protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private :
//prepare for ut8 conversion
using convert_typeX = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_typeX, wchar_t> converterX;
std::vector<TodoItem> todoItems;
HBRUSH hbrBackgnd = NULL;
HWND GetCurScintilla();
};
#endif //TASKLIST_DLG_H