#include "nlite_include.h"
-
-
-//
-//\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
-///////////////////////////////////////////////////////
-
-CCommentView::CCommentView():
- m_commentListWindow(*this)
+namespace nlite{
+
+ //\90F\92è\90\94
+ namespace ColorList{
+ enum type{
+ selectBack = RGB(255,240,240),
+ outLineSelect = RGB(255,0,0),
+ outLineNomal = RGB(0,0,0),
+ colLine = RGB(224,224,224)
+ };
+ };
+
+ //
+ //\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
+ ///////////////////////////////////////////////////////
+
+ CCommentView::CCommentView():
+ m_commentListWindow(*this)
{
LOGFONT lf = {0};
hHeaderFontNew = CreateFontIndirect(&lf);
-
+
+ return;
+
+ }
+
+ CCommentView::~CCommentView(){
+
+
+ DeleteObject(hHeaderFontNew);
+
return;
+ }
+
+
+
+
+ VOID CCommentView::OnConnect(){
+ m_commentListWindow.SetRedraw(FALSE);
+ commentlist.OnConnect();
+
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.cbSize = sizeof(vScrollInfo);
+ vScrollInfo.fMask = SIF_ALL;
+
+ this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+
+ m_commentListWindow.SetRedraw(TRUE);
+
+
+ }
+
-}
+ UINT_PTR CCommentView::GetColumnHolSizeSum(){
-CCommentView::~CCommentView(){
+ INT_PTR nMin = 0;
+ INT_PTR nMax = 0;
+ this->GetScrollRange(SB_HORZ,&nMin,&nMax);
-
- DeleteObject(hHeaderFontNew);
+ return nMax;
+ }
- return;
-}
+ VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
+ viewproperty = setProperty;
+ return;
+ }
+ CommentViewProperty &CCommentView::GetProperty(){
-VOID CCommentView::Lock(){
- ccs.Lock();
-}
+ return viewproperty;
-VOID CCommentView::Unlock(){
- ccs.Unlock();
-}
+ }
-VOID CCommentView::OnConnect(){
- commentlist.OnConnect();
-// m_commentListWindow.SetRedraw(FALSE);
-
-}
-UINT_PTR CCommentView::GetColumnHolSizeSum(){
- INT_PTR nMin = 0;
- INT_PTR nMax = 0;
- this->GetScrollRange(SB_HORZ,&nMin,&nMax);
+ HWND CCommentView::Create(HWND hWndParent){
- return nMax;
-}
-VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
- viewproperty = setProperty;
- return;
-}
+ HWND rslt = __super::Create(hWndParent,0,commentViewConstant::NLITE_COMMENTVIEW,WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER,0,commentViewConstant::MENU_OR_ID);
-CommentViewProperty &CCommentView::GetProperty(){
+ PAINTSTRUCT ps;
+ HDC hdc = m_header.BeginPaint(&ps);
+ SIZE size;
- return viewproperty;
+ HFONT hOld = (HFONT)SelectObject(hdc,hHeaderFontNew);
-}
+ LPTSTR columns[] = {TEXT("\83R\83\81\94Ô"),TEXT("\83\86\81[\83U\81[\96¼"),TEXT("\83R\83\81\83\93\83g"),TEXT("\8e\9e\8aÔ"),TEXT("\8fî\95ñ")};
+ UINT_PTR holizenSize[] = {0,0,100,0,0};
+ for(UINT_PTR index = 0;index < ARRAY_LENGTH(columns) ;++index){
+ GetTextExtentPoint32(hdc , columns[index] , _tcslen(columns[index]) , &size);
+ UINT_PTR holsize = holizenSize[index] + size.cx + 15;
+ holizenSize[index] = viewproperty.headerholSize[index] >= 0 ? viewproperty.headerholSize[index] : holsize;
+ }
+ SelectObject(hdc,hOld);
+ m_header.EndPaint(&ps);
-HWND CCommentView::Create(HWND hWndParent){
-
+ HEADERSINFO headersinfo = {columns,holizenSize,ARRAY_LENGTH(columns)};
- HWND rslt = __super::Create(hWndParent,0,commentViewConstant::NLITE_COMMENTVIEW,WS_VISIBLE | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_BORDER,0,commentViewConstant::MENU_OR_ID);
+ AddHeader(&headersinfo);
- PAINTSTRUCT ps;
- HDC hdc = m_header.BeginPaint(&ps);
- SIZE size;
+ m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
- HFONT hOld = (HFONT)SelectObject(hdc,hHeaderFontNew);
- LPTSTR columns[] = {TEXT("\83R\83\81\94Ô"),TEXT("\83\86\81[\83U\81[\96¼"),TEXT("\83R\83\81\83\93\83g"),TEXT("\8e\9e\8aÔ"),TEXT("\8fî\95ñ")};
- UINT_PTR holizenSize[] = {0,0,100,0,0};
- for(UINT_PTR index = 0;index < ARRAY_LENGTH(columns) ;++index){
- GetTextExtentPoint32(hdc , columns[index] , _tcslen(columns[index]) , &size);
- UINT_PTR holsize = holizenSize[index] + size.cx + 15;
- holizenSize[index] = viewproperty.headerholSize[index] >= 0 ? viewproperty.headerholSize[index] : holsize;
+ return rslt;
}
- SelectObject(hdc,hOld);
- m_header.EndPaint(&ps);
-
-
- HEADERSINFO headersinfo = {columns,holizenSize,ARRAY_LENGTH(columns)};
- AddHeader(&headersinfo);
- m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
-
-
-
-
- return rslt;
-}
+ LRESULT CCommentView::OnHeaderEndTrack(LPNMHDR lParam){
+
+
+ if(lParam->hwndFrom == m_header.m_hWnd){
+
+
+ m_commentListWindow.SetRedraw(FALSE);
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
+
+ this->GetScrollInfo(SB_VERT,&vScrollInfo);
+ vScrollInfo.nPage = m_commentListWindow.CalcScrollPage(vScrollInfo.nMax);
+ vScrollInfo.fMask = SIF_PAGE;
+ this->SetScrollInfo(SB_VERT,&vScrollInfo);
+
+ BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage + 1>= vScrollInfo.nMax;
+ UINT_PTR commentCount = commentlist.Size();
+ LPNMHEADER lpNmHdr = (LPNMHEADER )lParam;
+
+ m_header.SetItem(lpNmHdr->iItem,lpNmHdr->pitem);
+
+
+
+
+
+
+
+ if(scrollFlag == TRUE){
+
+ this->SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+ }
+
+ INT_PTR itemCount = m_header.GetItemCount();
+ RECT itemSizeRect;
+
+ INT_PTR nMax = 0;
+ for(INT_PTR itemIndex = 0;itemIndex < itemCount;itemIndex++){
+ m_header.GetItemRect(itemIndex,&itemSizeRect);
+ nMax += itemSizeRect.right - itemSizeRect.left;
+ }
+ INT_PTR nMin = 0;
+ this->SetScrollRange(SB_HORZ,nMin,nMax,TRUE);
+ DecisionHorzSize();
+ auto begin = commentlist.begin();
-LRESULT CCommentView::OnheaderItemChanged(LPNMHDR lParam){
+ auto end = commentlist.end();
+
+ /*
+ for(;begin != end;++begin){
+
+ begin->height = m_commentListWindow.CalcItemHeight(*begin);
+ }
+ */
+ m_commentListWindow.SetRedraw(TRUE);
+ if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+ m_commentListWindow.Invalidate();
+ m_commentListWindow.Unlock();
+ }
+
+ }
+
+ return 0;
+ }
+
+ VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
+
+ commentlist.OnChatReceve(chat,commnetCountSum,this->m_commentListWindow);
+
+ return;
+ }
+
+
+ VOID CCommentView::SetStreamStatus(StreamStatus_P st){
+
+ streamStatus.SetStreamStatus(st);
+ }
+
+ VOID CCommentView::OnChatReceveSettle(UINT_PTR chatNo,UINT_PTR commentCountSum){
-
- if(lParam->hwndFrom == m_header.m_hWnd){
-
-
SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
+
+ //vScrollCcs.Lock();
+
+ vScrollInfo.fMask = SIF_ALL;
+
this->GetScrollInfo(SB_VERT,&vScrollInfo);
- vScrollInfo.nPos++;
BOOL scrollFlag = vScrollInfo.nPos + (int)vScrollInfo.nPage >= vScrollInfo.nMax;
- UINT_PTR commentCount = commentlist.Size();
-
- //m_commentListWindow.SetRedraw(FALSE);
- //m_commentListWindow.ResetContent();
- /*
- for(UINT_PTR index =0;index < commentCount;index++){
- m_commentListWindow.AddString((LPCTSTR)&commentlist.GetChatAt(index));
- }
- */
-
-
-
-
+ // vScrollInfo.fMask = SIF_RANGE;
+ vScrollInfo.cbSize = sizeof(vScrollInfo);
- //m_commentListWindow.SetRedraw(TRUE);
- m_commentListWindow.Invalidate();
-
+ vScrollInfo.nMax = commentCountSum;
+ // this->SetScrollRange(SB_VERT,vScrollInfo.nMin,vScrollInfo.nMax,FALSE);
+ // this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+ vScrollInfo.fMask = SIF_RANGE | SIF_PAGE;
+ vScrollInfo.nPage = m_commentListWindow.CalcScrollPage(vScrollInfo.nMax);
- if(scrollFlag == TRUE){
-// m_commentListWindow.SendMessageW(WM_VSCROLL,SB_BOTTOM,0);
+ this->SetScrollInfo(SB_VERT,&vScrollInfo,FALSE);
+
+
+
+
+ if(scrollFlag == TRUE){
+ this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
}
- INT_PTR itemCount = m_header.GetItemCount();
- RECT itemSizeRect;
-
- INT_PTR nMax = 0;
- for(INT_PTR imtemIndex = 0;imtemIndex < itemCount;imtemIndex++){
- m_header.GetItemRect(imtemIndex,&itemSizeRect);
- nMax += itemSizeRect.right - itemSizeRect.left;
+ if(vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) >= vScrollInfo.nMax - static_cast<INT_PTR>(vScrollInfo.nPage)&& TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+ m_commentListWindow.Invalidate();
+ m_commentListWindow.Unlock();
}
- INT_PTR nMin = 0;
- this->SetScrollRange(SB_HORZ,nMin,nMax,TRUE);
- DecisionHorzSize();
-
+
+
+ //this->SetScrollInfo(SB_VERT,NULL);
+
+ return;
}
- return 0;
-}
+ static UCHAR getrgb(){
-VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
-
+ UCHAR rgb = 160 + rand() % 92;
+ return rgb;
+ }
-
-
-
- commentlist.Lock();
- commentlist.OnChatReceve(chat,commnetCountSum);
- commentlist.Unlock();
-
-
- return;
-}
-VOID CCommentView::SetStreamStatus(StreamStatus &st){
-
- streamStatus.SetStreamStatus(st);
-}
-VOID CCommentView::OnChatReceveSettle(UINT_PTR chatNo,UINT_PTR commentCountSum){
-
- SCROLLINFO scrollInfo = {0};
- scrollInfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
- this->GetScrollInfo(SB_VERT,&scrollInfo);
-
- if(scrollInfo.nPos + (int)scrollInfo.nPage >= scrollInfo.nMax == TRUE){
- scrollInfo.nPos = commentCountSum;
+
+
+
+
+
+ LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
+ ChangeSize(lParam);
+
+ return 0;
}
-
- scrollInfo.nMax = commentCountSum;
- scrollInfo.nPage = m_commentListWindow.CalcScrolPage();
- this->SetScrollInfo(SB_VERT,&scrollInfo);
- m_commentListWindow.Invalidate();
- return;
-}
-static UCHAR getrgb(){
+ VOID CCommentView::ChangeSize(const SIZE& client){
- UCHAR rgb = 160 + rand() % 92;
- return rgb;
-}
+ SCROLLINFO hScrollInfo = {0};
+ hScrollInfo.cbSize = sizeof(hScrollInfo);
+ hScrollInfo.fMask = SIF_PAGE;
+ hScrollInfo.nPage = client.cx;
-LRESULT CCommentView::OnListBoxDoubleClick(UINT uNotifyCode, int nID, CWindow wndCtl){
-
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+ hScrollInfo.fMask = SIF_ALL;
+ this->GetScrollInfo(SB_HORZ,&hScrollInfo);
- /*
- if(wndCtl.m_hWnd == m_commentListWindow.m_hWnd){
- //INT_PTR cursel = m_commentListWindow.GetCurSel();
- INT_PTR cursel = 0;
- if(cursel == LB_ERR)return 0;
-
- auto chatData = commentlist.GetChatAt(cursel);
- COLORREF bkColor;
- if(chatData.listenerData->originBkFlag == FALSE){
- CListenerColorCollector colorCollector;
- listenerList.BkColorCollect(colorCollector);
- UCHAR red;
- UCHAR green;
- UCHAR blue;
-
- srand((unsigned int)time(NULL));
- do{
+ HDWP hDwp = BeginDeferWindowPos(2);
- red = getrgb();
- green = getrgb();
- blue = getrgb();
- bkColor = RGB(red,green,blue);
- }while(colorCollector.Find(bkColor));
+ INT_PTR movePos = -1 * hScrollInfo.nPos;
- chatData.listenerData->originBkFlag = TRUE;
+ m_header.DeferWindowPos(hDwp,m_header.m_hWnd,movePos,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
+ m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,::GetSystemMetrics(SM_CXFULLSCREEN),client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);
- } else {
+ EndDeferWindowPos(hDwp);
+
+
+ RECT bkRect;
+ RECT headerRectSize;
+ m_header.GetWindowRect(&headerRectSize);
+ bkRect.left = headerRectSize.right - headerRectSize.left - hScrollInfo.nPos;
+ bkRect.top = 0;
+ bkRect.right = client.cx ;
+ bkRect.bottom = client.cy;
+
+
+ return;
+ }
+
+
+ LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
+
+ return TRUE;
+ }
+
+
+ VOID CCommentView::OnDestroy(){
+ m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+ INT_PTR headerItemcount = m_header.GetItemCount();
+ RECT headerItemRect;
+ for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
+
+ m_header.GetItemRect(itemindex,&headerItemRect);
+ viewproperty.headerholSize[itemindex] = headerItemRect.right - headerItemRect.left;
+ }
+ commentlist.OnDestroy();
+ m_header.DestroyWindow();
+ m_commentListWindow.DestroyWindow();
+ return;
+
+ }
+
+ LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
+
+ if(lParam->hwndFrom == m_header.m_hWnd){
+ if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+
+ m_commentListWindow.Invalidate();
+ m_commentListWindow.Unlock();
+ }
+
+ }
+
+ return 0;
+ }
+
+
+ VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+
+
+ INT_PTR dy;
+ SCROLLINFO hScrollInfo = {0};
+ hScrollInfo.cbSize = sizeof(hScrollInfo);
+ hScrollInfo.fMask = SIF_ALL;
+ this->GetScrollInfo(SB_HORZ,&hScrollInfo);
+ switch(loWParam){
+
+ case SB_THUMBPOSITION:
+ case SB_THUMBTRACK:
+ dy = hiWParam - hScrollInfo.nPos;
+ break;
+
+ case SB_LINELEFT:
+ case SB_PAGELEFT:
+
+ dy = -1 * hScrollInfo.nPage;
+
+ break;
+
+ case SB_LINERIGHT:
+ case SB_PAGERIGHT:
+
+ dy = hScrollInfo.nPage + hScrollInfo.nPos > (UINT_PTR)hScrollInfo.nMax ? 0 :(UINT_PTR) (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) < hScrollInfo.nPage ? (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) : hScrollInfo.nPage;
+
+ break;
+
+ default:
+ dy = 0;
+ break;
- bkColor = viewproperty.backColor;
- chatData.listenerData->originBkFlag = FALSE;
}
-
-
+ dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
+
+
+ if(dy != 0){
+ hScrollInfo.nPos += dy;
+ INT_PTR moveRange = -(hScrollInfo.nPos);
- chatData.listenerData->SetBkColor(bkColor);
+ HDWP hDwp = BeginDeferWindowPos(2);
- m_commentListWindow.Invalidate(TRUE);
+ m_header.DeferWindowPos(hDwp,m_header.m_hWnd,moveRange,0,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);
+
+
+ this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+ }
+
+ return;
}
- */
- return 0;
-}
+
+
+ VOID CCommentView::OnVScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+
+ INT_PTR dy;
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_ALL;
+
+
+ this->GetScrollInfo(SB_VERT,&vScrollInfo);
+
+ switch(loWParam){
+
+
+ case SB_THUMBPOSITION:
+ case SB_THUMBTRACK:
+
+ dy = hiWParam - vScrollInfo.nPos;
+
+ break;
+
+ case SB_LINEUP:
+
+ dy = -1;
+ break;
+
+ case SB_LINEDOWN:
+
+ dy = 1;
+
+ break;
+
+ case SB_PAGEUP:
+
+ dy = -1 * vScrollInfo.nPage;
+
+ break;
+
+ case SB_PAGEDOWN:
+
+ dy = vScrollInfo.nPage;
+
+ break;
+
+
+ case SB_TOP:
+
+ dy = -vScrollInfo.nPos;
+
+ break;
+
+ case SB_BOTTOM:
+
+ dy = vScrollInfo.nMax;
+
+ break;
+
+ default:
+
+ dy = 0;
+
+ break;
+
+ }
+ if(dy != 0){
+ vScrollInfo.nPos += dy;
+ // viewStartHeight = vScrollInfo.nPos;
+ this->SetScrollPos(SB_VERT,vScrollInfo.nPos);
+ //this->SetScrollInfo(SB_VERT,&vScrollInfo);
+ this->UpdateWindow();
+ if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+ m_commentListWindow.Invalidate();
+ m_commentListWindow.Unlock();
+ }
+ }
+
+
+
+ return;
+ }
-VOID CCommentView::OnSizing(UINT wParam,LPRECT 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_commentListWindow.Create(m_hWnd,0,commentViewConstant::NLITE_COMMENTLISTWINDOW,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN , 0,commentViewConstant::LISTWINDOW);
- ChangeSize( _WTYPES_NS::CSize(lParam->right - lParam->left,lParam->bottom - lParam->top));
-
- return;
-}
+ return 0;
+ }
+
+ VOID CCommentView::AddHeader(LPHEADERSINFO infos){
+
+ m_header.SetFont(hHeaderFontNew);
+ HDITEM item;
+ item.mask = HDI_FORMAT | HDI_TEXT | HDI_WIDTH;
+ item.fmt = HDF_CENTER | HDF_STRING;
-LRESULT CCommentView::OnSize(UINT wParam,SIZE lParam){
- ChangeSize(lParam);
-
- return 0;
-}
+ for(UINT_PTR index = 0;index < infos->count ;++index){
-VOID CCommentView::ChangeSize(const SIZE& client){
-
- SCROLLINFO hScrollInfo = {0};
- hScrollInfo.cbSize = sizeof(hScrollInfo);
- hScrollInfo.fMask = SIF_PAGE;
- hScrollInfo.nPage = client.cx;
- this->SetScrollInfo(SB_HORZ,&hScrollInfo);
- hScrollInfo.fMask = SIF_ALL;
- this->GetScrollInfo(SB_HORZ,&hScrollInfo);
+ item.pszText = infos->columns[index];
- HDWP hDwp = BeginDeferWindowPos(2);
-
+ item.cxy = infos->holizensize[index];
+ m_header.AddItem(&item);
+ }
+
+ RECT itemRect;
+ INT_PTR nMax = 0;
+ UINT_PTR itemCount = m_header.GetItemCount();
+ for(UINT_PTR u_index = 0;u_index < itemCount;++u_index){
- INT_PTR movePos = -1 * hScrollInfo.nPos;
-
- m_header.DeferWindowPos(hDwp,m_header.m_hWnd,movePos,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
- m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,movePos,commentViewConstant::HEADER_HAIGHT,::GetSystemMetrics(SM_CXFULLSCREEN),client.cy - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER);
+ m_header.GetItemRect(u_index,&itemRect);
+ nMax += itemRect.right - itemRect.left;
- EndDeferWindowPos(hDwp);
-
-
- RECT bkRect;
- RECT headerRectSize;
- m_header.GetWindowRect(&headerRectSize);
- bkRect.left = headerRectSize.right - headerRectSize.left - hScrollInfo.nPos;
- bkRect.top = 0;
- bkRect.right = client.cx ;
- bkRect.bottom = client.cy;
- this->InvalidateRect(&bkRect);
+ }
- return;
-}
+ this->SetScrollRange(SB_HORZ,0,nMax,TRUE);
+ DecisionHorzSize();
+ return;
+ }
-LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
+ VOID CCommentView::DecisionHorzSize(){
- return TRUE;
-}
+ HDWP hWindowPosInfo = BeginDeferWindowPos(2);
+ RECT bkWindowRect;
+ this->GetClientRect(&bkWindowRect);
+ m_header.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
+ m_commentListWindow.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
+ EndDeferWindowPos(hWindowPosInfo);
-VOID CCommentView::OnDestroy(){
- m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
- INT_PTR headerItemcount = m_header.GetItemCount();
- RECT headerItemRect;
- for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
-
- m_header.GetItemRect(itemindex,&headerItemRect);
- viewproperty.headerholSize[itemindex] = headerItemRect.right - headerItemRect.left;
+ return;
}
- commentlist.OnDestroy();
- m_header.DestroyWindow();
-// m_commentListWindow.DestroyWindow();
- return;
-}
-LRESULT CCommentView::OnHeaderEndDrag(LPNMHDR lParam){
- if(lParam->hwndFrom == m_header.m_hWnd){
-// m_commentListWindow.Invalidate();
+ //
+ //\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
+ ////////////////////////////////////////////////////////////////////
+
+ CCommentListWindow::CCommentListWindow(CCommentView &in_self):
+ self(in_self)
+ {}
+ CCommentListWindow::~CCommentListWindow(){
}
- return 0;
-}
+
+ VOID CCommentListWindow::OnPaint(HDC in_hdc){
+
+
+
+ RECT windowRect;
+ RECT listRect = {0};
+ RECT clientRect;
+
+ self.GetClientRect(&clientRect);
+ clientRect.bottom -= commentViewConstant::HEADER_HAIGHT;
+
+ this->GetWindowRect(&windowRect);
+ windowRect.right -= windowRect.left;
+ windowRect.bottom -= windowRect.top;
+ windowRect.left = 0;
+ windowRect.top = 0;
-VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
+ CPaintDC pdc(*this);
-
- INT_PTR dy;
- SCROLLINFO hScrollInfo = {0};
- hScrollInfo.cbSize = sizeof(hScrollInfo);
- hScrollInfo.fMask = SIF_ALL;
- this->GetScrollInfo(SB_HORZ,&hScrollInfo);
- switch(loWParam){
+ {
+ CMemoryDC mdc(pdc,windowRect);
+ mdc.SelectFont(AtlGetDefaultGuiFont());
- case SB_THUMBPOSITION:
- case SB_THUMBTRACK:
- dy = hiWParam - hScrollInfo.nPos;
- break;
- case SB_LINELEFT:
- case SB_PAGELEFT:
+ CCommentList &commentList = self.commentlist;
- dy = -1 * hScrollInfo.nPage;
+ BOOL selectFlag = FALSE;
+ CCommentList::iterator selectData;
+ RECT selectRect = {0};
+ UINT_PTR viewStartHeight = self.GetScrollPos(SB_VERT);
- break;
- case SB_LINERIGHT:
- case SB_PAGERIGHT:
+ if(commentList.Size() > (UINT_PTR)viewStartHeight){
- dy = hScrollInfo.nPage + hScrollInfo.nPos > (UINT_PTR)hScrollInfo.nMax ? 0 :(UINT_PTR) (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) < hScrollInfo.nPage ? (hScrollInfo.nMax - ( hScrollInfo.nPage + hScrollInfo.nPos)) : hScrollInfo.nPage;
+ listRect = windowRect;
+ listRect.right = self.GetColumnHolSizeSum();
- break;
+ CCommentList::iterator chatData = commentList.begin();
+ std::advance(chatData,viewStartHeight);
- default:
- dy = 0;
- break;
+
+ CBrush baseBkBrush;
+ baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+ mdc.FillRect(&listRect,baseBkBrush);
+ baseBkBrush.DeleteObject();
+ CCommentList::iterator endData = commentList.end();
+ listRect.bottom = 0;
+
+ CPen outLinePen;
+ outLinePen.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
+ mdc.SelectPen(outLinePen);
+ mdc.MoveTo(listRect.right,listRect.top);
+ mdc.LineTo(listRect.right,listRect.bottom);
+
+
+ for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
+ listRect.bottom += CalcItemHeight(*chatData);
+
+
+ if(chatData->selectFlag == TRUE){
+ selectFlag = TRUE;
+ selectData = chatData;
+ selectRect = listRect;
+ } else {
+
+ this->DrawItem(mdc,listRect,*chatData);
+ }
+
+
+ listRect.top = listRect.bottom;
+ }
+
+ mdc.SelectPen(outLinePen);
+ mdc.MoveTo(listRect.left,listRect.bottom);
+ mdc.LineTo(listRect.right,listRect.bottom);
+
+ if(selectFlag == TRUE){
+ this->DrawItem(mdc,selectRect,*selectData);
+ }
+
+ }
+ windowRect.left = listRect.right;
+ mdc.FillRect(&windowRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
+
+
+
+
+ }
+
+
+
+
+ return;
}
-
- dy = max(-1 * hScrollInfo.nPos, min(dy, hScrollInfo.nMax - hScrollInfo.nPos));
+
+ VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
- if(dy != 0){
- hScrollInfo.nPos += dy;
- //RECT headerPosRect;
- //RECT listBoxPosRect;
- //m_header.GetWindowRect(&headerPosRect);
- //m_commentListWindow.GetWindowRect(&listBoxPosRect);
- INT_PTR moveRange = -(hScrollInfo.nPos);
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_ALL;
+
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ BOOL scrollFlag = (UINT)(vScrollInfo.nPage + vScrollInfo.nPos + 1) >= (UINT)vScrollInfo.nMax;
+ vScrollInfo.nPage = CalcScrollPage(vScrollInfo.nMax);
+
+ vScrollInfo.fMask = SIF_PAGE;
+ self.SetScrollInfo(SB_VERT,&vScrollInfo);
+
+
+
+ if(scrollFlag == TRUE){
+ self.SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+ }
+
+ this->Invalidate();
+
+ return;
+ }
+
+
+ UINT_PTR CCommentListWindow::CalcScrollPage(UINT_PTR nMax){
+
+ RECT clientRect;
+ INT_PTR rslt = 0;
+ LONG height = 0;
+ this->GetClientRect(&clientRect);
+
+ SCROLLINFO vScrollInfo = {0};
+ if(self.commentlist.empty() != TRUE){
+
+ CCommentList::reverse_iterator rbegin = self.commentlist.rbegein();
+ CCommentList::reverse_iterator rend = self.commentlist.rend();
+ for(;rbegin != rend;++rbegin){
+
+ height += CalcItemHeight(*rbegin);
+ rslt++;
+ if(height > clientRect.bottom)goto overclientrect;
+
+ }
+ }
/*
- headerPosRect.bottom -= headerPosRect.top;
- headerPosRect.top = 0;
- headerPosRect.right += moveRange - headerPosRect.left;
- headerPosRect.left = moveRange;
-
- listBoxPosRect.bottom -= (listBoxPosRect.top - commentViewConstant::HEADER_HAIGHT);
- listBoxPosRect.top = commentViewConstant::HEADER_HAIGHT;
- listBoxPosRect.right += moveRange - listBoxPosRect.left;
- listBoxPosRect.left = moveRange;
-
- m_header.MoveWindow(&headerPosRect);
- m_commentListWindow.MoveWindow(&listBoxPosRect);
-
+ vScrollInfo.fMask = SIF_RANGE;
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
*/
-
+ rslt = nMax+ 1;
- HDWP hDwp = BeginDeferWindowPos(2);
- m_header.DeferWindowPos(hDwp,m_header.m_hWnd,moveRange,0,0,0,SWP_NOSIZE | SWP_NOZORDER);
- m_commentListWindow.DeferWindowPos(hDwp,m_commentListWindow.m_hWnd,moveRange,commentViewConstant::HEADER_HAIGHT,0,0,SWP_NOSIZE | SWP_NOZORDER);
+overclientrect:
- EndDeferWindowPos(hDwp);
-
-
- this->SetScrollInfo(SB_HORZ,&hScrollInfo);
+ return rslt;
}
-
- return;
-}
-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_commentListWindow.Create(m_hWnd,0,commentViewConstant::NLITE_COMMENTLISTWINDOW,WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN , 0,commentViewConstant::LISTBOX_ID);
-
-
-
-
- return 0;
-}
+ VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
-VOID CCommentView::AddHeader(LPHEADERSINFO infos){
+ RECT noViewRect;
+ RECT userNameViewRect;
+ RECT timeViewRect;
+ RECT chatViewRect;
+ RECT infoViewRect;
- m_header.SetFont(hHeaderFontNew);
-
- HDITEM item;
- item.mask = HDI_FORMAT | HDI_TEXT | HDI_WIDTH;
- item.fmt = HDF_CENTER | HDF_STRING;
-
-
- for(UINT_PTR index = 0;index < infos->count ;++index){
-
- item.pszText = infos->columns[index];
-
- item.cxy = infos->holizensize[index];
- m_header.AddItem(&item);
- }
-
- RECT itemRect;
- INT_PTR nMax = 0;
- UINT_PTR itemCount = m_header.GetItemCount();
- for(UINT_PTR u_index = 0;u_index < itemCount;++u_index){
-
- m_header.GetItemRect(u_index,&itemRect);
- nMax += itemRect.right - itemRect.left;
-
- }
-
- this->SetScrollRange(SB_HORZ,0,nMax,TRUE);
-
- DecisionHorzSize();
- return;
-}
-
-VOID CCommentView::DecisionHorzSize(){
-
- HDWP hWindowPosInfo = BeginDeferWindowPos(2);
- RECT bkWindowRect;
- this->GetClientRect(&bkWindowRect);
- m_header.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
- m_commentListWindow.DeferWindowPos(hWindowPosInfo,m_header.m_hWnd,0,0,::GetSystemMetrics(SM_CXFULLSCREEN),bkWindowRect.bottom - commentViewConstant::HEADER_HAIGHT,SWP_NOZORDER | SWP_NOMOVE);
-
- EndDeferWindowPos(hWindowPosInfo);
-
- return;
-}
-
-
-//
-//\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
-////////////////////////////////////////////////////////////////////
-
-CCommentListWindow::CCommentListWindow(CCommentView &in_self):self(in_self){
-
- colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
- outLinePenNomal.CreatePen(PS_SOLID,1,ColorList::outLineNomal);
- outLinePenSelect.CreatePen(PS_SOLID,1,ColorList::outLineSelect);
-
-
-}
-
-CCommentListWindow::~CCommentListWindow(){
-
- colLinePen.DeleteObject();
- outLinePenNomal.DeleteObject();
- outLinePenSelect.DeleteObject();
-
-}
-
-VOID CCommentListWindow::OnPaint(HDC hdc){
-
-
-
- RECT windowRect;
-
- RECT clientRect;
-
- this->GetClientRect(&clientRect);
-
- this->GetWindowRect(&windowRect);
- windowRect.right -= windowRect.left;
- windowRect.bottom -= windowRect.top;
- windowRect.left = 0;
- windowRect.top = 0;
- RECT listRect = windowRect;
- listRect.right = self.GetColumnHolSizeSum();
-
- m_memoryDC.FillRect(&clientRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
-
- CCommentList &commentList = self.commentlist;
-
- //\83R\83\81\83\93\83g\83\8a\83X\83g\83\8d\83b\83N
- commentList.Lock();
-
- SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_ALL;
- self.GetScrollInfo(SB_VERT,&vScrollInfo);
- if(commentList.Size() > (UINT_PTR)vScrollInfo.nPos){
- CCommentList::iterator chatData = commentList.begin();
- chatData += vScrollInfo.nPos;
- m_memoryDC.FillRect(&listRect,self.viewproperty.backColor);
- CCommentList::iterator endData = commentList.end();
- listRect.bottom = 0;
- for(;chatData != endData;++chatData){
- listRect.bottom += this->CalcItemHeight(*chatData);
-
- this->DrawItem(m_memoryDC,listRect,*chatData);
- listRect.top = listRect.bottom;
-
- if(listRect.top >= clientRect.bottom)break;
-
+ time_t chatTime = (time_t)difftime(chatData.date,self.streamStatus.start_time);
+
+
+ BOOL beforeStartFlag = chatTime < 0 ? TRUE : FALSE;
+ TCHAR noString[sizeof(chatData.no) * 8];
+ TCHAR dateString[LENGTH_16];
+ if(chatData.no != 0)_stprintf(noString,TEXT("%u"),chatData.no);
+ else _tcscpy(noString,TEXT(""));
+ CNLiteString timeFormat;
+
+
+ if(beforeStartFlag == TRUE){
+
+ timeFormat = TEXT("-");
+ chatTime = -chatTime;
+ }
+ tm ct = *gmtime(&chatTime);
+ if(ct.tm_hour != 0 ){
+
+ timeFormat += TEXT("%H:%M:%S");
+
+ } else {
+
+ timeFormat += TEXT("%M:%S");
}
-
+ _tcsftime(dateString,ARRAY_LENGTH(dateString),timeFormat,&ct);
+
+ COLORREF bkColor;
+ COLORREF outLineColor;
+
+ CPen outLinePen;
+ CPen colLinePen;
+ CBrush bkBrush;
+ colLinePen.CreatePen(PS_SOLID,1,ColorList::colLine);
+
+
+ //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
+ if (chatData.selectFlag == TRUE)
+ {
+ bkColor = ColorList::selectBack;
+ outLineColor = ColorList::outLineSelect;
+
+
+ }
+ else
+ {
+
+ outLineColor = ColorList::outLineNomal;
+
+ if(chatData.listenerData->originBkFlag == TRUE){
+
+ bkColor = chatData.listenerData->bkColor;
+
+
+ } else {
+ bkColor = self.viewproperty.backColor;
+
+
+
+ }
+ }
+
+ outLinePen.CreatePen(PS_SOLID,1,outLineColor);
+ bkBrush.CreateSolidBrush(bkColor);
+ dc.SelectPen(outLinePen);
+
+ if(chatData.selectFlag == TRUE){
+
+ dc.MoveTo(rc.left,rc.bottom);
+ dc.LineTo(rc.right,rc.bottom);
+ }
+ dc.FillRect(&rc,bkBrush);
+ dc.SetBkColor(bkColor);
+ dc.MoveTo(rc.left,rc.top);
+ dc.LineTo(rc.right,rc.top);
+
+
+
+ dc.SetTextColor(self.viewproperty.baseStringColor);
+
+
+
+
+
+ //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
+
+ self.m_header.GetItemRect(CCommentView::NO,&noViewRect);
+ self.m_header.GetItemRect(CCommentView::USERNAME,&userNameViewRect);
+ self.m_header.GetItemRect(CCommentView::COMMENT,&chatViewRect);
+ self.m_header.GetItemRect(CCommentView::TIME,&timeViewRect);
+ self.m_header.GetItemRect(CCommentView::INFO,&infoViewRect);
+
+ noViewRect.left += 2;
+ userNameViewRect.left += 2;
+ timeViewRect.left += 2;
+ chatViewRect.left += 2;
+ infoViewRect.left += 2;
+
+ noViewRect.right -= 2;
+ userNameViewRect.right -= 2;
+ timeViewRect.right -= 2;
+ chatViewRect.right -= 2;
+ infoViewRect.right -= 2;
+
+ noViewRect.top = rc.top + 2;
+ userNameViewRect.top = rc.top + 2;
+ timeViewRect.top = rc.top + 2;
+ chatViewRect.top = rc.top + 2;
+ infoViewRect.top = rc.top + 2;
+
+ noViewRect.bottom = rc.bottom - 2;
+ userNameViewRect.bottom = rc.bottom - 2;
+ timeViewRect.bottom = rc.bottom - 2;
+ chatViewRect.bottom = rc.bottom - 2;
+ infoViewRect.bottom = rc.bottom - 2;
+
+ dc.SelectPen(colLinePen);
+
+ dc.MoveTo(noViewRect.right,rc.top);
+ dc.LineTo(noViewRect.right,rc.bottom);
+ dc.MoveTo(userNameViewRect.right,rc.top);
+ dc.LineTo(userNameViewRect.right,rc.bottom);
+ dc.MoveTo(chatViewRect.right,rc.top);
+ dc.LineTo(chatViewRect.right,rc.bottom);
+ dc.MoveTo(timeViewRect.right,rc.top);
+ dc.LineTo(timeViewRect.right,rc.bottom);
+
+ dc.DrawTextW(noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
+ dc.DrawTextW(chatData.listenerData->user_id,chatData.listenerData->user_id.GetLength(),&userNameViewRect,DT_WORD_ELLIPSIS);
+ dc.DrawTextW(chatData.chatBuf,chatData.chatBuf.GetLength(),&chatViewRect,DT_WORDBREAK);
+ dc.DrawTextW(dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
+
+ return;
+ }
+
+
+ UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
+
+ RECT drowSize;
+ self.m_header.GetItemRect(CCommentView::COMMENT,&drowSize);
+ drowSize.left += 2;
+ drowSize.top += 2;
+ drowSize.right -= 2;
+ drowSize.bottom = 0;
+
+ CPaintDC pdc(*this);
+ pdc.SelectFont(AtlGetDefaultGuiFont());
+ ::DrawTextW(pdc,chatData.chatBuf,chatData.chatBuf.GetLength(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
+ drowSize.top -= 2;
+ drowSize.bottom += 2;
+
+ return drowSize.bottom;
}
- //\83R\83\81\83\93\83g\83\8a\83X\83g\83\8d\83b\83N\89ð\8f\9c
- commentList.Unlock();
- PAINTSTRUCT ps;
- HDC selfDC = this->BeginPaint(&ps);
- ::BitBlt(selfDC,0,0,windowRect.right,windowRect.bottom,m_memoryDC,0,0,SRCCOPY);
- this->EndPaint(&ps);
-
- return;
-}
-VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
- SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_PAGE;
- vScrollInfo.nPage = CalcScrolPage();
+ LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
+
+ return 0;
+ }
+
+ INT_PTR CCommentListWindow::CalcClickLine(INT_PTR height){
+ SCROLLINFO vScrollInfo = {0};
+ vScrollInfo.fMask = SIF_POS;
- self.SetScrollInfo(SB_VERT,&vScrollInfo);
- return;
-}
+ self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ INT_PTR heightSum = 0;
+ INT_PTR lineNo = vScrollInfo.nPos;
+ CCommentList::iterator chatData = self.commentlist.begin();
+ CCommentList::iterator end = self.commentlist.end();
+ std::advance(chatData,vScrollInfo.nPos);
+ for(; chatData != end;++chatData){
-UINT_PTR CCommentListWindow::CalcScrolPage(){
-
- RECT clientRect;
- INT_PTR rslt = 0;
- LONG height = 0;
- this->GetClientRect(&clientRect);
- self.commentlist.Lock();
- if(self.commentlist.empty() != TRUE){
- CCommentList::iterator lastData = --self.commentlist.end();
- CCommentList::iterator begin = self.commentlist.begin();
- for(;lastData != begin;--lastData){
+ heightSum += CalcItemHeight(*chatData);
- height += CalcItemHeight(*lastData);
+ if(heightSum >= height){
- if(height > clientRect.bottom)goto overclientrect;
- rslt++;
+ goto end;
+ }
+
+ ++lineNo;
}
- INT_PTR nMin;
-
- rslt = self.GetScrollRange(SB_VERT,&nMin,&rslt);
+ lineNo = -1;
+end:
+ return lineNo;
}
-overclientrect:
- self.commentlist.Unlock();
- return rslt;
-}
-VOID CCommentListWindow::DrawItem(CDC &dc,RECT &rc,CChatData &chatData){
- RECT noViewRect;
- RECT userNameViewRect;
- RECT timeViewRect;
- RECT chatViewRect;
- RECT infoViewRect;
+ VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
- time_t chatTime = (time_t)difftime(chatData.date,self.streamStatus.start_time);
- tm ct = *gmtime(&chatTime);
-
- TCHAR noString[sizeof(chatData.no) * 8];
- TCHAR dateString[LENGTH_16];
- _stprintf(noString,TEXT("%u"),chatData.no);
- _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
- COLORREF bkColor;
-
- //\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
- if (chatData.selectFlag == TRUE)
- {
- bkColor = ColorList::selectBack;
- dc.SelectPen(outLinePenSelect);
- dc.SetBkColor(ColorList::selectBack);
+ this->SetFocus();
+ if(self.commentlist.empty() == TRUE)return;
+ auto curselItem = self.commentlist.GetCurSelItem();
+ if(curselItem != self.commentlist.end()){
+ curselItem->selectFlag = FALSE;
+ }
+ self.commentlist.SetCurSel(CalcClickLine(point.y));
+ if(TryEnterCriticalSection(&this->m_sec) == TRUE){
+ this->Invalidate();
+ this->Unlock();
+ }
+ return;
}
- else
- {
- dc.SelectPen(outLinePenNomal);
-
- if(chatData.listenerData->originBkFlag == TRUE){
-
- bkColor = chatData.listenerData->bkColor;
-
- dc.SetBkColor(chatData.listenerData->bkColor);
+ VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
+
+
+
+
+ this->SetFocus();
+ if(self.commentlist.empty() == TRUE)return;
+
+ auto chatData = self.commentlist.GetChatAt(CalcClickLine(point.y));
+ COLORREF bkColor;
+ if(chatData.listenerData->originBkFlag == FALSE){
+ CListenerColorCollector colorCollector;
+ listenerList.BkColorCollect(colorCollector);
+ UCHAR red;
+ UCHAR green;
+ UCHAR blue;
+
+ srand((unsigned int)time(NULL));
+ do{
+
+ red = getrgb();
+ green = getrgb();
+ blue = getrgb();
+ bkColor = RGB(red,green,blue);
+
+ }while(colorCollector.Find(bkColor));
+
+ chatData.listenerData->originBkFlag = TRUE;
+ chatData.listenerData->SetBkColor(bkColor);
} else {
- bkColor = self.viewproperty.backColor;
- dc.SetBkColor(self.viewproperty.backColor);
-
-
+
+
+ chatData.listenerData->originBkFlag = FALSE;
}
+
+
+
+
+
+
+ if(TryEnterCriticalSection(&this->m_sec) == TRUE){
+ this->Invalidate(TRUE);
+ this->Unlock();
+ }
+
+
+
+
+ return;
}
-
- dc.SetTextColor(self.viewproperty.baseStringColor);
- //\83e\83L\83X\83g\82Ì\83J\83\89\81[\82ð\90Ý\92è
- dc.FillRect(&rc,bkColor);
-
- //\95`\89æ\83T\83C\83Y\82ð\8cv\8eZ
-
- self.m_header.GetItemRect(CCommentView::NO,&noViewRect);
- self.m_header.GetItemRect(CCommentView::USERNAME,&userNameViewRect);
- self.m_header.GetItemRect(CCommentView::COMMENT,&chatViewRect);
- self.m_header.GetItemRect(CCommentView::TIME,&timeViewRect);
- self.m_header.GetItemRect(CCommentView::INFO,&infoViewRect);
-
- dc.MoveTo(rc.left,rc.top,NULL);
- dc.LineTo(rc.right,rc.top);
- dc.MoveTo(rc.left,rc.bottom,NULL);
- dc.LineTo(rc.right,rc.bottom);
-
- noViewRect.left += 2;
- userNameViewRect.left += 2;
- timeViewRect.left += 2;
- chatViewRect.left += 2;
- infoViewRect.left += 2;
-
- noViewRect.right -= 2;
- userNameViewRect.right -= 2;
- timeViewRect.right -= 2;
- chatViewRect.right -= 2;
- infoViewRect.right -= 2;
-
- noViewRect.top = rc.top + 2;
- userNameViewRect.top = rc.top + 2;
- timeViewRect.top = rc.top + 2;
- chatViewRect.top = rc.top + 2;
- infoViewRect.top = rc.top + 2;
-
- noViewRect.bottom = rc.bottom - 2;
- userNameViewRect.bottom = rc.bottom - 2;
- timeViewRect.bottom = rc.bottom - 2;
- chatViewRect.bottom = rc.bottom - 2;
- infoViewRect.bottom = rc.bottom - 2;
-
- dc.SelectPen(colLinePen);
-
- dc.MoveTo(noViewRect.right,rc.top);
- dc.LineTo(noViewRect.right,rc.bottom);
- dc.MoveTo(userNameViewRect.right,rc.top);
- dc.LineTo(userNameViewRect.right,rc.bottom);
- dc.MoveTo(chatViewRect.right,rc.top);
- dc.LineTo(chatViewRect.right,rc.bottom);
- dc.MoveTo(timeViewRect.right,rc.top);
- dc.LineTo(timeViewRect.right,rc.bottom);
-
- dc.DrawTextW(noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
- dc.DrawTextW(chatData.listenerData->user_id.c_str(),chatData.listenerData->user_id.length(),&userNameViewRect,DT_WORD_ELLIPSIS);
- dc.DrawTextW(chatData.chatBuf.c_str(),chatData.chatBuf.length(),&chatViewRect,DT_WORDBREAK);
- dc.DrawTextW(dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
-
- return;
-}
-
-
-UINT_PTR CCommentListWindow::CalcItemHeight(CChatData &chatData){
-
- RECT drowSize;
- self.m_header.GetItemRect(CCommentView::COMMENT,&drowSize);
- drowSize.left += 2;
- drowSize.top += 2;
- drowSize.right -= 2;
- drowSize.bottom = 0;
-
-
- m_memoryDC.DrawTextW(chatData.chatBuf.c_str(),chatData.chatBuf.length(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
-
- drowSize.top -= 2;
- drowSize.bottom += 2;
-
- return drowSize.bottom;
-}
-
-
-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;
-}
-
-VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
-
- return;
-}
-
-
-VOID CCommentListWindow::OnLButtonDbClk(UINT wParam, _WTYPES_NS::CPoint &point){
-
- return;
-}
-
-LRESULT CCommentListWindow::OnEraseBkGnd(HDC lparam){
-
- return TRUE;
-}
+
+ LRESULT CCommentListWindow::OnEraseBkGnd(HDC lparam){
+
+ return TRUE;
+ }
+
+ LRESULT CCommentListWindow::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
+
+
+ self.SendMessageW(WM_VSCROLL,MAKELONG(hiWparam < 0 ? SB_PAGEDOWN : SB_PAGEUP ,0),0);
+
+
+ return 0;
+ }
+
+
+
+}
\ No newline at end of file