OSDN Git Service

2011/11/14 16:28:20
[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         class CLiveUserData {
10
11         public:
12
13                 CCommentView &commentView;
14
15         
16                 CLiveUserData(CCommentView& cv):commentView(cv){}
17
18         };
19
20         class CNicoVideoAuth{
21
22         private:
23                 NicoVideoAuth_P nicoVideoAuth;
24
25
26         public:
27                 CNicoVideoAuth()
28                         :nicoVideoAuth(NicoVideoAuth_new()){}
29
30                 ~CNicoVideoAuth(){
31
32                         NicoVideoAuth_delete(&nicoVideoAuth);
33                 }
34
35                 VOID SetBrowserType(BROWSERTYPE bt){
36                         NLIB_RESULT rslt;
37
38                         rslt = NicoVideoAuth_getNicoVideoAuth(nicoVideoAuth,bt);
39                         if(rslt != NLIB_ERR_OK){
40
41                                 throw NLIBException(rslt);
42                         }
43
44                 }
45
46                 NicoVideoAuth_P GetAuth(){
47
48                         return this->nicoVideoAuth;
49                 }
50
51         };
52
53         class CNicoLiveStream{
54
55         private:
56                 NicoLiveStream_P nicoLiveStream;
57                 
58
59         public:
60                 CNicoLiveStream()
61                         :nicoLiveStream(NicoLiveStream_new())   
62                 {}
63                 ~CNicoLiveStream(){
64
65                         NicoLiveStream_delete(&nicoLiveStream);
66                         
67                 }
68
69                 
70
71                 VOID Connect(CNicoVideoAuth &nicoVideoAuth,LPCTSTR url,NicoRecvCallBack callback,LPVOID option){
72
73                         NLIB_RESULT rslt;
74
75                         rslt = NicoLiveStream_connect(nicoLiveStream,nicoVideoAuth.GetAuth(),url,callback,option);
76
77                         if(rslt != NLIB_ERR_OK){
78
79                                 throw NLIBException(rslt);
80                         }
81                 }
82                 
83
84                 VOID DisConnect(){
85
86                         NicoLiveStream_disConnect(nicoLiveStream);
87                 }
88                 
89                 VOID SendChat(LPCTSTR chatBuf,std::vector<LPCTSTR> mails,std::vector<LPCTSTR> extends){
90                         NLIB_RESULT rslt;
91                         mails.insert( mails.end(),(LPCTSTR)NULL);
92                         extends.insert(extends.end(),(LPCTSTR)NULL);
93                         rslt = NicoLiveStream_sendChat(nicoLiveStream,chatBuf,&mails[0],&extends[0]);
94
95                         if(rslt != NLIB_ERR_OK){
96                                 throw NLIBException(rslt);
97                         }
98                 }
99                 
100
101         };
102
103         class CNliteMainFrame : public CFrameWindowImpl<CNliteMainFrame>,
104                 /*public CUpdateUI<CNliteMainFrame>,*/public CMessageFilter, public CIdleHandler
105         {
106         public:
107
108                 typedef CFrameWindowImpl<CNliteMainFrame> baseWindow;
109
110                 // \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^
111                 //DECLARE_FRAME_WND_CLASS_EX(NLITE_MAINWINDOW, IDC_NLITE,CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_WINDOW)
112                 //DECLARE_FRAME_WND_CLASS_EX(NLITE_MAINWINDOW, IDC_NLITE,CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS, COLOR_WINDOW)
113                 DECLARE_FRAME_WND_CLASS(NULL,IDC_NLITE);
114         private:
115                 CCommentView commentView;
116                 CNicoLiveStream nicoLiveStream;
117                 CNicoVideoAuth nicoVideoAuth;
118                 CStatusBarCtrl statusBar;
119                 CLiveUserData userData;
120                 CTabCtrl tabctrl;
121                 HFONT hTabFont;
122         private:
123
124                 // \83\81\83b\83Z\81[\83W\83t\83B\83\8b\83^\8f\88\97\9d
125                 virtual BOOL PreTranslateMessage(MSG* pMsg){
126                         // \8aî\92ê\83N\83\89\83X\82ÌPreTranslateMessage\82ð\8cÄ\82Ñ\8fo\82·
127                         return CFrameWindowImpl<CNliteMainFrame>::PreTranslateMessage(pMsg);
128                 }
129
130                 // \83A\83C\83h\83\8b\8f\88\97\9d
131                 virtual BOOL OnIdle(){
132 //                      UIUpdateStatusBar();
133                         return FALSE;
134                 }
135
136
137         public:
138
139                 CNliteMainFrame():userData(commentView){
140                         LOGFONT lf = {0};
141
142                         lf.lfHeight = 12;
143                         lf.lfCharSet = SHIFTJIS_CHARSET;
144                         hTabFont = CreateFontIndirect(&lf);
145
146                 }
147
148                 ~CNliteMainFrame(){
149
150                         DeleteObject(hTabFont);
151                 }
152
153                 /*
154                 BEGIN_UPDATE_UI_MAP(CNliteMainFrame)
155                         // \83G\83\93\83g\83\8a\82È\82µ
156                 END_UPDATE_UI_MAP()
157                 */
158                 // \83\81\83b\83Z\81[\83W\83}\83b\83v
159                 BEGIN_MSG_MAP_EX(CNliteMainFrame)
160                         MSG_WM_CREATE(OnCreate)
161                         MSG_WM_DESTROY(OnDestroy)
162                         MESSAGE_HANDLER(WM_SIZING,OnSizing)
163                         MESSAGE_HANDLER(WM_SIZE,OnSize);
164                         
165                         COMMAND_ID_HANDLER_EX(IDM_EXIT, OnMenuExit)
166                         COMMAND_ID_HANDLER_EX(IDM_ABOUT,OnMenuAbount)
167                         // CFrameWindowImpl\83N\83\89\83X\82Ö\83`\83F\81[\83\93
168 //                      CHAIN_MSG_MAP(CUpdateUI<CNliteMainFrame>)
169                         CHAIN_MSG_MAP(CFrameWindowImpl<CNliteMainFrame>)
170                 END_MSG_MAP()
171
172                 //\83T\83C\83Y\95Ï\8dX\92\86
173                 LRESULT OnSizing(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
174
175                         
176                         RECT client;
177                         GetClientRect(&client);
178
179                         ChangeSize( _WTYPES_NS::CSize(client.right - client.left,client.bottom - client.top));
180                         
181                         
182
183                         bHandled = FALSE;
184                         
185                         return 0;
186
187                 }
188                 
189                 
190                 //\83T\83C\83Y\95Ï\8dX\8cã
191                 LRESULT OnSize(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
192
193
194                         SIZE clientSize;
195                         clientSize.cx = LOWORD(lParam);
196                         clientSize.cy = HIWORD(lParam);
197                         ChangeSize(clientSize);
198
199                         bHandled = FALSE;
200                         
201                         
202
203                         return 0;
204                 }
205
206                 VOID ChangeSize(const SIZE& client);
207
208
209                 LRESULT OnCreate(LPCREATESTRUCT lpcs);
210
211
212
213                 
214                 VOID OnDestroy(){
215
216                         commentView.DestroyWindow();
217                         PostQuitMessage(0);
218                         return;
219                 }
220
221                 //\83\81\83j\83\85\81[\82©\82ç\83t\83@\83C\83\8b\82ð\8fI\97¹\82ð\91I\91ð
222                 void OnMenuExit(UINT uNotifyCode, int nID, HWND hWndCtl){
223                         PostMessage(WM_CLOSE);
224                 }
225
226                 //\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¦
227                 void OnMenuAbount(UINT uNotifyCode,int nID,HWND hWndCtl){
228                 
229
230                         appInfo->show();
231                 }
232         };
233
234
235
236
237         
238
239 }