2 #include "nlite_include.h"
7 const static SIZE commentColorBoxSize = {35,0};
9 const static LPCTSTR ANONYMOUS_BOTTONSTRING = TEXT("184");
10 const static LPCTSTR WRITE_BOTTONSTRING = TEXT("
\8f\91\82«
\8d\9e\82Ý");
11 const static LPCTSTR CHECKBUTTON_HIDDENSTRING = TEXT(" ");
13 const static RECT COMMENTWRITEWINDOW_SEPARATEFSIZE = {0,5,0,5};
14 const static UINT_PTR COMMENTWRITEWINDOW_SIDESEPARATESIZE = 5;
15 const static UINT_PTR INIT_COMMENTWRITE_MAXLENGTH = 60;
16 const static UINT_PTR CHECKBUTTON_SUBSCRIPT_HEIGHT = 10;
18 const static COLORREF MAX_COLOR = 0xFFFFFF;
20 const CommentColorInfo generalUser::COMMENT_COLORLIST[] = {
21 {TEXT("white"),RGB(0xFF,0xFF,0xFF)},
22 {TEXT("red"),RGB(0xFF,0x00,0x00)},
23 {TEXT("pink"),RGB(0xFF,0x80,0x80)},
24 {TEXT("orange"),RGB(0xFF,0xC0,0x00)},
25 {TEXT("yellow"),RGB(0xFF,0xFF,0x00)},
26 {TEXT("green"),RGB(0x00,0xFF,0x00)},
27 {TEXT("cyan"),RGB(0x00,0xFF,0xFF)},
28 {TEXT("blue"),RGB(0x00,0x00,0xFF)},
29 {TEXT("purple"),RGB(0xC0,0x00,0xFF)},
33 const CommentColorInfo premiumUser::COMMENT_COLORLIST[] = {
34 {TEXT("black"),RGB(0x00,0x00,0x00)},
35 {TEXT("white2"),RGB(0xCC,0xCC,0x99)},
36 {TEXT("red2"),RGB(0xCC,0x00,0x33)},
37 {TEXT("pink2"),RGB(0xFF,0x33,0xCC)},
38 {TEXT("orange2"),RGB(0xFF,0x66,0x00)},
39 {TEXT("yellow2"),RGB(0x99,0x99,0x00)},
40 {TEXT("green2"),RGB(0x00,0xCC,0x66)},
41 {TEXT("cyan2"),RGB(0x00,0xCC,0xCC)},
42 {TEXT("blue2"),RGB(0x33,0x99,0xFF)},
43 {TEXT("purple2"),RGB(0x66,0x33,0xCC)}
44 // {TEXT("black2"),RGB(0x66,0x66,0x66)}
47 const CommentSizeInfo generalUser::COMMENT_SIZELIST[] = {
48 {TEXT("
\95\81\92Ê
\81@"),TEXT("medium")},
49 {TEXT("
\8f¬
\81@"),TEXT("small")}
52 const CommentSizeInfo premiumUser::COMMENT_SIZELIST[] = {
53 {TEXT("
\91å
\81@"),TEXT("big")}
56 const CommentPosInfo generalUser::COMMENT_POSLIST[] = {
57 {TEXT("
\92Ê
\8fí
\81@"),TEXT("naka")}
60 const CommentPosInfo premiumUser::COMMENT_POSLIST[] = {
61 {TEXT("
\89º
\81@"),TEXT("shita")},
62 {TEXT("
\8fã
\81@"),TEXT("ue")}
67 static VOID addItemList(CComboBox &combo,T * colorList,UINT_PTR length){
69 UINT_PTR startItemcount = combo.GetCount();
70 for(UINT_PTR index = startItemcount; index < length;index++){
72 combo.AddString(colorList[index - startItemcount].name);
73 combo.SetItemDataPtr(index,(LPVOID)&colorList[index - startItemcount]);
83 static UINT_PTR CalcComboBoxWidth(CComboBox &combo){
88 UINT_PTR itemCount = combo.GetCount();
90 for(UINT_PTR index = 0;index < itemCount;index++){
91 name = ((T*)combo.GetItemDataPtr(index))->name;
92 ::GetTextExtentPoint32(pdc,name,_tcslen(name),&size);
93 rslt = rslt < (UINT_PTR)size.cx ? size.cx : rslt;
99 CCommentWriteWindow::CCommentWriteWindow():
100 commentWriteHeight(0),
101 commentWriteInternalHeight(0),
102 commentWriteMaxLength(INIT_COMMENTWRITE_MAXLENGTH){
108 LRESULT CCommentWriteWindow::OnCreate(LPCREATESTRUCT lpReateStruct){
110 commentPosBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST ,0,COMMENTPOS_BOX);
111 commentSizeBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,0,COMMENTSIZE_BOX);
112 commentColorBox.Create(m_hWnd,0,WC_COMBOBOX,WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED ,0,COMMENTCOLOR_BOX);
113 anonymousButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_CHECKBOX,0,ANONYMOUS_BUTTON);
114 commentEdit.Create(m_hWnd,0,WC_EDIT,WS_CHILD | WS_VISIBLE | WS_BORDER,0,COMMENT_EDIT);
115 commentWriteButton.Create(m_hWnd,0,WC_BUTTON,WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,0,COMMENTWRITE_BOTTON);
116 commentPosBox.SetFont(AtlGetDefaultGuiFont());
117 commentSizeBox.SetFont(AtlGetDefaultGuiFont());
118 commentColorBox.SetFont(AtlGetDefaultGuiFont());
121 anonymousButton.SetWindowTextW(CHECKBUTTON_HIDDENSTRING);
122 anonymousButton.SetFont(AtlGetDefaultGuiFont());
123 commentEdit.SetFont(AtlGetDefaultGuiFont());
124 commentEdit.SetLimitText(commentWriteMaxLength);
125 commentWriteButton.SetWindowTextW(WRITE_BOTTONSTRING);
126 commentWriteButton.SetFont(AtlGetDefaultGuiFont());
127 commentEdit.SetWindowTextW(TEXT(""));
129 addItemList(commentColorBox,generalUser::COMMENT_COLORLIST,ARRAY_LENGTH(generalUser::COMMENT_COLORLIST));
130 addItemList(commentSizeBox,generalUser::COMMENT_SIZELIST,ARRAY_LENGTH(generalUser::COMMENT_SIZELIST));
131 addItemList(commentPosBox,generalUser::COMMENT_POSLIST,ARRAY_LENGTH(generalUser::COMMENT_POSLIST));
132 commentColorBox.SetCurSel(0);
133 commentSizeBox.SetCurSel(0);
134 commentPosBox.SetCurSel(0);
136 font = AtlGetDefaultGuiFont();
139 LPCTSTR sample = TEXT(" ");
140 GetTextExtentPoint32(pdc,sample,_tcslen(sample),&thisSize);
141 commentWriteHeight = thisSize.cy + (CHECKBUTTON_SUBSCRIPT_HEIGHT / 2) + COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom;
142 commentWriteInternalHeight = commentWriteHeight - (COMMENTWRITEWINDOW_SEPARATEFSIZE.top + COMMENTWRITEWINDOW_SEPARATEFSIZE.bottom);
146 VOID CCommentWriteWindow::OnDestroy(){
147 commentPosBox.DestroyWindow();
148 commentSizeBox.DestroyWindow();
149 commentColorBox.DestroyWindow();
150 anonymousButton.DestroyWindow();
151 commentEdit.DestroyWindow();
152 commentWriteButton.DestroyWindow();
156 VOID CCommentWriteWindow::OnSizing(UINT wParam,LPRECT lParam){
159 GetClientRect(&client);
161 ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
165 LRESULT CCommentWriteWindow::OnSize(UINT wParam,SIZE lParam){
169 VOID CCommentWriteWindow::OnPaint(HDC hdc){
173 this->GetClientRect(&clientRect);
175 pdc.FillRect(&clientRect,COLOR_BTNFACE);
179 SIZE anonymousStringSize;
181 anonymousButton.GetWindowRect(&anonymousRect);
182 CPoint anonymousPoint(anonymousRect.left,anonymousRect.top);
183 ::ScreenToClient(*this,&anonymousPoint);
184 anonymousRect.right -= anonymousRect.left;
185 anonymousRect.bottom -= anonymousRect.top;
186 anonymousRect.left = anonymousPoint.x;
187 anonymousRect.top = anonymousPoint.y + anonymousRect.bottom;
190 ::GetTextExtentPoint32(pdc,ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousStringSize);
191 anonymousRect.right = anonymousRect.left + anonymousStringSize.cx;
192 anonymousRect.bottom = anonymousRect.top + anonymousStringSize.cy;
194 LOGFONT anonymousLogFont = {0};
195 anonymousLogFont.lfHeight = CHECKBUTTON_SUBSCRIPT_HEIGHT;
196 anonymousLogFont.lfCharSet = SHIFTJIS_CHARSET;
198 CFont anonymousFont = CreateFontIndirect(&anonymousLogFont);
199 pdc.SelectFont(anonymousFont);
200 pdc.DrawText(ANONYMOUS_BOTTONSTRING,_tcslen(ANONYMOUS_BOTTONSTRING),&anonymousRect,0);
205 VOID CCommentWriteWindow::ChangeSize(SIZE &size){
209 SIZE commentAnonymousButtonSize;
210 SIZE commentWriteButtonSize;
211 commentWriteButton.GetIdealSize(&commentWriteButtonSize);
212 anonymousButton.GetIdealSize(&commentAnonymousButtonSize);
214 RECT commentPosBoxRect;
215 RECT commentSizeBoxRect;
216 RECT commentColorBoxRect;
217 RECT anonymousButtonRect;
218 RECT commentEditRect;
219 RECT commentWriteButtonRect;
222 this->GetWindowRect(&thisWindowRect);
224 commentPosBoxRect.left = COMMENTWRITEWINDOW_SIDESEPARATESIZE;
225 this->commentPosBoxCS.Lock();
226 commentPosBoxRect.right = commentPosBoxRect.left + CalcComboBoxWidth<CommentPosInfo>(commentPosBox);
227 this->commentPosBoxCS.Unlock();
229 commentSizeBoxRect.left = commentPosBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
230 this->commentSizeBoxCS.Lock();
231 commentSizeBoxRect.right = commentSizeBoxRect.left + CalcComboBoxWidth<CommentSizeInfo>(commentSizeBox);
232 this->commentSizeBoxCS.Unlock();
234 commentColorBoxRect.left = commentSizeBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
235 commentColorBoxRect.right = commentColorBoxRect.left + commentColorBoxSize.cx;
237 CDC cdc(anonymousButton.GetDC());
238 SIZE anonymousStringSize;
239 ::GetTextExtentPoint32(cdc,CHECKBUTTON_HIDDENSTRING,_tcslen(CHECKBUTTON_HIDDENSTRING),&anonymousStringSize);
241 anonymousButtonRect.left = commentColorBoxRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
242 anonymousButtonRect.right = anonymousButtonRect.left + commentAnonymousButtonSize.cx - anonymousStringSize.cx;
244 commentEditRect.left = anonymousButtonRect.right + COMMENTWRITEWINDOW_SIDESEPARATESIZE;
246 commentWriteButtonRect.right = size.cx - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
247 commentWriteButtonRect.left = commentWriteButtonRect.right - commentWriteButtonSize.cx;
249 commentEditRect.right = commentWriteButtonRect.left - COMMENTWRITEWINDOW_SIDESEPARATESIZE;
253 //
\88Ú
\93®
\8f\88\97\9d
254 HDWP hDwp = BeginDeferWindowPos(6);
256 commentPosBox.DeferWindowPos(hDwp,*this,
257 commentPosBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentPosBoxRect.right - commentPosBoxRect.left,commentWriteInternalHeight,
260 commentSizeBox.DeferWindowPos(hDwp,*this,
261 commentSizeBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentSizeBoxRect.right - commentSizeBoxRect.left,commentWriteInternalHeight,
264 commentColorBox.DeferWindowPos(hDwp,*this,
265 commentColorBoxRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentColorBoxRect.right - commentColorBoxRect.left,commentWriteInternalHeight,
268 anonymousButton.DeferWindowPos(hDwp,*this,
269 anonymousButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,anonymousButtonRect.right - anonymousButtonRect.left,commentWriteInternalHeight - CHECKBUTTON_SUBSCRIPT_HEIGHT,
272 commentEdit.DeferWindowPos(hDwp,*this,
273 commentEditRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentEditRect.right - commentEditRect.left,commentWriteInternalHeight,
276 commentWriteButton.DeferWindowPos(hDwp,*this,
277 commentWriteButtonRect.left,COMMENTWRITEWINDOW_SEPARATEFSIZE.top,commentWriteButtonRect.right - commentWriteButtonRect.left,commentWriteInternalHeight,
280 EndDeferWindowPos(hDwp);
285 VOID CCommentWriteWindow::OnDrawItem(UINT wParam,LPDRAWITEMSTRUCT lParam){
289 if(lParam->hwndItem == commentColorBox.m_hWnd && commentColorBox.GetCount() > 0){
293 RECT drawRect = lParam->rcItem;
295 INT_PTR curselNo = commentColorBox.GetCurSel();
296 CDCHandle dcHandle = lParam->hDC;
298 const UINT_PTR width = 1;
299 drawRect.left += width;
300 drawRect.top += width;
301 drawRect.right -= width;
302 drawRect.bottom -= width;
304 if(lParam->itemID == ((UINT)-1)){
305 itemNo = curselNo == CB_ERR ? 0 : curselNo;
307 itemNo = lParam->itemID;
310 CommentInfo<COLORREF> &commentColor = *(CommentInfo<COLORREF> *)commentColorBox.GetItemDataPtr(itemNo);
313 if(lParam->itemState & (ODS_FOCUS | ODS_COMBOBOXEDIT)){
317 bkBrush.CreateSolidBrush(RGB(160,160,160));
321 bkBrush.CreateSolidBrush(RGB(255,255,255));
331 brush.CreateSolidBrush(commentColor.userData);
332 dcHandle.SelectBrush(brush);
333 dcHandle.FillRect(&lParam->rcItem,bkBrush);
334 dcHandle.SelectBrush(brush);
335 dcHandle.SelectPen((HPEN)::GetStockObject(BLACK_PEN));
336 dcHandle.Rectangle(&drawRect);
343 LRESULT CCommentWriteWindow::OnEraseBkGnd(HDC wParam){
348 VOID CCommentWriteWindow::OnMeasureItem(UINT wParam,LPMEASUREITEMSTRUCT lParam){
350 switch(lParam->CtlID){
352 case COMMENTCOLOR_BOX:
356 pdc.SelectFont(AtlGetDefaultGuiFont());
357 LPCTSTR sample = TEXT(" ");
358 ::GetTextExtentPoint32(pdc,sample,_tcslen(sample),&itemSize);
359 lParam->itemHeight = itemSize.cy;