foobar2000 SDK  2015-08-03
inplace_edit_v2.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 
3 namespace InPlaceEdit {
4 
6  PFC_ASSERT( TableEdit_IsColumnEditable(col) );
7  pfc::array_t<t_size> colOrder; GrabColumnOrder(colOrder);
8  t_size skipped = 0;
9  for(t_size walk = 0; walk < colOrder.get_size(); ++walk) {
10  const t_size curCol = colOrder[walk];
11  if (TableEdit_IsColumnEditable(curCol)) {
12  if (curCol == col) return skipped;
13  ++skipped;
14  }
15  }
16  PFC_ASSERT( !"Should not get here." );
17  return ~0;
18  }
20  pfc::array_t<t_size> colOrder; GrabColumnOrder(colOrder);
21  t_size skipped = 0;
22  for(t_size walk = 0; walk < colOrder.get_size(); ++walk) {
23  const t_size curCol = colOrder[walk];
24  if (TableEdit_IsColumnEditable(curCol)) {
25  if (skipped == pos) return curCol;
26  ++skipped;
27  }
28  }
29  PFC_ASSERT( !"Should not get here." );
30  return ~0;
31  }
33  const t_size total = TableEdit_GetColumnCount();
34  t_size found = 0;
35  for(t_size walk = 0; walk < total; ++walk) {
36  if (TableEdit_IsColumnEditable(walk)) found++;
37  }
38  return found;
39  }
40 
41  bool CTableEditHelperV2::TableEdit_Advance(t_size & item, t_size & subItem, t_uint32 whathappened) {
42  //moo
43  unsigned _item((unsigned)item), _subItem((unsigned)ColumnToPosition(subItem));
44  if (!InPlaceEdit::TableEditAdvance(_item,_subItem,(unsigned) TableEdit_GetItemCount(), (unsigned) EditableColumnCount(), whathappened)) return false;
45  item = _item; subItem = PositionToColumn(_subItem);
46  return true;
47  }
48 
49  void CTableEditHelperV2::TableEdit_Abort(bool forwardContent) {
50  if (this->have_task(KTaskID)) {
51  this->orphan_task(KTaskID);
52  if (forwardContent && (m_editFlags & KFlagReadOnly) == 0) {
53  if (m_editData.is_valid()) {
54  pfc::string8 temp(*m_editData);
56  }
57  }
59  SetFocus(NULL);
61  }
62 
63  }
64 
66  PFC_ASSERT( TableEdit_IsColumnEditable( subItem ) );
67  m_editItem = item; m_editSubItem = subItem;
68  _ReStart();
69  }
70 
72  PFC_ASSERT( m_editItem < TableEdit_GetItemCount() );
73  PFC_ASSERT( m_editSubItem < TableEdit_GetColumnCount() );
74 
76  m_editData.new_t();
77  t_size lineCount = 1;
80 
82  if (lineCount > 1) {
83  rc.bottom = rc.top + (rc.bottom - rc.top) * lineCount;
85  }
88 
90  }
91 
92  void CTableEditHelperV2::on_task_completion(unsigned id, unsigned status) {
93  if (id == KTaskID) {
95  if (m_editData.is_valid()) {
98  }
100  }
101 
103  _ReStart();
104  } else {
106  }
107  }
108  }
109 
110 
111 
112 
113 
115  pfc::array_t<int> temp; temp.set_size(count);
116  WIN32_OP_D( ListView_GetColumnOrderArray( TableEdit_GetParentWnd(), count, temp.get_ptr() ) );
117  for(t_size walk = 0; walk < count; ++walk) out[walk] = temp[walk];
118  }
119 
121  RECT rc;
122  WIN32_OP_D( ListView_GetSubItemRect(TableEdit_GetParentWnd(),item,subItem,LVIR_LABEL,&rc) );
123  return rc;
124  }
125 
128  lineCount = pfc::is_multiline(out) ? 5 : 1;
129  }
130  void CTableEditHelperV2_ListView::TableEdit_SetField(t_size item, t_size subItem, const char * value) {
131  WIN32_OP_D( listview_helper::set_item_text( TableEdit_GetParentWnd(), item, subItem, value) );
132  }
134  LRESULT temp;
135  WIN32_OP_D( ( temp = ListView_GetItemCount( TableEdit_GetParentWnd() ) ) >= 0 );
136  return (t_size) temp;
137  }
140  }
141 }
virtual t_uint32 TableEdit_GetEditFlags(t_size item, t_size subItem) const
bool have_task(unsigned p_id) const
void orphan_task(unsigned p_id)
const t_item * get_ptr() const
Definition: array.h:213
void new_t()
Definition: rcptr.h:101
void TableEdit_Abort(bool forwardContent)
T * get_ptr() const
Definition: com_ptr_t.h:49
bool set_item_text(HWND p_listview, unsigned p_index, unsigned p_column, const char *p_name)
t_size ColumnToPosition(t_size col) const
t_size PositionToColumn(t_size pos) const
bool is_multiline(const char *p_string, t_size p_len)
virtual void TableEdit_SetField(t_size item, t_size subItem, const char *value)=0
virtual t_size TableEdit_GetColumnCount() const =0
virtual t_size TableEdit_GetItemCount() const =0
virtual bool TableEdit_GetAutoComplete(t_size item, t_size subItem, pfc::com_ptr_t< IUnknown > &out)
static const unsigned KTaskID
void get_item_text(HWND p_listview, unsigned p_index, unsigned p_column, pfc::string_base &p_out)
void TableEdit_GetColumnOrder(t_size *out, t_size count) const
void TableEdit_Start(t_size item, t_size subItem)
size_t t_size
Definition: int_types.h:48
void on_task_completion(unsigned p_id, unsigned p_status)
void set_size(t_size p_size)
Definition: array.h:104
pfc::rcptr_t< pfc::string8 > m_editData
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)
virtual bool TableEdit_IsColumnEditable(t_size subItem) const
completion_notify_ptr create_task(unsigned p_id)
virtual HWND TableEdit_GetParentWnd() const =0
void TableEdit_SetItemFocus(t_size item, t_size subItem)
void TableEdit_SetField(t_size item, t_size subItem, const char *value)
bool TableEditAdvance(unsigned &p_item, unsigned &p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened)
RECT TableEdit_GetItemRect(t_size item, t_size subItem) const
void release()
Definition: com_ptr_t.h:41
virtual void TableEdit_SetItemFocus(t_size item, t_size subItem)=0
void GrabColumnOrder(pfc::array_t< t_size > &buffer) const
virtual RECT TableEdit_GetItemRect(t_size item, t_size subItem) const =0
void release()
Definition: rcptr.h:86
virtual bool TableEdit_Advance(t_size &item, t_size &subItem, t_uint32 whathappened)
bool select_single_item(HWND p_listview, unsigned p_index)
t_size get_size() const
Definition: array.h:130
bool is_valid() const
Definition: rcptr.h:80
void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base &out, t_size &lineCount)
uint32_t t_uint32
Definition: int_types.h:5
virtual void TableEdit_GetField(t_size item, t_size subItem, pfc::string_base &out, t_size &lineCount)=0