OSDN Git Service

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