#include <customlist.h>
Protected Member Functions | |
CCustomListScrollableArea (CCustomList *parent) | |
virtual | ~CCustomListScrollableArea () |
CCustomListRowWnd * | AddRow () |
void | SelectRow (INT32 RowNum) |
void | HandleScrollMessage (UINT32 nSBCode, UINT32 nPos) |
CCustomListRowWnd * | GetRow (INT32 row) |
INT32 | GetHeight () const |
virtual void | PostNcDestroy () |
afx_msg void | OnSize (UINT32 nType, INT32 cx, INT32 cy) |
Private Attributes | |
CCustomListRowWnd ** | m_ListRowsArray |
INT32 | m_ScrollPos |
INT32 | m_CurrentSelectedRow |
CFont | m_Font |
INT32 | m_RowCount |
CCustomList * | m_Parent |
Friends | |
class | CCustomListRowWnd |
class | CCustomList |
Definition at line 188 of file customlist.h.
|
Definition at line 614 of file customlist.cpp. 00614 : 00615 m_CurrentSelectedRow(-1), 00616 m_RowCount(0), 00617 m_Parent(parent), 00618 m_ListRowsArray(NULL), 00619 m_ScrollPos(0) 00620 { 00621 // create font for text items 00622 LOGFONT lf; // Used to create the CFont. 00623 memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure. 00624 lf.lfHeight = CCustomList::FONTHEIGHT; 00625 strcpy(lf.lfFaceName, "Microsoft Sans Serif"); // with face name "Arial". 00626 m_Font.CreateFontIndirect(&lf); // Create the font. 00627 00628 // create the row objects 00629 m_ListRowsArray = new CCustomListRowWnd*[CCustomList::MAXROWS]; 00630 for(INT32 i=0; i<CCustomList::MAXROWS; i++) 00631 { 00632 m_ListRowsArray[i] = NULL; 00633 } 00634 00635 // set up window class for the rows 00636 WNDCLASS NewWindowClass; 00637 memset(&NewWindowClass, 0, sizeof(WNDCLASS)); 00638 NewWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ; 00639 NewWindowClass.lpfnWndProc = ::DefWindowProc; 00640 NewWindowClass.hInstance = AfxGetInstanceHandle(); 00641 NewWindowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); ;//(HBRUSH) ((COLOR_BTNFACE)); 00642 NewWindowClass.lpszMenuName = NULL; 00643 NewWindowClass.lpszClassName = _T("RowClass"); 00644 AfxRegisterClass(&NewWindowClass); 00645 }
|
|
Definition at line 648 of file customlist.cpp. 00649 { 00650 delete m_ListRowsArray; 00651 m_ListRowsArray = NULL; 00652 }
|
|
Definition at line 1071 of file customlist.cpp. 01072 { 01073 CCustomListRowWnd* pRow = new CCustomListRowWnd(m_RowCount,this); 01074 ASSERT(pRow); 01075 m_ListRowsArray[m_RowCount] = pRow; 01076 m_RowCount++; 01077 01078 CRect parentRect; 01079 m_Parent->GetClientRect(&parentRect); 01080 01081 CRect rect ; 01082 rect.top = (m_RowCount-1) * CCustomList::ROWHEIGHT ; 01083 rect.left = 0 ; 01084 rect.bottom = 0 + (m_RowCount) * CCustomList::ROWHEIGHT ; 01085 rect.right = parentRect.right - 1; 01086 01087 pRow->Create("RowClass","",WS_CHILD,rect,this,0); 01088 pRow->ShowWindow(SW_SHOW); 01089 01090 // recalculate height and scrollbar position 01091 BOOL needScroll = GetHeight() > parentRect.Height(); 01092 INT32 width = parentRect.right; 01093 if(needScroll) 01094 width=width - ::GetSystemMetrics(SM_CXVSCROLL); //+2 01095 m_Parent->m_VScrollBar->ShowWindow(needScroll ? SW_SHOW : SW_HIDE); 01096 SetWindowPos(NULL,0,0,width,GetHeight(),0); 01097 01098 return pRow; 01099 }
|
|
Definition at line 202 of file customlist.h. 00202 {return m_RowCount * CCustomList::ROWHEIGHT ;}
|
|
Definition at line 704 of file customlist.cpp. 00705 { 00706 ASSERT(row < m_RowCount); 00707 return m_ListRowsArray[row] ; 00708 }
|
|
Definition at line 663 of file customlist.cpp. 00664 { 00665 SCROLLINFO si; 00666 si.cbSize = sizeof(SCROLLINFO); 00667 si.fMask = SIF_TRACKPOS|SIF_PAGE|SIF_RANGE; 00668 m_Parent->GetVScrollBar()->GetScrollInfo(&si); 00669 00670 INT32 NewPos = m_ScrollPos ; 00671 switch(nSBCode) 00672 { 00673 case SB_PAGEDOWN: 00674 NewPos = m_ScrollPos + si.nPage; 00675 break ; 00676 case SB_PAGEUP: 00677 NewPos = m_ScrollPos - si.nPage; 00678 break ; 00679 case SB_LINEDOWN: 00680 NewPos = m_ScrollPos + CCustomList::ROWHEIGHT; 00681 break ; 00682 case SB_LINEUP: 00683 NewPos = m_ScrollPos - CCustomList::ROWHEIGHT; 00684 break ; 00685 case SB_THUMBTRACK: 00686 case SB_THUMBPOSITION: 00687 NewPos = nPos; 00688 break; 00689 } 00690 INT32 LastPos = si.nMax-si.nPage + 1 ; 00691 00692 if( NewPos < 0 ) 00693 NewPos = 0; 00694 if( NewPos > LastPos ) 00695 NewPos = LastPos ; 00696 00697 INT32 offset = m_ScrollPos - NewPos; 00698 this->ScrollWindow(0,offset); 00699 m_ScrollPos = NewPos; 00700 m_Parent->GetVScrollBar()->SetScrollPos(m_ScrollPos , true); 00701 }
|
|
Definition at line 747 of file customlist.cpp. 00748 { 00749 ASSERT( GetHeight() == cy ); 00750 CWnd::OnSize(nType, cx, cy); 00751 00752 CRect parentRect; 00753 m_Parent->GetClientRect(parentRect); 00754 00755 // scrollbar window may not actually be visible 00756 SCROLLINFO si; 00757 si.cbSize = sizeof(SCROLLINFO); 00758 si.fMask = SIF_PAGE|SIF_RANGE; 00759 si.nPage = (INT32)parentRect.Height(); 00760 si.nMin = 0; 00761 si.nMax = GetHeight(); 00762 m_Parent->m_VScrollBar->SetScrollInfo(&si, true); 00763 }
|
|
Definition at line 655 of file customlist.cpp.
|
|
Definition at line 715 of file customlist.cpp. 00716 { 00717 if( m_CurrentSelectedRow > -1 ) 00718 { 00719 m_ListRowsArray[m_CurrentSelectedRow]->m_Selected = false ; 00720 m_ListRowsArray[m_CurrentSelectedRow]->RedrawWindow(); 00721 } 00722 m_CurrentSelectedRow = RowNum; 00723 00724 if( m_CurrentSelectedRow > -1 && this->IsWindowEnabled()) 00725 { 00726 // scroll if necessary so that the selection is in view 00727 CRect parentRect; 00728 m_Parent->GetClientRect(&parentRect); 00729 INT32 Page = parentRect.Height(); 00730 if((m_CurrentSelectedRow) * CCustomList::ROWHEIGHT < m_ScrollPos) 00731 { 00732 HandleScrollMessage(SB_THUMBPOSITION,m_CurrentSelectedRow * CCustomList::ROWHEIGHT); 00733 } 00734 else if((m_CurrentSelectedRow+1) * CCustomList::ROWHEIGHT > (m_ScrollPos + Page)) 00735 { 00736 HandleScrollMessage(SB_THUMBPOSITION,(m_CurrentSelectedRow+1) * CCustomList::ROWHEIGHT - Page); 00737 } 00738 00739 ASSERT(m_ListRowsArray!=NULL); 00740 m_ListRowsArray[m_CurrentSelectedRow]->m_Selected = true ; 00741 m_ListRowsArray[m_CurrentSelectedRow]->RedrawWindow(); 00742 m_ListRowsArray[m_CurrentSelectedRow]->SetFocus(); 00743 } 00744 }
|
|
Definition at line 191 of file customlist.h. |
|
Definition at line 190 of file customlist.h. |
|
Definition at line 220 of file customlist.h. |
|
Definition at line 221 of file customlist.h. |
|
Definition at line 218 of file customlist.h. |
|
Definition at line 223 of file customlist.h. |
|
Definition at line 222 of file customlist.h. |
|
Definition at line 219 of file customlist.h. |