2 #include "nlite_include.h"
7 const static SIZE commentColorBoxSize = {35,0};
9 const static LPCTSTR ANONYMOUS_MAILCOMMAND = TEXT("184");
10 const static LPCTSTR ANONYMOUS_BOTTONSTRING = ANONYMOUS_MAILCOMMAND;
12 const static LPCTSTR WRITE_BOTTONSTRING = TEXT("
\8f\91\82«
\8d\9e\82Ý");
13 const static LPCTSTR CHECKBUTTON_HIDDENSTRING = TEXT(" ");
15 const static RECT COMMENTWRITEWINDOW_SEPARATEFSIZE = {0,5,0,5};
16 const static UINT_PTR COMMENTWRITEWINDOW_SIDESEPARATESIZE = 5;
17 const static UINT_PTR INIT_COMMENTWRITE_MAXLENGTH = 60;
18 const static UINT_PTR CHECKBUTTON_SUBSCRIPT_HEIGHT = 10;
20 const static COLORREF MAX_COLOR = 0xFFFFFF;
22 const CommentColorInfo generalUser::COMMENT_COLORLIST[] = {
23 {TEXT("white"),RGB(0xFF,0xFF,0xFF)},
24 {TEXT("red"),RGB(0xFF,0x00,0x00)},
25 {TEXT("pink"),RGB(0xFF,0x80,0x80)},
26 {TEXT("orange"),RGB(0xFF,0xC0,0x00)},
27 {TEXT("yellow"),RGB(0xFF,0xFF,0x00)},
28 {TEXT("green"),RGB(0x00,0xFF,0x00)},
29 {TEXT("cyan"),RGB(0x00,0xFF,0xFF)},
30 {TEXT("blue"),RGB(0x00,0x00,0xFF)},
31 {TEXT("purple"),RGB(0xC0,0x00,0xFF)},
35 const CommentColorInfo premiumUser::COMMENT_COLORLIST[] = {
36 {TEXT("black"),RGB(0x00,0x00,0x00)},
37 {TEXT("white2"),RGB(0xCC,0xCC,0x99)},
38 {TEXT("red2"),RGB(0xCC,0x00,0x33)},
39 {TEXT("pink2"),RGB(0xFF,0x33,0xCC)},
40 {TEXT("orange2"),RGB(0xFF,0x66,0x00)},
41 {TEXT("yellow2"),RGB(0x99,0x99,0x00)},
42 {TEXT("green2"),RGB(0x00,0xCC,0x66)},
43 {TEXT("cyan2"),RGB(0x00,0xCC,0xCC)},
44 {TEXT("blue2"),RGB(0x33,0x99,0xFF)},
45 {TEXT("purple2"),RGB(0x66,0x33,0xCC)}
46 // {TEXT("black2"),RGB(0x66,0x66,0x66)}
49 const CommentSizeInfo generalUser::COMMENT_SIZELIST[] = {
50 {TEXT("
\95\81\92Ê
\81@"),TEXT("medium")},
51 {TEXT("
\8f¬
\81@"),TEXT("small")}
54 const CommentSizeInfo premiumUser::COMMENT_SIZELIST[] = {
55 {TEXT("
\91å
\81@"),TEXT("big")}
58 const CommentPosInfo generalUser::COMMENT_POSLIST[] = {
59 {TEXT("
\92Ê
\8fí
\81@"),TEXT("naka")}
62 const CommentPosInfo premiumUser::COMMENT_POSLIST[] = {
63 {TEXT("
\89º
\81@"),TEXT("shita")},
64 {TEXT("
\8fã
\81@"),TEXT("ue")}
69 static VOID addItemList(CComboBox &combo,T * colorList,UINT_PTR length){
71 UINT_PTR startItemcount = combo.GetCount();
72 for(UINT_PTR index = startItemcount; index < length;index++){
74 combo.AddString(colorList[index - startItemcount].name);
75 combo.SetItemDataPtr(index,(LPVOID)&colorList[index - startItemcount]);
85 static UINT_PTR CalcComboBoxWidth(CComboBox &combo){
90 UINT_PTR itemCount = combo.GetCount();
92 for(UINT_PTR index = 0;index < itemCount;index++){
93 name = ((T*)combo.GetItemDataPtr(index))->name;
94 ::GetTextExtentPoint32(pdc,name,_tcslen(name),&size);
95 rslt = rslt < (UINT_PTR)size.cx ? size.cx : rslt;
101 CCommentWriteWindow::CCommentWriteWindow(CNicoLiveStream &in_nicoLiveStream):
102 commentWriteHeight(0),
103 commentWriteInternalHeight(0),
104 commentWriteMaxLength(INIT_COMMENTWRITE_MAXLENGTH),
105 nicoLiveStream(in_nicoLiveStream),
106 commentSubEdit(*this)
113 LRESULT CCommentWriteWindow::OnCreate(LPCREATESTRUCT lpReateStruct){
115 commentPosBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST ,0,COMMENTPOS_BOX);
116 commentSizeBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,0,COMMENTSIZE_BOX);
117 commentColorBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED ,0,COMMENTCOLOR_BOX);
118 anonymousButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX ,0,ANONYMOUS_BUTTON);
119 commentEdit.Create(m_hWnd,0,WC_EDIT,WS_CHILD | WS_VISIBLE | WS_BORDER,0,COMMENT_EDIT);
120 commentWriteButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0,COMMENTWRITE_BOTTON);
121 commentPosBox.SetFont(AtlGetDefaultGuiFont());
122 commentSizeBox.SetFont(AtlGetDefaultGuiFont());
123 commentColorBox.SetFont(AtlGetDefaultGuiFont());
126 anonymousButton.SetWindowTextW(CHECKBUTTON_HIDDENSTRING);
127 anonymousButton.SetFont(AtlGetDefaultGuiFont());
128 commentEdit.SetFont(AtlGetDefaultGuiFont());
129 commentEdit.SetLimitText(commentWriteMaxLength);
130 commentWriteButton.SetWindowTextW(WRITE_BOTTONSTRING);
131 commentWriteButton.SetFont(AtlGetDefaultGuiFont());
132 commentEdit.SetWindowTextW(TEXT(""));
134 addItemList(commentColorBox,generalUser::COMMENT_COLORLIST,ARRAY_LENGTH(generalUser::COMMENT_COLORLIST));
135 addItemList(commentSizeBox,generalUser::COMMENT_SIZELIST,ARRAY_LENGTH(generalUser::COMMENT_SIZELIST));
136 addItemList(commentPosBox,generalUser::COMMENT_POSLIST,ARRAY_LENGTH(generalUser::COMMENT_POSLIST));
137 commentColorBox.SetCurSel(0);
138 commentSizeBox.SetCurSel(0);
139 commentPosBox.SetCurSel(0);
141 font = AtlGetDefaultGuiFont();
144 LPCTSTR sample = TEXT(" ");
145 commentSubEdit.SubclassWindow(commentEdit);
146 GetTextExtentPoint32(pdc,sample,_tcslen(sample),&thisSize);
147 commentWriteHeight = thisSize.cy + (CHECKBUTTON_SUBSCRIPT_HEIGHT / 2) + COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom;
148 commentWriteInternalHeight = commentWriteHeight - (COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom);
152 VOID CCommentWriteWindow::OnDestroy(){
153 commentPosBox.DestroyWindow();
154 commentSizeBox.DestroyWindow();
155 commentColorBox.DestroyWindow();
156 anonymousButton.DestroyWindow();
157 commentEdit.DestroyWindow();
158 commentWriteButton.DestroyWindow();
162 VOID CCommentWriteWindow::OnSizing(UINT wParam,LPRECT lParam){
165 GetClientRect(&client);
167 ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
171 LRESULT CCommentWriteWindow::OnSize(UINT wParam,SIZE lParam){
175 VOID CCommentWriteWindow::OnPaint(HDC hdc){
179 this->GetClientRect(&clientRect);
181 pdc.FillRect(&clientRect,COLOR_BTNFACE);
185 SIZE anonymousStringSize;
187 anonymousButton.GetWindowRect(&anonymousRect);
188 CPoint anonymousPoint(anonymousRect.left,anonymousRect.top);
189 ::ScreenToClient(*this,&anonymousPoint);
190 anonymousRect.right -= anonymousRect.left;
191 anonymousRect.bottom -= anonymousRect.top;
192 anonymousRect.left = anonymousPoint.x;
193 anonymousRect.top = anonymousPoint.y + anonymousRect.bottom;
196 ::GetTextExtentPoint32(pdc,ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousStringSize);
197 anonymousRect.right = anonymousRect.left + anonymousStringSize.cx;
198 anonymousRect.bottom = anonymousRect.top + anonymousStringSize.cy;
200 LOGFONT anonymousLogFont = {0};
201 anonymousLogFont.lfHeight = CHECKBUTTON_SUBSCRIPT_HEIGHT;
202 anonymousLogFont.lfCharSet = SHIFTJIS_CHARSET;
204 CFont anonymousFont = CreateFontIndirect(&anonymousLogFont);
205 pdc.SelectFont(anonymousFont);
206 pdc.SetBkColor(GetSysColor(COLOR_BTNFACE));
207 pdc.DrawText(ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousRect,0);
212 static VOID agreeEnterKeyThread(LPVOID userData){
215 ((CSubChatEdit*)userData)->AgreeEnter();
220 VOID CCommentWriteWindow::SendChat(){
221 CCommentMaker commentMaker;
222 std::vector<TCHAR> chat(commentEdit.GetWindowTextLengthW() + 1);
223 commentEdit.GetWindowTextW(&chat[0],chat.size());
224 commentMaker.SetChatString(&chat[0]);
225 if(this->anonymousButton.GetCheck() == BST_CHECKED){
227 commentMaker.AddMail(ANONYMOUS_MAILCOMMAND);
230 if(nicoLiveStream.SendChat(commentMaker) != NLIB_ERR_OK){
232 commentSubEdit.AgreeEnter();
235 _beginthread(agreeEnterKeyThread,0,&commentSubEdit);
245 VOID CCommentWriteWindow::ChangeSize(SIZE &size){
247 SIZE commentAnonymousButtonSize;
248 SIZE commentWriteButtonSize;
249 commentWriteButton.GetIdealSize(&commentWriteButtonSize);
250 anonymousButton.GetIdealSize(&commentAnonymousButtonSize);
252 RECT commentPosBoxRect;
253 RECT commentSizeBoxRect;
254 RECT commentColorBoxRect;
255 RECT anonymousButtonRect;
256 RECT commentEditRect;
257 RECT commentWriteButtonRect;
260 this->GetWindowRect(&thisWindowRect);
262 commentPosBoxRect.left = COMMENTWRITEWINDOW_SIDESEPARATESIZE;
263 this->commentPosBoxCS.Lock();
264 commentPosBoxRect.right = commentPosBoxRect.left + CalcComboBoxWidth<CommentPosInfo>(commentPosBox);
265 this->commentPosBoxCS.Unlock();
267 commentSizeBoxRect.left = commentPosBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
268 this->commentSizeBoxCS.Lock();
269 commentSizeBoxRect.right = commentSizeBoxRect.left + CalcComboBoxWidth<CommentSizeInfo>(commentSizeBox);
270 this->commentSizeBoxCS.Unlock();
272 commentColorBoxRect.left = commentSizeBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
273 commentColorBoxRect.right = commentColorBoxRect.left + commentColorBoxSize.cx;
275 CDC cdc(anonymousButton.GetDC());
276 SIZE anonymousStringSize;
277 ::GetTextExtentPoint32(cdc,CHECKBUTTON_HIDDENSTRING,_tcslen(CHECKBUTTON_HIDDENSTRING),&anonymousStringSize);
279 anonymousButtonRect.left = commentColorBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
280 anonymousButtonRect.right = anonymousButtonRect.left + commentAnonymousButtonSize.cx - anonymousStringSize.cx;
282 commentEditRect.left = anonymousButtonRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
284 commentWriteButtonRect.right = size.cx - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
285 commentWriteButtonRect.left = commentWriteButtonRect.right - commentWriteButtonSize.cx;
287 commentEditRect.right = commentWriteButtonRect.left - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
291 //
\88Ú
\93®
\8f\88\97\9d
292 HDWP hDwp = BeginDeferWindowPos(6);
294 commentPosBox.DeferWindowPos(hDwp,*this,
295 commentPosBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentPosBoxRect.right - commentPosBoxRect.left,commentWriteInternalHeight,
298 commentSizeBox.DeferWindowPos(hDwp,*this,
299 commentSizeBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentSizeBoxRect.right - commentSizeBoxRect.left,commentWriteInternalHeight,
302 commentColorBox.DeferWindowPos(hDwp,*this,
303 commentColorBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentColorBoxRect.right - commentColorBoxRect.left,commentWriteInternalHeight,
306 anonymousButton.DeferWindowPos(hDwp,*this,
307 anonymousButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,anonymousButtonRect.right - anonymousButtonRect.left,commentWriteInternalHeight - CHECKBUTTON_SUBSCRIPT_HEIGHT,
310 commentEdit.DeferWindowPos(hDwp,*this,
311 commentEditRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentEditRect.right - commentEditRect.left,commentWriteInternalHeight,
314 commentWriteButton.DeferWindowPos(hDwp,*this,
315 commentWriteButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentWriteButtonRect.right - commentWriteButtonRect.left,commentWriteInternalHeight,
318 EndDeferWindowPos(hDwp);
323 VOID CCommentWriteWindow::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lParam){
327 if(lParam->hwndItem == commentColorBox.m_hWnd && commentColorBox.GetCount() > 0){
331 RECT drawRect = lParam->rcItem;
333 INT_PTR curselNo = commentColorBox.GetCurSel();
334 CDCHandle dcHandle = lParam->hDC;
336 const UINT_PTR width = 1;
337 drawRect.left += width;
338 drawRect.top += width;
339 drawRect.right -= width;
340 drawRect.bottom -= width;
342 if(lParam->itemID == ((UINT)-1)){
343 itemNo = curselNo == CB_ERR ? 0 : curselNo;
345 itemNo = lParam->itemID;
348 CommentInfo<COLORREF> &commentColor = *(CommentInfo<COLORREF> *)commentColorBox.GetItemDataPtr(itemNo);
351 if(lParam->itemState & (ODS_FOCUS | ODS_COMBOBOXEDIT)){
355 bkBrush.CreateSolidBrush(RGB(160,160,160));
359 bkBrush.CreateSolidBrush(RGB(255,255,255));
369 brush.CreateSolidBrush(commentColor.userData);
370 dcHandle.SelectBrush(brush);
371 dcHandle.FillRect(&lParam->rcItem,bkBrush);
372 dcHandle.SelectBrush(brush);
373 dcHandle.SelectPen((HPEN)::GetStockObject(BLACK_PEN));
374 dcHandle.Rectangle(&drawRect);
381 LRESULT CCommentWriteWindow::OnEraseBkGnd(HDC wParam){
387 LRESULT CCommentWriteWindow::OnButton(UINT hiWparam,INT_PTR loWparam,HWND lParam){
389 if(lParam == commentWriteButton){
398 VOID CCommentWriteWindow::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lParam){
400 switch(lParam->CtlID){
402 case COMMENTCOLOR_BOX:
406 pdc.SelectFont(AtlGetDefaultGuiFont());
407 LPCTSTR sample = TEXT(" ");
408 ::GetTextExtentPoint32(pdc,sample,_tcslen(sample),&itemSize);
409 lParam->itemHeight = itemSize.cy;
424 VOID CCommentWriteWindow::OnSendChatResult(){
426 commentSubEdit.AgreeEnter();
437 ////////////////////////////////////////
439 void CSubChatEdit::OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
440 if(wParam == VK_RETURN){
444 if(untilConnectingFlag == FALSE){
445 untilConnectingFlag = TRUE;
457 VOID CSubChatEdit::AgreeEnter(){
459 untilConnectingFlag = FALSE;