foobar2000 SDK  2015-08-03
inplace_edit.h
Go to the documentation of this file.
1 namespace InPlaceEdit {
2 
3  enum {
9 
12 
13  KFlagReadOnly = 1 << 0,
14  KFlagMultiLine = 1 << 1,
15  KFlagAlignCenter = 1 << 2,
16  KFlagAlignRight = 1 << 3,
17  };
18 
19  HWND Start(HWND p_parentwnd,const RECT & p_rect,bool p_multiline,pfc::rcptr_t<pfc::string_base> p_content,completion_notify_ptr p_notify);
20 
21  HWND StartEx(HWND p_parentwnd,const RECT & p_rect,unsigned p_flags,pfc::rcptr_t<pfc::string_base> p_content,completion_notify_ptr p_notify, IUnknown * ACData = NULL, DWORD ACOpts = 0);
22 
23  void Start_FromListView(HWND p_listview,unsigned p_item,unsigned p_subitem,unsigned p_linecount,pfc::rcptr_t<pfc::string_base> p_content,completion_notify_ptr p_notify);
24  void Start_FromListViewEx(HWND p_listview,unsigned p_item,unsigned p_subitem,unsigned p_linecount,unsigned p_flags,pfc::rcptr_t<pfc::string_base> p_content,completion_notify_ptr p_notify);
25 
26  bool TableEditAdvance(unsigned & p_item,unsigned & p_column, unsigned p_item_count,unsigned p_column_count, unsigned p_whathappened);
27  bool TableEditAdvance_ListView(HWND p_listview,unsigned p_column_base,unsigned & p_item,unsigned & p_column, unsigned p_item_count,unsigned p_column_count, unsigned p_whathappened);
28 
29 
31  public:
32  void TableEdit_Start(HWND p_listview,unsigned p_item,unsigned p_column,unsigned p_itemcount,unsigned p_columncount,unsigned p_basecolumn,unsigned p_flags = 0) {
33  if (m_notify.is_valid() || p_columncount == 0 || p_itemcount == 0 || p_item >= p_itemcount || p_column >= p_columncount) return;
34  m_listview = p_listview;
35  m_item = p_item;
36  m_column = p_column;
37  m_itemcount = p_itemcount;
38  m_columncount = p_columncount;
39  m_basecolumn = p_basecolumn;
40  m_flags = p_flags;
41  __Start();
42  }
43 
44  void TableEdit_Abort(bool p_forwardcontent) {
45  if (m_notify.is_valid()) {
46  m_notify->orphan();
47  m_notify.release();
48 
49  if (p_forwardcontent && (m_flags & KFlagReadOnly) == 0) {
50  if (m_content.is_valid()) {
51  pfc::string8 temp(*m_content);
54  }
55  } else {
57  }
58  SetFocus(NULL);
60  }
61  }
62 
63 
64  bool TableEdit_IsActive() const {
65  return m_notify.is_valid();
66  }
67 
68  virtual bool TableEdit_GetItemText(unsigned p_item,unsigned p_column,pfc::string_base & p_out,unsigned & p_linecount) {
70  p_linecount = pfc::is_multiline(p_out) ? 5 : 1;
71  return true;
72  }
73  virtual void TableEdit_SetItemText(unsigned p_item,unsigned p_column,const char * p_text) {
74  listview_helper::set_item_text(m_listview,p_item,p_column + m_basecolumn,p_text);
75  }
76 
77  virtual void TableEdit_Finished() {}
78 
79  void on_task_completion(unsigned p_taskid,unsigned p_state) {
80  if (p_taskid == KTaskID) {
81  m_notify.release();
82  if (m_content.is_valid()) {
85  }
87  }
88  /*if (InPlaceEdit::TableEditAdvance(m_item,m_column,m_itemcount,m_columncount,p_state))*/
91  __Start();
92  } else {
94  }
95  }
96  }
97 
99  if (m_notify.is_valid()) {
100  m_notify->orphan();
101  m_notify.release();
102  }
103  }
104  protected:
105  HWND TableEdit_GetListView() const {return m_listview;}
106  //return false to abort
107  virtual bool TableEdit_OnEditCompleted(unsigned item,unsigned column,unsigned state) {return true;}
108  private:
109  void __Start() {
111  m_content.new_t();
112  unsigned linecount = 1;
113  if (!TableEdit_GetItemText(m_item,m_column,*m_content,linecount)) return;
116  }
117  enum {
118  KTaskID = 0xc0ffee
119  };
121  unsigned m_item,m_column;
123  unsigned m_flags;
126  };
127 
128 }
void TableEdit_Abort(bool p_forwardcontent)
Definition: inplace_edit.h:44
void new_t()
Definition: rcptr.h:101
HWND TableEdit_GetListView() const
Definition: inplace_edit.h:105
bool set_item_text(HWND p_listview, unsigned p_index, unsigned p_column, const char *p_name)
void Start_FromListView(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, pfc::rcptr_t< pfc::string_base > p_content, completion_notify_ptr p_notify)
virtual void TableEdit_Finished()
Definition: inplace_edit.h:77
virtual bool TableEdit_GetItemText(unsigned p_item, unsigned p_column, pfc::string_base &p_out, unsigned &p_linecount)
Definition: inplace_edit.h:68
void TableEdit_Start(HWND p_listview, unsigned p_item, unsigned p_column, unsigned p_itemcount, unsigned p_columncount, unsigned p_basecolumn, unsigned p_flags=0)
Definition: inplace_edit.h:32
service_ptr_t< completion_notify_orphanable > m_notify
Definition: inplace_edit.h:125
bool is_multiline(const char *p_string, t_size p_len)
virtual bool TableEdit_OnEditCompleted(unsigned item, unsigned column, unsigned state)
Definition: inplace_edit.h:107
void get_item_text(HWND p_listview, unsigned p_index, unsigned p_column, pfc::string_base &p_out)
bool is_valid() const
Definition: service.h:119
virtual void TableEdit_SetItemText(unsigned p_item, unsigned p_column, const char *p_text)
Definition: inplace_edit.h:73
bool TableEdit_IsActive() const
Definition: inplace_edit.h:64
HWND StartEx(HWND p_parentwnd, const RECT &p_rect, unsigned p_flags, pfc::rcptr_t< pfc::string_base > p_content, completion_notify_ptr p_notify, IUnknown *ACData=NULL, DWORD ACOpts=0)
void release()
Definition: service.h:109
void on_task_completion(unsigned p_taskid, unsigned p_state)
Definition: inplace_edit.h:79
bool TableEditAdvance(unsigned &p_item, unsigned &p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened)
service_nnptr_t< completion_notify_orphanable > completion_notify_create(t_receiver *p_receiver, unsigned p_taskid)
void Start_FromListViewEx(HWND p_listview, unsigned p_item, unsigned p_subitem, unsigned p_linecount, unsigned p_flags, pfc::rcptr_t< pfc::string_base > p_content, completion_notify_ptr p_notify)
void release()
Definition: rcptr.h:86
bool select_single_item(HWND p_listview, unsigned p_index)
bool TableEditAdvance_ListView(HWND p_listview, unsigned p_column_base, unsigned &p_item, unsigned &p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened)
pfc::rcptr_t< pfc::string8 > m_content
Definition: inplace_edit.h:124
bool is_valid() const
Definition: rcptr.h:80
HWND Start(HWND p_parentwnd, const RECT &p_rect, bool p_multiline, pfc::rcptr_t< pfc::string_base > p_content, completion_notify_ptr p_notify)