1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | using namespace ActiveBasic::IDE;
|
---|
4 | using namespace ActiveBasic::IDE::WindowComponents;
|
---|
5 |
|
---|
6 | LRESULT CALLBACK WindowFunc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
|
---|
7 | void SetupWindow(HWND hwnd);
|
---|
8 | void ResetTextEditFont(HWND hwnd);
|
---|
9 |
|
---|
10 | ::LRESULT MainFrame::OnCreate( ::UINT msg, ::WPARAM wParam, ::LPARAM lParam, ::BOOL& handled )
|
---|
11 | {
|
---|
12 | // ウィンドウエリアマネージャに親ウィンドウを登録
|
---|
13 | wam.SetParentWnd( m_hWnd );
|
---|
14 |
|
---|
15 | RECT rect;
|
---|
16 | GetClientRect( &rect );
|
---|
17 |
|
---|
18 | // MDIベースを作成
|
---|
19 | mdiWindow = new MdiWindow();
|
---|
20 | mdiWindow->Create(
|
---|
21 | m_hWnd,
|
---|
22 | rect,
|
---|
23 | NULL,
|
---|
24 | WS_CHILD
|
---|
25 | );
|
---|
26 | wam.AddMdiWindow( mdiWindow );
|
---|
27 |
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | extern HWND hOwner;
|
---|
33 | hOwner = m_hWnd;
|
---|
34 | extern WNDPROC oldMainFrameWndProc;
|
---|
35 | oldMainFrameWndProc = (WNDPROC)::GetWindowLong( hOwner, GWL_WNDPROC );
|
---|
36 | ::SetWindowLong( hOwner, GWL_WNDPROC, (LONG)WindowFunc );
|
---|
37 |
|
---|
38 | SetupWindow(hOwner);
|
---|
39 |
|
---|
40 | //テキストエディタフォント設定
|
---|
41 | ResetTextEditFont(hOwner);
|
---|
42 |
|
---|
43 |
|
---|
44 |
|
---|
45 | return 0;
|
---|
46 | }
|
---|
47 |
|
---|
48 | void MainFrame::OnSize(UINT nType, CSize size)
|
---|
49 | {
|
---|
50 | //mdiWindow->MoveWindow( 0, 0, size.cx, size.cy );
|
---|
51 | }
|
---|
52 |
|
---|
53 | ::LRESULT MainFrame::OnClose( ::UINT msg, ::WPARAM wParam, ::LPARAM lParam, ::BOOL& handled )
|
---|
54 | {
|
---|
55 | DestroyWindow();
|
---|
56 | return 0;
|
---|
57 | }
|
---|
58 | ::LRESULT MainFrame::OnDestroy( ::UINT msg, ::WPARAM wParam, ::LPARAM lParam, ::BOOL& handled )
|
---|
59 | {
|
---|
60 | mdiWindow->DestroyWindow();
|
---|
61 | delete mdiWindow;
|
---|
62 |
|
---|
63 | ::PostQuitMessage( 0 );
|
---|
64 |
|
---|
65 | return 0;
|
---|
66 | }
|
---|
67 |
|
---|
68 | void backup(void *dummy);
|
---|
69 | void MainFrame::OnTimer( UINT_PTR id )
|
---|
70 | {
|
---|
71 | switch( id )
|
---|
72 | {
|
---|
73 | case ID_TIMER_BACKUP:
|
---|
74 | _beginthread( backup, 0, 0 );
|
---|
75 | break;
|
---|
76 |
|
---|
77 | #ifndef THETEXT
|
---|
78 | case ID_DEBUGSAFTY:
|
---|
79 | {
|
---|
80 | //BasicCompiler.exeが強制終了しているかどうかを検証
|
---|
81 | extern CDebugger *pobj_Debugger;
|
---|
82 | pobj_Debugger->SaftyCheck();
|
---|
83 | break;
|
---|
84 | }
|
---|
85 | #endif
|
---|
86 | }
|
---|
87 | }
|
---|
88 |
|
---|
89 | void ResetState_EditMenu(void);
|
---|
90 | void MainFrame::OnDrawClipboard()
|
---|
91 | {
|
---|
92 | ResetState_EditMenu();
|
---|
93 | }
|
---|
94 |
|
---|
95 | void MenuAdvice(WPARAM msg);
|
---|
96 | void MainFrame::OnMenuSelect( UINT nItemID, UINT nFlags, CMenu menu )
|
---|
97 | {
|
---|
98 | MenuAdvice( nItemID );
|
---|
99 | }
|
---|
100 |
|
---|
101 | void MainFrame::OnInitMenu( CMenu menu )
|
---|
102 | {
|
---|
103 | extern CNonVolatile *pobj_nv;
|
---|
104 | extern CSubMenuEx *pobj_FileHistoryMenu;
|
---|
105 | pobj_nv->pobj_History->ResetFileMenu(pobj_FileHistoryMenu,1);
|
---|
106 | #ifndef THETEXT
|
---|
107 | extern CSubMenuEx *pobj_ProjectHistoryMenu;
|
---|
108 | pobj_nv->pobj_ProjectHistory->ResetFileMenu(pobj_ProjectHistoryMenu,0);
|
---|
109 | #endif
|
---|
110 | }
|
---|
111 |
|
---|
112 | void MainFrame::OnMeasureItem( int nIDCtl, LPMEASUREITEMSTRUCT lpMI )
|
---|
113 | {
|
---|
114 | if(lpMI->CtlType==ODT_MENU){
|
---|
115 | SIZE size;
|
---|
116 | CMenuItemData *pobj_MenuItemData;
|
---|
117 | pobj_MenuItemData=(CMenuItemData *)lpMI->itemData;
|
---|
118 | if(pobj_MenuItemData->pobj_ThisMenu->hMenu==pobj_MainMenu->hMenu){
|
---|
119 | //メインメニューの親アイテム
|
---|
120 | pobj_MainMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
|
---|
121 | lpMI->itemWidth = size.cx;
|
---|
122 | lpMI->itemHeight = size.cy;
|
---|
123 | }
|
---|
124 | else{
|
---|
125 | //メインメニューにぶらさがるサブメニュー
|
---|
126 | pobj_MenuItemData->pobj_ThisMenu->GetItemSize(pobj_MenuItemData->item_index,&size);
|
---|
127 | lpMI->itemWidth = size.cx;
|
---|
128 | lpMI->itemHeight = size.cy;
|
---|
129 | }
|
---|
130 | }
|
---|
131 | }
|
---|
132 |
|
---|
133 | void MainFrame::OnDrawItem( int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct )
|
---|
134 | {
|
---|
135 | if(lpDrawItemStruct->CtlType==ODT_MENU){
|
---|
136 | if(!pobj_MainMenu) return;
|
---|
137 |
|
---|
138 | CMenuItemData *pobj_MenuItemData;
|
---|
139 | pobj_MenuItemData=(CMenuItemData *)lpDrawItemStruct->itemData;
|
---|
140 | if(pobj_MainMenu->hMenu==pobj_MenuItemData->pobj_ThisMenu->hMenu){
|
---|
141 | //メインメニューの親アイテム
|
---|
142 | pobj_MainMenu->OwnerDrawMenu(lpDrawItemStruct->hDC,
|
---|
143 | &lpDrawItemStruct->rcItem,
|
---|
144 | (lpDrawItemStruct->itemState&ODS_SELECTED)!=0,
|
---|
145 | pobj_MenuItemData->item_index);
|
---|
146 | }
|
---|
147 | else{
|
---|
148 | //メインメニューにぶらさがるサブメニュー
|
---|
149 | pobj_MainMenu->OwnerDrawSubMenu(pobj_MenuItemData->pobj_ThisMenu->hMenu,
|
---|
150 | lpDrawItemStruct->hDC,
|
---|
151 | &lpDrawItemStruct->rcItem,
|
---|
152 | (lpDrawItemStruct->itemState&ODS_SELECTED)!=0,
|
---|
153 | pobj_MenuItemData->item_index);
|
---|
154 | }
|
---|
155 | }
|
---|
156 | }
|
---|
157 |
|
---|
158 | LRESULT MainFrame::OnNotify( int idCtrl, LPNMHDR pnmh )
|
---|
159 | {
|
---|
160 | NMPGCALCSIZE *lpCalcSize;
|
---|
161 | NMPGSCROLL *lpScroll;
|
---|
162 |
|
---|
163 | if(!pnmh) return 0;
|
---|
164 | LPTOOLTIPTEXT TipText=(LPTOOLTIPTEXT)pnmh;
|
---|
165 | if(TipText->hdr.code==TTN_NEEDTEXT) ShowToolTipText(TipText);
|
---|
166 |
|
---|
167 | extern HWND hStandardToolbarPager;
|
---|
168 | extern HWND hDebuggerToolbarPager;
|
---|
169 | if(pobj_Rebar){
|
---|
170 | //レバーオブジェクトが存在するとき
|
---|
171 | if(pnmh->hwndFrom==pobj_Rebar->hRebar&&pnmh->code==RBN_HEIGHTCHANGE){
|
---|
172 | ResizeOwnerWnd();
|
---|
173 | return 0;
|
---|
174 | }
|
---|
175 | }
|
---|
176 | if(pnmh->hwndFrom==hStandardToolbarPager){
|
---|
177 | if(pnmh->code==PGN_CALCSIZE){
|
---|
178 | lpCalcSize=(LPNMPGCALCSIZE)pnmh;
|
---|
179 | if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
|
---|
180 | lpCalcSize->iWidth=BMPNUM_STANDARDTOOLBAR*23+SEPNUM_STANDARDTOOLBAR*8;
|
---|
181 | }
|
---|
182 | else if(pnmh->code==PGN_SCROLL){
|
---|
183 | lpScroll=(LPNMPGSCROLL)pnmh;
|
---|
184 | lpScroll->iScroll=20;
|
---|
185 | }
|
---|
186 | }
|
---|
187 | else if(pnmh->hwndFrom==hDebuggerToolbarPager){
|
---|
188 | if(pnmh->code==PGN_CALCSIZE){
|
---|
189 | lpCalcSize=(LPNMPGCALCSIZE)pnmh;
|
---|
190 | if(lpCalcSize->dwFlag==PGF_CALCWIDTH)
|
---|
191 | lpCalcSize->iWidth=BMPNUM_DEBUGGERTOOLBAR*23+SEPNUM_DEBUGGERTOOLBAR*8;
|
---|
192 | }
|
---|
193 | else if(pnmh->code==PGN_SCROLL){
|
---|
194 | lpScroll=(LPNMPGSCROLL)pnmh;
|
---|
195 | lpScroll->iScroll=20;
|
---|
196 | }
|
---|
197 | }
|
---|
198 |
|
---|
199 | if(pobj_MainTab){
|
---|
200 | if(pnmh->hwndFrom==pobj_MainTab->hTab){
|
---|
201 | if(pnmh->code==TCN_SELCHANGE)
|
---|
202 | pobj_MainTab->SelChangeEvent();
|
---|
203 |
|
---|
204 | if(pnmh->code==NM_RCLICK){
|
---|
205 |
|
---|
206 | TCHITTESTINFO tcHitTest;
|
---|
207 | GetCursorPos(&tcHitTest.pt);
|
---|
208 | ::ScreenToClient(pobj_MainTab->hTab,&tcHitTest.pt);
|
---|
209 | int index = TabCtrl_HitTest(pobj_MainTab->hTab,&tcHitTest);
|
---|
210 | if( index == -1 ) return 0;
|
---|
211 |
|
---|
212 | TabCtrl_SetCurSel(pobj_MainTab->hTab,index);
|
---|
213 |
|
---|
214 | pobj_MainTab->SelChangeEvent();
|
---|
215 |
|
---|
216 |
|
---|
217 | /////////////////////
|
---|
218 | // メニューを表示
|
---|
219 | /////////////////////
|
---|
220 |
|
---|
221 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
222 | int WndNum=GetWndNum(hChild);
|
---|
223 |
|
---|
224 | //保存コマンドの文字列をセット
|
---|
225 | char temporary[1024], temp2[1024];
|
---|
226 | MENUITEMINFO mii;
|
---|
227 | mii.cbSize=sizeof(MENUITEMINFO);
|
---|
228 | mii.fMask=MIIM_TYPE;
|
---|
229 | mii.dwTypeData=temporary;
|
---|
230 | mii.fType=MFT_STRING;
|
---|
231 | if(MdiInfo[WndNum].path[0]){
|
---|
232 | _splitpath(MdiInfo[WndNum].path,NULL,NULL,temporary,temp2);
|
---|
233 | lstrcat(temporary,temp2);
|
---|
234 | lstrcat(temporary," を保存(&S)");
|
---|
235 | }
|
---|
236 | else{
|
---|
237 | lstrcpy(temporary,"保存(&S)");
|
---|
238 | }
|
---|
239 | extern HMENU hTabMenu;
|
---|
240 | SetMenuItemInfo(hTabMenu,IDM_SAVE,FALSE,&mii);
|
---|
241 |
|
---|
242 | /*「絶対パスをコピー」「フォルダを開く」「ファイルを削除」
|
---|
243 | コマンドを場合によって無効化にする */
|
---|
244 | if(MdiInfo[WndNum].path[0]){
|
---|
245 | EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_ENABLED);
|
---|
246 | EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_ENABLED);
|
---|
247 | EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_ENABLED);
|
---|
248 | }
|
---|
249 | else{
|
---|
250 | EnableMenuItem(hTabMenu,IDM_PATH_COPY,MF_BYCOMMAND|MF_GRAYED);
|
---|
251 | EnableMenuItem(hTabMenu,IDM_FOLDER_OPEN,MF_BYCOMMAND|MF_GRAYED);
|
---|
252 | EnableMenuItem(hTabMenu,IDM_DELETE_FILE,MF_BYCOMMAND|MF_GRAYED);
|
---|
253 | }
|
---|
254 |
|
---|
255 | POINT MousePos;
|
---|
256 | GetCursorPos(&MousePos);
|
---|
257 | TrackPopupMenu(hTabMenu,TPM_LEFTALIGN|TPM_RIGHTBUTTON,MousePos.x,MousePos.y,0,hOwner,NULL);
|
---|
258 | }
|
---|
259 | }
|
---|
260 | }
|
---|
261 | if(pobj_SideWeb){
|
---|
262 | if(pnmh->hwndFrom==pobj_SideWeb->hTab&&pnmh->code==TCN_SELCHANGE){
|
---|
263 | pobj_SideWeb->SelChangeEvent();
|
---|
264 | }
|
---|
265 | }
|
---|
266 |
|
---|
267 | return 0;
|
---|
268 | }
|
---|
269 |
|
---|
270 | void MainFrame::OnCmdNew( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
271 | {
|
---|
272 |
|
---|
273 | #ifdef THETEXT
|
---|
274 | NewTextEditWindow(NULL,WNDTYPE_TEXT);
|
---|
275 | return;
|
---|
276 | #else
|
---|
277 | int FileType;
|
---|
278 | BOOL bAddToProject;
|
---|
279 | char temporary[MAX_PATH];
|
---|
280 |
|
---|
281 | FileType=DialogBox(hResInst,MAKEINTRESOURCE(IDD_NEWFILE),hOwner,(DLGPROC)DlgNewFile);
|
---|
282 | if(FileType==-1) return;
|
---|
283 |
|
---|
284 | if(FileType&0x00008000){
|
---|
285 | bAddToProject=1;
|
---|
286 | FileType&=0x0FFF;
|
---|
287 | extern char NewFileName[MAX_PATH];
|
---|
288 | lstrcpy(temporary,NewFileName);
|
---|
289 | if(!strstr(temporary,".")) lstrcat(temporary,".ab");
|
---|
290 | GetFullPath(temporary,ProjectInfo.dir);
|
---|
291 | }
|
---|
292 | else bAddToProject=0;
|
---|
293 |
|
---|
294 | switch(FileType){
|
---|
295 | case FT_BASICPROGRAM: //Basicプログラム
|
---|
296 | case FT_SUBPROGRAM:
|
---|
297 | if(bAddToProject){
|
---|
298 | WriteBuffer(temporary,0,0);
|
---|
299 | NewTextEditWindow(temporary,WNDTYPE_BASIC);
|
---|
300 | Project_File_Insert(temporary);
|
---|
301 | }
|
---|
302 | else NewTextEditWindow(NULL,WNDTYPE_BASIC);
|
---|
303 | break;
|
---|
304 |
|
---|
305 | case FT_PROJECT:
|
---|
306 | DlgNewProjectWizard(hOwner);
|
---|
307 | break;
|
---|
308 |
|
---|
309 | case FT_TEXT:
|
---|
310 | NewTextEditWindow(NULL,WNDTYPE_TEXT);
|
---|
311 | break;
|
---|
312 |
|
---|
313 | case FT_HTML:
|
---|
314 | NewTextEditWindow(NULL,WNDTYPE_HTML);
|
---|
315 | break;
|
---|
316 |
|
---|
317 | case FT_ICON:
|
---|
318 | NewIconEditWindow(NULL);
|
---|
319 | break;
|
---|
320 | }
|
---|
321 | #endif
|
---|
322 | }
|
---|
323 |
|
---|
324 | void MainFrame::OnCmdOpen( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
325 | {
|
---|
326 | //"ファイルを指定してください"
|
---|
327 | extern LPSTR DefFileFilter;
|
---|
328 | char temporary[1024];
|
---|
329 | if(!GetFilePathDialog(m_hWnd,temporary,DefFileFilter,STRING_FILEOPENTITLE_DEFAULT,TRUE)) return;
|
---|
330 |
|
---|
331 | OpenFileWithExtension( temporary );
|
---|
332 | }
|
---|
333 |
|
---|
334 | void MainFrame::OnCmdClose( UINT uNotifyCode, int nID, CWindow wndCtl )
|
---|
335 | {
|
---|
336 | HWND hChild=::GetWindow(hClient,GW_CHILD);
|
---|
337 | if(::IsWindow(hChild)) SendMessage(hChild,WM_CLOSE,0,0);
|
---|
338 | }
|
---|