43 DEFSUPER(CHeaderCtrl);
48 , m_textColor(::GetSysColor(COLOR_WINDOWTEXT)), m_backColor(CLR_INVALID), m_isEnableChangeWidth(true)
50 m_pPartsDraw = &m_standardParts;
71 m_pPartsDraw = pParts;
73 if ( m_backBrush.GetSafeHandle() != NULL )
75 m_backBrush.DeleteObject();
88 if ( col >=0 && _super::GetItemCount() > col )
90 return m_columnDrawers.
Set(col, draw.
Clone());
102 m_isAutoAdjustWidth = b;
112 return m_isAutoAdjustWidth;
121 m_isEnableChangeWidth = b;
141 return IsWindow() ? _super::GetItemCount() : 1;
161 if ( (GetStyle() & HDS_BUTTONS) == 0 )
163 m_isEnableChangeWidth =
false;
165 _super::PreSubclassWindow();
179 virtual BOOL
OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* _pResult)
181 if ( message == WM_NOTIFY )
183 LPNMHDR lpNmHdr =
reinterpret_cast<LPNMHDR
>(lParam);
184 if ( lpNmHdr->code == NM_CUSTOMDRAW )
186 LPNMLVCUSTOMDRAW P =
reinterpret_cast<LPNMLVCUSTOMDRAW
>(lParam);
187 *_pResult = CDRF_DODEFAULT;
188 switch ( P->nmcd.dwDrawStage )
191 *_pResult = CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT;
193 case CDDS_ITEMPREPAINT:
194 m_columnStates.
Set(P->nmcd.dwItemSpec, P->nmcd.uItemState);
213 virtual LRESULT
WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
218 m_Draw(CPaintDC(
this));
222 if ( ! m_isStateChecking )
224 HDC dc =
reinterpret_cast<HDC
>(wParam);
230 if ( ! m_isStateChecking )
237 case WM_LBUTTONDBLCLK:
238 if ( ! m_isEnableChangeWidth )
246 LRESULT r = _super::WindowProc(message, wParam, lParam);
249 m_columnDrawers.
Remove(col);
255 return _super::WindowProc(message, wParam, lParam);
264 _super::GetClientRect(&clientRect);
266 m_isStateChecking =
true;
269 m_isStateChecking =
false;
272 enum { sizeOfBuffer = 256 };
273 TCHAR lpBuffer[sizeOfBuffer];
274 hdi.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT;
275 hdi.pszText = lpBuffer;
276 hdi.cchTextMax = sizeOfBuffer;
282 int right = clientRect.right;
284 bool isEnabled = !! _super::IsWindowEnabled();
285 CWnd* pParent = _super::GetParent();
286 if ( pParent != NULL )
288 pParent->GetClientRect(&parentRect);
289 right = parentRect.right;
290 isEnabled = !! pParent->IsWindowEnabled();
293 if ( m_isAutoAdjustWidth )
295 CRect rc = clientRect;
296 int cnt = _super::GetItemCount();
297 for (
int i = 0; i < cnt; i++ )
299 if ( ! _super::GetItem(i, &hdi) )
303 rc.right = rc.left + hdi.cxy;
304 bool r = (rc.right > right);
307 r = (rc.right != right);
313 h.cxy = right - rc.left;
318 _super::SetItem(i, &h);
325 CRect rc = clientRect;
326 loop ( i, _super::GetItemCount() )
328 if ( ! _super::GetItem(
ToInt(i), &hdi) )
332 rc.right = rc.left + hdi.cxy;
334 CPoint offset = edgeOffset;
335 UINT state = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT;
336 if ( (m_columnStates[i] & CDIS_SELECTED) != 0 )
338 state |= DFCS_PUSHED;
339 offset += pushOffset;
343 state |= DFCS_INACTIVE;
345 if ( (GetStyle() & HDS_BUTTONS) == 0 )
350 ::FillRect(dc, &r,
static_cast<HBRUSH
>(::GetStockObject(WHITE_BRUSH)));
353 HRGN hRgn = ::CreateRectRgnIndirect(&r);
354 ::SelectClipRgn(dc, hRgn);
355 CSize clientSize = rc.Size() - edgeOffset - edgeOffset;
360 pDr->
Draw(dc, rc.left + offset.x, rc.top + offset.y);
364 CFont* pFont = _super::GetFont();
365 UINT style = DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS;
366 if ( (hdi.fmt & HDF_CENTER) != 0 )
370 else if ( (hdi.fmt & HDF_RIGHT) != 0 )
374 COLORREF c = isEnabled ? m_textColor : CLR_INVALID;
375 CTextDrawer d(clientSize, *pFont, c, lpBuffer, style);
376 d.Draw(dc, rc.left + offset.x, rc.top + offset.y);
379 ::SelectClipRgn(dc, NULL);
383 if ( rc.right < right )
386 if ( IS_RGBVALUE(m_backColor) )
388 if ( m_backBrush.GetSafeHandle() == NULL )
390 m_backBrush.CreateSolidBrush(m_backColor);
392 ::FillRect(dc, rc, m_backBrush);
396 UINT state = DFCS_BUTTONPUSH;
397 if ( ! _super::IsWindowEnabled() )
399 state |= DFCS_INACTIVE;
408 COLORREF m_backColor;
410 COLORREF m_textColor;
414 bool m_isStateChecking;
415 bool m_isAutoAdjustWidth;
416 bool m_isEnableChangeWidth;
#define loop(VAR, CNT)
loop構文.
virtual bool Set(INDEX index, const TYP &t)
[設定] 要素の設定.
bool SetFromClient(HWND hWnd, const RECT &rect, COLORREF backColor=CLR_INVALID)
[設定] クライアントからイメージ設定.
virtual bool Remove(INDEX index)
[削除] 要素一つ削除.
int ToInt(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
virtual bool Resize(const SIZE &size)=0
[設定] サイズ設定.
virtual IDrawable * Clone(void) const =0
[作成] クローン作成.
virtual void Draw(HDC dc, int x=0, int y=0) const =0
[描画] 描画.
virtual void GetEdgeOffset(POINT &_po) const =0
[取得] エッジの幅、高さ.
virtual bool DrawButtonControl(HDC hdc, LPRECT _lprc, UINT uState) const =0
[描画] ボタンコントロール描画.
virtual void GetPushedOffset(POINT &_po) const =0
[取得] 押下状態のずれ.