foobar2000 SDK  2015-01-14
Public Member Functions | Private Member Functions | Private Attributes
CStaticThemed

#include <misc.h>

+ Inheritance diagram for CStaticThemed:

Public Member Functions

 CStaticThemed ()
 
 BEGIN_MSG_MAP_EX (CStaticThemed) MSG_WM_PAINT(OnPaint) MSG_WM_THEMECHANGED(OnThemeChanged) MSG_WM_SETTEXT(OnSetText) END_MSG_MAP() void SetThemePart(int id)
 

Private Member Functions

void OnPaint (CDCHandle)
 
int OnSetText (LPCTSTR lpstrText)
 
void OnThemeChanged ()
 

Private Attributes

bool m_fallback
 
int m_id
 
CTheme m_theme
 

Detailed Description

Definition at line 588 of file misc.h.

Constructor & Destructor Documentation

CStaticThemed::CStaticThemed ( )
inline

Definition at line 590 of file misc.h.

590 : CContainedWindowT<CStatic>(this, 0), m_id(), m_fallback() {}
bool m_fallback
Definition: misc.h:643
int m_id
Definition: misc.h:641

Member Function Documentation

CStaticThemed::BEGIN_MSG_MAP_EX ( CStaticThemed  )
inline

Definition at line 591 of file misc.h.

597  {m_id = id; if (m_hWnd != NULL) Invalidate();}
int m_id
Definition: misc.h:641
void CStaticThemed::OnPaint ( CDCHandle  )
inlineprivate

Definition at line 608 of file misc.h.

608  {
609  if (m_fallback) {
610  SetMsgHandled(FALSE); return;
611  }
612  if (m_theme == NULL) {
613  m_theme.OpenThemeData(*this, L"TextStyle");
614  if (m_theme == NULL) {
615  m_fallback = true; SetMsgHandled(FALSE); return;
616  }
617  }
618  CPaintDC dc(*this);
619  TCHAR buffer[512] = {};
620  GetWindowText(buffer, _countof(buffer));
621  const int txLen = pfc::strlen_max_t(buffer, _countof(buffer));
622  CRect contentRect;
623  WIN32_OP_D( GetClientRect(contentRect) );
624  SelectObjectScope scopeFont(dc, GetFont());
625  dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
626  dc.SetBkMode(TRANSPARENT);
627 
628  if (txLen > 0) {
629  CRect rcText(contentRect);
630  DWORD flags = 0;
631  DWORD style = GetStyle();
632  if (style & SS_LEFT) flags |= DT_LEFT;
633  else if (style & SS_RIGHT) flags |= DT_RIGHT;
634  else if (style & SS_CENTER) flags |= DT_CENTER;
635  if (style & SS_ENDELLIPSIS) flags |= DT_END_ELLIPSIS;
636 
637  HRESULT retval = DrawThemeText(m_theme, dc, m_id, 0, buffer, txLen, flags, 0, rcText);
638  PFC_ASSERT( SUCCEEDED( retval ) );
639  }
640  }
bool m_fallback
Definition: misc.h:643
t_size strlen_max_t(const t_char *ptr, t_size max)
Definition: string_base.h:84
int m_id
Definition: misc.h:641
HTHEME OpenThemeData(HWND wnd, LPCWSTR classList)
Definition: WTL-PP.h:96
CTheme m_theme
Definition: misc.h:642
int CStaticThemed::OnSetText ( LPCTSTR  lpstrText)
inlineprivate

Definition at line 599 of file misc.h.

599  {
600  Invalidate();
601  SetMsgHandled(FALSE);
602  return 0;
603  }
void CStaticThemed::OnThemeChanged ( )
inlineprivate

Definition at line 604 of file misc.h.

604  {
605  m_theme.Release();
606  m_fallback = false;
607  }
bool m_fallback
Definition: misc.h:643
void Release()
Definition: WTL-PP.h:101
CTheme m_theme
Definition: misc.h:642

Field Documentation

bool CStaticThemed::m_fallback
private

Definition at line 643 of file misc.h.

int CStaticThemed::m_id
private

Definition at line 641 of file misc.h.

CTheme CStaticThemed::m_theme
private

Definition at line 642 of file misc.h.


The documentation for this class was generated from the following file: