2 #include "nlite_include.h"
7 VOID CCommentView::CommentLineSet(CChatData &chat,UINT_PTR count){
11 CDC cdc = listBox.GetDC();
14 header.GetItemRect(COMMENT,&drowSize);
20 SelectObject(cdc,AtlGetDefaultGuiFont());
23 cdc.DrawTextW(chat.chatBuf.c_str(),chat.chatBuf.length(),&drowSize, DT_CALCRECT | DT_WORDBREAK);
29 listBox.SetItemHeight(listBox.GetCount() -1,drowSize.bottom - drowSize.top);
36 VOID CCommentView::OnHeaderTrack(){
40 INT_PTR curSel = listBox.GetCurSel();
41 listBox.ShowWindow(SW_HIDE);
43 UINT_PTR commentCount = commentlist.Size();
47 for(UINT_PTR index =0;index < commentCount;index++){
49 CommentLineSet(commentlist.GetChatAt(index),index);
55 listBox.ShowWindow(SW_SHOW);
56 listBox.SetRedraw(TRUE);
57 listBox.SetCurSel(curSel);
64 VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
69 commentlist.OnChatReceve(chat,count);
70 listBox.AddString(NULL);
71 CommentLineSet(commentlist.back(),count);
79 VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
81 listBox.SetRedraw(TRUE);
86 static UCHAR getrgb(){
89 UCHAR rgb = 160 + rand() % 92;
93 VOID CCommentView::OnListBoxDoubleClick(){
94 INT_PTR cursel = listBox.GetCurSel();
95 if(cursel == LB_ERR)return;
97 auto chatData = commentlist.GetChatAt(cursel);
99 if(chatData.listenerData->originBkFlag == FALSE){
100 CListenerColorCollector colorCollector;
101 listenerList.BkColorCollect(colorCollector);
106 srand((unsigned int)time(NULL));
112 bkColor = RGB(red,green,blue);
114 }while(colorCollector.Find(bkColor));
117 bkColor = viewproperty.backColor;
123 chatData.listenerData->SetBkColor(bkColor);
125 listBox.Invalidate(TRUE);
130 VOID CCommentView::OnDrawList(LPDRAWITEMSTRUCT lpDrawItemStruct){
134 RECT userNameViewRect;
141 CChatData &chatData = commentlist.GetChatAt(lpDrawItemStruct->itemID);
143 time_t chatTime = (time_t)difftime(chatData.date,streamStatus.start_time);
144 tm ct = *gmtime(&chatTime);
147 TCHAR noString[sizeof(chatData.no) * 8];
148 TCHAR dateString[LENGTH_16];
149 _stprintf(noString,TEXT("%u"),chatData.no);
151 _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
155 //
\91I
\91ð
\8fó
\91Ô
\82©
\83`
\83F
\83b
\83N
156 if ((lpDrawItemStruct->itemState) & (ODS_SELECTED))
159 SelectObject(lpDrawItemStruct->hDC,bkBurushSelect);
160 SelectObject(lpDrawItemStruct->hDC,outLinePenSelect);
161 SetBkColor(lpDrawItemStruct->hDC,RGB(255,240,240)) ;
165 SelectObject(lpDrawItemStruct->hDC,outLinePenNomal);
167 if(chatData.listenerData->originBkFlag == TRUE){
169 SelectObject(lpDrawItemStruct->hDC,chatData.listenerData->baseBkBrush);
170 SetBkColor(lpDrawItemStruct->hDC,chatData.listenerData->bkColor) ;
174 SelectObject(lpDrawItemStruct->hDC,bkBurushNomal);
175 SetBkColor(lpDrawItemStruct->hDC,viewproperty.backColor) ;
181 //
\83e
\83L
\83X
\83g
\82Ì
\83J
\83\89\81[
\82ð
\90Ý
\92è
182 SetTextColor(lpDrawItemStruct->hDC,viewproperty.baseStringColor);
186 Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom);
194 //
\95`
\89æ
\83T
\83C
\83Y
\82ð
\8cv
\8eZ
196 header.GetItemRect(NO,&noViewRect);
197 header.GetItemRect(USERNAME,&userNameViewRect);
198 header.GetItemRect(COMMENT,&chatViewRect);
199 header.GetItemRect(TIME,&timeViewRect);
200 header.GetItemRect(INFO,&infoViewRect);
202 SelectObject(lpDrawItemStruct->hDC,colLinePen);
204 MoveToEx(lpDrawItemStruct->hDC,noViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
205 LineTo(lpDrawItemStruct->hDC,noViewRect.right,lpDrawItemStruct->rcItem.bottom);
206 MoveToEx(lpDrawItemStruct->hDC,userNameViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
207 LineTo(lpDrawItemStruct->hDC,userNameViewRect.right,lpDrawItemStruct->rcItem.bottom);
208 MoveToEx(lpDrawItemStruct->hDC,chatViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
209 LineTo(lpDrawItemStruct->hDC,chatViewRect.right,lpDrawItemStruct->rcItem.bottom);
210 MoveToEx(lpDrawItemStruct->hDC,timeViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
211 LineTo(lpDrawItemStruct->hDC,timeViewRect.right,lpDrawItemStruct->rcItem.bottom);
212 MoveToEx(lpDrawItemStruct->hDC,infoViewRect.right,lpDrawItemStruct->rcItem.top,NULL);
213 LineTo(lpDrawItemStruct->hDC,infoViewRect.right,lpDrawItemStruct->rcItem.bottom);
215 noViewRect.left += 2;
216 userNameViewRect.left += 2;
217 timeViewRect.left += 2;
218 chatViewRect.left += 2;
219 infoViewRect.left += 2;
221 noViewRect.right += 2;
222 userNameViewRect.right += 2;
223 timeViewRect.right += 2;
224 chatViewRect.right += 2;
225 infoViewRect.right += 2;
227 noViewRect.top = lpDrawItemStruct->rcItem.top + 2;
228 userNameViewRect.top = lpDrawItemStruct->rcItem.top + 2;
229 timeViewRect.top = lpDrawItemStruct->rcItem.top + 2;
230 chatViewRect.top = lpDrawItemStruct->rcItem.top + 2;
231 infoViewRect.top = lpDrawItemStruct->rcItem.top + 2;
233 noViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
234 userNameViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
235 timeViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
236 chatViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
237 infoViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
243 ::DrawText(lpDrawItemStruct->hDC,noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
245 ::DrawText(lpDrawItemStruct->hDC,chatData.listenerData->user_id.c_str(),chatData.listenerData->user_id.length(),&userNameViewRect,DT_WORD_ELLIPSIS);
247 ::DrawText(lpDrawItemStruct->hDC,chatData.chatBuf.c_str(),chatData.chatBuf.length(),&chatViewRect,DT_WORDBREAK);
249 ::DrawText(lpDrawItemStruct->hDC,dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);