CCustomListRowWnd Class Reference

#include <customlist.h>

List of all members.

Public Member Functions

 CCustomListRowWnd (INT32 i, CCustomListScrollableArea *parent)
virtual ~CCustomListRowWnd ()
void AddText (INT32 col, CString text)
void SetText (INT32 col, CString text)
void AddCheck (INT32 col)
void AddBitmap (INT32 col, HBITMAP bmp1, HBITMAP bmp2, DWORD dwBackColour=0xFFFFFFFF)
void SetChecked (INT32 col, BOOL checked)
bool IsChecked (INT32 col) const
CString GetText (INT32 col) const

Protected Member Functions

virtual BOOL OnCommand (WPARAM wParam, LPARAM lParam)
virtual void PostNcDestroy ()
afx_msg void OnLButtonUp (UINT32 nFlags, CPoint point)
afx_msg BOOL OnEraseBkgnd (CDC *pDC)
afx_msg HBRUSH OnCtlColor (CDC *pDC, CWnd *pWnd, UINT32 nCtlColor)
afx_msg void OnLButtonDblClk (UINT32 nFlags, CPoint point)
afx_msg void OnKeyDown (UINT32 nChar, UINT32 nRepCnt, UINT32 nFlags)
afx_msg UINT32 OnGetDlgCode ()
afx_msg void OnDestroy ()

Private Member Functions

HBRUSH GetBackgroundBrush ()

Private Attributes

friend CCustomListScrollableArea
const INT32 m_RowNum
CCustomListScrollableAream_Parent
CBrush m_BackBrush
CBrush m_BackBrushSel
CObject ** m_ColumnObjects
bool m_Selected


Detailed Description

Definition at line 230 of file customlist.h.


Constructor & Destructor Documentation

CCustomListRowWnd::CCustomListRowWnd INT32  i,
CCustomListScrollableArea parent
 

Definition at line 788 of file customlist.cpp.

00788                                                                                    :
00789     m_BackBrush(RGB(255,255,255)) ,
00790     m_BackBrushSel(::GetSysColor (COLOR_HIGHLIGHT)),
00791     m_Selected(false),
00792     m_RowNum(RowNo),
00793     m_Parent(parent)
00794 {
00795 
00796     // column object storage
00797     m_ColumnObjects = new CObject* [CCustomList::MAXCOLUMNS];
00798     for( INT32 i=0; i < CCustomList::MAXCOLUMNS; i++)
00799         m_ColumnObjects[i] = NULL;
00800 }

CCustomListRowWnd::~CCustomListRowWnd  )  [virtual]
 

Definition at line 802 of file customlist.cpp.

00803 {
00804     // clear down column object storage
00805     for( INT32 i=0; i < CCustomList::MAXCOLUMNS; i++)
00806     {
00807         if ( m_ColumnObjects[i] !=NULL )
00808         {
00809             delete m_ColumnObjects[i];
00810             m_ColumnObjects[i] = NULL;
00811         }
00812     }
00813     delete m_ColumnObjects ;
00814 }


Member Function Documentation

void CCustomListRowWnd::AddBitmap INT32  col,
HBITMAP  bmp1,
HBITMAP  bmp2,
DWORD  dwBackColour = 0xFFFFFFFF
 

Definition at line 943 of file customlist.cpp.

00944 {
00945     CStatic* pStat = new CStatic();
00946     ASSERT(m_ColumnObjects[col] == NULL);
00947     m_ColumnObjects[col] = pStat ;
00948 
00949     CRect cr;
00950     GetClientRect(&cr);
00951 
00952     BITMAP bitmap;
00953     CBitmap::FromHandle(hBitmap)->GetBitmap(&bitmap);
00954     CRect srect;
00955     srect.left = m_Parent->m_Parent->m_ColumnOffsetsArray[col] ;
00956     srect.right = srect.left + bitmap.bmWidth;
00957     srect.top   = cr.Height()/2 - bitmap.bmHeight/2;
00958     srect.bottom = cr.Height()/2 + bitmap.bmHeight/2;
00959 
00961     HDC hBitmapDC = CreateCompatibleDC(NULL);
00962     if (!hBitmapDC)
00963     {
00964         ERROR2RAW("Non-fatal GDI error");
00965     }
00966     SelectObject(hBitmapDC, hBitmap);
00967     // Iff we haven't been told what the background colour is...
00968     // We make the assumption that the pixel in the lower right corner has the background colour
00969     if (dwBackColour == 0xFFFFFFFF)
00970         dwBackColour = (DWORD) GetPixel(hBitmapDC, bitmap.bmWidth - 1, bitmap.bmHeight -1); 
00971     DWORD sysBkColour = GetSysColor(COLOR_3DFACE);
00972     for (INT32 i = 0; i < bitmap.bmWidth; i++)
00973     {
00974         for (INT32 j = 0; j < bitmap.bmHeight; j++)
00975         {
00976             if ((DWORD) GetPixel(hBitmapDC, i, j) == dwBackColour)
00977                 SetPixelV(hBitmapDC, i, j, (COLORREF) sysBkColour);
00978         }
00979     }
00980     DeleteDC(hBitmapDC);
00981 
00983     pStat->Create(NULL, WS_VISIBLE | SS_BITMAP, srect, this);
00984     pStat->SetBitmap(hBitmap);
00985 }

void CCustomListRowWnd::AddCheck INT32  col  ) 
 

Definition at line 848 of file customlist.cpp.

00849 {
00850     CButton* pBut = new CButton();
00851     m_ColumnObjects[col] = pBut ;
00852 
00853     CRect cr;
00854     GetClientRect(&cr);
00855     ASSERT(cr.Height() == CCustomList::ROWHEIGHT);
00856 
00857     CRect rect;
00858     rect.left   =   m_Parent->m_Parent->m_ColumnOffsetsArray[col] ;
00859     rect.right  =   rect.left + GetSystemMetrics(SM_CXMENUCHECK);
00860     rect.top    = (CCustomList::ROWHEIGHT - GetSystemMetrics(SM_CYMENUCHECK))/2;
00861     rect.bottom = rect.top + GetSystemMetrics(SM_CYMENUCHECK)  ;
00862     pBut->Create(NULL, WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, rect, this, 4);
00863 }

void CCustomListRowWnd::AddText INT32  col,
CString  text
 

Definition at line 907 of file customlist.cpp.

00908 {
00909     ASSERT(m_ColumnObjects[col] == NULL);
00910 
00911     CStatic* pStat = new CStatic();
00912     m_ColumnObjects[col] = pStat ;
00913     
00914     CRect cr;
00915     GetClientRect(&cr);
00916 
00917     CRect srect;
00918     srect.left= m_Parent->m_Parent->m_ColumnOffsetsArray[col] ;
00919     if( col < CCustomList::MAXCOLUMNS && m_Parent->m_Parent->m_ColumnOffsetsArray[col + 1] > 0)
00920         srect.right= m_Parent->m_Parent->m_ColumnOffsetsArray[col + 1] ;
00921     else
00922         srect.right= cr.right;
00923     srect.top   = (CCustomList::ROWHEIGHT - CCustomList::FONTHEIGHT)/2;
00924     srect.bottom = srect.top + CCustomList::FONTHEIGHT;
00925     pStat->Create(text, WS_CHILD|WS_VISIBLE|WS_EX_LEFT, srect, this);
00926     pStat->SetFont(&m_Parent->m_Font);
00927 }

HBRUSH CCustomListRowWnd::GetBackgroundBrush  )  [inline, private]
 

Definition at line 247 of file customlist.h.

00247 {return (m_Selected ? m_BackBrushSel:m_BackBrush ); }

CString CCustomListRowWnd::GetText INT32  col  )  const
 

Definition at line 1018 of file customlist.cpp.

01019 {
01020     CStatic* pStat = (CStatic*)m_ColumnObjects[col];
01021     CString ret ;
01022     pStat->GetWindowText(ret);
01023     return ret;
01024 }

bool CCustomListRowWnd::IsChecked INT32  col  )  const
 

Definition at line 877 of file customlist.cpp.

00878 {
00879     CButton* pBut = (CButton*)m_ColumnObjects[col];
00880     return pBut->GetCheck() == BST_CHECKED;
00881 }

BOOL CCustomListRowWnd::OnCommand WPARAM  wParam,
LPARAM  lParam
[protected, virtual]
 

Definition at line 1047 of file customlist.cpp.

HBRUSH CCustomListRowWnd::OnCtlColor CDC pDC,
CWnd *  pWnd,
UINT32  nCtlColor
[protected]
 

Definition at line 989 of file customlist.cpp.

00990 {
00991     HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
00992     COLORREF text = m_Selected ? GetSysColor(COLOR_HIGHLIGHTTEXT) : GetSysColor(COLOR_WINDOWTEXT);
00993     pDC->SetTextColor(text);
00994     pDC->SetBkMode(TRANSPARENT);
00995 
00996     return GetBackgroundBrush();
00997 }

void CCustomListRowWnd::OnDestroy  )  [protected]
 

Definition at line 825 of file customlist.cpp.

00826 {
00827     CWnd::OnDestroy();
00828     for( INT32 i=0; i < CCustomList::MAXCOLUMNS; i++)
00829     {
00830         if ( m_ColumnObjects[i] !=NULL )
00831         {
00832             if( m_ColumnObjects[i]->IsKindOf(RUNTIME_CLASS(CStatic)) )
00833             {
00834                 if( ((CStatic*)m_ColumnObjects[i])->GetSafeHwnd() )
00835                 {
00836                     HBITMAP hBitmap = ((CStatic*)m_ColumnObjects[i])->GetBitmap();
00837                     if(hBitmap)
00838                     {
00839                         ::DeleteObject(hBitmap);
00840                     }
00841                 }
00842             }
00843         }
00844     }
00845 }

BOOL CCustomListRowWnd::OnEraseBkgnd CDC pDC  )  [protected]
 

Definition at line 893 of file customlist.cpp.

00894 {
00895     CBrush* pOldBrush = pDC->SelectObject(m_Selected ? &m_BackBrushSel : &m_BackBrush);
00896 
00897     CRect rect;
00898     pDC->GetClipBox(&rect);     // Erase the area needed
00899 
00900     pDC->PatBlt(rect.left,rect.top,rect.Width(),rect.Height(),PATCOPY);
00901     pDC->SelectObject(pOldBrush);
00902 
00903     return true;
00904 }

UINT32 CCustomListRowWnd::OnGetDlgCode  )  [protected]
 

Definition at line 1038 of file customlist.cpp.

01039 {
01040     UINT32 uRet = CWnd::OnGetDlgCode();
01041     uRet |= DLGC_WANTARROWS;
01042     return uRet;
01043 }

void CCustomListRowWnd::OnKeyDown UINT32  nChar,
UINT32  nRepCnt,
UINT32  nFlags
[protected]
 

Definition at line 1027 of file customlist.cpp.

01028 {
01029     if(nChar == CAMKEY(DOWN) && m_RowNum + 1 < m_Parent->m_RowCount)
01030         m_Parent->SelectRow(m_RowNum+1);
01031     else if(nChar == CAMKEY(UP) && m_RowNum - 1 >= 0)
01032         m_Parent->SelectRow(m_RowNum-1);
01033 
01034     CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
01035 }

void CCustomListRowWnd::OnLButtonDblClk UINT32  nFlags,
CPoint  point
[protected]
 

Definition at line 1001 of file customlist.cpp.

01002 {
01003     m_Parent->SelectRow(m_RowNum); // make sure we are selected
01004     CWnd* caller = m_Parent->m_Parent->GetOwner();
01005     INT32 ControlID = m_Parent->m_Parent->GetDlgCtrlID();
01006     if(caller && ControlID )
01007     {
01008         NMHDR nm;
01009         nm.hwndFrom = m_Parent->m_Parent->m_hWnd;
01010         nm.idFrom = ControlID;
01011         nm.code = NM_DBLCLK;
01012 
01013         ::SendMessage(caller->m_hWnd ,WM_NOTIFY,ControlID , (LPARAM)&nm );
01014     }
01015 }

void CCustomListRowWnd::OnLButtonUp UINT32  nFlags,
CPoint  point
[protected]
 

Definition at line 885 of file customlist.cpp.

00886 {
00887     CWnd::OnLButtonUp(nFlags, point);
00888     m_Parent->SelectRow(m_RowNum);
00889     CWnd::OnLButtonUp(nFlags, point);
00890 }

void CCustomListRowWnd::PostNcDestroy  )  [protected, virtual]
 

Definition at line 817 of file customlist.cpp.

00818 {
00819     delete this;
00820     CWnd::PostNcDestroy();
00821 }

void CCustomListRowWnd::SetChecked INT32  col,
BOOL  checked
 

Definition at line 866 of file customlist.cpp.

00867 {
00868     ASSERT(m_ColumnObjects[col] != NULL );
00869     ASSERT(m_ColumnObjects[col]->IsKindOf(RUNTIME_CLASS( CButton)));
00870 
00871     CButton* pBut = (CButton*)m_ColumnObjects[col];
00872     pBut->SetCheck(checked ? BST_CHECKED : BST_UNCHECKED );
00873     pBut->UpdateWindow();
00874 }

void CCustomListRowWnd::SetText INT32  col,
CString  text
 

Definition at line 930 of file customlist.cpp.

00931 {
00932     CStatic* pStat = (CStatic*)m_ColumnObjects[col];
00933     if( pStat == NULL )
00934         AddText(col,text);
00935     else
00936     {
00937         pStat->SetWindowText(text);
00938         pStat->UpdateWindow();
00939     }
00940 }


Member Data Documentation

friend CCustomListRowWnd::CCustomListScrollableArea [private]
 

Definition at line 232 of file customlist.h.

CBrush CCustomListRowWnd::m_BackBrush [private]
 

Definition at line 251 of file customlist.h.

CBrush CCustomListRowWnd::m_BackBrushSel [private]
 

Definition at line 252 of file customlist.h.

CObject** CCustomListRowWnd::m_ColumnObjects [private]
 

Definition at line 253 of file customlist.h.

CCustomListScrollableArea* CCustomListRowWnd::m_Parent [private]
 

Definition at line 250 of file customlist.h.

const INT32 CCustomListRowWnd::m_RowNum [private]
 

Definition at line 249 of file customlist.h.

bool CCustomListRowWnd::m_Selected [private]
 

Definition at line 254 of file customlist.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:52:14 2007 for Camelot by  doxygen 1.4.4