foobar2000 SDK  2015-08-03
Data Structures | Enumerations | Functions
InPlaceEdit Namespace Reference

Data Structures

class  CTableEditHelper
 
class  CTableEditHelperV2
 
class  CTableEditHelperV2_ListView
 

Enumerations

enum  {
  KEditAborted = 0, KEditTab, KEditShiftTab, KEditEnter,
  KEditLostFocus, KEditMaskReason = 0xFF, KEditFlagContentChanged = 0x100, KFlagReadOnly = 1 << 0,
  KFlagMultiLine = 1 << 1, KFlagAlignCenter = 1 << 2, KFlagAlignRight = 1 << 3
}
 

Functions

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)
 
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)
 
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)
 
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)
 
bool TableEditAdvance (unsigned &p_item, unsigned &p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened)
 
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)
 

Enumeration Type Documentation

anonymous enum
Enumerator
KEditAborted 
KEditTab 
KEditShiftTab 
KEditEnter 
KEditLostFocus 
KEditMaskReason 
KEditFlagContentChanged 
KFlagReadOnly 
KFlagMultiLine 
KFlagAlignCenter 
KFlagAlignRight 

Definition at line 3 of file inplace_edit.h.

Function Documentation

HWND InPlaceEdit::Start ( HWND  p_parentwnd,
const RECT &  p_rect,
bool  p_multiline,
pfc::rcptr_t< pfc::string_base p_content,
completion_notify_ptr  p_notify 
)

Definition at line 332 of file inplace_edit.cpp.

332  {
333  return StartEx(p_parentwnd,p_rect,p_multiline ? KFlagMultiLine : 0, p_content,p_notify);
334 }
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 InPlaceEdit::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 
)

Definition at line 336 of file inplace_edit.cpp.

336  {
337  Start_FromListViewEx(p_listview,p_item,p_subitem,p_linecount,0,p_content,p_notify);
338 }
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 InPlaceEdit::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 
)

Definition at line 419 of file inplace_edit.cpp.

419  {
420  try {
421  ListView_EnsureVisible(p_listview,p_item,FALSE);
422  RECT itemrect;
423  WIN32_OP_D( ListView_GetSubItemRect(p_listview,p_item,p_subitem,LVIR_LABEL,&itemrect) );
424 
425  const bool multiline = p_linecount > 1;
426  if (multiline) {
427  itemrect.bottom = itemrect.top + (itemrect.bottom - itemrect.top) * p_linecount;
428  }
429 
430  StartEx(p_listview,itemrect,p_flags | (multiline ? KFlagMultiLine : 0),p_content,p_notify);
431  } catch(...) {
432  fail(p_notify);
433  }
434 }
static void fail(completion_notify_ptr p_notify)
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)
HWND InPlaceEdit::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 
)

Definition at line 409 of file inplace_edit.cpp.

409  {
410  try {
411  PFC_ASSERT( (CWindow(p_parentwnd).GetWindowLong(GWL_STYLE) & WS_CLIPCHILDREN) != 0 );
412  return (new CWindowAutoLifetime<InPlaceEditContainer>(p_parentwnd,p_rect,p_flags,p_content,p_notify, ACData, ACOpts))->GetEditBox();
413  } catch(...) {
414  fail(p_notify);
415  return NULL;
416  }
417 }
static void fail(completion_notify_ptr p_notify)
bool InPlaceEdit::TableEditAdvance ( unsigned &  p_item,
unsigned &  p_column,
unsigned  p_item_count,
unsigned  p_column_count,
unsigned  p_whathappened 
)

Definition at line 371 of file inplace_edit.cpp.

371  {
372  if (p_item >= p_item_count || p_column >= p_column_count) return false;
373  int delta = 0;
374 
375  switch(p_whathappened & KEditMaskReason) {
376  case KEditEnter:
377  delta = (int) p_column_count;
378  break;
379  case KEditTab:
380  delta = 1;
381  break;
382  case KEditShiftTab:
383  delta = -1;
384  break;
385  default:
386  return false;
387  }
388  while(delta > 0) {
389  p_column++;
390  if (p_column >= p_column_count) {
391  p_column = 0;
392  p_item++;
393  if (p_item >= p_item_count) return false;
394  }
395  delta--;
396  }
397  while(delta < 0) {
398  if (p_column == 0) {
399  if (p_item == 0) return false;
400  p_item--;
401  p_column = p_column_count;
402  }
403  p_column--;
404  delta++;
405  }
406  return true;
407 }
bool InPlaceEdit::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 
)

Definition at line 340 of file inplace_edit.cpp.

340  {
341  if (p_column >= p_column_count) return false;
342 
343 
344  pfc::array_t<t_size> orderRev;
345  {
347  const unsigned orderExCount = /*p_column_base + p_column_count*/ ListView_GetColumnCount(p_listview);
348  PFC_ASSERT( orderExCount >= p_column_base + p_column_count );
349  pfc::array_t<int> orderEx; orderEx.set_size(orderExCount);
350  if (!ListView_GetColumnOrderArray(p_listview,orderExCount,orderEx.get_ptr())) {
351  PFC_ASSERT(!"Should not get here - probably mis-calculated column count");
352  return false;
353  }
354  order.set_size(p_column_count);
355  for(unsigned walk = 0; walk < p_column_count; ++walk) order[walk] = orderEx[p_column_base + walk];
356 
357  orderRev.set_size(p_column_count); order_helper::g_fill(orderRev);
358  pfc::sort_get_permutation_t(order,pfc::compare_t<unsigned,unsigned>,p_column_count,orderRev.get_ptr());
359  }
360 
361  unsigned columnVisible = (unsigned)orderRev[p_column];
362 
363 
364  if (!TableEditAdvance(p_item,columnVisible,p_item_count,p_column_count,p_whathappened)) return false;
365 
366  p_column = (unsigned)order_helper::g_find_reverse(orderRev.get_ptr(),columnVisible);
367 
368  return true;
369 }
static void sort_get_permutation_t(const t_container &p_data, t_compare p_compare, t_size p_count, t_permutation const &p_permutation)
Definition: sort.h:176
const t_item * get_ptr() const
Definition: array.h:213
static void g_fill(t_int *p_order, const t_size p_count)
Definition: order_helper.h:38
int ListView_GetColumnCount(HWND listView)
void set_size(t_size p_size)
Definition: array.h:104
bool TableEditAdvance(unsigned &p_item, unsigned &p_column, unsigned p_item_count, unsigned p_column_count, unsigned p_whathappened)
static t_size g_find_reverse(const t_size *order, t_size val)
Insecure - may deadlock or crash on invalid permutation content. In theory faster than walking the pe...
Definition: other.cpp:90