2 #include "nlite_include.h"
7 VOID CCommentView::CommentLineSet(LPCTSTR chat,UINT_PTR count){
11 CDC cdc = listBox.GetDC();
14 header.GetItemRect(COMMENT,&drowSize);
20 SelectObject(cdc,AtlGetDefaultGuiFont());
21 cdc.DrawTextW(chat,-1,&drowSize, DT_CALCRECT | DT_WORDBREAK);
27 listBox.SetItemHeight(listBox.GetCount() -1,drowSize.bottom - drowSize.top);
33 VOID CCommentView::OnHeaderTrack(){
37 listBox.ShowWindow(SW_HIDE);
39 UINT_PTR commentCount = commentlist.Size();
40 listBox.ResetContent();
41 for(UINT_PTR index =0;index < commentCount;index++){
42 listBox.AddString(NULL);
43 CommentLineSet(commentlist.GetChatAt(index).chatBuf.c_str(),index);
47 listBox.ShowWindow(SW_SHOW);
51 //listBox.InvalidateRect(NULL,TRUE);
57 VOID CCommentView::OnChatReceve(NicoLiveChat_P chat,UINT_PTR count){
62 commentlist.OnChatReceve(chat,count);
63 listBox.AddString(NULL);
66 CommentLineSet(chat->chatBuf,count);
71 VOID CCommentView::OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum){
77 VOID CCommentView::OnDrawList(LPDRAWITEMSTRUCT lpDrawItemStruct){
84 RECT userNameViewRect;
89 header.GetItemRect(NO,&noViewRect);
90 header.GetItemRect(USERNAME,&userNameViewRect);
91 header.GetItemRect(TIME,&timeViewRect);
92 header.GetItemRect(COMMENT,&chatViewRect);
93 header.GetItemRect(INFO,&infoViewRect);
96 userNameViewRect.left += 2;
97 timeViewRect.left += 2;
98 chatViewRect.left += 2;
99 infoViewRect.left += 2;
101 noViewRect.right += 2;
102 userNameViewRect.right += 2;
103 timeViewRect.right += 2;
104 chatViewRect.right += 2;
105 infoViewRect.right += 2;
107 noViewRect.top = lpDrawItemStruct->rcItem.top + 2;
108 userNameViewRect.top = lpDrawItemStruct->rcItem.top + 2;
109 timeViewRect.top = lpDrawItemStruct->rcItem.top + 2;
110 chatViewRect.top = lpDrawItemStruct->rcItem.top + 2;
111 infoViewRect.top = lpDrawItemStruct->rcItem.top + 2;
113 noViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
114 userNameViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
115 timeViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
116 chatViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
117 infoViewRect.bottom = lpDrawItemStruct->rcItem.bottom - 2;
119 CChatData &chatData = commentlist.GetChatAt(lpDrawItemStruct->itemID);
121 time_t chatTime = (time_t)difftime(chatData.date,streamStatus.start_time);
122 tm ct = *gmtime(&chatTime);
125 TCHAR noString[sizeof(chatData.no) * 8];
126 TCHAR dateString[LENGTH_16];
127 _stprintf(noString,TEXT("%u"),chatData.no);
129 _tcsftime(dateString,ARRAY_LENGTH(dateString),ct.tm_hour != 0 ? TEXT("%H:%M:%S") : TEXT("%M:%S"),&ct);
134 //
\91I
\91ð
\8fó
\91Ô
\82©
\83`
\83F
\83b
\83N
135 if ((lpDrawItemStruct->itemState) & (ODS_SELECTED))
138 //
\83u
\83\89\83V
\8dì
\90¬
139 bkBurush=CreateSolidBrush(RGB(255,240,240));
140 // outLinePen = CreatePen(PS_SOLID,3,RGB(255,0,0));
141 //
\83e
\83L
\83X
\83g
\82Ì
\94w
\8ci
\90F
\82ð
\8ew
\92è
142 SetBkColor(lpDrawItemStruct->hDC,RGB(255,240,240)) ;
146 //
\83u
\83\89\83V
\8dì
\90¬
147 bkBurush=CreateSolidBrush(viewproperty.backColor);
150 //
\83e
\83L
\83X
\83g
\82Ì
\94w
\8ci
\90F
\82ð
\8ew
\92è
151 SetBkColor(lpDrawItemStruct->hDC,viewproperty.backColor) ;
154 outLinePen = CreatePen(PS_SOLID,1,RGB(127,127,127));
155 //
\83e
\83L
\83X
\83g
\82Ì
\83J
\83\89\81[
\82ð
\90Ý
\92è
156 SetTextColor(lpDrawItemStruct->hDC,viewproperty.baseStringColor);
158 SelectObject(lpDrawItemStruct->hDC,bkBurush);
159 SelectObject(lpDrawItemStruct->hDC,outLinePen);
160 Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom);
161 DeleteObject(outLinePen);
162 DeleteObject(colLinePen);
163 DeleteObject(bkBurush);
165 ::DrawText(lpDrawItemStruct->hDC,noString,_tcslen(noString),&noViewRect,DT_WORD_ELLIPSIS);
167 ::DrawText(lpDrawItemStruct->hDC,chatData.user_id.c_str(),chatData.user_id.length(),&userNameViewRect,DT_WORD_ELLIPSIS);
169 ::DrawText(lpDrawItemStruct->hDC,chatData.chatBuf.c_str(),chatData.chatBuf.length(),&chatViewRect,DT_WORDBREAK);
171 ::DrawText(lpDrawItemStruct->hDC,dateString,_tcslen(dateString),&timeViewRect,DT_WORD_ELLIPSIS);
184 VOID CCommentList::OnChatReceve(NicoLiveChat_P chatData_in, UINT_PTR count){
188 chatData.SetChat(*chatData_in);
192 chatList.push_back(chatData);
198 VOID CChatData::SetChat(NicoLiveChat &chat_in){
201 this->anonymity = _ttol(chat_in.anonymity);
202 this->premium = _ttol(chat_in.premium);
203 this->chatBuf = chat_in.chatBuf;
204 this->no = _ttol(chat_in.no);
206 if(_tcscmp(chat_in.locale,TEXT("jp")) == 0){
207 this->locale = cuntry::jp;
209 this->locale = cuntry::unknown;
211 this->mail.reserve(chat_in.mailCount);
212 for(UINT_PTR index = 0;index < chat_in.mailCount ;index++){
214 this->mail.push_back(chat_in.mail[index]);
217 this->name = chat_in.name;
219 this->user_id = chat_in.user_id;
223 this->vpos = _ttol(chat_in.vpos);
224 this->thread = _ttol(chat_in.thread);
225 this->date = _ttol(chat_in.date);