OSDN Git Service

2012/01/10 18:28:02
authorqwerty2501 <riot313@gmail.com>
Tue, 10 Jan 2012 09:28:03 +0000 (18:28 +0900)
committerqwerty2501 <riot313@gmail.com>
Tue, 10 Jan 2012 09:28:03 +0000 (18:28 +0900)
nlite.suo
nlite/nlite_commentview.cpp
nlite/nlite_commentview.h

index ef9bbd0..9d4372e 100644 (file)
Binary files a/nlite.suo and b/nlite.suo differ
index 1be0df7..116e5ab 100644 (file)
@@ -9,7 +9,8 @@
 ///////////////////////////////////////////////////////
 
 CCommentView::CCommentView():
-               hScrollInfo()
+               hScrollInfo(),
+               m_commentListWindow(*this)
        {
                hScrollInfo.fMask = SIF_ALL;
                hScrollInfo.cbSize = sizeof(hScrollInfo);
@@ -52,8 +53,8 @@ VOID CCommentView::Unlock(){
 
 VOID CCommentView::OnConnect(){
        commentlist.OnConnect();
-       m_listBox.SetRedraw(FALSE);
-       m_listBox.ResetContent();
+       m_commentListWindow.SetRedraw(FALSE);
+       m_commentListWindow.ResetContent();
 }
 
 
@@ -85,7 +86,7 @@ VOID CCommentView::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lpMersureItemSt
 
                auto &chat = *(CChatData*)lpMersureItemStruct->itemData;
 
-               CDC cdc = m_listBox.GetDC();
+               CDC cdc = m_commentListWindow.GetDC();
        
                RECT drowSize;
                m_header.GetItemRect(COMMENT,&drowSize);
@@ -159,36 +160,36 @@ LRESULT CCommentView::OnheaderItemChanged(LPNMHDR lParam){
        
        if(lParam->hwndFrom == m_header.m_hWnd){
 
-               INT_PTR curSel = m_listBox.GetCurSel();
+               INT_PTR curSel = m_commentListWindow.GetCurSel();
 
                SCROLLINFO scrollInfo = {0};
                scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-               m_listBox.GetScrollInfo(SB_VERT,&scrollInfo);
+               m_commentListWindow.GetScrollInfo(SB_VERT,&scrollInfo);
                scrollInfo.nPos++;
                BOOL scrollFlag = scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax;
                UINT_PTR commentCount = commentlist.Size();
 
        
-               m_listBox.SetRedraw(FALSE);
-               m_listBox.ResetContent();
+               m_commentListWindow.SetRedraw(FALSE);
+               m_commentListWindow.ResetContent();
                for(UINT_PTR index =0;index < commentCount;index++){
-                       m_listBox.AddString((LPCTSTR)&commentlist.GetChatAt(index));
+                       m_commentListWindow.AddString((LPCTSTR)&commentlist.GetChatAt(index));
                }
        
 
        
 
-               m_listBox.SetCurSel(curSel);
+               m_commentListWindow.SetCurSel(curSel);
 
        
 
-               m_listBox.SetRedraw(TRUE);
-               m_listBox.Invalidate();
+               m_commentListWindow.SetRedraw(TRUE);
+               m_commentListWindow.Invalidate();
        
 
                if(scrollFlag == TRUE){
 
-                       m_listBox.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
+                       m_commentListWindow.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
                }
 
                INT_PTR itemCount = m_header.GetItemCount();
@@ -213,18 +214,18 @@ VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
 
        
        Lock();
-       m_listBox.SetRedraw(FALSE);
+       m_commentListWindow.SetRedraw(FALSE);
        commentlist.OnChatReceve(chat,count);
-       m_listBox.AddString((LPCTSTR)&commentlist.back());
+       m_commentListWindow.AddString((LPCTSTR)&commentlist.back());
 
        SCROLLINFO scrollInfo = {0};
        scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
-       m_listBox.GetScrollInfo(SB_VERT,&scrollInfo);
+       m_commentListWindow.GetScrollInfo(SB_VERT,&scrollInfo);
        scrollInfo.nPos++;
        
        
        if(scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax == TRUE){
-               m_listBox.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);     
+               m_commentListWindow.SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);   
        }
        Unlock();
 }
@@ -237,7 +238,7 @@ VOID CCommentView::SetStreamStatus(StreamStatus &st){
 
 VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
 
-       m_listBox.SetRedraw(TRUE);
+       m_commentListWindow.SetRedraw(TRUE);
        
 
        return;
@@ -253,9 +254,9 @@ LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wn
        
 
 
-       if(wndCtl.m_hWnd == m_listBox.m_hWnd){
+       if(wndCtl.m_hWnd == m_commentListWindow.m_hWnd){
 
-               INT_PTR cursel = m_listBox.GetCurSel();
+               INT_PTR cursel = m_commentListWindow.GetCurSel();
                if(cursel == LB_ERR)return 0;
        
                auto chatData = commentlist.GetChatAt(cursel);
@@ -290,7 +291,7 @@ LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wn
 
                chatData.listenerData->SetBkColor(bkColor);
 
-               m_listBox.Invalidate(TRUE);
+               m_commentListWindow.Invalidate(TRUE);
        }
 
        return 0;
@@ -298,7 +299,7 @@ LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wn
 
 VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
 
-       if((lpDrawItemStruct->hwndItem  == m_listBox.m_hWnd) && ((UINT)m_listBox.GetCount() > lpDrawItemStruct->itemID)){
+       if((lpDrawItemStruct->hwndItem  == m_commentListWindow.m_hWnd) && ((UINT)m_commentListWindow.GetCount() > lpDrawItemStruct->itemID)){
                                        
                RECT noViewRect;
                RECT userNameViewRect;
@@ -430,15 +431,9 @@ VOID CCommentView::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lpDrawItemStruct){
 VOID CCommentView::OnPaint(HDC wParam){
        PAINTSTRUCT paintStruct;
        HDC paintDC = this->BeginPaint(&paintStruct);
-       HPEN hPen = (HPEN)GetStockPen(NULL_PEN);
-       HPEN oldPen = (HPEN)::SelectObject(paintDC,hPen);
-       HBRUSH brush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
-       HBRUSH oldBrush = (HBRUSH)::SelectObject(paintDC,brush);
-
-       ::Rectangle(paintDC,paintStruct.rcPaint.left,paintStruct.rcPaint.top,paintStruct.rcPaint.right,paintStruct.rcPaint.bottom);
+       ::FillRect(paintDC,&paintStruct.rcPaint,(HBRUSH)GetStockObject(LTGRAY_BRUSH));
        this->EndPaint(&paintStruct);
-       ::SelectObject(paintDC,oldBrush);
-       ::SelectObject(paintDC,oldPen);
+
                        
        return;
 }
@@ -479,7 +474,7 @@ VOID CCommentView::ChangeSize(const SIZE& client){
        INT_PTR movePos =  -1 * hScrollInfo.nPos;
        
        m_header.DeferWindowPos(hDwp,m_header.m_hWnd,movePos,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
-       m_listBox.DeferWindowPos(hDwp,m_listBox.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,hScrollInfo.nMax,client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);                
+       m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,hScrollInfo.nMax,client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);            
 
        EndDeferWindowPos(hDwp);
        
@@ -514,7 +509,7 @@ VOID CCommentView::OnDestroy(){
        }
        commentlist.OnDestroy();
        m_header.DestroyWindow();
-       m_listBox.DestroyWindow();
+       m_commentListWindow.DestroyWindow();
        return;
 
 }
@@ -523,7 +518,7 @@ LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
 
        if(lParam->hwndFrom == m_header.m_hWnd){
 
-               m_listBox.Invalidate();
+               m_commentListWindow.Invalidate();
 
        }
 
@@ -570,7 +565,7 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
                RECT headerPosRect;
                RECT listBoxPosRect;
                m_header.GetWindowRect(&headerPosRect);
-               m_listBox.GetWindowRect(&listBoxPosRect);
+               m_commentListWindow.GetWindowRect(&listBoxPosRect);
                INT_PTR moveRange = -(hScrollInfo.nPos);
                headerPosRect.bottom -= headerPosRect.top;
                headerPosRect.top = 0;
@@ -583,7 +578,7 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
                listBoxPosRect.left = moveRange;
                        
                m_header.MoveWindow(&headerPosRect);
-               m_listBox.MoveWindow(&listBoxPosRect);
+               m_commentListWindow.MoveWindow(&listBoxPosRect);
                                        
                                
                                        
@@ -591,7 +586,7 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
                HDWP hDwp = BeginDeferWindowPos(2);
 
                m_header.DeferWindowPos(hDwp,m_header.m_hWnd,moveRange,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
-               m_listBox.DeferWindowPos(hDwp,m_listBox.m_hWnd,moveRange,commentViewConstant::HEADER_HAIGHT,0,0,SWP_NOSIZE | SWP_NOZORDER);             
+               m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,moveRange,commentViewConstant::HEADER_HAIGHT,0,0,SWP_NOSIZE | SWP_NOZORDER);         
 
                EndDeferWindowPos(hDwp);
                                        
@@ -604,10 +599,10 @@ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
 
 LRESULT CCommentView::OnCreate(LPCREATESTRUCT lpcs){
        m_header.Create(m_hWnd,0,WC_HEADER,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN   | HDS_BUTTONS | HDS_HOTTRACK |HDS_DRAGDROP | HDS_FULLDRAG  ,0,commentViewConstant::HEADER_ID);
-       m_listBox.Create(m_hWnd,0,WC_LISTBOX,WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN   | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY | LBS_NOREDRAW , 0,commentViewConstant::LISTBOX_ID);
-       m_listBox.SetFont(AtlGetDefaultGuiFont());
+       m_commentListWindow.Create(m_hWnd,0,WC_LISTBOX,WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_CLIPCHILDREN   | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY | LBS_NOREDRAW , 0,commentViewConstant::LISTBOX_ID);
+       m_commentListWindow.SetFont(AtlGetDefaultGuiFont());
        /*
-       m_subListBox.SubclassWindow(m_listBox);
+       m_subListBox.SubclassWindow(m_commentListWindow);
        m_subListBox.CreateMemoryDC();
        */              
        return 0;
@@ -652,7 +647,7 @@ VOID CCommentView::DecisionHorzSize(){
        RECT bkWindowRect;
        this->GetClientRect(&bkWindowRect);
        m_header.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
-       m_listBox.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
+       m_commentListWindow.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,hScrollInfo.nMax,bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
 
        EndDeferWindowPos(hWindowPosInfo);
        bkWindowRect.left = hScrollInfo.nMax;
@@ -667,26 +662,4 @@ VOID CCommentView::DecisionHorzSize(){
 //\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\93à\95\94\83\8a\83X\83g\83N\83\89\83X
 ////////////////////////////////////////////////////////////////////
 
-
-VOID CCommentView::CSubCommentListBox::OnPaint(HDC hdc){
-
-       PAINTSTRUCT ps;
-       this->BeginPaint(&ps);
-
-
-       this->EndPaint(&ps);
-
-       return;
-}
-
-
-
-VOID CCommentView::CSubCommentListBox::CreateMemoryDC(){
-       HDC hdc = this->GetDC();
-       m_MemoryDC.CreateCompatibleDC(hdc);
-       m_Bitmap.CreateCompatibleBitmap(m_MemoryDC,300,200);
-       
-       ReleaseDC(hdc);
-       return;
-}
-                       
\ No newline at end of file
+CCommentListWindow::CCommentListWindow(CCommentView &in_self):self(in_self){}
\ No newline at end of file
index 9f78e9f..52f9bc0 100644 (file)
@@ -3,7 +3,11 @@
 namespace nlite{
 
        namespace commentViewConstant{
-               const static LPCTSTR  NLITE_COMMENTVIEW = TEXT("commentViewConstant::NLITE_COMMENTVIEW");
+               const static LPCTSTR  NLITE_COMMENTVIEW = TEXT("NLITE_COMMENTVIEW");
+
+               const static LPCTSTR NLITE_COMMENTLISTBASE = TEXT("NLITE_COMMENTLISTBASE");
+
+               const static LPCTSTR NLITE_COMMENTLISTWINDOW = TEXT("NLITE_COMMENTLISTWINDOW");
 
                const static UINT_PTR HEADER_HAIGHT = 20;
 
@@ -13,10 +17,47 @@ namespace nlite{
 
                const static UINT_PTR MENU_OR_ID = 256;
        }
+
+       class CCommentView;
+       //\83R\83\81\83\93\83g\95\\8e¦\97p\83E\83B\83\93\83h\83E
+       class CCommentListWindow:public CWindowImpl<CCommentListWindow>{
+
+               
+       private:
+               CCommentView &self;
+
+
        
-       class CCommentView:public CWindowImpl<CCommentView>{
+
+               
+
+       public:
+
+               DECLARE_WND_CLASS(commentViewConstant::NLITE_COMMENTLISTWINDOW)
+
+
+               //
+               //\83\81\83b\83Z\81[\83W\83}\83b\83v
+               //
+               BEGIN_MSG_MAP(CCommentListWindow)
+                       
+               END_MSG_MAP()
+
 
 
+       public:
+
+               ///
+               ///\83R\83\93\83X\83g\83\89\83N\83^
+               ///
+               CCommentListWindow(CCommentView &self);
+
+
+       };
+       
+       class CCommentView:public CWindowImpl<CCommentView>{
+
+               friend CCommentListWindow;
                //\83v\83\89\83C\83x\81[\83g\8c^\81E\83N\83\89\83X\92è\8b`
        private:
 
@@ -29,38 +70,37 @@ namespace nlite{
                }HEADERSINFO,*LPHEADERSINFO;
 
                
-               
+               //\83R\83\81\83\93\83g\95\\8e¦\83E\83B\83\93\83h\83E\82Ì\83x\81[\83X\82Æ\82È\82é\83E\83B\83\93\83h\83E
+               class CCommentListBaseWindow:public CWindowImpl<CCommentListBaseWindow>{
 
-               class CSubCommentListBox:public CDoubleBufferWindowImpl<CSubCommentListBox>{
 
-                       //\83v\83\89\83C\83x\81[\83g\83\81\83\93\83o
-               private:
-                       CDC m_MemoryDC;
-                       CBitmap m_Bitmap;
-                       LPDWORD lpPixel;
 
                public:
+                       //
+                       //\83E\83B\83\93\83h\83E\83N\83\89\83X\90é\8c¾
+                       //
+                       DECLARE_WND_CLASS_EX(commentViewConstant::NLITE_COMMENTLISTBASE,0,COLOR_BACKGROUND)
 
-
-                       BEGIN_MSG_MAP_EX(CSubCommentListBox)
-                               MSG_WM_PAINT(OnPaint)
-                               CHAIN_MSG_MAP(CDoubleBufferWindowImpl<CSubCommentListBox>)
-                       END_MSG_MAP()
-
-                       VOID CreateMemoryDC();
-                       
-               private:
-                       VOID OnPaint(HDC hdc);
+                       BEGIN_MSG_MAP(CCommentListBaseWindow)
                        
+                               MSG_WM_ERASEBKGND(OnEraseBkgnd)
                        
+                       END_MSG_MAP()
+
+                       LRESULT OnEraseBkgnd(HDC wParam){
+
+                               return TRUE;
+                       }
 
                };
 
+               
+
                //\83\81\83\93\83o\90é\8c¾
        private:
 
                CHeaderCtrl m_header;
-               CListBox  m_listBox;
+               CCommentListWindow  m_commentListWindow;
                CComAutoCriticalSection ccs;
                CStreamStatus streamStatus;
                CCommentList commentlist;