#include "stdafx.h"
#include "nlite_include.h"
-
+using namespace std::tr1;
namespace nlite{
+ static const LPCTSTR LIVEURL_PART = TEXT("http://live.nicovideo.jp/watch/");
+ static const LPCTSTR ADDMYLIST_PART = TEXT("http://www.nicovideo.jp/mylist_add/video/");
static const UINT_PTR SELL_SPACE_LENGTH = 1;
//
//\83R\83\81\83\93\83g\83r\83\85\81[\93à\82Ì\83R\83\93\83g\83\8d\81[\83\8b\83N\83\89\83X
///////////////////////////////////////////////////////////////////
- BOOL CChatReadEdit::SetWindowText(LPCTSTR str){
+ CChatReadEdit::CChatReadEdit(CCommentView &m_master):m_master(m_master){
+
+
+ }
+
+ BOOL CChatReadEdit::SetWindowText(const CChatData &chat){
+
+ BOOL rslt = FALSE;
+ try{
+
+ tstring viewString(regex_replace(tstring(chat.chatBuf),nliteregex::TAGSTRING,nliteregex::text::NUTHINGSTRING));
+ rslt = __super::SetWindowText(viewString.c_str());
+
+ CHARFORMAT2 defaultFormat;
+ this->GetDefaultCharFormat(defaultFormat);
+ defaultFormat.dwMask |= CFM_COLOR;
+ if(chat.premium == 2 || chat.premium == 3){
+
+ defaultFormat.crTextColor = m_master.viewproperty.ownerStringColor;
+ }
+
+ else {
+
+ defaultFormat.crTextColor = m_master.viewproperty.baseStringColor;
+
+ }
- return __super::SetWindowText(str);
+ BOOL rslt = this->SetDefaultCharFormat(defaultFormat);
+
+
+
+ linkStringBeside(viewString,nliteregex::LILNKREGEX);
+
+
+
+ } catch(std::exception &e){
+ e;
+ rslt = FALSE;
+
+ }
+
+ return rslt;
}
-
+ VOID CChatReadEdit::linkStringBeside(const tstring &target,const nliteregex::tregex &re){
+
+ match_results<tstring::const_iterator> regexRslt;
+ tstring::const_iterator beginStr = target.begin();
+ tstring::const_iterator endstr = target.end();
+ CHARFORMAT2 cf;
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_LINK;
+ cf.dwEffects = CFE_LINK;
+ INT_PTR basePosition = 0;
+ while(regex_search(beginStr,endstr,regexRslt,re)){
+ basePosition += regexRslt.position(0);
+ this->SetSel(basePosition,basePosition + regexRslt.length());
+ this->SetCharFormat(cf,SCF_SELECTION);
+ basePosition += regexRslt.length();
+
+ beginStr = regexRslt[0].second;
+ }
+
+ }
+
+ VOID CChatReadEdit::Reset(){
+
+ __super::SetWindowText(TEXT(""));
+
+ return;
+ }
HWND CChatReadEdit::GeneralCreate(HWND hParent,DWORD eventMask,UINT id){
int point = -MulDiv(deflogFont.lfHeight,72,picy);
int twips = point * 20;
m_defCharFormat.yHeight = twips;
+ m_defCharFormat.dwEffects ^= CFE_AUTOCOLOR;
_tcscpy(m_defCharFormat.szFaceName,deflogFont.lfFaceName);
this->SetEventMask(eventMask);
}
CChatChildCtrls::CChatChildCtrls(CCommentView &hMaster):
- m_master(hMaster)
+ m_master(hMaster),
+ chatDispCtrl(hMaster)
{
return;
return;
}
- VOID CChatChildCtrls::Hide(){
- HDWP hdwp = ::BeginDeferWindowPos(GetCtrlCount());
- chatDispCtrl.DeferWindowPos(hdwp,chatDispCtrl.m_hWnd,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_HIDEWINDOW);
- ::EndDeferWindowPos(hdwp);
+ VOID CChatChildCtrls::Hide(HDWP hdwp){
+
+ chatDispCtrl.DeferWindowPos(hdwp,chatDispCtrl,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_HIDEWINDOW);
+
}
- VOID CChatChildCtrls::SetCtrl(const RECT &rc,CCommentList::reference comment,BOOL mulutiLineFlag){
+ VOID CChatChildCtrls::SetCtrl(HDWP hdwp,const RECT &rc,CCommentList::reference comment,BOOL mulutiLineFlag){
- chatDispCtrl.SetWindowText(comment.chatBuf);
+ chatDispCtrl.SetWindowText(comment);
RECT chatRect = rc;
bkColor = comment.viewData.backColor;
- }else if(comment.listenerData->originBkFlag == TRUE){
+ }else if(comment.listenerData->bgcolor != ListenerData::INIT_COLOR){
- bkColor = comment.listenerData->bkColor;
+ bkColor = comment.listenerData->bgcolor;
} else {
chatDispCtrl.SetBackgroundColor(bkColor);
-// dumpln(TEXT("height:%d"),rc.bottom - rc.top);
- HDWP hdwp = ::BeginDeferWindowPos(GetCtrlCount());
+
chatDispCtrl.DeferWindowPos(hdwp,NULL,chatRect.left,chatRect.top,chatRect.right - chatRect.left ,chatRect.bottom - chatRect.top, SWP_NOZORDER | SWP_SHOWWINDOW);
- ::EndDeferWindowPos(hdwp);
+
return;
}
VOID CChatChildCtrlsList::ShowCntrls(){
- dumpln(TEXT("showcntrls:start"));
- RECT headerRect;
- RECT tmpRect;
- RECT listRect;
- m_hMaster.m_commentListWindow.GetClientRect(&listRect);
- m_hMaster.m_header.GetItemRect(CCommentView::COMMENT,&headerRect);
- headerRect.top = 0;
- headerRect.bottom = 0;
-
- INT_PTR heightSum =0;
- auto ctrlsBegin = m_list.begin();
- auto ctrlsEnd = m_list.end();
+
if(m_hMaster.commentlist.Size() > 0){
-
+
+
+
+ RECT headerRect;
+ RECT tmpRect;
+ RECT listRect;
+ m_hMaster.m_commentListWindow.GetClientRect(&listRect);
+ m_hMaster.m_header.GetItemRect(CCommentView::COMMENT,&headerRect);
+ headerRect.top = 0;
+ headerRect.bottom = 0;
+
+ UINT_PTR counter = 0;
+ INT_PTR heightSum =0;
+
+ auto ctrlsBegin = m_list.begin();
+ auto ctrlsEnd = m_list.end();
auto chatDataBegin = m_hMaster.commentlist.GetShortCut();
+ auto chatDataEnd = m_hMaster.commentlist.end();
+ auto chatDataTmp = chatDataBegin;
+ for(;chatDataBegin != chatDataEnd && heightSum < listRect.bottom;++chatDataBegin){
+ m_hMaster.m_commentListWindow.CalcItemHeight(*chatDataBegin);
+ counter++;
+ heightSum += chatDataBegin->viewData.height;
+ }
- for(; chatDataBegin != m_hMaster.commentlist.end() && heightSum < listRect.bottom;++ctrlsBegin,++chatDataBegin){
+
+ chatDataBegin = chatDataTmp;
+ heightSum = 0;
+ HDWP hdwp = ::BeginDeferWindowPos(CChatChildCtrls::GetCtrlCount() * (counter > m_list.size() ? counter : m_list.size()));
+ for(; chatDataBegin != chatDataEnd && counter > 0 ;++ctrlsBegin,++chatDataBegin,--counter){
- m_hMaster.m_commentListWindow.CalcItemHeight(*chatDataBegin);
+
tmpRect = headerRect;
tmpRect.top += heightSum;
tmpRect.bottom += heightSum + chatDataBegin->viewData.height;
if(ctrlsBegin == ctrlsEnd)ctrlsBegin = Extend();
- ctrlsBegin->SetCtrl(tmpRect,*chatDataBegin,m_hMaster.viewproperty.commentFoldingFlag);
+ ctrlsBegin->SetCtrl(hdwp,tmpRect,*chatDataBegin,m_hMaster.viewproperty.commentFoldingFlag);
heightSum = tmpRect.bottom;
+
+
}
for(;ctrlsBegin != ctrlsEnd;++ctrlsBegin){
- ctrlsBegin->Hide();
+ ctrlsBegin->Hide(hdwp);
}
+
+ ::EndDeferWindowPos(hdwp);
}
auto begin =m_list.begin();
auto end = m_list.end();
-
+ HDWP hdwp = ::BeginDeferWindowPos(CChatChildCtrls::GetCtrlCount() * m_list.size());
for(;begin != end;++begin){
- begin->Hide();
+ begin->Hide(hdwp);
}
+ ::EndDeferWindowPos(hdwp);
}
//\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X\83\81\83\\83b\83h
///////////////////////////////////////////////////////
- CCommentView::CCommentView(CNicoLiveStream &stream):
+ CCommentView::CCommentView(CNicoLiveStream &stream,CNicoVideoAuth &in_refAuth):
m_commentListWindow(*this),
- stream(stream)
-#ifdef USE_RICHEDIT
+ stream(stream),
+ refAuth(in_refAuth)
,chatChildCtrlsList(*this)
-#endif
+
{
LOGFONT lf = {0};
return;
}
+ VOID CCommentView::UpDateUI(){
+ this->chatChildCtrlsList.ShowCntrls();
+ this->m_commentListWindow.Invalidate();
+ return;
+ }
VOID CCommentView::OnConnect(){
m_commentListWindow.SetRedraw(FALSE);
+ m_commentListWindow.ResetViewSellHeight();
+
+ chatChildCtrlsList.AllHide();
+
+
commentlist.OnConnect();
SCROLLINFO vScrollInfo = {0};
m_commentListWindow.SetRedraw(TRUE);
m_commentListWindow.Invalidate();
-#ifdef USE_RICHEDIT
- chatChildCtrlsList.AllHide();
-#endif
}
return nMax;
}
- VOID CCommentView::SetProperty(CommentViewProperty &setProperty){
+ VOID CCommentView::SetProperty(const CommentViewProperty &setProperty,const GeneralProperty &in_generalProperty){
+
viewproperty = setProperty;
+ generalProperty = in_generalProperty;
+ m_commentListWindow.OnSetProperty();
+
return;
}
AddHeader(&headersinfo);
- m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+ m_header.SetOrderArray(ARRAY_LENGTH(viewproperty.headerOrderArray),viewproperty.headerOrderArray);
if(scrollFlag == TRUE){
- this->SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
+ this->m_commentListWindow.SendMessageW(WM_VSCROLL,MAKELONG(SB_BOTTOM,0),0);
}
INT_PTR itemCount = m_header.GetItemCount();
m_commentListWindow.SetRedraw(TRUE);
- if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
- m_commentListWindow.Invalidate();
- m_commentListWindow.Unlock();
- }
+
+ m_commentListWindow.Invalidate();
+ this->m_commentListWindow.SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
}
VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR commnetCountSum){
- commentlist.OnChatReceve(chat,commnetCountSum,this->m_commentListWindow);
+ commentlist.OnChatReceve(chat,stream.GetDefaultCommunity(),commnetCountSum,this->m_commentListWindow);
return;
}
if(scrollFlag == TRUE){
- this->SendMessageW(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
+ this->PostMessage(WM_VSCROLL,MAKEWORD(SB_BOTTOM,0),0);
}
- if(vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) >= vScrollInfo.nMax - static_cast<INT_PTR>(vScrollInfo.nPage)&& TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
+ if(vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) >= vScrollInfo.nMax - static_cast<INT_PTR>(vScrollInfo.nPage)){
m_commentListWindow.Invalidate();
-#ifdef USE_RICHEDIT
- //chatChildCtrlsList.ShowCntrls();
-#endif
- m_commentListWindow.Unlock();
+
+ this->m_commentListWindow.PostMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
}
return;
}
+
+ LRESULT CCommentView::OnClickChatNo(UINT uMsg,WPARAM wParam,LPARAM lParam){
+
+
+ ::SendMessage(::GetAncestor(*this,GA_ROOT),uMsg,wParam,lParam);
+
+ return 0;
+ }
+
+
+ LRESULT CCommentView::OnClickUserName(UINT uMsg,WPARAM wParam,LPARAM lParam){
+
+
+ ::SendMessage(::GetAncestor(*this,GA_ROOT),uMsg,wParam,lParam);
+
+ return 0;
+ }
+
LRESULT CCommentView::OnEraseBkgnd(HDC wParam){
return TRUE;
VOID CCommentView::OnDestroy(){
- m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOraderArray),viewproperty.headerOraderArray);
+ m_header.GetOrderArray(ARRAY_LENGTH(viewproperty.headerOrderArray),viewproperty.headerOrderArray);
INT_PTR headerItemcount = m_header.GetItemCount();
RECT headerItemRect;
for(INT_PTR itemindex = 0;itemindex < headerItemcount;itemindex++){
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();
- }
+
+ LPNMHEADER pNMHeader = (LPNMHEADER) lParam;
+ this->m_header.SetItem(pNMHeader->iItem,pNMHeader->pitem);
+
+ m_commentListWindow.Invalidate();
+ this->m_commentListWindow.SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
+
}
return 0;
}
-
VOID CCommentView::OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam){
this->commentlist.SetShortCut(this->GetScrollPos(SB_VERT));
//this->SetScrollInfo(SB_VERT,&vScrollInfo);
this->UpdateWindow();
- if(TryEnterCriticalSection(&m_commentListWindow.m_sec) == TRUE){
- m_commentListWindow.Invalidate();
- m_commentListWindow.Unlock();
- }
+
+ m_commentListWindow.Invalidate();
+ this->m_commentListWindow.SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
}
////////////////////////////////////////////////////////////////////
CCommentListWindow::CCommentListWindow(CCommentView &in_self):
- self(in_self)
- {}
+ self(in_self),
+ viewSellHeight(0)
+ {
+ CFontHandle font = ::AtlGetDefaultGuiFont();
+ LOGFONT logfont;
+ font.GetLogFont(&logfont);
+ logfont.lfUnderline = TRUE;
+
+ linkFont.CreateFontIndirect(&logfont);
+ }
CCommentListWindow::~CCommentListWindow(){
}
+
- VOID CCommentListWindow::OnPaint(HDC in_hdc){
+ VOID CCommentListWindow::OnSetProperty(){
+ if(IsWindow() == TRUE)this->SetRedraw(FALSE);
+ if(collLinePen.IsNull() == FALSE)collLinePen.DeleteObject();
+ if(normalSellLinePen.IsNull() == FALSE)normalSellLinePen.DeleteObject();
+ if(normalBkBrush.IsNull() == FALSE)normalBkBrush.DeleteObject();
+ if(selectSellLinePen.IsNull() ==FALSE)selectSellLinePen.DeleteObject();
+ if(selectBkBrush.IsNull() == FALSE)selectBkBrush.DeleteObject();
+ collLinePen.CreatePen(PS_SOLID,1,self.viewproperty.colLineColor);
+ normalSellLinePen.CreatePen(PS_SOLID,1,self.viewproperty.normalSellLineColor);
+ normalBkBrush.CreateSolidBrush(self.viewproperty.backColor);
+ selectSellLinePen.CreatePen(PS_SOLID,1,self.viewproperty.selectSellLineColor);
+ selectBkBrush.CreateSolidBrush(self.viewproperty.selectBackColor);
+
+
+ if(IsWindow() == TRUE)this->SetRedraw(TRUE);
+ }
+
+
+ VOID CCommentListWindow::OnPaint(HDC in_hdc){
+
+ this->self.refAuth.GetUserSession();
RECT windowRect;
RECT listRect = {0};
RECT clientRect;
listRect.right = self.GetColumnHolSizeSum();
CCommentList::iterator chatData = commentList.GetShortCut();
-
-
-
- CBrush baseBkBrush;
- baseBkBrush.CreateSolidBrush(self.viewproperty.backColor);
- mdc.FillRect(&listRect,baseBkBrush);
- baseBkBrush.DeleteObject();
+
+
+
+ mdc.FillRect(&listRect,this->normalBkBrush);
+
CCommentList::iterator endData = commentList.end();
listRect.bottom = 0;
+ RECT headerRects[COMMENTVIEW_HEADERITEMSIZE];
+ RECT colLineRects[COMMENTVIEW_HEADERITEMSIZE];
+ RECT selectHeaderRects[COMMENTVIEW_HEADERITEMSIZE];
+
+ self.m_header.GetItemRect(CCommentView::NO,&headerRects[CCommentView::NO]);
+ self.m_header.GetItemRect(CCommentView::USERNAME,&headerRects[CCommentView::USERNAME]);
+ self.m_header.GetItemRect(CCommentView::COMMENT,&headerRects[CCommentView::COMMENT]);
+ self.m_header.GetItemRect(CCommentView::TIME,&headerRects[CCommentView::TIME]);
+ self.m_header.GetItemRect(CCommentView::INFO,&headerRects[CCommentView::INFO]);
+
+ memcpy(colLineRects,headerRects,sizeof(headerRects));
+
+
+
+
+ headerRects[CCommentView::NO].left += SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].left += SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].left += SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].left += SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].left += SELL_SPACE_LENGTH;
+
+ headerRects[CCommentView::NO].right -= SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].right -= SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].right -= SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].right -= SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].right -= SELL_SPACE_LENGTH;
+
+ headerRects[CCommentView::NO].top = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].top = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].top = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].top = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].top = SELL_SPACE_LENGTH;
+
+ headerRects[CCommentView::NO].bottom = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].bottom = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].bottom = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].bottom = SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].bottom = SELL_SPACE_LENGTH;
+
+ INT_PTR listRectTop = listRect.top;
for(;chatData != endData && listRect.top < clientRect.bottom;++chatData){
CalcItemHeight(*chatData);
// dumpln(TEXT("height:%d"),chatData->viewData.height);
listRect.bottom += chatData->viewData.height;
+ headerRects[CCommentView::NO].top = listRect.top + SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].top = listRect.top + SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].top = listRect.top + SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].top = listRect.top + SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].top = listRect.top + SELL_SPACE_LENGTH;
+
+ headerRects[CCommentView::NO].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+ headerRects[CCommentView::USERNAME].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+ headerRects[CCommentView::COMMENT].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+ headerRects[CCommentView::TIME].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+ headerRects[CCommentView::INFO].bottom = listRect.bottom - SELL_SPACE_LENGTH;
+
if(chatData->viewData.selectFlag == TRUE){
selectFlag = TRUE;
selectData = chatData;
selectRect = listRect;
+ memcpy(selectHeaderRects,headerRects,sizeof(headerRects));
} else {
- this->DrawItem(mdc,listRect,*chatData);
+
+
+
+ this->DrawItem(mdc,listRect,headerRects,*chatData);
}
listRect.top = listRect.bottom;
}
-
-
+ viewSellHeight = listRect.bottom;
+
+
if(selectFlag == TRUE){
- this->DrawItem(mdc,selectRect,*selectData);
+ this->DrawItem(mdc,selectRect,selectHeaderRects,*selectData);
}
+ //\8d\80\96Ú\82Ì\8fc\90ü\82ð\95`\89æ
+ mdc.SelectPen(collLinePen);
+ mdc.MoveTo(colLineRects[CCommentView::NO].right,listRectTop);
+ mdc.LineTo(colLineRects[CCommentView::NO].right,listRect.bottom);
+ mdc.MoveTo(colLineRects[CCommentView::USERNAME].right,listRectTop);
+ mdc.LineTo(colLineRects[CCommentView::USERNAME].right,listRect.bottom);
+ mdc.MoveTo(colLineRects[CCommentView::COMMENT].right,listRectTop);
+ mdc.LineTo(colLineRects[CCommentView::COMMENT].right,listRect.bottom);
+ mdc.MoveTo(colLineRects[CCommentView::TIME].right,listRectTop);
+ mdc.LineTo(colLineRects[CCommentView::TIME].right,listRect.bottom);
+ mdc.MoveTo(colLineRects[CCommentView::INFO].right,listRectTop);
+ mdc.LineTo(colLineRects[CCommentView::INFO].right,listRect.bottom);
+
}
windowRect.left = listRect.right;
mdc.FillRect(&windowRect,(HBRUSH)::GetStockObject(GRAY_BRUSH));
return;
}
+
+ LRESULT CCommentListWindow::OnSetCtrol(UINT uMsg,WPARAM wparam,LPARAM lparam){
+
+
+
+ self.chatChildCtrlsList.ShowCntrls();
+
+
+
+ return 0;
+ }
+
VOID CCommentListWindow::OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize){
}
this->Invalidate();
+ this->SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
return;
}
return rslt;
}
- VOID CCommentListWindow::DrawItem(CDC &dc,const RECT &rc,CChatData &chatData){
+ VOID CCommentListWindow::DrawItem(CDC &dc,const RECT &rc,const RECT *headerRect,CChatData &chatData){
- RECT noViewRect; //\83R\83\81\94Ô\95\\8e¦\97Ì\88æ
- RECT userNameViewRect; //\83\86\81[\83U\96¼\95\\8e¦\97Ì\88æ
- RECT timeViewRect; //\8e\9e\8aÔ\95\\8e¦\97Ì\88æ
- RECT chatViewRect; //\83R\83\81\83\93\83g\95\\8e¦\97Ì\88æ
- RECT infoViewRect; //\83R\83\81\83\93\83g\8fî\95ñ\95\\8e¦\97Ì\88æ
+ RECT noViewRect = headerRect[CCommentView::NO]; //\83R\83\81\94Ô\95\\8e¦\97Ì\88æ
+ RECT userNameViewRect = headerRect[CCommentView::USERNAME]; //\83\86\81[\83U\96¼\95\\8e¦\97Ì\88æ
+ RECT chatViewRect = headerRect[CCommentView::COMMENT]; //\83R\83\81\83\93\83g\95\\8e¦\97Ì\88æ
+ RECT timeViewRect = headerRect[CCommentView::TIME]; //\8e\9e\8aÔ\95\\8e¦\97Ì\88æ
+ RECT infoViewRect = headerRect[CCommentView::INFO]; //\83R\83\81\83\93\83g\8fî\95ñ\95\\8e¦\97Ì\88æ
//
COLORREF bkColor; //\94w\8ci\90F
- COLORREF sellLineColor; //\98g\90ü\90F
- CPen sellLinePen; //\98g\90ü\95`\89æ\97p\83y\83\93
- CPen collLinePen; //\8d\80\96Ú\8fc\90ü\95`\89æ\97p\83y\83\93
- CBrush bkBrush; //\94w\8ci\95`\89æ\97p\83u\83\89\83V
- collLinePen.CreatePen(PS_SOLID,1,self.viewproperty.colLineColor);
-
-
+ CPen originSellLinePen; //\98g\90ü\95`\89æ\97p\83y\83\93
+ CBrush originBkBrush; //\94w\8ci\95`\89æ\97p\83u\83\89\83V
+
//\91I\91ð\8fó\91Ô\82©\83`\83F\83b\83N
if (chatData.viewData.selectFlag == TRUE)
{
bkColor = self.viewproperty.selectBackColor;
- sellLineColor = self.viewproperty.selectSellLineColor;
+
+ dc.SelectBrush(this->selectBkBrush);
+ dc.SelectPen(this->selectSellLinePen);
}
else
{
- sellLineColor = chatData.viewData.sellLineColor == CChatData::ViewData::INIT_COLOR ? self.viewproperty.normalSellLineColor : chatData.viewData.sellLineColor;
+ if(chatData.viewData.sellLineColor == CChatData::ViewData::INIT_COLOR){
+ dc.SelectPen(this->normalSellLinePen);
- if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR){
-
- bkColor = chatData.viewData.backColor;
+ } else {
- }else if(chatData.listenerData->originBkFlag == TRUE){
+ originSellLinePen.CreatePen(PS_SOLID,1,chatData.viewData.sellLineColor);
+ dc.SelectPen(originSellLinePen);
+ }
- bkColor = chatData.listenerData->bkColor;
+
+ if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR || chatData.listenerData->bgcolor != ListenerData::INIT_COLOR){
+
+ if(chatData.viewData.backColor != CChatData::ViewData::INIT_COLOR){
+ bkColor = chatData.viewData.backColor;
+ originBkBrush.CreateSolidBrush(chatData.viewData.backColor);
+
+ }else if(chatData.listenerData->bgcolor != ListenerData::INIT_COLOR){
+ bkColor = chatData.listenerData->bgcolor;
+ originBkBrush.CreateSolidBrush(chatData.listenerData->bgcolor);
+
+ }
+
+ dc.SelectBrush(originBkBrush);
} else {
bkColor = self.viewproperty.backColor;
-
+ dc.SelectBrush(this->normalBkBrush);
+ dc.SelectBrush(this->normalBkBrush);
}
}
//\94w\8ci\82Æ\98g\90ü\82ð\95`\89æ
- sellLinePen.CreatePen(PS_SOLID,1,sellLineColor);
- bkBrush.CreateSolidBrush(bkColor);
- dc.SelectPen(sellLinePen);
- dc.SelectBrush(bkBrush);
+
+
dc.Rectangle(rc.left,rc.top - 1,rc.right ,rc.bottom + 1);
dc.SetBkColor(bkColor);
- dc.SetTextColor(chatData.viewData.stringColor == CChatData::ViewData::INIT_COLOR ? chatData.viewData.stringColor :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 += SELL_SPACE_LENGTH;
- userNameViewRect.left += SELL_SPACE_LENGTH;
- timeViewRect.left += SELL_SPACE_LENGTH;
- chatViewRect.left += SELL_SPACE_LENGTH;
- infoViewRect.left += SELL_SPACE_LENGTH;
-
- noViewRect.right -= SELL_SPACE_LENGTH;
- userNameViewRect.right -= SELL_SPACE_LENGTH;
- timeViewRect.right -= SELL_SPACE_LENGTH;
- chatViewRect.right -= SELL_SPACE_LENGTH;
- infoViewRect.right -= SELL_SPACE_LENGTH;
-
- noViewRect.top = rc.top + SELL_SPACE_LENGTH;
- userNameViewRect.top = rc.top + SELL_SPACE_LENGTH;
- timeViewRect.top = rc.top + SELL_SPACE_LENGTH;
- chatViewRect.top = rc.top + SELL_SPACE_LENGTH;
- infoViewRect.top = rc.top + SELL_SPACE_LENGTH;
-
- noViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
- userNameViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
- timeViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
- chatViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
- infoViewRect.bottom = rc.bottom - SELL_SPACE_LENGTH;
-
- //\8d\80\96Ú\82Ì\8fc\90ü\82ð\95`\89æ
- dc.SelectPen(collLinePen);
- 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);
-
+
+
+ CComBSTR &viewUserName = chatData.listenerData->name.Length() == 0 ? chatData.listenerData->user_id : chatData.listenerData->name;
+ dc.SelectFont(linkFont);
+ dc.SetTextColor(chatData.listenerData->nameColor != ListenerData::INIT_COLOR ? chatData.listenerData->nameColor : self.viewproperty.linkStringColor);
//\83e\83L\83X\83g\95`\89æ
dc.DrawTextW(noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
- dc.DrawTextW(chatData.listenerData->user_id,chatData.listenerData->user_id.Length(),&userNameViewRect,DT_WORD_ELLIPSIS);
- dc.DrawTextW(chatData.chatBuf,chatData.chatBuf.Length(),&chatViewRect,DT_WORDBREAK | DT_EDITCONTROL);
+
+
+ dc.DrawTextW(viewUserName,viewUserName.Length(),&userNameViewRect,DT_WORD_ELLIPSIS);
+ dc.SelectFont(::AtlGetDefaultGuiFont());
+ dc.SetTextColor(chatData.viewData.stringColor == CChatData::ViewData::INIT_COLOR ? chatData.viewData.stringColor :self.viewproperty.baseStringColor);
dc.DrawTextW(dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
return;
}
+ VOID CCommentListWindow::ResetViewSellHeight(){
+
+ viewSellHeight = 0;
+
+ return;
+ }
VOID CCommentListWindow::ShowCurSel(){
- INT_PTR cursel = self.commentlist.GetCurSel();
- if(cursel == CCommentList::ERR)goto end;
+ auto end = self.commentlist.end();
+ INT_PTR cursel = self.commentlist.GetCurSelNo();
+ if(cursel == -1)goto end;
SCROLLINFO vScrollInfo;
vScrollInfo.cbSize = sizeof(vScrollInfo);
vScrollInfo.fMask = SIF_ALL;
self.GetScrollInfo(SB_VERT,&vScrollInfo);
-
+
if(!(cursel >= vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) / 2 && cursel <= vScrollInfo.nPos + static_cast<INT_PTR>(vScrollInfo.nPage) / 2)){
self.SetScrollPos(SB_VERT,cursel - (vScrollInfo.nPage / 2));
+ self.commentlist.SetShortCut(self.GetScrollPos(SB_VERT));
}
this->Invalidate();
+
+ this->SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
end:
return;
VOID CCommentListWindow::CalcItemHeight(CChatData &chatData){
if(chatData.viewData.height == 0){
- // dumpln(TEXT("viewdataupdate"));
RECT drowSize;
self.m_header.GetItemRect(CCommentView::COMMENT,&drowSize);
drowSize.bottom = 0;
- CChatReadEdit cedit;
+ CChatReadEdit cedit(self);
cedit.GeneralCreate(*this,ENM_REQUESTRESIZE,CALCEDIT_ID);
- cedit.SetWindowText(TEXT(""));
+ cedit.Reset();
cedit.SetWindowPos(NULL,0,0,drowSize.right - drowSize.left,drowSize.bottom - drowSize.top,SWP_NOZORDER | SWP_NOMOVE | SWP_NOREDRAW);
- cedit.SetWindowText(chatData.chatBuf);
+ cedit.SetWindowText(chatData);
cedit.GetClientRect(&drowSize);
cedit.DestroyWindow();
- if(drowSize.bottom - drowSize.top > 70)drowSize.bottom = drowSize.top + 70;
+ drowSize.bottom += 12;
+ if(drowSize.bottom - drowSize.top > 120)drowSize.bottom = drowSize.top + 120;
chatData.viewData.height = drowSize.bottom - drowSize.top;
}
LRESULT CCommentListWindow::OnCreate(LPCREATESTRUCT lpCreateStruct){
+
+ //CComPtr<IUnknown> iu;
+ //::AtlAxCreateControlEx(TEXT("MSHTML:<HTML><BODY></BODY></HTML>"),*this,(IStream*)NULL,(IUnknown**)NULL,&iu,GUID_NULL);
-// calcEdit.GeneralCreate(*this,ENM_REQUESTRESIZE,CALCEDIT_ID);
+ //iu->QueryInterface(DIID_DWebBrowserEvents2,&addToMyListWindow);
+ RECT rc = {0,0,300,200};
+// addToMyListWindow.Create(m_hWnd, &rc,_T("Shell.Explorer.2"),WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN , 0);
-
return 0;
}
- INT_PTR CCommentListWindow::CalcClickLine(INT_PTR height){
- SCROLLINFO vScrollInfo = {0};
- vScrollInfo.fMask = SIF_POS;
-
- self.GetScrollInfo(SB_VERT,&vScrollInfo);
+ CCommentList::iterator CCommentListWindow::CalcClickLine(INT_PTR height){
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){
+
+ CCommentList::iterator chatData = self.commentlist.GetShortCut();
+ CCommentList::iterator end = self.commentlist.end();
+
+
+
+ for(; chatData != end ;(++chatData)){
CalcItemHeight(*chatData);
heightSum += chatData->viewData.height;
- if(heightSum >= height){
+
+ if(heightSum >= height)break;
+ }
+
+
+
+
+ return chatData;
+ }
- goto end;
- }
- ++lineNo;
+ BOOL CCommentListWindow::IsOnNoOrUserName(UINT_PTR index,const POINT &point){
+
+ RECT rc = {0};
+
+ self.m_header.GetItemRect(index,&rc);
+ BOOL rslt = FALSE;
+
+ if((point.x >= rc.left && point.x <= rc.right) && (point.y < static_cast<INT_PTR>(viewSellHeight))){
+
+ INT_PTR heightsum = 0;
+ auto clickData = self.commentlist.GetShortCut();
+ auto endData = self.commentlist.end();
+ for(;clickData != endData;++clickData){
+
+ heightsum += clickData->viewData.height;
+
+ if(heightsum > point.y){
+
+ CDC cdc = this->GetDC();
+
+ rc.top = heightsum -= clickData->viewData.height;
+ RECT calcRect = {0};
+ cdc.SelectFont(linkFont);
+
+
+ if(index == CCommentView::USERNAME){
+ LPCTSTR viewStr = clickData->listenerData->name.Length() == 0 ? clickData->listenerData->user_id : clickData->listenerData->name;
+ cdc.DrawTextW(viewStr ,_tcslen(viewStr),&calcRect,DT_CALCRECT);
+
+ } else if(index == CCommentView::NO){
+ TCHAR viewStr[sizeof(UINT_PTR) * 8];
+ _stprintf(viewStr,TEXT("%d"),clickData->no);
+ cdc.DrawTextW(viewStr,_tcslen(viewStr),&calcRect,DT_CALCRECT);
+
+ }
+ rc.bottom = rc.top + calcRect.bottom - calcRect.top;
+ rc.right = rc.right > rc.left + calcRect.right - calcRect.left ? rc.left + calcRect.right - calcRect.left : rc.right;
+ rslt = (point.y >= rc.top && point.y <= rc.bottom && point.x >= rc.left && point.x <= rc.right);
+
+ break;
+
+ }
+ }
+
}
- lineNo = -1;
-end:
+ return rslt;
- return lineNo;
}
+ VOID CCommentListWindow::OnDestroy(){
- VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+// this->addToMyListWindow.DestroyWindow();
+ }
+ VOID CCommentListWindow::OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point){
+ CCommentList::iterator ite;
+ this->SetFocus();
if(point.x > (INT_PTR)self.GetColumnHolSizeSum()) goto end;
- this->SetFocus();
+
if(self.commentlist.empty() == TRUE)goto end;
- self.commentlist.SetCurSel(CalcClickLine(point.y));
- if(TryEnterCriticalSection(&this->m_sec) == TRUE){
- this->Invalidate();
- this->Unlock();
+ ite = CalcClickLine(point.y);
+ self.commentlist.SetCurSel(ite);
+
+ if(this->IsOnNoOrUserName(CCommentView::NO,point) == TRUE){
+
+ ::SendMessage(self,UM_CLICK_CHATNO,(WPARAM)&(*ite),(LPARAM)self.m_hWnd);
+
+ } else if(this->IsOnNoOrUserName(CCommentView::USERNAME,point) == TRUE){
+
+ ::SendMessage(self,UM_CLICK_USERNAME,(WPARAM)&(*ite),(LPARAM)self.m_hWnd);
}
+
end:
-#ifdef USE_RICHEDIT
- self.chatChildCtrlsList.ShowCntrls();
-#endif
+ this->Invalidate();
+ this->SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
return;
}
- if(point.x > (INT_PTR)self.GetColumnHolSizeSum()) return;
+ if(!(point.x > (INT_PTR)self.GetColumnHolSizeSum() || self.commentlist.empty() == TRUE)){
- INT_PTR lineNo = CalcClickLine(point.y);
- if(self.commentlist.empty() == TRUE || lineNo == -1)return;
+ auto end = self.commentlist.end();
+ auto lineIte = CalcClickLine(point.y);
+ if( lineIte == end)goto endlabel;
+
+ COLORREF bkColor;
+ if(lineIte->listenerData->bgcolor == ListenerData::INIT_COLOR){
+ CListenerColorCollector colorCollector;
+ listenerList.BkColorCollect(colorCollector);
+ UCHAR red;
+ UCHAR green;
+ UCHAR blue;
- auto chatData = self.commentlist.GetChatAt(lineNo);
- COLORREF bkColor;
- if(chatData.listenerData->originBkFlag == FALSE){
- CListenerColorCollector colorCollector;
- listenerList.BkColorCollect(colorCollector);
- UCHAR red;
- UCHAR green;
- UCHAR blue;
-
- srand((unsigned int)time(NULL));
- do{
+ srand((unsigned int)time(NULL));
+ do{
- red = getrgb();
- green = getrgb();
- blue = getrgb();
- bkColor = PALETTERGB(red,green,blue);
+ red = getrgb();
+ green = getrgb();
+ blue = getrgb();
+ bkColor = PALETTERGB(red,green,blue);
- }while(colorCollector.Find(bkColor));
+ }while(colorCollector.Find(bkColor));
- chatData.listenerData->originBkFlag = TRUE;
- chatData.listenerData->SetBkColor(bkColor);
- } else {
+
+ lineIte->listenerData->SetBkColor(bkColor);
+ } else {
- chatData.listenerData->originBkFlag = FALSE;
+ lineIte->listenerData->bgcolor = ListenerData::INIT_COLOR;
+ }
}
+endlabel:
- if(TryEnterCriticalSection(&this->m_sec) == TRUE){
- this->Invalidate(TRUE);
- this->Unlock();
- }
-
-#ifdef USE_RICHEDIT
- self.chatChildCtrlsList.ShowCntrls();
-#endif
+ this->Invalidate(TRUE);
+ this->SendMessage(UM_COMMENTVIEW_SETCTRL,NULL,NULL);
return;
}
}
- dy += self.commentlist.GetCurSel();
- if(dy < 0 || dy >= static_cast<INT_PTR>(self.commentlist.Size()))goto end;
+
- self.commentlist.SetCurSel(dy);
+ auto cursel = self.commentlist.GetCurSel();
+ if((dy < 0 && cursel == self.commentlist.begin()) || dy >= static_cast<INT_PTR>(self.commentlist.Size()))goto end;
+
+
+ std::advance(cursel,dy);
+ self.commentlist.SetCurSel(cursel);
this->ShowCurSel();
end:
return;
}
+ LRESULT CCommentListWindow::OnSetCursor(HWND wparam,UINT loLparam,UINT hiLparam){
+
+
+ POINT mousePoint = {0};
+
+ GetCursorPos(&mousePoint);
+ ::ScreenToClient(*this,&mousePoint);
+
+ if(( IsOnNoOrUserName(CCommentView::NO,mousePoint) || IsOnNoOrUserName(CCommentView::USERNAME,mousePoint))){
+
+
+ ::SetCursor(::LoadCursorW(NULL,IDC_HAND));
+
+ } else {
+
+ DefWindowProc ();
+
+ }
+
+
+
+
+
+ return FALSE;
+ }
+
LRESULT CCommentListWindow::OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point){
return 0;
}
+
+
LRESULT CCommentListWindow::OnChatControlNortify(LPNMHDR lParam){
switch(lParam->code){
case EN_LINK:
-
-
- break;
-
- /*
- case EN_REQUESTRESIZE:
{
- REQRESIZE *pReqResize = (REQRESIZE *) lParam;
- self.chatChildCtrlsList.rcBuf = pReqResize->rc;
- dumpln(TEXT("calcheight:%d"),pReqResize->rc.bottom - pReqResize->rc.top);
+ ENLINK *lpenlk = (ENLINK *)lParam;
+ if (lpenlk->msg == WM_LBUTTONDOWN) {
+ CRichEditCtrl chatReadEdit = lpenlk->nmhdr.hwndFrom;
+ chatReadEdit.SetSel(lpenlk->chrg);
+ CString selTextBuf;
+ chatReadEdit.GetSelText(selTextBuf);
+ if(regex_match((LPCTSTR)selTextBuf,nliteregex::URL) == TRUE){
+
+
+
+
+ } else if(regex_match((LPCTSTR)selTextBuf,nliteregex::VIDEOID) == TRUE){
+
+ selTextBuf.Insert(0,ADDMYLIST_PART);
+
+ } else if( regex_match((LPCTSTR)selTextBuf,nliteregex::LIVEID) == TRUE){
+
+ selTextBuf.Insert(0,LIVEURL_PART);
+
+ }
+
+ OpenURL(*this,self.generalProperty,selTextBuf,SW_SHOWNORMAL);
+ }
}
break;
- */
case EN_MSGFILTER:
+ {
+ auto pmf = (MSGFILTER *)lParam;
+ if (pmf->msg == WM_LBUTTONDOWN || pmf->msg== WM_LBUTTONDBLCLK || pmf->msg == WM_MOUSEWHEEL){
+
+ RECT windowrect;
+ ::GetWindowRect(pmf->nmhdr.hwndFrom,&windowrect);
+ _WTYPES_NS::CPoint point(windowrect.left + LOWORD(pmf->lParam),windowrect.top + HIWORD(pmf->lParam));
+ ::ScreenToClient(*this,&point);
+
+ switch(pmf->msg){
+
+ case WM_LBUTTONDOWN:
+ OnLButtonDown(pmf->wParam,point);
+ break;
+ case WM_LBUTTONDBLCLK:
+ OnLButtonDblClk(pmf->wParam,point);
+ break;
+ case WM_MOUSEWHEEL:
+ OnMouseWheel(LOWORD(pmf->wParam),HIWORD(pmf->wParam),point);
+ break;
+
+ default:
+
+ break;
+ }
+
+ }
+
+
+
+
+ }
break;
auto pReqResize = reinterpret_cast <REQRESIZE *>(lParam);
::SetWindowPos(pReqResize->nmhdr.hwndFrom,NULL,0,0,pReqResize->rc.right - pReqResize->rc.left,pReqResize->rc.bottom - pReqResize->rc.top,SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW);
- //calcRc = pReqResize->rc;
return 0;
}