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 namespace generalUser{
23 const CommentColorInfo COMMENT_COLORLIST[] = {
24 {TEXT("white"),RGB(0xFF,0xFF,0xFF)}, //
\94\92
25 {TEXT("red"),RGB(0xFF,0x00,0x00)}, //
\90Ô
26 {TEXT("pink"),RGB(0xFF,0x80,0x80)}, //
\83s
\83\93\83N
27 {TEXT("orange"),RGB(0xFF,0xC0,0x00)}, //
\83I
\83\8c\83\93\83W
28 {TEXT("yellow"),RGB(0xFF,0xFF,0x00)}, //
\89©
\90F
29 {TEXT("green"),RGB(0x00,0xFF,0x00)}, //
\97Î
30 {TEXT("cyan"),RGB(0x00,0xFF,0xFF)}, //
\8a¦
\90F
31 {TEXT("blue"),RGB(0x00,0x00,0xFF)}, //
\90Â
32 {TEXT("purple"),RGB(0xC0,0x00,0xFF)}, //
\8e\87
36 const CommentSizeInfo COMMENT_SIZELIST[] = {
37 {TEXT("
\95\81\92Ê
\81@"),TEXT("medium")}, //
\95\81\92Ê
\83T
\83C
\83Y
38 {TEXT("
\8f¬
\81@"),TEXT("small")} //
\8f¬
\83T
\83C
\83Y
42 const CommentPosInfo COMMENT_POSLIST[] = {
43 {TEXT("
\92Ê
\8fí
\81@"),TEXT("naka")} //
\92Ê
\8fí
\95\
\8e¦
47 namespace premiumUser{
49 const CommentColorInfo COMMENT_COLORLIST[] = {
50 {TEXT("black"),RGB(0x00,0x00,0x00)}, //
\8d\95
51 {TEXT("white2"),RGB(0xCC,0xCC,0x99)}, //
\94\92\82»
\82Ì
\82Q
52 {TEXT("red2"),RGB(0xCC,0x00,0x33)}, //
\90Ô
\82»
\82Ì
\82Q
53 {TEXT("pink2"),RGB(0xFF,0x33,0xCC)}, //
\83s
\83\93\83N
\82»
\82Ì
\82Q
54 {TEXT("orange2"),RGB(0xFF,0x66,0x00)}, //
\83I
\83\8c\83\93\83W
\82»
\82Ì
\82Q
55 {TEXT("yellow2"),RGB(0x99,0x99,0x00)}, //
\89©
\90F
\82»
\82Ì
\82Q
56 {TEXT("green2"),RGB(0x00,0xCC,0x66)}, //
\97Î
\82»
\82Ì
\82Q
57 {TEXT("cyan2"),RGB(0x00,0xCC,0xCC)}, //
\8a¦
\90F
\82»
\82Ì
\82Q
58 {TEXT("blue2"),RGB(0x33,0x99,0xFF)}, //
\90Â
\82»
\82Ì
\82Q
59 {TEXT("purple2"),RGB(0x66,0x33,0xCC)} //
\8e\87\82»
\82Ì
\82Q
60 // {TEXT("black2"),RGB(0x66,0x66,0x66)} //
\8d\95\82»
\82Ì
\82Q
\82Í
\82È
\82¢
\81H
63 const CommentSizeInfo COMMENT_SIZELIST[] = {
64 {TEXT("
\91å
\81@"),TEXT("big")} //
\91å
\83T
\83C
\83Y
69 const CommentPosInfo COMMENT_POSLIST[] = {
70 {TEXT("
\89º
\81@"),TEXT("shita")}, //
\89º
\82É
\95\
\8e¦
71 {TEXT("
\8fã
\81@"),TEXT("ue")} //
\8fã
\82É
\95\
\8e¦
80 static VOID addItemList(CComboBox &combo,T * colorList,UINT_PTR length){
82 UINT_PTR startItemcount = combo.GetCount();
83 for(UINT_PTR index = startItemcount; index < length;index++){
85 combo.AddString(colorList[index - startItemcount].name);
86 combo.SetItemDataPtr(index,(LPVOID)&colorList[index - startItemcount]);
96 static UINT_PTR CalcComboBoxWidth(CComboBox &combo){
101 UINT_PTR itemCount = combo.GetCount();
103 for(UINT_PTR index = 0;index < itemCount;index++){
104 name = ((T*)combo.GetItemDataPtr(index))->name;
105 ::GetTextExtentPoint32(pdc,name,_tcslen(name),&size);
106 rslt = rslt < (UINT_PTR)size.cx ? size.cx : rslt;
112 CCommentWriteWindow::CCommentWriteWindow(CNicoLiveStream &in_nicoLiveStream):
113 commentWriteHeight(0),
114 commentWriteInternalHeight(0),
115 commentWriteMaxLength(INIT_COMMENTWRITE_MAXLENGTH),
116 nicoLiveStream(in_nicoLiveStream),
117 commentSubEdit(*this)
122 LRESULT CCommentWriteWindow::OnCreate(LPCREATESTRUCT lpReateStruct){
124 commentPosBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST ,0,COMMENTPOS_BOX);
125 commentSizeBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,0,COMMENTSIZE_BOX);
126 commentColorBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED ,0,COMMENTCOLOR_BOX);
127 anonymousButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_CHECKBOX | BS_AUTOCHECKBOX ,0,ANONYMOUS_BUTTON);
128 commentEdit.Create(m_hWnd,0,WC_EDIT,WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL,0,COMMENT_EDIT);
129 commentWriteButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0,COMMENTWRITE_BOTTON);
130 commentPosBox.SetFont(AtlGetDefaultGuiFont());
131 commentSizeBox.SetFont(AtlGetDefaultGuiFont());
132 commentColorBox.SetFont(AtlGetDefaultGuiFont());
135 anonymousButton.SetWindowTextW(CHECKBUTTON_HIDDENSTRING);
136 anonymousButton.SetFont(AtlGetDefaultGuiFont());
137 commentEdit.SetFont(AtlGetDefaultGuiFont());
138 commentEdit.SetLimitText(commentWriteMaxLength);
139 commentWriteButton.SetWindowTextW(WRITE_BOTTONSTRING);
140 commentWriteButton.SetFont(AtlGetDefaultGuiFont());
141 commentEdit.SetWindowTextW(TEXT(""));
143 addItemList(commentColorBox,generalUser::COMMENT_COLORLIST,ARRAY_LENGTH(generalUser::COMMENT_COLORLIST));
144 addItemList(commentSizeBox,generalUser::COMMENT_SIZELIST,ARRAY_LENGTH(generalUser::COMMENT_SIZELIST));
145 addItemList(commentPosBox,generalUser::COMMENT_POSLIST,ARRAY_LENGTH(generalUser::COMMENT_POSLIST));
146 commentColorBox.SetCurSel(0);
147 commentSizeBox.SetCurSel(0);
148 commentPosBox.SetCurSel(0);
150 font = AtlGetDefaultGuiFont();
153 LPCTSTR sample = TEXT(" ");
154 commentSubEdit.SubclassWindow(commentEdit);
155 GetTextExtentPoint32(pdc,sample,_tcslen(sample),&thisSize);
156 commentWriteHeight = thisSize.cy + (CHECKBUTTON_SUBSCRIPT_HEIGHT / 2) + COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom;
157 commentWriteInternalHeight = commentWriteHeight - (COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom);
161 VOID CCommentWriteWindow::OnDestroy(){
162 commentPosBox.DestroyWindow();
163 commentSizeBox.DestroyWindow();
164 commentColorBox.DestroyWindow();
165 anonymousButton.DestroyWindow();
166 commentEdit.DestroyWindow();
167 commentWriteButton.DestroyWindow();
171 VOID CCommentWriteWindow::OnSizing(UINT wParam,LPRECT lParam){
174 GetClientRect(&client);
176 ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
180 LRESULT CCommentWriteWindow::OnSize(UINT wParam,SIZE lParam){
184 VOID CCommentWriteWindow::OnPaint(HDC hdc){
188 this->GetClientRect(&clientRect);
190 pdc.FillRect(&clientRect,COLOR_BTNFACE);
194 SIZE anonymousStringSize;
196 anonymousButton.GetWindowRect(&anonymousRect);
197 CPoint anonymousPoint(anonymousRect.left,anonymousRect.top);
198 ::ScreenToClient(*this,&anonymousPoint);
199 anonymousRect.right -= anonymousRect.left;
200 anonymousRect.bottom -= anonymousRect.top;
201 anonymousRect.left = anonymousPoint.x;
202 anonymousRect.top = anonymousPoint.y + anonymousRect.bottom;
205 ::GetTextExtentPoint32(pdc,ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousStringSize);
206 anonymousRect.right = anonymousRect.left + anonymousStringSize.cx;
207 anonymousRect.bottom = anonymousRect.top + anonymousStringSize.cy;
209 LOGFONT anonymousLogFont = {0};
210 anonymousLogFont.lfHeight = CHECKBUTTON_SUBSCRIPT_HEIGHT;
211 anonymousLogFont.lfCharSet = SHIFTJIS_CHARSET;
213 CFont anonymousFont = CreateFontIndirect(&anonymousLogFont);
214 pdc.SelectFont(anonymousFont);
215 pdc.SetBkColor(GetSysColor(COLOR_BTNFACE));
216 pdc.DrawText(ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousRect,0);
221 static VOID agreeEnterKeyThread(LPVOID userData){
224 ((CSubChatEdit*)userData)->AgreeEnter();
229 BOOL CCommentWriteWindow::SendChat(){
230 this->commentEdit.SetReadOnly(TRUE);
231 CCommentMaker commentMaker;
232 std::vector<TCHAR> chat(commentEdit.GetWindowTextLengthW() + 1);
233 commentEdit.GetWindowTextW(&chat[0],chat.size());
234 commentMaker.SetChatString(&chat[0]);
235 if(this->anonymousButton.GetCheck() == BST_CHECKED){
237 commentMaker.AddMail(ANONYMOUS_MAILCOMMAND);
240 NLIB_RESULT code = nicoLiveStream.SendChat(commentMaker);
247 this->commentEdit.SetWindowText(TEXT(""));
250 case NLIB_ERR_NOT_LIVECONNECT:
252 ::MessageBox(NULL,NLIB_GetErrorMessage(code),TEXT("
\83R
\83\81\83\93\83g
\8f\91\82«
\8d\9e\82Ý
\83G
\83\89\81["),MB_ICONERROR | MB_OK);
258 errprint(TEXT("
\83R
\83\81\83\93\83g
\8f\91\82«
\8d\9e\82Ý
\92\86\82É
\83G
\83\89\81[:%s"),NLIB_GetErrorMessage(code));
259 UnexpectedErrorMessageShow(TEXT("
\83R
\83\81\83\93\83g
\8f\91\82«
\8d\9e\82Ý
\92\86\82É"),NLIB_GetErrorMessage(code));
273 VOID CCommentWriteWindow::ChangeSize(SIZE &size){
275 SIZE commentAnonymousButtonSize;
276 SIZE commentWriteButtonSize;
277 commentWriteButton.GetIdealSize(&commentWriteButtonSize);
278 anonymousButton.GetIdealSize(&commentAnonymousButtonSize);
280 RECT commentPosBoxRect;
281 RECT commentSizeBoxRect;
282 RECT commentColorBoxRect;
283 RECT anonymousButtonRect;
284 RECT commentEditRect;
285 RECT commentWriteButtonRect;
288 this->GetWindowRect(&thisWindowRect);
290 commentPosBoxRect.left = COMMENTWRITEWINDOW_SIDESEPARATESIZE;
291 this->commentPosBoxCS.Lock();
292 commentPosBoxRect.right = commentPosBoxRect.left + CalcComboBoxWidth<CommentPosInfo>(commentPosBox);
293 this->commentPosBoxCS.Unlock();
295 commentSizeBoxRect.left = commentPosBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
296 this->commentSizeBoxCS.Lock();
297 commentSizeBoxRect.right = commentSizeBoxRect.left + CalcComboBoxWidth<CommentSizeInfo>(commentSizeBox);
298 this->commentSizeBoxCS.Unlock();
300 commentColorBoxRect.left = commentSizeBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
301 commentColorBoxRect.right = commentColorBoxRect.left + commentColorBoxSize.cx;
303 CDC cdc(anonymousButton.GetDC());
304 SIZE anonymousStringSize;
305 ::GetTextExtentPoint32(cdc,CHECKBUTTON_HIDDENSTRING,_tcslen(CHECKBUTTON_HIDDENSTRING),&anonymousStringSize);
307 anonymousButtonRect.left = commentColorBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
308 anonymousButtonRect.right = anonymousButtonRect.left + commentAnonymousButtonSize.cx - anonymousStringSize.cx;
310 commentEditRect.left = anonymousButtonRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
312 commentWriteButtonRect.right = size.cx - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
313 commentWriteButtonRect.left = commentWriteButtonRect.right - commentWriteButtonSize.cx;
315 commentEditRect.right = commentWriteButtonRect.left - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
319 //
\88Ú
\93®
\8f\88\97\9d
320 HDWP hDwp = BeginDeferWindowPos(6);
322 commentPosBox.DeferWindowPos(hDwp,*this,
323 commentPosBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentPosBoxRect.right - commentPosBoxRect.left,commentWriteInternalHeight,
326 commentSizeBox.DeferWindowPos(hDwp,*this,
327 commentSizeBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentSizeBoxRect.right - commentSizeBoxRect.left,commentWriteInternalHeight,
330 commentColorBox.DeferWindowPos(hDwp,*this,
331 commentColorBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentColorBoxRect.right - commentColorBoxRect.left,commentWriteInternalHeight,
334 anonymousButton.DeferWindowPos(hDwp,*this,
335 anonymousButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,anonymousButtonRect.right - anonymousButtonRect.left,commentWriteInternalHeight - CHECKBUTTON_SUBSCRIPT_HEIGHT,
338 commentEdit.DeferWindowPos(hDwp,*this,
339 commentEditRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentEditRect.right - commentEditRect.left,commentWriteInternalHeight,
342 commentWriteButton.DeferWindowPos(hDwp,*this,
343 commentWriteButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentWriteButtonRect.right - commentWriteButtonRect.left,commentWriteInternalHeight,
346 EndDeferWindowPos(hDwp);
351 VOID CCommentWriteWindow::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lParam){
355 if(lParam->hwndItem == commentColorBox.m_hWnd && commentColorBox.GetCount() > 0){
359 RECT drawRect = lParam->rcItem;
361 INT_PTR curselNo = commentColorBox.GetCurSel();
362 CDCHandle dcHandle = lParam->hDC;
364 const UINT_PTR width = 1;
365 drawRect.left += width;
366 drawRect.top += width;
367 drawRect.right -= width;
368 drawRect.bottom -= width;
370 if(lParam->itemID == ((UINT)-1)){
371 itemNo = curselNo == CB_ERR ? 0 : curselNo;
373 itemNo = lParam->itemID;
376 CommentInfo<COLORREF> &commentColor = *(CommentInfo<COLORREF> *)commentColorBox.GetItemDataPtr(itemNo);
379 if(lParam->itemState & (ODS_FOCUS | ODS_COMBOBOXEDIT)){
383 bkBrush.CreateSolidBrush(RGB(160,160,160));
387 bkBrush.CreateSolidBrush(RGB(255,255,255));
397 brush.CreateSolidBrush(commentColor.userData);
398 dcHandle.SelectBrush(brush);
399 dcHandle.FillRect(&lParam->rcItem,bkBrush);
400 dcHandle.SelectBrush(brush);
401 dcHandle.SelectPen((HPEN)::GetStockObject(BLACK_PEN));
402 dcHandle.Rectangle(&drawRect);
409 LRESULT CCommentWriteWindow::OnEraseBkGnd(HDC wParam){
415 LRESULT CCommentWriteWindow::OnButton(UINT hiWparam,INT_PTR loWparam,HWND lParam){
417 if(lParam == commentWriteButton){
426 VOID CCommentWriteWindow::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lParam){
428 switch(lParam->CtlID){
430 case COMMENTCOLOR_BOX:
434 pdc.SelectFont(AtlGetDefaultGuiFont());
435 LPCTSTR sample = TEXT(" ");
436 ::GetTextExtentPoint32(pdc,sample,_tcslen(sample),&itemSize);
437 lParam->itemHeight = itemSize.cy;
452 VOID CCommentWriteWindow::OnSendChatResult(){
454 commentSubEdit.AgreeEnter();
465 ////////////////////////////////////////
467 void CSubChatEdit::OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
468 if(wParam == VK_RETURN){
472 if(untilConnectingFlag == FALSE){
473 untilConnectingFlag = TRUE;
476 if(self.SendChat() != TRUE){
478 _beginthread(agreeEnterKeyThread,0,this);
495 VOID CSubChatEdit::AgreeEnter(){
497 self.commentEdit.SetReadOnly(FALSE);
498 untilConnectingFlag = FALSE;