OSDN Git Service

2012/01/17 16:06:09
[nlite/nlite.git] / nlite / nlite_commentview.cpp
index aa95a07..eacbff7 100644 (file)
@@ -270,7 +270,6 @@ VOID CCommentView::ChangeSize(const SIZE& client){
        this->GetScrollInfo(SB_HORZ,&hScrollInfo);
 
        
-
        HDWP hDwp = BeginDeferWindowPos(2);
        
 
@@ -466,7 +465,7 @@ VOID CCommentView::OnVScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
                }
        }
 
-
+       
                
        return;
 }
@@ -537,15 +536,13 @@ VOID CCommentView::DecisionHorzSize(){
 
 CCommentListWindow::CCommentListWindow(CCommentView &in_self):
        self(in_self)
-{}
+       {}
 
 CCommentListWindow::~CCommentListWindow(){
-
-       
 }
 
 
-VOID CCommentListWindow::OnPaint(HDC hdc){
+VOID CCommentListWindow::OnPaint(HDC in_hdc){
 
        
        
@@ -555,6 +552,7 @@ VOID CCommentListWindow::OnPaint(HDC hdc){
        
        this->GetClientRect(&clientRect);
        
+
        this->GetWindowRect(&windowRect);
        windowRect.right -= windowRect.left;
        windowRect.bottom -= windowRect.top;
@@ -562,51 +560,57 @@ VOID CCommentListWindow::OnPaint(HDC hdc){
        windowRect.top = 0;
        RECT listRect = windowRect;
        listRect.right = self.GetColumnHolSizeSum();
-       
-       m_memoryDC.FillRect(&clientRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
 
-       CCommentList &commentList = self.commentlist;
+       HDC hdc = this->GetDC();
+       {
+               CMemoryDC mdc(hdc,listRect);
+               mdc.SelectFont(AtlGetDefaultGuiFont());
+               mdc.FillRect(&clientRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
+
+               CCommentList &commentList = self.commentlist;
 
 
 
        
        
-       if(commentList.Size() > (UINT_PTR)self.viewStartHeight){
+               if(commentList.Size() > (UINT_PTR)self.viewStartHeight){
 
        
-               
-               CCommentList::iterator chatData = commentList.begin();
-               std::advance(chatData,self.viewStartHeight);
+                       clock_t start,sum = 0;;
+                       CCommentList::iterator chatData = commentList.begin();
+                       std::advance(chatData,self.viewStartHeight);
                
 
 
-               CBrush baseBkBrush;
-               baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
-               m_memoryDC.FillRect(&listRect,baseBkBrush);
-               baseBkBrush.DeleteObject();
-               CCommentList::iterator endData = commentList.end();
-               listRect.bottom = 0;
-               for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
-                       listRect.bottom += chatData->height;
+                       CBrush baseBkBrush;
+                       baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+                       mdc.FillRect(&listRect,baseBkBrush);
+                       baseBkBrush.DeleteObject();
+                       CCommentList::iterator endData = commentList.end();
+                       listRect.bottom = 0;
+                       for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
+                               listRect.bottom += chatData->height;
 
+                               start = clock();
+                               this->DrawItem(mdc,listRect,*chatData);
+                               sum += clock() - start;
                        
-                       this->DrawItem(m_memoryDC,listRect,*chatData);
                        
-                       
-                       
-                       listRect.top = listRect.bottom;
-               }
+                               listRect.top = listRect.bottom;
+                       }
+
+
+                       dumpln(TEXT("viewtime:%d"),sum);
 
                
-       }
+               }
 
        
        
        
-       PAINTSTRUCT ps;
-       HDC selfDC = this->BeginPaint(&ps);
-       BOOL rslt = ::BitBlt(selfDC,0,0,windowRect.right,windowRect.bottom,m_memoryDC,0,0,SRCCOPY);
-       this->EndPaint(&ps);
+       }
+       this->ReleaseDC(hdc);
+       
 
        
        return;
@@ -614,6 +618,7 @@ VOID CCommentListWindow::OnPaint(HDC hdc){
 
 VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
 
+       
        SCROLLINFO vScrollInfo = {0};
        vScrollInfo.fMask = SIF_ALL;
 
@@ -668,6 +673,7 @@ overclientrect:
 
 VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
 
+       
        RECT noViewRect;
        RECT userNameViewRect;
        RECT timeViewRect;
@@ -684,9 +690,11 @@ VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
        _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
 
        COLORREF bkColor;
-
+       COLORREF outLineColor;
+       
        CPen outLinePen;
        CPen colLinePen;
+       CBrush bkBrush;
        colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
        
        
@@ -694,17 +702,20 @@ VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
        if (chatData.selectFlag == TRUE)
        {
                bkColor = ColorList::selectBack;
-               outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineSelect);
+               outLineColor = ColorList::outLineSelect;
+               
+               
        }
        else  
        {
                
-               outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
+               outLineColor = ColorList::outLineNomal;
 
                if(chatData.listenerData->originBkFlag == TRUE){
                        
                        bkColor = chatData.listenerData->bkColor;
-
+                       
+                       
                } else {
                        
                        bkColor = self.viewproperty.backColor;
@@ -714,15 +725,19 @@ VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
                }
        }
 
+       outLinePen.CreatePen(PS_SOLID,1,outLineColor);
+       bkBrush.CreateSolidBrush(bkColor);
+       dc.FillRect(&rc,bkBrush);
        dc.SelectPen(outLinePen);
+       
        dc.SetBkColor(bkColor);
        //\83e\83L\83X\83g\82Ì\83J\83\89\81[\82ð\90Ý\92è        
        dc.SetTextColor(self.viewproperty.baseStringColor);
        
-       CBrush bkBrush;
-       bkBrush.CreateSolidBrush(bkColor);
-       dc.FillRect(&rc,bkBrush);
-       bkBrush.DeleteObject();
+       
+       
+       
+       
 
        //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
        
@@ -792,9 +807,10 @@ UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
        drowSize.right -= 2;
        drowSize.bottom = 0;
 
-       
-       m_memoryDC.DrawTextW(chatData.chatBuf,chatData.chatBuf.length(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
-       
+       CDCHandle cdc = this->GetDC();
+       cdc.SelectFont(AtlGetDefaultGuiFont());
+       ::DrawTextW(cdc,chatData.chatBuf,chatData.chatBuf.length(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
+       this->ReleaseDC(cdc);
        drowSize.top -= 2;
        drowSize.bottom += 2;
 
@@ -804,15 +820,6 @@ UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
 
 LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
        
-
-       HDC hdc = this->GetDC();
-       m_memoryDC.CreateCompatibleDC(hdc);
-       
-       m_bitmap.CreateCompatibleBitmap(hdc,::GetSystemMetrics(SM_CXFULLSCREEN),::GetSystemMetrics(SM_CYFULLSCREEN));
-       m_memoryDC.SelectBitmap(m_bitmap);
-       m_memoryDC.SelectFont(AtlGetDefaultGuiFont());
-       this->ReleaseDC(hdc);
-       
        return 0;
 }
 
@@ -892,19 +899,19 @@ VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
                        bkColor = RGB(red,green,blue);
 
                }while(colorCollector.Find(bkColor));
-
+               
                chatData.listenerData->originBkFlag = TRUE;
-
+               chatData.listenerData->SetBkColor(bkColor);
        } else {
 
-               bkColor = self.viewproperty.backColor;
+               
                chatData.listenerData->originBkFlag = FALSE;
        }
 
        
        
 
-       chatData.listenerData->SetBkColor(bkColor);
+       
 
        if(TryEnterCriticalSection(&this->m_sec) == TRUE){
                this->Invalidate(TRUE);