OSDN Git Service

フォーカス処理修正
[nlite/nlite.git] / nlite / nlite_commentview.h
1 #pragma once
2
3 namespace nlite{
4
5         class CCommentView;
6         class CCommentListWindow;
7         class CChatChildCtrlsList;
8         class CChatChildCtrls;
9
10         //\92è\90\94\97p\82Ì\96¼\91O\8bó\8aÔ
11         namespace commentViewConstant{
12
13                 //\83R\83\81\83\93\83g\83r\83\85\81[\83E\83B\83\93\83h\83E\96¼
14                 const static LPCTSTR  NLITE_COMMENTVIEW = TEXT("NLITE_COMMENTVIEW");
15
16                 //\83R\83\81\83\93\83g\83\8a\83X\83g\83E\83B\83\93\83h\83E\96¼
17                 const static LPCTSTR NLITE_COMMENTLISTWINDOW = TEXT("NLITE_COMMENTLISTWINDOW");
18
19                 //\83w\83b\83_\81[\82Ì\8d\82\82³
20                 const static UINT_PTR HEADER_HAIGHT = 20;
21
22                 //\83w\83b\83_\81[\83R\83\93\83g\83\8d\81[\83\8bID
23                 const static UINT_PTR HEADER_ID = 257;
24
25                 //\83R\83\81\83\93\83g\83\8a\83X\83g\83E\83B\83\93\83h\83EID
26                 const static UINT_PTR LISTWINDOW = 258;
27
28                 //baseWindowID
29                 const static UINT_PTR MENU_OR_ID = 256;
30         }
31
32         class CChatReadEdit :public CWindowImpl<CChatReadEdit,CRichEditCtrl>{
33                 friend CCommentListWindow;
34                 friend CChatChildCtrls;
35
36                 BEGIN_MSG_MAP(CChatReadEdit)
37
38                 END_MSG_MAP()
39
40                 BOOL SetWindowText(const CChatData &str);
41
42                 VOID Reset();
43
44                 VOID linkStringBeside(const tstring &target,const nliteregex::tregex &re);
45                 
46
47                 HWND GeneralCreate(HWND hParent,DWORD eventMask,UINT id);
48         };
49
50         class CChatChildCtrls{
51                 friend CCommentListWindow;
52                 friend CChatChildCtrlsList;
53         private:
54                 CChatReadEdit chatDispCtrl;
55                 CHyperLink noDispCtrl;
56                 CHyperLink userNameDispCtrl;
57                 CCommentView &m_master;
58                 
59
60         private:
61
62                 enum {
63                         NO_DIOSCTRL_ID = 10000000,
64                         USERNAME_DISPCTRL_ID = 20000000,
65                         CHAT_DISPCTRL_ID = 30000000
66
67                 };
68                 
69                 ///
70                 ///\83R\83\93\83X\83g\83\89\83N\83^
71                 ///
72                 CChatChildCtrls(CCommentView &hMaster);
73                 
74                 ///
75                 ///\8ew\92è\82µ\82½\8d\82\82³\82É\83R\83\93\83g\83\8d\81[\83\8b\82ð\83Z\83b\83g
76                 ///
77                 VOID SetCtrl(HDWP,const RECT &rc,CCommentList::reference commen,BOOL mulutiLineFlag);
78
79                 VOID AdjustRect(RECT &rc);
80
81                 VOID Hide(HDWP hdwp);
82
83                 VOID Create();
84
85                 ///
86                 ///\83R\83\93\83g\83\8d\81[\83\8b\82Ì\8cÂ\90\94\82ð\8eæ\93¾
87                 ///
88                 static UINT_PTR GetCtrlCount();
89
90
91
92         };
93
94
95         class CChatChildCtrlsList{
96                 friend CCommentView;
97                 friend CCommentListWindow;
98                 friend CChatChildCtrls;
99                 
100         private:
101                 typedef std::list<CChatChildCtrls> InternalList;
102
103                 InternalList m_list;
104                 CCommentView &m_hMaster;
105                 RECT rcBuf;
106
107
108         private:
109                 typedef InternalList::reference reference;
110                 typedef InternalList::iterator iterator;
111                 
112                 ///
113                 ///\83R\83\93\83X\83g\83\89\83N\83^
114                 ///
115                 CChatChildCtrlsList(CCommentView &hMaster);
116
117         
118
119                 ///
120                 ///\83R\83\93\83g\83\8d\81[\83\8b\82ð\95\\8e¦
121                 ///
122                 VOID ShowCntrls();
123
124                 ///
125                 ///\94ñ\95\\8e¦\8f\88\97\9d
126                 ///
127                 VOID AllHide();
128
129         private:
130
131                 ///
132                 ///\8ag\92£\8f\88\97\9d
133                 ///
134                 iterator Extend();
135
136
137         };
138
139         
140         //\83R\83\81\83\93\83g\95\\8e¦\97p\83E\83B\83\93\83h\83E
141         class CCommentListWindow:public CWindowImpl<CCommentListWindow>{
142
143                 friend CCommentView;
144                 friend CChatChildCtrls;
145                 friend CChatChildCtrlsList;
146                 
147                 
148                 //\83\81\83\93\83o
149         private:
150                 CCommentView &self;
151                 UINT_PTR viewSellHeight;
152                 CPen collLinePen;                                                                                                       //\8d\80\96Ú\8fc\90ü\95`\89æ\97p\83y\83\93
153                 CPen normalSellLinePen;                                                                                                 //\98g\90ü\95`\89æ\97p\83y\83\93
154                 CBrush normalBkBrush;                                                                                                           //\94w\8ci\95`\89æ\97p\83u\83\89\83V
155                 CPen selectSellLinePen;                                                                                                 //\98g\90ü\95`\89æ\97p\83y\83\93
156                 CBrush selectBkBrush;                                                                                                           //\94w\8ci\95`\89æ\97p\83u\83\89\83V
157                 CFont linkFont;
158
159
160                 //\83\8a\83\93\83N\95\8e\9a\97ñ\97p\82Ì\83t\83H\83\93\83g
161                 enum {
162                         CALCEDIT_ID = 100
163
164                 };
165
166         public:
167
168                 
169                 DECLARE_WND_CLASS(commentViewConstant::NLITE_COMMENTLISTWINDOW)
170
171
172                 //
173                 //\83\81\83b\83Z\81[\83W\83}\83b\83v
174                 //
175                 BEGIN_MSG_MAP(CCommentListWindow)
176                         MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk)
177                         MSG_WM_LBUTTONDOWN(OnLButtonDown)
178                         MSG_WM_CREATE(OnCreate)
179                         MSG_WM_ERASEBKGND(OnEraseBkGnd)
180                         MSG_WM_MOUSEWHEEL(OnMouseWheel)
181                         MSG_WM_PAINT(OnPaint)
182                         MSG_WM_SIZE(OnSize)
183                         MSG_WM_KEYDOWN(OnKeyDown)
184                         MSG_WM_SETCURSOR(OnSetCursor)
185                         MESSAGE_HANDLER_EX(UM_COMMENTVIEW_SETCTRL,OnSetCtrol)
186                         NOTIFY_ID_HANDLER_EX(CChatChildCtrls::CHAT_DISPCTRL_ID,OnChatControlNortify)
187                         NOTIFY_HANDLER_EX(CALCEDIT_ID,EN_REQUESTRESIZE,OnCalcSellSize)
188                 END_MSG_MAP()
189
190
191
192         private:
193
194                 ///
195                 ///\83R\83\93\83X\83g\83\89\83N\83^
196                 ///
197                 CCommentListWindow(CCommentView &self_in);
198
199                 ///
200                 ///\83f\83X\83g\83\89\83N\83^
201                 ///
202                 ~CCommentListWindow();
203
204
205                 ///
206                 ///\83v\83\8d\83p\83e\83B\90Ý\92è\8e\9e\82Ì\8f\88\97\9d
207                 ///
208                 VOID OnSetProperty();
209
210                 ///
211                 ///\83X\83N\83\8d\81[\83\8b\83y\81[\83W\8cv\8eZ
212                 ///
213                 UINT_PTR CalcScrollPage(UINT_PTR nMax);
214
215                 ///
216                 ///\8ds\82Ì\8d\82\82³\82ð\96â\82¢\8d\87\82í\82¹
217                 ///
218                 VOID CalcItemHeight(CChatData &chatData);
219
220                 ///
221                 ///\91I\91ð\8ds\82ð\95\\8e¦
222                 ///
223                 VOID ShowCurSel();
224
225                 VOID CalcChatRect(const CDC &cdc,RECT &rc,const CNLiteString &str);
226                 
227
228                 //\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
229         private:
230
231                 ///
232                 ///\83A\83C\83e\83\80\95`\89æ
233                 ///
234                 VOID DrawItem(CDC &dc,const RECT &rc,const RECT *headerRect,CChatData &chatData);
235
236                 ///
237                 ///\95`\89æ\8d\82\82³\82ð\83\8a\83Z\83b\83g
238                 ///
239                 VOID ResetViewSellHeight();
240                 
241
242                 ///
243                 ///\83N\83\8a\83b\83N\82µ\82½\8ds\82ð\8cv\8eZ
244                 ///
245                 CCommentList::iterator CalcClickLine(INT_PTR height);
246
247                 ///
248                 ///\83\86\81[\83U\96¼\82©\83R\83\81\94Ô\8fã\82©\82Ì\94»\92è
249                 ///
250                 BOOL IsOnNoOrUserName(UINT_PTR index,const POINT &point);
251
252                 //\83\81\83b\83Z\81[\83W\83n\83\93\83h\83\89
253         private:
254                 
255                 ///
256                 ///\83E\83B\83\93\83h\83E\8dì\90¬\8e\9e\82Ì\8f\88\97\9d
257                 ///
258                 LRESULT OnCreate(LPCREATESTRUCT lpCreateStruct);
259
260                 ///
261                 ///\83}\83E\83X\83N\83\8a\83b\83N\8e\9e\82Ì\8f\88\97\9d
262                 ///
263                 VOID OnLButtonDown(UINT wParam, _WTYPES_NS::CPoint &point);
264
265                 ///
266                 ///\95`\89æ\8f\88\97\9d
267                 ///
268                 VOID OnPaint(HDC hdc);
269
270                 ///
271                 ///\83R\83\93\83g\83\8d\81[\83\8b\83Z\83b\83g\8f\88\97\9d
272                 ///
273                 LRESULT OnSetCtrol(UINT uMsg,WPARAM wparam,LPARAM lparam);
274
275                 ///
276                 ///\83T\83C\83Y\95Ï\8dX
277                 ///
278                 VOID OnSize(UINT wParam, _WTYPES_NS::CSize &windowSize);
279
280                 ///
281                 ///\83}\83E\83X\83_\83u\83\8b\83N\83\8a\83b\83N\8e\9e\82Ì\8f\88\97\9d
282                 ///
283                 VOID OnLButtonDblClk(UINT wParam, _WTYPES_NS::CPoint &point);
284
285                 ///
286                 ///\94w\8ci\93h\82è\82Â\82Ô\82µ
287                 ///
288                 LRESULT OnEraseBkGnd(HDC lparam);
289
290                 ///
291                 ///\83}\83E\83X\83z\83C\81[\83\8b
292                 ///
293                 LRESULT OnMouseWheel(UINT loWparam,SHORT hiWparam,CPoint &point);
294
295                 ///
296                 ///\83L\81[\89\9f\89º\8e\9e\82Ì\8f\88\97\9d
297                 ///
298                 VOID OnKeyDown(TCHAR vKey,UINT loLParam,UINT hiLParam);
299
300                 ///
301                 ///\83J\81[\83\\83\8b\95Ï\8dX\8f\88\97\9d
302                 ///
303                 LRESULT OnSetCursor(HWND wparam,UINT loLparam,UINT hiLparam);
304
305                 ///
306                 ///\83`\83\83\83b\83g\83R\83\93\83g\83\8d\81[\83\8b\92Ê\92m
307                 ///
308                 LRESULT OnChatControlNortify(LPNMHDR lParam);
309
310                 LRESULT OnCalcSellSize(LPNMHDR lParam);
311                 
312         };
313         
314         ///
315         ///\83R\83\81\83\93\83g\83r\83\85\81[\83N\83\89\83X
316         ///
317         class CCommentView:public CWindowImpl<CCommentView>{
318                 friend CChatChildCtrls;
319                 friend CCommentListWindow;                                              //\83t\83\8c\83\93\83h\90é\8c¾
320                 friend CChatChildCtrlsList;
321                 friend CChatChildCtrls;
322                 //\83v\83\89\83C\83x\81[\83g\8c^\81E\83N\83\89\83X\92è\8b`
323         private:
324
325                 //\83w\83b\83_\81[\8fî\95ñ\8ai\94[\97p\83I\83u\83W\83F\83N\83g
326                 typedef struct{
327
328                         LPTSTR *columns;
329                         UINT_PTR *holizensize;
330                         UINT_PTR count;
331
332                 }HEADERSINFO,*LPHEADERSINFO;
333
334                 
335                 
336
337                 
338
339                 //\83\81\83\93\83o\90é\8c¾
340         private:
341
342                 CHeaderCtrl m_header;                                           //\83w\83b\83_\81[\83R\83\93\83g\83\8d\81[\83\8b
343                 CCommentListWindow  m_commentListWindow;        //\83R\83\81\83\93\83g\83\8a\83X\83g\83E\83B\83\93\83h\83E
344                 CNicoLiveStream &stream;                                //\95ú\91\97\83I\83u\83W\83F\83N\83g
345                 GeneralProperty generalProperty;                        //\88ê\94Ê\90Ý\92è
346                 CCommentList commentlist;                                       //\83R\83\81\83\93\83g\83\8a\83X\83g
347                 CommentViewProperty viewproperty;                       //\95\\8e¦\83v\83\8d\83p\83e\83B
348                 HFONT hHeaderFontNew;                                           //\83w\83b\83_\81[\83t\83H\83\93\83g
349                 CNicoVideoAuth &refAuth;                                        //\83j\83R\83j\83R\90\95ú\91\97\94F\8fØ\83I\83u\83W\83F\83N\83g\8eQ\8fÆ
350
351                 CChatChildCtrlsList chatChildCtrlsList;
352
353                 
354
355
356                 
357                 
358
359                 
360         public:
361
362                 enum{
363                         NO,
364                         USERNAME,
365                         COMMENT,
366                         TIME,
367                         INFO
368
369                 };
370                 
371                 ///
372                 ///\83R\83\93\83X\83g\83\89\83N\83^
373                 ///
374                 CCommentView(CNicoLiveStream &stream,CNicoVideoAuth &refAuth);
375                 
376                 ///
377                 ///\83f\83X\83g\83\89\83N\83^
378                 ///
379                 ~CCommentView();
380
381                 
382
383                 //
384                 //\83E\83B\83\93\83h\83E\83N\83\89\83X\90é\8c¾
385                 //
386                 DECLARE_WND_CLASS_EX(commentViewConstant::NLITE_COMMENTVIEW,0,COLOR_BACKGROUND)
387                 
388                 //
389                 //\83\81\83b\83Z\81[\83W\83}\83b\83v
390                 //
391                 BEGIN_MSG_MAP(CCommentView)
392                         MSG_WM_CREATE(OnCreate)
393                         MSG_WM_DESTROY(OnDestroy)                       
394                         MSG_WM_SIZE(OnSize)
395                         MSG_WM_HSCROLL(OnHScroll)
396                         MSG_WM_VSCROLL(OnVScroll)
397                         MSG_WM_ERASEBKGND(OnEraseBkgnd)
398                         NOTIFY_CODE_HANDLER_EX(HDN_ENDTRACK   ,OnHeaderEndTrack)
399                         NOTIFY_CODE_HANDLER_EX(HDN_ENDDRAG  ,OnHeaderEndDrag)
400                 END_MSG_MAP()
401
402                 ///
403                 ///\83v\83\8d\83p\83e\83B\90Ý\92è
404                 ///
405                 VOID SetProperty(const CommentViewProperty &setProperty,const GeneralProperty &in_generalProperty);
406
407                 ///
408                 ///\83v\83\8d\83p\83e\83B\8eæ\93¾
409                 ///
410                 CommentViewProperty &GetProperty();
411                 
412                 ///
413                 ///\83E\83B\83\93\83h\83E\8dì\90¬
414                 ///
415                 HWND Create(HWND hWndParent);
416
417                 ///
418                 ///\83w\83b\83_\82Ì\89¡\95\9d\8eæ\93¾
419                 ///
420                 UINT_PTR GetColumnHolSizeSum();
421
422                 ///
423                 ///\83j\83R\90\82É\90Ú\91±\8e\9e\82Ì\8f\88\97\9d
424                 ///
425                 VOID OnConnect();
426
427                 ///
428                 ///\83`\83\83\83b\83g\83R\83\81\83\93\83g\8eó\90M\8e\9e\82Ì\8f\88\97\9d
429                 ///
430                 VOID OnChatReceve(NicoLiveChat_P chat,UINT_PTR count);
431
432                 ///
433                 ///\83`\83\83\83b\83g\83R\83\81\83\93\83g\8eó\90M\8am\92è\8f\88\97\9d
434                 ///
435                 VOID OnChatReceveSettle(UINT_PTR commentCount,UINT_PTR commentCountSum);
436                 
437
438
439                 //\83v\83\89\83C\83x\81[\83g\8aÖ\90\94
440         private:
441
442
443                 ///
444                 ///\83w\83b\83_\92Ç\89Á
445                 ///
446                 VOID AddHeader(LPHEADERSINFO infos);
447                 
448                 ///
449                 ///\83w\83b\83_\82Ì\89¡\95\9d\8c\88\92è
450                 ///
451                 VOID DecisionHorzSize();
452
453
454                 ///
455                 ///\83T\83C\83Y\95Ï\8dX\8f\88\97\9d
456                 ///
457                 VOID ChangeSize(const SIZE& client);
458
459                 //\83E\83B\83\93\83h\83E\83\81\83b\83Z\81[\83W\83n\83\93\83h\83\89
460         private:
461
462                 
463
464                 ///
465                 ///\83T\83C\83Y\95Ï\8dX\8cã\8f\88\97\9d
466                 ///
467                 LRESULT OnSize(UINT wParam,SIZE lParam);
468
469                 
470                 
471
472                 ///
473                 ///\94w\8ci\93h\82è\82Â\82Ô\82µ\8f\88\97\9d
474                 ///
475                 LRESULT OnEraseBkgnd(HDC wParam);
476                 
477                 ///
478                 ///\83E\83B\83\93\83h\83E\94j\8aü\8e\9e\82Ì\8f\88\97\9d
479                 ///
480                 VOID OnDestroy();
481                 
482                 ///
483                 ///\83w\83b\83_\83A\83C\83e\83\80\95Ï\8dX\8e\9e\8f\88\97\9d
484                 ///
485                 LRESULT OnHeaderEndTrack(LPNMHDR lParam);
486
487
488                 ///
489                 ///\83w\83b\83_\83h\83\89\83b\83O\8cã\8f\88\97\9d
490                 ///
491                 LRESULT OnHeaderEndDrag(LPNMHDR lParam);
492
493
494
495                 ///
496                 ///\89¡\83X\83N\83\8d\81[\83\8b\8e\9e\82Ì\8f\88\97\9d
497                 ///
498                 VOID OnHScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam);
499                 
500                 ///
501                 ///\8fc\83X\83N\83\8d\81[\83\8b\8e\9e\82Ì\8f\88\97\9d
502                 ///
503                 VOID OnVScroll(INT_PTR loWParam,SHORT hiWParam,HWND lParam);
504
505                 ///
506                 ///\8dì\90¬\8e\9e\82Ì\8f\88\97\9d
507                 ///
508                 LRESULT OnCreate(LPCREATESTRUCT lpcs);
509                 
510                 
511                 
512                 
513                 
514
515
516         };
517         
518 }