OSDN Git Service

2011/12/03 20:00:17
[nlite/nlite.git] / nlite / nlite_mailframe.h
1 #pragma once
2
3 namespace nlite{
4         
5
6         
7         const static LPCTSTR NLITE_MAINWINDOW = TEXT("nlite");
8
9         const static SIZE lowestFrameSize = {300,300};
10
11         
12
13         class CLiveUserData {
14
15         public:
16
17                 CCommentView &commentView;
18
19         
20                 CLiveUserData(CCommentView& cv):commentView(cv){}
21                 
22
23         };
24
25
26
27
28
29
30         class CNliteMainFrame : public CFrameWindowImpl<CNliteMainFrame>,
31                 public CUpdateUI<CNliteMainFrame>,public CMessageFilter, public CIdleHandler
32         {
33
34                 
35                 class CSubLiveNoComboBox:public CWindowImpl<CEdit>{
36
37                         
38
39                 private:
40                         CNliteMainFrame &self;
41
42                 public:
43                         CSubLiveNoComboBox(CNliteMainFrame &in_self):self(in_self){}
44
45
46                         BEGIN_MSG_MAP_EX(CSubLiveNoComboBox)
47                                 MSG_WM_KEYDOWN(OnKeyDown)
48                         END_MSG_MAP()
49
50                         void OnKeyDown(TCHAR wParam, UINT upLParam,UINT loLParam){
51                                 if(wParam == VK_RETURN){
52                                         std::vector<TCHAR> buffer(this->GetWindowTextLengthW() + 1); 
53                                         ::GetWindowTextW(this->m_hWnd,&buffer[0],buffer.size());
54                                         self.ConnectNicoLive(&buffer[0]);
55                                 }
56                                 return;
57                         }
58
59                 };
60
61                 
62         public:
63
64                 typedef CFrameWindowImpl<CNliteMainFrame> baseWindow;
65
66                 // \83E\83B\83\93\83h\83E\83N\83\89\83X\96¼\81A\8b¤\92Ê\83\8a\83\\81[\83XID\81A\83X\83^\83C\83\8b\81A\94w\8ci\90F\82ð\93o\98^
67                 DECLARE_FRAME_WND_CLASS_EX(NLITE_MAINWINDOW, IDC_NLITE,CS_HREDRAW | CS_VREDRAW  | CS_DBLCLKS, COLOR_WINDOW)
68                 //DECLARE_FRAME_WND_CLASS_EX(NLITE_MAINWINDOW, IDC_NLITE,CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_WINDOW)
69                 //DECLARE_FRAME_WND_CLASS(NULL,IDC_NLITE);
70         private:
71                 CCommentView commentView;
72                 
73                 
74                 CStatusBarCtrl statusBar;
75                 CLiveUserData userData;
76                 CSubLiveNoComboBox subLiveNoComboBox;
77                 CCommentWriteWindow commentWriteWindow;
78                 CTabCtrl tabctrl;
79                 
80                 HFONT hTabFont;
81                 CComboBoxEx lvNoCombo;
82                 INT_PTR statusBarHeight;
83                 INT_PTR toolBarHeight;
84                 CNicoVideoAuth nicoVideoAuth;
85                 Property nliteProperty;
86                 CNicoLiveStream nicoLiveStream;
87         private:
88
89                 // \83\81\83b\83Z\81[\83W\83t\83B\83\8b\83^\8f\88\97\9d
90                 virtual BOOL PreTranslateMessage(MSG* pMsg){
91                         // \8aî\92ê\83N\83\89\83X\82ÌPreTranslateMessage\82ð\8cÄ\82Ñ\8fo\82·
92                         return CFrameWindowImpl<CNliteMainFrame>::PreTranslateMessage(pMsg);
93                 }
94
95                 // \83A\83C\83h\83\8b\8f\88\97\9d
96                 virtual BOOL OnIdle(){
97                         return FALSE;
98                 }
99
100
101         public:
102
103                 CNliteMainFrame()
104                         :userData(commentView),
105                         subLiveNoComboBox(*this)
106                 {
107                         LOGFONT lf = {0};
108
109                         lf.lfHeight = 12;
110                         lf.lfCharSet = SHIFTJIS_CHARSET;
111                         hTabFont = CreateFontIndirect(&lf);
112                 }
113
114                 ~CNliteMainFrame(){
115
116                         DeleteObject(hTabFont);
117                 }
118
119                 
120                 BEGIN_UPDATE_UI_MAP(CNliteMainFrame)
121                         // \83G\83\93\83g\83\8a\82È\82µ
122                 END_UPDATE_UI_MAP()
123                 
124                 // \83\81\83b\83Z\81[\83W\83}\83b\83v
125                 BEGIN_MSG_MAP_EX(CNliteMainFrame)
126                         MSG_WM_CREATE(OnCreate)
127                         MSG_WM_DESTROY(OnDestroy)
128                         MESSAGE_HANDLER(WM_SIZING,OnSizing)
129                         MESSAGE_HANDLER(WM_SIZE,OnSize)
130 //                      MSG_WM_NOTIFY(OnNotify)
131                         MESSAGE_HANDLER_EX(WM_ERASEBKGND,OnErasekgnd);
132                         COMMAND_ID_HANDLER_EX(IDM_EXIT, OnMenuExit)
133                         COMMAND_ID_HANDLER_EX(IDM_ABOUT,OnMenuAbount)
134                         COMMAND_ID_HANDLER_EX(IDM_COOKIE,OnCookie)
135                         NOTIFY_HANDLER(ATL_IDW_TOOLBAR,RBN_HEIGHTCHANGE,OnRbnHeightChange)
136                         // CFrameWindowImpl\83N\83\89\83X\82Ö\83`\83F\81[\83\93
137 //                      CHAIN_MSG_MAP(CUpdateUI<CNliteMainFrame>)
138                         CHAIN_MSG_MAP(CFrameWindowImpl<CNliteMainFrame>)
139                 END_MSG_MAP()
140
141                 //\83T\83C\83Y\95Ï\8dX\92\86
142                 LRESULT OnSizing(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
143
144                         ((LPRECT)lParam)->right = ((LPRECT)lParam)->right - ((LPRECT)lParam)->left < lowestFrameSize.cx ? lowestFrameSize.cx + ((LPRECT)lParam)->left : ((LPRECT)lParam)->right;
145                         ((LPRECT)lParam)->bottom = ((LPRECT)lParam)->bottom - ((LPRECT)lParam)->top < lowestFrameSize.cy ? lowestFrameSize.cy + ((LPRECT)lParam)->top : ((LPRECT)lParam)->bottom;
146                         RECT client;
147                         GetClientRect(&client);
148
149                         ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
150                         
151                         
152
153                         bHandled = FALSE;
154                         
155                         return 0;
156
157                 }
158
159                 //\83`\83\89\83c\83L\82ð\82È\82­\82·\81B\82 \82ñ\82Ü\8cø\89Ê\82È\82¢\81H
160                 LRESULT OnErasekgnd(UINT uMsg,WPARAM wParam,LPARAM lParam){
161
162                         return TRUE;
163                 }
164
165
166                 //\83c\81[\83\8b\83o\81[\8d\82\82³\95Ï\8dX
167                 LRESULT OnRbnHeightChange(INT_PTR wParam,LPNMHDR lParam,BOOL &bHandled){
168
169                         RECT toolbarRect;
170                         ::GetClientRect(m_hWndToolBar,&toolbarRect);
171                         toolBarHeight = toolbarRect.bottom - toolbarRect.top;
172
173                         RECT client;
174                         GetClientRect(&client);
175
176                         ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
177
178
179
180                         return 0;
181                 }
182                 
183                 
184                 //\83T\83C\83Y\95Ï\8dX\8cã
185                 LRESULT OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
186
187
188                         SIZE clientSize;
189                         clientSize.cx = LOWORD(lParam);
190                         clientSize.cy = HIWORD(lParam);
191                         ChangeSize(clientSize);
192
193                         bHandled = FALSE;
194                         
195                         
196
197                         return 0;
198                 }
199
200                 VOID ChangeSize(const SIZE& client);
201
202
203                 LRESULT OnCreate(LPCREATESTRUCT lpcs);
204
205                 VOID ConnectNicoLive(LPCTSTR liveNo){
206                         
207 //                      nicoLiveStream.Connect(nicoVideoAuth,liveNo,LiveCallBack,&userData);
208
209                 }
210
211                 VOID Initialize(LPCTSTR localAppDataPath){
212
213                         nliteProperty.ReadIniFile();
214                         
215                 }
216
217                 VOID Finalaize(){
218
219                         nliteProperty.WriteIniFile();
220                 }
221
222                 VOID OnDestroy(){
223                         commentView.DestroyWindow();
224                         PostQuitMessage(0);
225                         return;
226                 }
227
228                 //\83\81\83j\83\85\81[\82©\82ç\83t\83@\83C\83\8b\82ð\8fI\97¹\82ð\91I\91ð
229                 void OnMenuExit(UINT uNotifyCode, int nID, HWND hWndCtl){
230                         PostMessage(WM_CLOSE);
231                 }
232
233                 //\83\81\83j\83\85\81[\82Ì\83A\83v\83\8a\83P\81[\83V\83\87\83\93\83o\81[\83W\83\87\83\93\8fî\95ñ\95\\8e¦
234                 void OnMenuAbount(UINT uNotifyCode,int nID,HWND hWndCtl){
235                 
236
237                         appInfo->show();
238                 }
239
240                 //\83N\83b\83L\81[\82Ì\90Ý\92è
241                 void OnCookie(UINT uNotifyCode,int nID,HWND hWndCtl){
242
243                         nliteProperty.CookieSetting();
244
245                         
246
247                 }
248                 static NLIB_RESULT LiveCallBack(NICOLIVE_EVENT eventType,NicoLiveStream_P pNicoLiveStream,LPVOID option,NICOLIVE_PARAM param1,NICOLIVE_PARAM param2);
249         };
250
251
252
253
254         
255
256 }