| 29 | |
| 30 | template <class TItem = CCustomTabItem> |
| 31 | class CButtonTabCtrl : |
| 32 | public CCustomTabCtrl<CButtonTabCtrl<TItem>, TItem> |
| 33 | { |
| 34 | protected: |
| 35 | typedef CCustomTabCtrl<CButtonTabCtrl, TItem> customTabClass; |
| 36 | |
| 37 | public: |
| 38 | DECLARE_WND_CLASS(_T("WTL_ButtonTabCtrl")) |
| 39 | |
| 40 | BEGIN_MSG_MAP(CButtonTabCtrl) |
| 41 | MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) |
| 42 | CHAIN_MSG_MAP(customTabClass) |
| 43 | END_MSG_MAP() |
| 44 | |
| 45 | LRESULT OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) |
| 46 | { |
| 47 | m_settings.iPadding = 10; |
| 48 | m_settings.iMargin = 3; |
| 49 | |
| 50 | UpdateLayout(); |
| 51 | Invalidate(); |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | // Overrides from CCustomTabCtrl |
| 56 | void Initialize(void) |
| 57 | { |
| 58 | ATLASSERT(::IsWindow(m_hWnd)); |
| 59 | ATLASSERT(GetStyle() & WS_CHILD); |
| 60 | ModifyStyle(0, SS_NOTIFY); // We need this for mouse-clicks |
| 61 | |
| 62 | customTabClass::Initialize(); |
| 63 | } |
| 64 | |
| 65 | void DoItemPaint(LPNMCTCCUSTOMDRAW lpNMCustomDraw) |
| 66 | { |
| 67 | CDCHandle dc(lpNMCustomDraw->nmcd.hdc); |
| 68 | RECT &rc = lpNMCustomDraw->nmcd.rc; |
| 69 | int nItem = lpNMCustomDraw->nmcd.dwItemSpec; |
| 70 | UINT uItemState = lpNMCustomDraw->nmcd.uItemState; |
| 71 | |
| 72 | UINT state = DFCS_BUTTONPUSH; |
| 73 | if( CDIS_SELECTED == (uItemState & CDIS_SELECTED) ) |
| 74 | { |
| 75 | state |= DFCS_PUSHED; |
| 76 | } |
| 77 | if( CDIS_DISABLED == (uItemState & CDIS_DISABLED) ) |
| 78 | { |
| 79 | state |= DFCS_INACTIVE; |
| 80 | } |
| 81 | dc.DrawFrameControl(&rc, DFC_BUTTON, state ); |
| 82 | |
| 83 | customTabClass::TItem* pItem = this->GetItem(nItem); |
| 84 | if(pItem) |
| 85 | { |
| 86 | if( CDIS_SELECTED == (uItemState & CDIS_SELECTED) ) |
| 87 | { |
| 88 | rc.left += 2; |
nothing calls this directly
no test coverage detected