|
1
|
1 #include "StdAfx.h"
|
|
|
2 #include "CTableEditHelper-Legacy.h"
|
|
|
3 #include <libPPUI/listview_helper.h>
|
|
|
4
|
|
|
5 namespace InPlaceEdit {
|
|
|
6 void CTableEditHelper::TableEdit_Start(HWND p_listview, unsigned p_item, unsigned p_column, unsigned p_itemcount, unsigned p_columncount, unsigned p_basecolumn, unsigned p_flags) {
|
|
|
7 if (m_notify.is_valid() || p_columncount == 0 || p_itemcount == 0 || p_item >= p_itemcount || p_column >= p_columncount) return;
|
|
|
8 m_listview = p_listview;
|
|
|
9 m_item = p_item;
|
|
|
10 m_column = p_column;
|
|
|
11 m_itemcount = p_itemcount;
|
|
|
12 m_columncount = p_columncount;
|
|
|
13 m_basecolumn = p_basecolumn;
|
|
|
14 m_flags = p_flags;
|
|
|
15 _Start();
|
|
|
16 }
|
|
|
17
|
|
|
18 void CTableEditHelper::TableEdit_Abort(bool p_forwardcontent) {
|
|
|
19 if (m_notify.is_valid()) {
|
|
|
20 m_notify->orphan();
|
|
|
21 m_notify.release();
|
|
|
22
|
|
|
23 if (p_forwardcontent && (m_flags & KFlagReadOnly) == 0) {
|
|
|
24 if (m_content.is_valid()) {
|
|
|
25 pfc::string8 temp(*m_content);
|
|
|
26 m_content.release();
|
|
|
27 TableEdit_SetItemText(m_item, m_column, temp);
|
|
|
28 }
|
|
|
29 } else {
|
|
|
30 m_content.release();
|
|
|
31 }
|
|
|
32 SetFocus(NULL);
|
|
|
33 TableEdit_Finished();
|
|
|
34 }
|
|
|
35 }
|
|
|
36
|
|
|
37 bool CTableEditHelper::TableEdit_GetItemText(unsigned p_item, unsigned p_column, pfc::string_base & p_out, unsigned & p_linecount) {
|
|
|
38 listview_helper::get_item_text(m_listview, p_item, p_column + m_basecolumn, p_out);
|
|
|
39 p_linecount = pfc::is_multiline(p_out) ? 5 : 1;
|
|
|
40 return true;
|
|
|
41 }
|
|
|
42 void CTableEditHelper::TableEdit_SetItemText(unsigned p_item, unsigned p_column, const char * p_text) {
|
|
|
43 listview_helper::set_item_text(m_listview, p_item, p_column + m_basecolumn, p_text);
|
|
|
44 }
|
|
|
45
|
|
|
46 void CTableEditHelper::on_task_completion(unsigned p_taskid, unsigned p_state) {
|
|
|
47 if (p_taskid == KTaskID) {
|
|
|
48 m_notify.release();
|
|
|
49 if (m_content.is_valid()) {
|
|
|
50 if (p_state & InPlaceEdit::KEditFlagContentChanged) {
|
|
|
51 TableEdit_SetItemText(m_item, m_column, *m_content);
|
|
|
52 }
|
|
|
53 m_content.release();
|
|
|
54 }
|
|
|
55 /*if (InPlaceEdit::TableEditAdvance(m_item,m_column,m_itemcount,m_columncount,p_state))*/
|
|
|
56 if (TableEdit_OnEditCompleted(m_item, m_column, p_state) &&
|
|
|
57 InPlaceEdit::TableEditAdvance_ListView(m_listview, m_basecolumn, m_item, m_column, m_itemcount, m_columncount, p_state)) {
|
|
|
58 _Start();
|
|
|
59 } else {
|
|
|
60 TableEdit_Finished();
|
|
|
61 }
|
|
|
62 }
|
|
|
63 }
|
|
|
64
|
|
|
65 CTableEditHelper::~CTableEditHelper() {
|
|
|
66 if (m_notify.is_valid()) {
|
|
|
67 m_notify->orphan();
|
|
|
68 m_notify.release();
|
|
|
69 }
|
|
|
70 }
|
|
|
71
|
|
|
72 void CTableEditHelper::_Start() {
|
|
|
73 listview_helper::select_single_item(m_listview, m_item);
|
|
|
74 m_content.new_t();
|
|
|
75 unsigned linecount = 1;
|
|
|
76 if (!TableEdit_GetItemText(m_item, m_column, *m_content, linecount)) return;
|
|
|
77 m_notify = completion_notify_create(this, KTaskID);
|
|
|
78 InPlaceEdit::Start_FromListViewEx(m_listview, m_item, m_column + m_basecolumn, linecount, m_flags, m_content, m_notify);
|
|
|
79 }
|
|
|
80 }
|