foobar2000 SDK  2015-08-03
Data Structures | Typedefs | Enumerations | Functions
misc.h File Reference

Go to the source code of this file.

Data Structures

class  CAddDummyMessageMap< TClass >
 
class  CContainedWindowSimpleT< TBase >
 
class  CDialogWithTooltip< T >
 
class  CEmbeddedDialog
 
class  CFlashWindow
 
class  CMenuDescriptionHybrid
 
class  CMenuDescriptionMap
 
class  CMenuSelectionReceiver
 
class  CMenuSelectionReceiver_UiElement
 
class  CMessageMapDummy
 
class  CPopupTooltipMessage
 
class  CSeparator
 
class  CStaticMainInstruction
 
class  CStaticSeparator
 
class  CStaticThemed
 
class  CTextControl< TClass >
 
class  CTypableWindowScope
 
class  CWindowAutoLifetime< TClass >
 
class  CWindowFixSEH< _parentClass >
 
class  ImplementModelessTracking< TClass >
 
class  preferences_page_impl< TDialog >
 
class  preferences_page_instance_impl< TDialog >
 
class  window_service_impl_t< _t_base >
 

Typedefs

typedef CWinTraits< WS_POPUP, WS_EX_TRANSPARENT|WS_EX_LAYERED|WS_EX_TOPMOST|WS_EX_TOOLWINDOW > CFlashWindowTraits
 

Enumerations

enum  CONTROLLABELSTATES { TS_CONTROLLABEL_NORMAL = 1, TS_CONTROLLABEL_DISABLED = 2 }
 
enum  HYPERLINKTEXTSTATES { TS_HYPERLINK_NORMAL = 1, TS_HYPERLINK_HOT = 2, TS_HYPERLINK_PRESSED = 3, TS_HYPERLINK_DISABLED = 4 }
 
enum  TEXTSTYLEPARTS {
  TEXT_MAININSTRUCTION = 1, TEXT_INSTRUCTION = 2, TEXT_BODYTITLE = 3, TEXT_BODYTEXT = 4,
  TEXT_SECONDARYTEXT = 5, TEXT_HYPERLINKTEXT = 6, TEXT_EXPANDED = 7, TEXT_LABEL = 8,
  TEXT_CONTROLLABEL = 9
}
 

Functions

static void AppendMenuPopup (HMENU menu, UINT flags, CMenu &popup, const TCHAR *label)
 
static void HeaderControl_SetSortIndicator (CHeaderCtrl header, int column, bool isUp)
 
static void ListView_FixContextMenuPoint (CListViewCtrl list, CPoint &coords)
 
pfc::string_baseoperator<< (pfc::string_base &p_fmt, const CPoint &p_point)
 
pfc::string_baseoperator<< (pfc::string_base &p_fmt, const CRect &p_rect)
 
void PaintSeparatorControl (CWindow wnd)
 
static void ui_element_instance_standard_context_menu (service_ptr_t< ui_element_instance > p_elem, LPARAM p_pt)
 
static void ui_element_instance_standard_context_menu_eh (service_ptr_t< ui_element_instance > p_elem, LPARAM p_pt)
 
static bool window_service_trait_defer_destruction (const service_base *)
 
static bool window_service_trait_defer_destruction (const preferences_page_instance *)
 

Typedef Documentation

typedef CWinTraits<WS_POPUP,WS_EX_TRANSPARENT|WS_EX_LAYERED|WS_EX_TOPMOST|WS_EX_TOOLWINDOW> CFlashWindowTraits

Definition at line 205 of file misc.h.

Enumeration Type Documentation

Enumerator
TS_CONTROLLABEL_NORMAL 
TS_CONTROLLABEL_DISABLED 

Definition at line 580 of file misc.h.

Enumerator
TS_HYPERLINK_NORMAL 
TS_HYPERLINK_HOT 
TS_HYPERLINK_PRESSED 
TS_HYPERLINK_DISABLED 

Definition at line 573 of file misc.h.

Enumerator
TEXT_MAININSTRUCTION 
TEXT_INSTRUCTION 
TEXT_BODYTITLE 
TEXT_BODYTEXT 
TEXT_SECONDARYTEXT 
TEXT_HYPERLINKTEXT 
TEXT_EXPANDED 
TEXT_LABEL 
TEXT_CONTROLLABEL 

Definition at line 561 of file misc.h.

Function Documentation

static void AppendMenuPopup ( HMENU  menu,
UINT  flags,
CMenu &  popup,
const TCHAR *  label 
)
static

Definition at line 349 of file misc.h.

349  {
350  PFC_ASSERT( flags & MF_POPUP );
351  WIN32_OP( CMenuHandle(menu).AppendMenu(flags, popup, label) );
352  popup.Detach();
353 }
static void HeaderControl_SetSortIndicator ( CHeaderCtrl  header,
int  column,
bool  isUp 
)
static

Definition at line 186 of file misc.h.

186  {
187  const int total = header.GetItemCount();
188  for(int walk = 0; walk < total; ++walk) {
189  HDITEM item = {}; item.mask = HDI_FORMAT;
190  if (header.GetItem(walk,&item)) {
191  DWORD newFormat = item.fmt;
192  newFormat &= ~( HDF_SORTUP | HDF_SORTDOWN );
193  if (walk == column) {
194  newFormat |= isUp ? HDF_SORTUP : HDF_SORTDOWN;
195  }
196  if (newFormat != item.fmt) {
197  item.fmt = newFormat;
198  header.SetItem(walk,&item);
199  }
200  }
201  }
202 }
static void ListView_FixContextMenuPoint ( CListViewCtrl  list,
CPoint &  coords 
)
static

Definition at line 459 of file misc.h.

459  {
460  if (coords == CPoint(-1,-1)) {
461  int selWalk = -1;
462  CRect rcClient; WIN32_OP_D(list.GetClientRect(rcClient));
463  for(;;) {
464  selWalk = list.GetNextItem(selWalk, LVNI_SELECTED);
465  if (selWalk < 0) {
466  CRect rc;
467  WIN32_OP_D( list.GetWindowRect(&rc) );
468  coords = rc.CenterPoint();
469  return;
470  }
471  CRect rcItem, rcVisible;
472  WIN32_OP_D( list.GetItemRect(selWalk, &rcItem, LVIR_BOUNDS) );
473  if (rcVisible.IntersectRect(rcItem, rcClient)) {
474  coords = rcVisible.CenterPoint();
475  WIN32_OP_D( list.ClientToScreen(&coords) );
476  return;
477  }
478  }
479  }
480 }
pfc::string_base& operator<< ( pfc::string_base p_fmt,
const CPoint &  p_point 
)
inline

Definition at line 80 of file misc.h.

80  {
81  return p_fmt << "(" << p_point.x << "," << p_point.y << ")";
82 }
pfc::string_base& operator<< ( pfc::string_base p_fmt,
const CRect &  p_rect 
)
inline

Definition at line 84 of file misc.h.

84  {
85  return p_fmt << "(" << p_rect.left << "," << p_rect.top << "," << p_rect.right << "," << p_rect.bottom << ")";
86 }
void PaintSeparatorControl ( CWindow  wnd)

Definition at line 3 of file misc.cpp.

3  {
4  CPaintDC dc(wnd);
5  TCHAR buffer[512] = {};
6  wnd.GetWindowText(buffer, _countof(buffer));
7  const int txLen = pfc::strlen_max_t(buffer, _countof(buffer));
8  CRect contentRect;
9  WIN32_OP_D( wnd.GetClientRect(contentRect) );
10 
11  dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
12  dc.SetBkMode(TRANSPARENT);
13 
14  {
15  CBrushHandle brush = (HBRUSH) wnd.GetParent().SendMessage(WM_CTLCOLORSTATIC, (WPARAM) (HDC) dc, (LPARAM) wnd.m_hWnd);
16  if (brush != NULL) dc.FillRect(contentRect, brush);
17  }
18  SelectObjectScope scopeFont(dc, wnd.GetFont());
19 
20  if (txLen > 0) {
21  CRect rcText(contentRect);
22  WIN32_OP_D( dc.DrawText(buffer,txLen,rcText,DT_NOPREFIX | DT_END_ELLIPSIS | DT_SINGLELINE | DT_VCENTER | DT_LEFT ) > 0);
23  }
24 
25  SIZE txSize, probeSize;
26  const TCHAR probe[] = _T("#");
27  if (dc.GetTextExtent(buffer,txLen,&txSize) && dc.GetTextExtent(probe, _countof(probe), &probeSize)) {
28  int spacing = txSize.cx > 0 ? (probeSize.cx / 4) : 0;
29  if (txSize.cx + spacing < contentRect.Width()) {
30  const CPoint center = contentRect.CenterPoint();
31  CRect rcEdge(contentRect.left + txSize.cx + spacing, center.y, contentRect.right, contentRect.bottom);
32  WIN32_OP_D( dc.DrawEdge(rcEdge, EDGE_ETCHED, BF_TOP) );
33  }
34  }
35 }
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
static void ui_element_instance_standard_context_menu ( service_ptr_t< ui_element_instance p_elem,
LPARAM  p_pt 
)
static

Definition at line 148 of file misc.h.

148  {
149  CPoint pt;
150  bool fromKeyboard;
151  if (p_pt == -1) {
152  fromKeyboard = true;
153  if (!p_elem->edit_mode_context_menu_get_focus_point(pt)) {
154  CRect rc;
155  WIN32_OP_D( GetWindowRect(p_elem->get_wnd(), rc) );
156  pt = rc.CenterPoint();
157  }
158  } else {
159  fromKeyboard = false;
160  pt = p_pt;
161  }
162  if (p_elem->edit_mode_context_menu_test(pt,fromKeyboard)) {
163  const unsigned idBase = 1;
164  CMenu menu;
165  WIN32_OP( menu.CreatePopupMenu() );
166  p_elem->edit_mode_context_menu_build(pt,fromKeyboard,menu,idBase);
167 
168  int cmd;
169  {
170  CMenuSelectionReceiver_UiElement receiver(p_elem,idBase);
171  cmd = menu.TrackPopupMenu(TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,pt.x,pt.y,receiver);
172  }
173  if (cmd > 0) p_elem->edit_mode_context_menu_command(pt,fromKeyboard,cmd,idBase);
174  }
175 }
static void ui_element_instance_standard_context_menu_eh ( service_ptr_t< ui_element_instance p_elem,
LPARAM  p_pt 
)
static

Definition at line 176 of file misc.h.

176  {
177  try {
179  } catch(std::exception const & e) {
180  console::complain("Context menu failure", e);
181  }
182 }
void complain(const char *what, const char *msg)
Definition: console.cpp:21
std::exception exception
Definition: primitives.h:193
static void ui_element_instance_standard_context_menu(service_ptr_t< ui_element_instance > p_elem, LPARAM p_pt)
Definition: misc.h:148
static bool window_service_trait_defer_destruction ( const service_base )
static

Definition at line 302 of file misc.h.

302 {return true;}
static bool window_service_trait_defer_destruction ( const preferences_page_instance )
static

Definition at line 488 of file misc.h.

488 {return false;}