source: dev/trunk/abdev/ProjectEditor/SubOperation.cpp@ 369

Last change on this file since 369 was 364, checked in by dai_9181, 17 years ago

Throw→Catch間のパラメータ引渡しに対応。
グローバル領域でのTryスコープを可能にした。これで例外処理機構実装完了。
エディタの補間機能にTry/Catch/Finally/EndTryを追加。

File size: 42.8 KB
Line 
1#include "Common.h"
2
3
4void ScreenToClient(HWND hwnd,RECT *pRect){
5 ScreenToClient(hwnd,(POINT *)pRect);
6 ScreenToClient(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
7}
8void ClientToScreen(HWND hwnd,RECT *pRect){
9 ClientToScreen(hwnd,(POINT *)pRect);
10 ClientToScreen(hwnd,(POINT *)(((long)(void *)pRect)+sizeof(POINT)));
11}
12
13
14typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE hProcess,PBOOL Wow64Process);
15BOOL IsWow64(void){
16 ///////////////////////////////////////////////////////////
17 // ProjectEditor.exeがWOW64技術で動作しているのかどうか
18 ///////////////////////////////////////////////////////////
19 BOOL bIsWow64 = FALSE;
20 LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
21
22 if (NULL != fnIsWow64Process)
23 {
24 if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
25 {
26 // handle error
27 bIsWow64 = FALSE;
28 }
29 }
30 return bIsWow64;
31}
32
33void URLEncode(LPSTR pszSrc){
34 char *temp;
35 temp=(char *)malloc(65535);
36
37 int i,i2;
38 for (i = 0,i2=0; ; i++,i2++)
39 {
40 if(pszSrc[i]=='\0'){
41 temp[i2] = 0;
42 break;
43 }
44
45 // 英数字 _ . - は変換しないでそのまま
46 if (isalnum((BYTE)pszSrc[i]) || pszSrc[i] == '_' || pszSrc[i] == '.' || pszSrc[i] == '-'){
47 temp[i2] = pszSrc[i];
48 }
49 // それ以外は %3B のような形式に変換
50 else{
51 sprintf(temp+i2,"%%%02X", (BYTE)pszSrc[i]);
52 i2+=lstrlen(temp+i2);
53 i2--;
54 }
55 }
56
57 lstrcpy(pszSrc,temp);
58 free(temp);
59}
60
61void Digit(int num,char *buffer){
62 char temporary[255];
63 int i,iPos;
64
65 sprintf(temporary,"%d",abs(num));
66
67 //カンマが不要の場合は抜ける
68 if(lstrlen(temporary)<=3){
69 wsprintf(buffer,"%d",num);
70 return;
71 }
72
73 //合計の文字数からバッファを確保
74 if(num<0){
75 buffer[0]='-';
76 iPos=1;
77 }
78 else{
79 buffer[0]=0;
80 iPos=0;
81 }
82
83 //3桁毎にカンマを加えながら文字列をコピーする
84 int iFirst;
85 iFirst=lstrlen(temporary)%3;
86 if(iFirst==0) iFirst=3;
87 memcpy(buffer+iPos,temporary,iFirst);
88 iPos+=iFirst;
89
90 int i2;
91 i2=(lstrlen(temporary)-4)/3;
92
93 for(i=0;i<=i2;i++){
94 buffer[iPos]=',';
95 iPos++;
96 memcpy(buffer+iPos,temporary+i*3+iFirst,3);
97 iPos+=3;
98 buffer[iPos]=0;
99 }
100}
101
102void RectNaturalFormat(RECT *ReadRect,RECT *CopyRect){
103 if(ReadRect->left > ReadRect->right){
104 CopyRect->left=ReadRect->right;
105 CopyRect->right=ReadRect->left;
106 }
107 else{
108 CopyRect->left=ReadRect->left;
109 CopyRect->right=ReadRect->right;
110 }
111 if(ReadRect->top > ReadRect->bottom){
112 CopyRect->top=ReadRect->bottom;
113 CopyRect->bottom=ReadRect->top;
114 }
115 else{
116 CopyRect->top=ReadRect->top;
117 CopyRect->bottom=ReadRect->bottom;
118 }
119}
120void RectNaturalFormat(int *x1,int *y1,int *x2,int *y2){
121 int temp;
122 if(*x1>*x2){
123 temp=*x1;
124 *x1=*x2;
125 *x2=temp;
126 }
127 if(*y1>*y2){
128 temp=*y1;
129 *y1=*y2;
130 *y2=temp;
131 }
132}
133void KillSpaces(char *str1,char *str2){
134 int i,i2,IsStr;
135 for(i=0,i2=0,IsStr=0;;i++,i2++){
136 while((str1[i]==' '||str1[i]=='\t')&&IsStr==0&&str1[i]!='\0') i++;
137 if(str1[i]=='\"') IsStr^=1;
138 str2[i2]=str1[i];
139 if(str1[i]=='\0') break;
140 }
141}
142void RemoveStringQuotes(char *str){
143 int i;
144 if(str[0]!='\"') return;
145 for(i=0;;i++){
146 str[i]=str[i+1];
147 if(str[i]=='\"') break;
148 }
149 str[i]=0;
150}
151void SlideString(char *buffer, int slide){
152 char *temp;
153 temp=(char *)malloc(lstrlen(buffer)+1);
154 lstrcpy(temp,buffer);
155 lstrcpy(buffer+slide,temp);
156 free(temp);
157}
158void SlideBuffer(char *buffer,int length,int slide){
159 void *temp;
160 temp=malloc(length+1);
161 memcpy(temp,buffer,length);
162 memcpy(buffer+slide,temp,length);
163 free(temp);
164}
165BOOL IsVariableTopChar(char c){
166 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_') return 1;
167 return 0;
168}
169bool IsNumberChar( char c ){
170 if(c>='0'&&c<='9'){
171 return true;
172 }
173 return false;
174}
175BOOL IsVariableChar(char c){
176 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||
177 c=='_'||c=='.'||c=='$') return 1;
178 return 0;
179}
180
181BOOL IsCommandBackDelimitation(char *buffer,int pos){
182 if(buffer[pos]=='\n'||buffer[pos]==':') return 1;
183 return 0;
184}
185BOOL IsCommandDelimitation(char *buffer,int p){
186 if(buffer[p]=='\r'&&buffer[p+1]=='\n') return 2;
187 if(buffer[p]=='\n'||buffer[p]==':'||buffer[p]=='\0') return 1;
188 return 0;
189}
190
191char *ComparisonString( char *str1, char *str2, bool isBigSmall, bool isWordUnit ){
192 char *temp1 = (char *)malloc( lstrlen( str1 ) +1 );
193 char *temp2 = (char *)malloc( lstrlen( str2 ) +1 );
194
195 lstrcpy( temp1, str1 );
196 lstrcpy( temp2, str2 );
197
198 if( isBigSmall == false ){
199 // 大文字小文字を区別しない場合
200 // すべて大文字にしておく
201 CharUpper( temp1 );
202 CharUpper( temp2 );
203 }
204
205 int len2 = lstrlen( temp2 );
206
207 const char *temp3 = strstr( temp1, temp2 );
208 while( temp3 ){
209 if( isWordUnit ){
210 int pos = (int)temp3 - (int)temp1;
211 if( pos == 0 ){
212 if( !( IsVariableTopChar( temp1[len2] ) || IsNumberChar( temp1[len2] ) ) ){
213 break;
214 }
215 }
216 else{
217 if( !( IsVariableTopChar( temp1[pos-1] ) || IsNumberChar( temp1[pos-1] ) )
218 && !( IsVariableTopChar( temp1[pos+len2] ) || IsNumberChar( temp1[pos+len2] ) )
219 ){
220 break;
221 }
222 }
223 }
224 else{
225 break;
226 }
227
228 temp3 = strstr( temp3 + 1, temp2 );
229 }
230
231 char *result = NULL;
232 if( temp3 ){
233 int pos = (int)temp3 - (int)temp1;
234 result = str1 + pos;
235 }
236
237 free( temp1 );
238 free( temp2 );
239
240 return result;
241}
242int GetOneParameter(char *Parameter,int pos,char *retAns){
243 int i,i2,IsStr,PareNum;
244 for(i=pos,i2=0,IsStr=0,PareNum=0;;i++,i2++){
245 if(IsDBCSLeadByte(Parameter[i])){
246 retAns[i2]=Parameter[i];
247 retAns[++i2]=Parameter[++i];
248 continue;
249 }
250 if(Parameter[i]=='\"') IsStr^=1;
251 if(Parameter[i]=='('&&IsStr==0) PareNum++;
252 if(Parameter[i]==')'&&IsStr==0) PareNum--;
253 if(Parameter[i]==','&&IsStr==0&&PareNum==0){
254 retAns[i2]=0;
255 break;
256 }
257 retAns[i2]=Parameter[i];
258 if(Parameter[i]=='\0'||Parameter[i]=='\r'&&Parameter[i+1]=='\n'){
259 retAns[i2]=0;
260 break;
261 }
262 }
263 if(Parameter[i]==',') i++;
264 return i;
265}
266int GetStringInPare(char *buffer,char *ReadBuffer){
267 int i,IsStr,PareNum;
268 for(i=0,IsStr=0,PareNum=0;;i++){
269 buffer[i]=ReadBuffer[i];
270 if(ReadBuffer[i]=='\"') IsStr^=1;
271 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
272 else if(ReadBuffer[i]==')'&&IsStr==0){
273 PareNum--;
274 if(PareNum==0){
275 i++;
276 buffer[i]=0;
277 break;
278 }
279 }
280 else if(ReadBuffer[i]=='\0') return 0;
281 }
282 return i;
283}
284int GetStringInBracket(char *buffer,char *ReadBuffer){
285 int i,IsStr,PareNum;
286 for(i=0,IsStr=0,PareNum=0;;i++){
287 buffer[i]=ReadBuffer[i];
288 if(IsDBCSLeadByte(ReadBuffer[i])){
289 i++;
290 buffer[i]=ReadBuffer[i];
291 continue;
292 }
293 if(ReadBuffer[i]=='\"') IsStr^=1;
294 else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;
295 else if(ReadBuffer[i]==']'&&IsStr==0){
296 PareNum--;
297 if(PareNum==0){
298 i++;
299 buffer[i]=0;
300 break;
301 }
302 }
303 else if(ReadBuffer[i]=='\0') return 0;
304 }
305 return i;
306}
307void JumpBlank(char *pBuf,int *piPos){
308 int i;
309 i=*piPos;
310
311 while(1){
312 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
313 if(pBuf[i]=='\0') break;
314 if(pBuf[i]=='\''){
315 //注釈文(一行)
316 for(i++;;i++){
317 if(pBuf[i]=='\0') break;
318 if(pBuf[i]=='\r'&&pBuf[i+1]=='\n'){
319 i+=2;
320 break;
321 }
322 }
323 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
324 }
325 if(pBuf[i]=='/'&&pBuf[i+1]=='*'){
326 //注釈文(複数行)
327 i+=2;
328 while(!(pBuf[i]=='*'&&pBuf[i+1]=='/')){
329 i++;
330 if(pBuf[i]=='\0') break;
331 }
332 if(pBuf[i]){
333 i+=2;
334 }
335 }
336 while(pBuf[i]=='\r'&&pBuf[i+1]=='\n') i+=2;
337
338 if(!(
339 pBuf[i]==' '||
340 pBuf[i]=='\t'||
341 pBuf[i]=='\''||
342 (pBuf[i]=='/'&&pBuf[i+1]=='*')
343 )) break;
344 }
345
346 *piPos=i;
347}
348
349BOOL CheckParenthesis(char *buffer){
350 int i,IsStr,PareNum,sw;
351 _int8 bracket[1024];
352
353 for(i=0,IsStr=0,PareNum=0,sw=0;;i++){
354 if(buffer[i]=='\"'){
355 IsStr^=1;
356 continue;
357 }
358
359 else if(buffer[i]=='('&&IsStr==0){
360 bracket[PareNum]=0;
361 PareNum++;
362 }
363 else if(buffer[i]=='['&&IsStr==0){
364 bracket[PareNum]=1;
365 PareNum++;
366 }
367
368 else if(buffer[i]==')'&&IsStr==0){
369 PareNum--;
370 if(bracket[PareNum]!=0||PareNum<0){
371 //"カッコ \'( )\'"
372 return 0;
373 }
374 }
375 else if(buffer[i]==']'&&IsStr==0){
376 PareNum--;
377 if(bracket[PareNum]!=1||PareNum<0){
378 //"カッコ \'( )\'"
379 return 0;
380 }
381 }
382
383 else if(buffer[i]=='\n'||buffer[i]=='\0'){
384
385 //"カッコ \'( )\'"
386 if(buffer[i]=='\0'){
387 if(PareNum!=0){
388 return 0;
389 }
390
391 if(IsStr!=0){
392 return 0;
393 }
394 }
395 if(buffer[i]=='\0') break;
396
397 sw=0;
398 }
399 }
400 return 1;
401}
402
403DWORD GetValue(char *value){
404 unsigned long ans;
405 if(value[0]=='&'){
406 if(value[1]=='o'||value[1]=='O') sscanf(value+2,"%o",&ans);
407 if(value[1]=='h'||value[1]=='H') sscanf(value+2,"%x",&ans);
408 }
409 else ans=atol(value);
410 return ans;
411}
412BOOL IsManagementCommand(int ComNum){
413 switch(ComNum){
414 case -1:
415 case COM_ABSTRACT:
416 case COM_CLASS:
417 case COM_CONST:
418 case COM_DEBUG:
419 case COM_DECLARE:
420 case COM_DEF:
421 case COM_DIM:
422 case COM_DO:
423 case COM_END:
424 case COM_ENUM:
425 case COM_FOR:
426 case COM_FUNCTION:
427 case COM_GOSUB:
428 case COM_GOTO:
429 case COM_IF:
430 case COM_INHERITS:
431 case COM_INTERFACE:
432 case COM_LOOP:
433 case COM_NAMESPACE:
434 case COM_NEXT:
435 case COM_PRIVATE:
436 case COM_PROTECTED:
437 case COM_PUBLIC:
438 case COM_RETURN:
439 case COM_SELECT:
440 case COM_SUB:
441 case COM_TRY:
442 case COM_TYPE:
443 case COM_TYPEDEF:
444 case COM_VIRTUAL:
445 case COM_OVERRIDE:
446 case COM_WEND:
447 case COM_WHILE:
448 case COM_WITH:
449 return 1;
450 default:
451 break;
452 }
453 return 0;
454}
455int IsBasicReservedWord(char *str){
456 if(str[0]=='a'||str[0]=='A'){
457 if(lstrcmpi(str,"Abstract")==0) return COM_ABSTRACT;
458 if(lstrcmpi(str,"As")==0) return -1;
459 }
460 else if(str[0]=='b'||str[0]=='B'){
461 if(lstrcmpi(str,"Beep")==0) return COM_BEEP;
462 if(lstrcmp(str,"Boolean")==0) return -1;
463 if(lstrcmpi(str,"ByRef")==0) return -1;
464 if(lstrcmpi(str,"ByVal")==0) return -1;
465 if(lstrcmp(str,"Byte")==0) return -1;
466 }
467 else if(str[0]=='c'||str[0]=='C'){
468 if(lstrcmpi(str,"Catch")==0) return -1;
469 if(lstrcmpi(str,"Case")==0) return -1;
470 if(lstrcmp(str,"Char")==0) return -1;
471 if(lstrcmpi(str,"ChDir")==0) return COM_CHDIR;
472 if(lstrcmpi(str,"Circle")==0) return COM_CIRCLE;
473 if(lstrcmpi(str,"Class")==0) return COM_CLASS;
474 if(lstrcmpi(str,"Close")==0) return COM_CLOSE;
475 if(lstrcmpi(str,"Cls")==0) return COM_CLS;
476 if(lstrcmpi(str,"Color")==0) return COM_COLOR;
477 if(lstrcmpi(str,"Const")==0) return COM_CONST;
478 if(lstrcmpi(str,"Continue")==0) return -1;
479 }
480 else if(str[0]=='d'||str[0]=='D'){
481 if(lstrcmpi(str,"Debug")==0) return COM_DEBUG;
482 if(lstrcmpi(str,"Declare")==0) return COM_DECLARE;
483 if(lstrcmpi(str,"Def")==0) return COM_DEF;
484 if(lstrcmpi(str,"Delete")==0) return -1;
485 if(lstrcmpi(str,"DelWnd")==0) return COM_DELWND;
486 if(lstrcmpi(str,"Dim")==0) return COM_DIM;
487 if(lstrcmpi(str,"Do")==0) return COM_DO;
488 if(lstrcmp(str,"Double")==0) return -1;
489 if(lstrcmp(str,"DWord")==0) return -1;
490 }
491 else if(str[0]=='e'||str[0]=='E'){
492 if(lstrcmpi(str,"Else")==0) return -1;
493 if(lstrcmpi(str,"ElseIf")==0) return -1;
494 if(lstrcmpi(str,"End")==0) return COM_END;
495 if(lstrcmpi(str,"EndIf")==0) return -1;
496 if(lstrcmpi(str,"EndFunction")==0) return -1;
497 if(lstrcmpi(str,"EndSub")==0) return -1;
498 if(lstrcmpi(str,"EndType")==0) return -1;
499 if(lstrcmpi(str,"EndSelect")==0) return -1;
500 if(lstrcmpi(str,"EndWith")==0) return -1;
501 if(lstrcmpi(str,"Enum")==0) return COM_ENUM;
502 if(lstrcmpi(str,"Exit")==0) return -1;
503 if(lstrcmpi(str,"ExitDo")==0) return -1;
504 if(lstrcmpi(str,"ExitFor")==0) return -1;
505 if(lstrcmpi(str,"ExitFunction")==0) return -1;
506 if(lstrcmpi(str,"ExitSub")==0) return -1;
507 if(lstrcmpi(str,"ExitWhile")==0) return -1;
508 }
509 else if(str[0]=='f'||str[0]=='F'){
510 if(lstrcmp(str,"False")==0) return -1;
511 if(lstrcmpi(str,"Field")==0) return COM_FIELD;
512 if(lstrcmpi(str,"Finally")==0) return -1;
513 if(lstrcmpi(str,"For")==0) return COM_FOR;
514 if(lstrcmpi(str,"Function")==0) return COM_FUNCTION;
515 }
516 else if(str[0]=='g'||str[0]=='G'){
517 if(lstrcmpi(str,"Get")==0) return COM_GET;
518 if(lstrcmpi(str,"GoSub")==0) return COM_GOSUB;
519 if(lstrcmpi(str,"Goto")==0) return COM_GOTO;
520 }
521 else if(str[0]=='i'||str[0]=='I'){
522 if(lstrcmpi(str,"If")==0) return COM_IF;
523 if(lstrcmpi(str,"Imports")==0) return -1;
524 if(lstrcmpi(str,"Implements")==0) return -1;
525 if(lstrcmpi(str,"Inherits")==0) return COM_INHERITS;
526 if(lstrcmpi(str,"Input")==0) return COM_INPUT;
527 if(lstrcmp(str,"Int64")==0) return -1;
528 if(lstrcmp(str,"Integer")==0) return -1;
529 if(lstrcmpi(str,"Interface")==0) return COM_INTERFACE;
530 }
531 else if(str[0]=='k'||str[0]=='K'){
532 if(lstrcmpi(str,"Kill")==0) return COM_KILL;
533 }
534 else if(str[0]=='l'||str[0]=='L'){
535 if(lstrcmpi(str,"Let")==0) return COM_LET;
536 if(lstrcmpi(str,"Line")==0) return COM_LINE;
537 if(lstrcmpi(str,"Locate")==0) return COM_LOCATE;
538 if(lstrcmp(str,"Long")==0) return -1;
539 if(lstrcmpi(str,"Loop")==0) return COM_LOOP;
540 }
541 else if(str[0]=='m'||str[0]=='M'){
542 if(lstrcmpi(str,"MkDir")==0) return COM_MKDIR;
543 if(lstrcmpi(str,"MsgBox")==0) return COM_MSGBOX;
544 }
545 else if(str[0]=='n'||str[0]=='N'){
546 if(lstrcmpi(str,"Namespace")==0) return COM_NAMESPACE;
547 if(lstrcmpi(str,"Next")==0) return COM_NEXT;
548 if(lstrcmpi(str,"New")==0) return -1;
549 if(lstrcmpi(str,"Nothing")==0) return -1;
550 }
551 else if(str[0]=='o'||str[0]=='O'){
552 if(lstrcmp(str,"Object")==0) return -1;
553 if(lstrcmpi(str,"Open")==0) return COM_OPEN;
554 if(lstrcmpi(str,"Operator")==0) return -1;
555 if(lstrcmpi(str,"Override")==0) return COM_OVERRIDE;
556 }
557 else if(str[0]=='p'||str[0]=='P'){
558 if(lstrcmpi(str,"Paint")==0) return COM_PAINT;
559 if(lstrcmpi(str,"Print")==0) return COM_PRINT;
560 if(lstrcmpi(str,"Private")==0) return COM_PRIVATE;
561 if(lstrcmpi(str,"Protected")==0) return COM_PROTECTED;
562 if(lstrcmpi(str,"PSet")==0) return COM_PSET;
563 if(lstrcmpi(str,"Put")==0) return COM_PUT;
564 if(lstrcmpi(str,"Public")==0) return COM_PUBLIC;
565 }
566 else if(str[0]=='q'||str[0]=='Q'){
567 if(lstrcmp(str,"QWord")==0) return -1;
568 }
569 else if(str[0]=='r'||str[0]=='R'){
570 if(lstrcmpi(str,"Randomize")==0) return COM_RANDOMIZE;
571 if(lstrcmpi(str,"Rem")==0) return COM_REM;
572 if(lstrcmpi(str,"Return")==0) return COM_RETURN;
573 }
574 else if(str[0]=='s'||str[0]=='S'){
575 if(lstrcmp(str,"SByte")==0) return -1;
576 if(lstrcmpi(str,"Select")==0) return COM_SELECT;
577 if(lstrcmpi(str,"SelectCase")==0) return COM_SELECT;
578 if(lstrcmp(str,"Single")==0) return -1;
579 if(lstrcmpi(str,"Sleep")==0) return COM_SLEEP;
580 if(lstrcmp(str,"Static")==0) return -1;
581 if(lstrcmp(str,"String")==0) return -1;
582 if(lstrcmpi(str,"Sub")==0) return COM_SUB;
583 if(lstrcmpi(str,"Super")==0) return -1;
584 }
585 else if(str[0]=='t'||str[0]=='T'){
586 if(lstrcmpi(str,"Then")==0) return -1;
587 if(lstrcmpi(str,"This")==0) return -1;
588 if(lstrcmpi(str,"Throw")==0) return -1;
589 if(lstrcmp(str,"True")==0) return -1;
590 if(lstrcmp(str,"Try")==0) return COM_TRY;
591 if(lstrcmpi(str,"Type")==0) return COM_TYPE;
592 if(lstrcmpi(str,"TypeDef")==0) return COM_TYPEDEF;
593 }
594 else if(str[0]=='u'||str[0]=='U'){
595 if(lstrcmpi(str,"Until")==0) return -1;
596 }
597 else if(str[0]=='v'||str[0]=='V'){
598 if(lstrcmpi(str,"Virtual")==0) return COM_VIRTUAL;
599 }
600 else if(str[0]=='w'||str[0]=='W'){
601 if(lstrcmpi(str,"Wend")==0) return COM_WEND;
602 if(lstrcmpi(str,"While")==0) return COM_WHILE;
603 if(lstrcmpi(str,"Window")==0) return COM_WINDOW;
604 if(lstrcmpi(str,"With")==0) return COM_WITH;
605 if(lstrcmp(str,"Word")==0) return -1;
606 if(lstrcmpi(str,"Write")==0) return COM_WRITE;
607 }
608 else if(str[0]=='#'){
609 if(lstrcmpi(str,"#include")==0) return -1;
610 if(lstrcmpi(str,"#strict")==0) return -1;
611 if(lstrcmpi(str,"#console")==0) return -1;
612 if(lstrcmpi(str,"#prompt")==0) return -1;
613 if(lstrcmpi(str,"#N88BASIC")==0) return -1;
614 if(lstrcmpi(str,"#define")==0) return -1;
615 if(lstrcmpi(str,"#ifdef")==0) return -1;
616 if(lstrcmpi(str,"#ifndef")==0) return -1;
617 if(lstrcmpi(str,"#else")==0) return -1;
618 if(lstrcmpi(str,"#endif")==0) return -1;
619 }
620 return 0;
621}
622
623HBITMAP CreateGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
624 //グラデーションビットマップを生成
625
626 BITMAPINFO BitmapInfo;
627 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
628 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
629 BitmapInfo.bmiHeader.biWidth=pSize->cx;
630 BitmapInfo.bmiHeader.biHeight=pSize->cy;
631 BitmapInfo.bmiHeader.biPlanes=1;
632 BitmapInfo.bmiHeader.biBitCount=24;
633
634 HDC hdc;
635 hdc=GetDC(GetDesktopWindow());
636
637 HBITMAP hBitmap;
638 BYTE *pByte;
639 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
640
641 int i,i2,x,y;
642 COLORREF rgb;
643 i=BitmapInfo.bmiHeader.biWidth*3;
644 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
645 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
646 if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
647 else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
648 else{
649 double ratio;
650 ratio=((double)y-((double)BitmapInfo.bmiHeader.biHeight/(double)2-(double)2))/(double)4;
651 //ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
652 rgb=RGB(
653 LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
654 HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
655 LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
656 );
657 }
658 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
659 i2=y*i+x*3;
660 pByte[i2+2]=LOBYTE(LOWORD(rgb));
661 pByte[i2+1]=HIBYTE(LOWORD(rgb));
662 pByte[i2]=LOBYTE(HIWORD(rgb));
663 }
664 }
665
666 ReleaseDC(GetDesktopWindow(),hdc);
667
668 return hBitmap;
669}
670HBITMAP CreateVertGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
671 //グラデーションビットマップを生成
672
673 BITMAPINFO BitmapInfo;
674 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
675 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
676 BitmapInfo.bmiHeader.biWidth=pSize->cx;
677 BitmapInfo.bmiHeader.biHeight=pSize->cy;
678 BitmapInfo.bmiHeader.biPlanes=1;
679 BitmapInfo.bmiHeader.biBitCount=24;
680
681 HDC hdc;
682 hdc=GetDC(GetDesktopWindow());
683
684 HBITMAP hBitmap;
685 BYTE *pByte;
686 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
687
688 int i,i2,x,y;
689 COLORREF rgb;
690 i=BitmapInfo.bmiHeader.biWidth*3;
691 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
692 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
693 if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
694 else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
695 else{
696 double ratio;
697 ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
698 rgb=RGB(
699 LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
700 HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
701 LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
702 );
703 }
704 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
705 i2=y*i+x*3;
706 pByte[i2+2]=LOBYTE(LOWORD(rgb));
707 pByte[i2+1]=HIBYTE(LOWORD(rgb));
708 pByte[i2]=LOBYTE(HIWORD(rgb));
709 }
710 }
711
712 ReleaseDC(GetDesktopWindow(),hdc);
713
714 return hBitmap;
715}
716HBITMAP CreateHorzGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
717 //グラデーションビットマップを生成
718
719 BITMAPINFO BitmapInfo;
720 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
721 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
722 BitmapInfo.bmiHeader.biWidth=pSize->cx;
723 BitmapInfo.bmiHeader.biHeight=pSize->cy;
724 BitmapInfo.bmiHeader.biPlanes=1;
725 BitmapInfo.bmiHeader.biBitCount=24;
726
727 HDC hdc;
728 hdc=GetDC(GetDesktopWindow());
729
730 HBITMAP hBitmap;
731 BYTE *pByte;
732 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
733
734 int i,i2,x,y;
735 COLORREF rgb;
736 i=BitmapInfo.bmiHeader.biWidth*3;
737 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
738 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
739 double ratio;
740 ratio=(double)x/(double)BitmapInfo.bmiHeader.biWidth;
741 rgb=RGB(
742 LOBYTE(LOWORD(color1))+(int)(double)(LOBYTE(LOWORD(color2))-LOBYTE(LOWORD(color1)))*(ratio), //赤要素
743 HIBYTE(LOWORD(color1))+(int)(double)(HIBYTE(LOWORD(color2))-HIBYTE(LOWORD(color1)))*(ratio), //緑要素
744 LOBYTE(HIWORD(color1))+(int)(double)(LOBYTE(HIWORD(color2))-LOBYTE(HIWORD(color1)))*(ratio) //青要素
745 );
746 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
747 i2=y*i+x*3;
748 pByte[i2+2]=LOBYTE(LOWORD(rgb));
749 pByte[i2+1]=HIBYTE(LOWORD(rgb));
750 pByte[i2]=LOBYTE(HIWORD(rgb));
751 }
752 }
753
754 ReleaseDC(GetDesktopWindow(),hdc);
755
756 return hBitmap;
757}
758HICON CreateGrayIcon(HICON hBaseIcon){
759 ////////////////////////
760 // 淡色アイコンを生成
761 ////////////////////////
762
763 HICON hGrayIcon;
764
765 ICONINFO IconInfo;
766 GetIconInfo(hBaseIcon,&IconInfo);
767
768
769 //ビットマップを加工
770 BITMAP Bitmap;
771 GetObject(IconInfo.hbmColor,sizeof(Bitmap),&Bitmap);
772
773 BITMAPINFO BitmapInfo;
774 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
775 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
776 BitmapInfo.bmiHeader.biWidth=Bitmap.bmWidth;
777 BitmapInfo.bmiHeader.biHeight=Bitmap.bmHeight;
778 BitmapInfo.bmiHeader.biPlanes=1;
779 BitmapInfo.bmiHeader.biBitCount=24;
780 BitmapInfo.bmiHeader.biCompression=BI_RGB;
781
782 HDC hdc;
783 hdc=GetDC(GetDesktopWindow());
784
785 BYTE *pByte;
786 pByte=(BYTE *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
787 GetDIBits(hdc,
788 IconInfo.hbmColor,
789 0,
790 Bitmap.bmHeight,
791 (void *)pByte,
792 &BitmapInfo,
793 DIB_RGB_COLORS);
794
795 int i,i2,x,y;
796 i=BitmapInfo.bmiHeader.biWidth*3;
797 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
798 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
799 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
800 i2=y*i+x*3;
801 if(pByte[i2+2]==0&&pByte[i2+1]==0&&pByte[i2]==0){
802 //透明色
803 //何もしない
804 }
805 else{
806 double ratio=0.5; //明るさ
807
808 pByte[i2+2]+=(BYTE)((double)(255-pByte[i2+2])*ratio);
809 pByte[i2+1]+=(BYTE)((double)(255-pByte[i2+1])*ratio);
810 pByte[i2]+=(BYTE)((double)(255-pByte[i2])*ratio);
811
812 pByte[i2+2]=(BYTE)(((int)pByte[i2+2]+(int)pByte[i2+1]+(int)pByte[i2])/3);
813 pByte[i2+1]=pByte[i2+2];
814 pByte[i2]=pByte[i2+2];
815 }
816 }
817 }
818
819 SetDIBits(hdc,
820 IconInfo.hbmColor,
821 0,
822 Bitmap.bmHeight,
823 (void *)pByte,
824 &BitmapInfo,
825 DIB_RGB_COLORS);
826
827 HeapDefaultFree(pByte);
828
829 ReleaseDC(GetDesktopWindow(),hdc);
830
831
832 hGrayIcon=CreateIconIndirect(&IconInfo);
833
834 //不要なビットマップを破棄
835 DeleteObject(IconInfo.hbmMask);
836 DeleteObject(IconInfo.hbmColor);
837
838 return hGrayIcon;
839}
840void GetSize(SIZE *pSize,RECT *pRect){
841 pSize->cx=pRect->right-pRect->left;
842 pSize->cy=pRect->bottom-pRect->top;
843}
844BOOL HitTest(RECT *pRect,POINT *pPos){
845 if(pRect->left<=pPos->x&&pPos->x<pRect->right&&
846 pRect->top<=pPos->y&&pPos->y<pRect->bottom) return 1;
847 return 0;
848}
849BOOL Rectangle(HDC hdc,RECT *pRect){
850 return Rectangle(hdc,pRect->left,pRect->top,pRect->right,pRect->bottom);
851}
852
853void ComboBox_SetSelText(HWND hCombo,char *lpszText){
854 SendMessage(hCombo,CB_SETCURSEL,
855 SendMessage(hCombo,CB_FINDSTRINGEXACT,0,(LPARAM)lpszText),
856 0);
857}
858
859void SetCursorByState(int state){
860 if(state==FRAME_UPPER_LEFT||state==FRAME_LOWER_RIGHT) SetCursor(LoadCursor(0,IDC_SIZENWSE));
861 else if(state==FRAME_UPPER_RIGHT||state==FRAME_LOWER_LEFT) SetCursor(LoadCursor(0,IDC_SIZENESW));
862 else if(state==FRAME_LEFT||state==FRAME_RIGHT) SetCursor(LoadCursor(0,IDC_SIZEWE));
863 else if(state==FRAME_UPPER||state==FRAME_LOWER) SetCursor(LoadCursor(0,IDC_SIZENS));
864 else if(state==FRAME_INSIDE) SetCursor(LoadCursor(0,IDC_SIZEALL));
865 else SetCursor(LoadCursor(0,IDC_ARROW));
866}
867
868void SetTextEditColorDesign(TEXTEDIT_COLOR_INFO *pColorInfo,CTheme *pobj_Theme,BOOL bRedraw){
869 pColorInfo->rgbDefault=pobj_Theme->TextColorInfo.rgbDefault;
870 pColorInfo->rgbComment=pobj_Theme->TextColorInfo.rgbComment;
871 pColorInfo->rgbStatement=pobj_Theme->TextColorInfo.rgbStatement;
872 pColorInfo->rgbString=pobj_Theme->TextColorInfo.rgbString;
873 pColorInfo->rgbCursorBack=pobj_Theme->TextColorInfo.rgbCursorBack;
874 pColorInfo->rgbBackground=pobj_Theme->TextColorInfo.rgbBackground;
875
876 //アクティブテーマにセット
877 lstrcpy(pobj_nv->szActiveTheme,pobj_Theme->m_name);
878
879 //テーマ依存の描画リソースを取得
880 pobj_DBTheme->unlock();
881 pobj_DBTheme->lock();
882
883 if(bRedraw){
884 //再描画
885 extern MDIINFO MdiInfo[MAX_WNDNUM];
886 int i;
887 for(i=0;i<MAX_WNDNUM;i++){
888 if(MdiInfo[i].hwnd){
889 if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
890 SetTextEditWordColor(i);
891 InvalidateRect(MdiInfo[i].pMdiTextEdit->hEdit,NULL,0);
892 }
893 }
894 }
895 }
896}
897
898BOOL SetupProjectEditor(void){
899 extern HINSTANCE hInst;
900 int i;
901 char str[MAX_PATH],temporary[MAX_PATH];
902
903
904 //リソース用DLLをマッピング
905#if defined(JPN)
906 //日本語リソース
907 sprintf(temporary,"%sSubOperation\\res.dll",pj_editor_Dir);
908#else
909 //英語リソース
910 sprintf(temporary,"%sSubOperation\\res_e.dll",pj_editor_Dir);
911#endif
912 hResInst=LoadLibrary(temporary);
913
914 //アイコンリソースDLLをマッピング
915 sprintf(temporary,"%sSubOperation\\icon_res.dll",pj_editor_Dir);
916 hIconResInst=LoadLibrary(temporary);
917
918 //LuxCtrl.dllをマッピング
919 sprintf(temporary,"%sSubOperation\\LuxCtrl.dll",pj_editor_Dir);
920 hLib_LuxCtrl=LoadLibrary(temporary);
921 if(!hLib_LuxCtrl){
922 MessageBox(0,"LuxCtrl.dllの読み込みに失敗しました。",APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
923 return 0;
924 }
925 LuxToolbar_CreateInstance=
926 (PROC_LuxToolbar_CreateInstance)GetProcAddress(hLib_LuxCtrl,"LuxToolbar_CreateInstance");
927
928
929 //モジュールディレクトリを取得
930 GetModuleFileName(hInst,temporary,MAX_PATH);
931 _splitpath(temporary,pj_editor_Dir,str,NULL,NULL);
932 lstrcat(pj_editor_Dir,str);
933
934 //ヒープオブジェクトを作成
935 extern HANDLE hHeap;
936 hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0);
937
938
939 //自動バックアップ用のディレクトリを生成
940 CreateBackupDir();
941
942
943 //COMを初期化
944 CoInitialize(0);
945
946 //スクリーンサイズを取得
947 ScreenX=GetSystemMetrics(SM_CXSCREEN);
948 ScreenY=GetSystemMetrics(SM_CYSCREEN);
949
950 //コンパイラ名をセット(デフォルトはWin32)
951 extern char *lpszCompilerName;
952 lpszCompilerName=WIN32_COMPILER_NAME;
953
954 //不揮発性のデータを取得
955 pobj_nv=new CNonVolatile;
956 pobj_nv->load();
957
958
959 //アルファブレンド用のAPIを取得
960 extern FWINLAYER pSetLayeredWindowAttributes;
961 extern HINSTANCE hUser32Lib;
962 hUser32Lib=LoadLibrary("user32.dll");
963 pSetLayeredWindowAttributes=(FWINLAYER)GetProcAddress(hUser32Lib,"pSetLayeredWindowAttributes");
964
965
966
967
968 /////////////////////
969 // フォントを定義
970 /////////////////////
971
972 //パラメータ ヒント フォント
973 extern METHODCHECKINFO MethodCheckInfo;
974 MethodCheckInfo.hFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
975 i=MethodCheckInfo.LogFont.lfWeight;
976 MethodCheckInfo.LogFont.lfWeight=FW_BOLD;
977 MethodCheckInfo.hBoldFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
978 MethodCheckInfo.LogFont.lfWeight=i;
979
980 //ステータスバー フォント
981 LOGFONT LogFont;
982 extern HFONT hStatusFont;
983 LogFont.lfHeight=-12;
984 LogFont.lfWidth=0;
985 LogFont.lfEscapement=0;
986 LogFont.lfOrientation=0;
987 LogFont.lfWeight=FW_REGULAR;
988 LogFont.lfItalic=NULL;
989 LogFont.lfUnderline=NULL;
990 LogFont.lfStrikeOut=NULL;
991 LogFont.lfCharSet=SHIFTJIS_CHARSET;
992 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
993 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
994 LogFont.lfQuality=DRAFT_QUALITY;
995 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
996 sprintf(LogFont.lfFaceName,"MS Pゴシック");
997 hStatusFont=CreateFontIndirect(&LogFont);
998
999 //ハイパーリンク フォント
1000 extern HFONT hHyperLinkFont;
1001 LogFont.lfHeight=-12;
1002 LogFont.lfWidth=0;
1003 LogFont.lfEscapement=0;
1004 LogFont.lfOrientation=0;
1005 LogFont.lfWeight=FW_REGULAR;
1006 LogFont.lfItalic=NULL;
1007 LogFont.lfUnderline=TRUE;
1008 LogFont.lfStrikeOut=NULL;
1009 LogFont.lfCharSet=SHIFTJIS_CHARSET;
1010 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1011 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1012 LogFont.lfQuality=DRAFT_QUALITY;
1013 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1014 sprintf(LogFont.lfFaceName,"MS Pゴシック");
1015 hHyperLinkFont=CreateFontIndirect(&LogFont);
1016
1017 //ルーラー フォント
1018 extern HFONT hRulerFont;
1019 LogFont.lfHeight=-10;
1020 LogFont.lfWidth=0;
1021 LogFont.lfEscapement=0;
1022 LogFont.lfOrientation=0;
1023 LogFont.lfWeight=FW_REGULAR;
1024 LogFont.lfItalic=NULL;
1025 LogFont.lfUnderline=0;
1026 LogFont.lfStrikeOut=NULL;
1027 LogFont.lfCharSet=SHIFTJIS_CHARSET;
1028 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1029 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1030 LogFont.lfQuality=DRAFT_QUALITY;
1031 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1032 sprintf(LogFont.lfFaceName,"MS ゴシック");
1033 hRulerFont=CreateFontIndirect(&LogFont);
1034
1035 //行番号の描画用
1036 extern HFONT hFont_LineNumber;
1037 LogFont.lfHeight=-11;
1038 LogFont.lfWidth=0;
1039 LogFont.lfEscapement=0;
1040 LogFont.lfOrientation=0;
1041 LogFont.lfWeight=FW_BOLD;
1042 LogFont.lfItalic=NULL;
1043 LogFont.lfUnderline=NULL;
1044 LogFont.lfStrikeOut=NULL;
1045 LogFont.lfCharSet=ANSI_CHARSET;
1046 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1047 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1048 LogFont.lfQuality=DRAFT_QUALITY;
1049 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1050 sprintf(LogFont.lfFaceName,"Courier New");
1051 hFont_LineNumber=CreateFontIndirect(&LogFont);
1052
1053 //メニューフォント
1054 NONCLIENTMETRICS NCMetrics;
1055 NCMetrics.cbSize = sizeof( NONCLIENTMETRICS );
1056 SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof( NONCLIENTMETRICS ), &NCMetrics, 0 );
1057 hMenuFont=CreateFontIndirect(&NCMetrics.lfMenuFont);
1058
1059
1060
1061 //背景ブラシ
1062 extern HBRUSH h3DFaceBackBrush;
1063 h3DFaceBackBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
1064
1065 //アイコン
1066 extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
1067 hOwnerIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1068 hBasicProgramIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_BASICPROGRAM),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1069 hTextDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1070 hWindowDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_WINDOW),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1071
1072
1073
1074
1075 //メインメニュー
1076 pobj_MainMenu=new CMenuEx(LoadMenu(hResInst,MAKEINTRESOURCE(IDR_MAINMENU)));
1077
1078 pobj_MainMenu->InitOwnerDraw(1); //オーナー描画の初期化
1079
1080 CSubMenuEx *pobj_FileMenu;
1081 pobj_FileMenu=pobj_MainMenu->ppobj_MenuItemData[0]->pobj_SubMenu;
1082
1083 //未完成
1084 extern HMENU hFirstMainMenu;
1085 hFirstMainMenu=0;
1086
1087 //「最近使ったファイル」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
1088 for(i=0;i<pobj_FileMenu->iMenuItemNum;i++){
1089 if(pobj_FileMenu->ppobj_MenuItemData[i]->str){
1090 if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"FileHistory")==0){
1091 pobj_FileMenu->RenameMenuItem(i,"最近使ったファイル(&F)");
1092
1093 extern CSubMenuEx *pobj_FileHistoryMenu;
1094 pobj_FileHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
1095 }
1096
1097#ifndef THETEXT
1098 //「最近使ったプロジェクト」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
1099 //※ProjectEditorのみ
1100 if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"ProjectHistory")==0){
1101 pobj_FileMenu->RenameMenuItem(i,"最近使ったプロジェクト(&J)");
1102
1103 extern CSubMenuEx *pobj_ProjectHistoryMenu;
1104 pobj_ProjectHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
1105 }
1106#endif
1107 }
1108 }
1109
1110#define ICONSET(itemID,iconID) pobj_MainMenu->SetIcon(itemID,(HICON)LoadImage(hIconResInst,MAKEINTRESOURCE(iconID),IMAGE_ICON,16,16,0));
1111 //メニューアイコンをセット
1112
1113 //ファイル
1114 ICONSET(IDM_NEW,IDI_NEW);
1115 ICONSET(IDM_OPEN,IDI_OPEN);
1116 ICONSET(IDM_SAVE,IDI_SAVE);
1117 ICONSET(IDM_ALLSAVE,IDI_ALLSAVE);
1118 ICONSET(IDM_PREVIEW,IDI_PREVIEW);
1119 ICONSET(IDM_PRINTOUT,IDI_PRINT);
1120
1121 //編集
1122 ICONSET(IDM_CUT,IDI_CUT);
1123 ICONSET(IDM_COPY,IDI_COPY);
1124 ICONSET(IDM_PASTE,IDI_PASTE);
1125 ICONSET(IDM_UNDO,IDI_UNDO);
1126 ICONSET(IDM_REDO,IDI_REDO);
1127 ICONSET(IDM_FIND,IDI_FIND);
1128
1129 //表示
1130 ICONSET(IDM_SET,IDI_OPTION);
1131
1132 //変換
1133 ICONSET(IDM_CONV_ALPHA_SMALL,IDI_CONV_ALPHA_SMALL);
1134 ICONSET(IDM_CONV_ALPHA_BIG,IDI_CONV_ALPHA_BIG);
1135 ICONSET(IDM_CONV_HALF,IDI_CONV_HALF);
1136 ICONSET(IDM_CONV_MULTI,IDI_CONV_MULTI);
1137 ICONSET(IDM_CONV_KATAKANA,IDI_CONV_KATAKANA);
1138 ICONSET(IDM_CONV_HIRAGANA,IDI_CONV_HIRAGANA);
1139
1140 //ヘルプ
1141 ICONSET(IDM_TOPIC,IDI_HELP);
1142
1143#ifdef THETEXT
1144 //TheTextのみの機能
1145 ICONSET(IDM_STRING_COUNT,IDI_STRINGCOUNT);
1146#else
1147 //ProjectEditorのみの機能
1148
1149 //リリース
1150 ICONSET(IDM_RELEASECOMPILE,IDI_RELEASECOMPILE);
1151 ICONSET(IDM_RELEASERUN,IDI_RELEASERUN);
1152
1153 //デバッグ
1154 ICONSET(IDM_ATTACH,IDI_ATTACH);
1155 ICONSET(IDM_DEBUGCOMPILE,IDI_DEBUGCOMPILE);
1156 ICONSET(IDM_DEBUG,IDI_DEBUGRUN);
1157 ICONSET(IDM_BREAKPOINT,IDI_BREAKPOINT);
1158 ICONSET(IDM_STEP_IN,IDI_STEPIN);
1159 ICONSET(IDM_STEP_OVER,IDI_STEPOVER);
1160 ICONSET(IDM_STEP_CURSOR,IDI_STEPTOCURSOR);
1161 ICONSET(IDM_DEBUG_PAUSE,IDI_DEBUGPAUSE);
1162 ICONSET(IDM_DEBUG_STOP,IDI_DEBUGSTOP);
1163
1164 //コミュニティ
1165 ICONSET(IDM_COMMUNITY,IDI_COMMUNITY_MAIN);
1166 ICONSET(IDM_COMMU_SEARCH,IDI_COMMUNITY_FIND);
1167 ICONSET(IDM_COMMU_PM,IDI_COMMUNITY_PRIVATEMSG);
1168 ICONSET(ID_COMMU_FORUM1,IDI_COMMUNITY_FORUM);
1169 ICONSET(ID_COMMU_FORUM2,IDI_COMMUNITY_FORUM);
1170 ICONSET(ID_COMMU_FORUM3,IDI_COMMUNITY_FORUM);
1171 ICONSET(ID_COMMU_FORUM4,IDI_COMMUNITY_FORUM);
1172 ICONSET(ID_COMMU_FORUM5,IDI_COMMUNITY_FORUM);
1173 ICONSET(ID_COMMU_FORUM6,IDI_COMMUNITY_FORUM_SECRET);
1174 ICONSET(ID_COMMU_FORUM7,IDI_COMMUNITY_FORUM);
1175 ICONSET(ID_COMMU_FORUM8,IDI_COMMUNITY_FORUM);
1176#endif
1177
1178#undef ICONSET
1179
1180
1181
1182
1183 extern HMENU hEditMenuBase,hEditMenu;
1184 hEditMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_EDITMENU));
1185 hEditMenu=GetSubMenu(hEditMenuBase,0);
1186
1187 extern HMENU hRebarMenuBase,hRebarMenu;
1188 hRebarMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_REBARMENU));
1189 hRebarMenu=GetSubMenu(hRebarMenuBase,0);
1190
1191 extern HMENU hTabMenuBase,hTabMenu,hTabColorMenu;
1192 hTabMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_TABMENU));
1193 hTabMenu=GetSubMenu(hTabMenuBase,0);
1194 hTabColorMenu=GetSubMenu(hTabMenu,0);
1195
1196 extern HMENU hFileTreeMenuBase;
1197 hFileTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_FILETREEMENU));
1198
1199 extern HMENU hProcedureTreeMenuBase;
1200 hProcedureTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_PROCEDURETREEMENU));
1201
1202 extern HMENU hMaterialTreeMenuBase;
1203 hMaterialTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_MATERIALTREEMENU));
1204
1205 extern HMENU hRadMenuBase;
1206 hRadMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_RADCONTEXTMENU));
1207
1208 //クリップボードのデータ形式(RAD用)を新規登録
1209 extern DWORD dwRadClipboardID;
1210 dwRadClipboardID=RegisterClipboardFormat("ProjectEditor-RAD");
1211
1212 //256色の標準パレットを読み込む
1213 extern RGBQUAD DefaultColorTable256[256];
1214 HANDLE hFile;
1215 DWORD dw;
1216 sprintf(temporary,"%sSubOperation\\8bit.plt",pj_editor_Dir);
1217 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1218 if(hFile==INVALID_HANDLE_VALUE){
1219 //"\"%s\" ファイルの読み込みに失敗しました。"
1220 sprintf(str,STRING_ERROR_CANT_FILEOPEN,temporary);
1221 MessageBox(NULL,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
1222 return 0;
1223 }
1224 ReadFile(hFile,DefaultColorTable256,sizeof(RGBQUAD)*256,&dw,NULL);
1225 CloseHandle(hFile);
1226
1227
1228
1229 //デザインテーマオブジェクトを生成
1230 pobj_DBTheme=new CDBTheme();
1231
1232
1233 /////////////////////////
1234 // カラーデザインを設定
1235 CTheme *pobj_Theme;
1236 pobj_Theme=pobj_DBTheme->GetActiveTheme();
1237 if(!pobj_Theme) pobj_Theme=pobj_DBTheme->ppobj_Theme[0];
1238
1239 SetTextEditColorDesign(&tci,pobj_Theme,0);
1240
1241
1242#ifndef THETEXT
1243 /////////////////////////////////////////////////////
1244 // ProjectEditorのみ
1245 /////////////////////////////////////////////////////
1246
1247
1248 //クラスビュー管理オブジェクトを生成
1249 pobj_ClassTreeView=new CClassTreeView();
1250
1251
1252 /////////////////////////
1253 // basic.sbpの内容を取得
1254 /////////////////////////
1255
1256 extern char *pHeaderBuf;
1257 sprintf(temporary,"%sbasic.sbp",pobj_nv->szIncludeDir);
1258 GetFullPath( temporary, pj_editor_Dir );
1259 pHeaderBuf=ReadBuffer(temporary);
1260
1261 if( !pHeaderBuf ){
1262 pHeaderBuf=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
1263 }
1264
1265 //ファイルをインクルード
1266 pHeaderBuf=IncludeFiles(pHeaderBuf);
1267
1268
1269 //デバッガ管理オブジェクトを生成
1270 pobj_Debugger=new CDebugger();
1271#endif
1272
1273
1274 //ブレークポイント管理オブジェクトを生成
1275 extern CDBBreakPoint *pobj_DBBreakPoint;
1276 pobj_DBBreakPoint=new CDBBreakPoint();
1277
1278
1279 return 1;
1280}
1281void EndProjectEditor(void){
1282
1283#ifndef THETEXT
1284 /////////////////////////////////////////////////////
1285 // ProjectEditorのみ
1286 /////////////////////////////////////////////////////
1287
1288
1289 //クラスビュー管理オブジェクトを破棄
1290 delete pobj_ClassTreeView;
1291 pobj_ClassTreeView=0;
1292
1293 //basic.sbpのソースコードバッファを解放
1294 extern char *pHeaderBuf;
1295 HeapDefaultFree(pHeaderBuf);
1296
1297 //デバッガ管理オブジェクトを破棄
1298 delete pobj_Debugger;
1299#endif
1300
1301 //ブレークポイント管理オブジェクトを破棄
1302 extern CDBBreakPoint *pobj_DBBreakPoint;
1303 delete pobj_DBBreakPoint;
1304
1305 //デザインテーマオブジェクトを破棄
1306 delete pobj_DBTheme;
1307
1308 //不揮発性のデータを保存
1309 pobj_nv->save();
1310 delete pobj_nv;
1311 pobj_nv=0;
1312
1313 //メインメニューオブジェクトを破棄
1314 delete pobj_MainMenu;
1315 pobj_MainMenu=0;
1316
1317 extern HFONT hStatusFont;
1318 DeleteObject(hStatusFont);
1319 extern HFONT hHyperLinkFont;
1320 DeleteObject(hHyperLinkFont);
1321 extern HFONT hRulerFont;
1322 DeleteObject(hRulerFont);
1323 extern HFONT hFont_LineNumber;
1324 DeleteObject(hFont_LineNumber);
1325 extern METHODCHECKINFO MethodCheckInfo;
1326 DeleteObject(MethodCheckInfo.hFont);
1327 DeleteObject(MethodCheckInfo.hBoldFont);
1328 extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
1329 DestroyIcon(hOwnerIcon);
1330 DestroyIcon(hBasicProgramIcon);
1331 DestroyIcon(hTextDocumentIcon);
1332 DestroyIcon(hWindowDocumentIcon);
1333 extern HMENU hEditMenuBase,hRebarMenuBase,hTabMenuBase;
1334 DestroyMenu(hEditMenuBase);
1335 DestroyMenu(hRebarMenuBase);
1336 DestroyMenu(hTabMenuBase);
1337 extern HMENU hFileTreeMenuBase;
1338 DestroyMenu(hFileTreeMenuBase);
1339 extern HMENU hProcedureTreeMenuBase;
1340 DestroyMenu(hProcedureTreeMenuBase);
1341 extern HMENU hMaterialTreeMenuBase;
1342 DestroyMenu(hMaterialTreeMenuBase);
1343 extern HMENU hRadMenuBase;
1344 DestroyMenu(hRadMenuBase);
1345
1346 //背景ブラシ
1347 extern HBRUSH h3DFaceBackBrush;
1348 DeleteObject(h3DFaceBackBrush);
1349
1350 //スタンダードツールバーを破棄
1351 if(pobj_StandardToolbar){
1352 pobj_StandardToolbar->Release();
1353 pobj_StandardToolbar=0;
1354 }
1355
1356 //ビルドツールバーを破棄
1357 if(pobj_ReleaseToolbar){
1358 pobj_ReleaseToolbar->Release();
1359 pobj_ReleaseToolbar=0;
1360 }
1361
1362 //デバッガ用ツールバーを破棄
1363 if(pobj_DebuggerToolbar){
1364 pobj_DebuggerToolbar->Release();
1365 pobj_DebuggerToolbar=0;
1366 }
1367
1368 //ヒープオブジェクトを解放
1369 extern HANDLE hHeap;
1370 HeapDestroy(hHeap);
1371
1372 //DLLを解放
1373 FreeLibrary(hResInst);
1374 FreeLibrary(hIconResInst);
1375 FreeLibrary(hLib_LuxCtrl);
1376
1377 //アルファブレンド用のAPIを解放
1378 extern HINSTANCE hUser32Lib;
1379 FreeLibrary(hUser32Lib);
1380
1381
1382
1383
1384 //////////////////////////////////////
1385 // バックアップ用ファイルを削除
1386 //////////////////////////////////////
1387 extern char szBackupDirPath[MAX_PATH];
1388 RemoveDirectoryStrong(szBackupDirPath);
1389
1390}
1391
1392//各ウィンドウ生成
1393void SetupWindow(HWND hwnd){
1394 extern HINSTANCE hInst;
1395 extern HMENU hFirstMainMenu;
1396 RECT rect;
1397 CLIENTCREATESTRUCT ccs;
1398
1399 INITCOMMONCONTROLSEX InitCommCtrl;
1400 InitCommCtrl.dwSize=sizeof(INITCOMMONCONTROLSEX);
1401 InitCommCtrl.dwICC=ICC_COOL_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_WIN95_CLASSES|ICC_TAB_CLASSES;
1402 InitCommonControlsEx(&InitCommCtrl);
1403
1404 //タブウィンドウ
1405 pobj_MainTab=new CMainTab(hwnd);
1406
1407 //MDIの親ウィンドウ(クライアントウィンドウ)を作成
1408 ccs.hWindowMenu=hFirstMainMenu;
1409 ccs.idFirstChild=ID_FIRSTCHILD;
1410 GetClientRect(hwnd,&rect);
1411 hClient=CreateWindowEx(WS_EX_CLIENTEDGE,"MDICLIENT",NULL,
1412 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE,
1413 0,0,0,0,
1414 hwnd,(HMENU)1,hInst,(LPSTR)&ccs);
1415
1416 //レバーオブジェクトを生成
1417 pobj_Rebar=new CMainRebar(hwnd);
1418
1419 //ステータスバー
1420 extern HWND hStatusBar;
1421 extern HFONT hStatusFont;
1422 hStatusBar=CreateStatusWindow(
1423 WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBARS_SIZEGRIP|CCS_BOTTOM,
1424 NULL,hwnd,NULL);
1425 SendMessage(hStatusBar,WM_SETFONT,(long)hStatusFont,0);
1426
1427 //プロジェクト ビュー
1428 extern HWND hProjectView;
1429 extern HWND hProjectView_ToolWindow;
1430 RECT *prc;
1431 prc=&pobj_nv->rectProjectView;
1432 hProjectView_ToolWindow=CreateWindowEx(WS_EX_TOOLWINDOW,"ProjectView_ToolWindow","ProjectView",
1433 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_CLIPCHILDREN,
1434 prc->left,prc->top,prc->right-prc->left,prc->bottom-prc->top,
1435 hwnd,0,hInst,0);
1436 hProjectView=CreateWindowEx(WS_EX_STATICEDGE,"ProjectView","ProjectView",
1437 WS_CHILD|WS_CLIPCHILDREN,
1438 0,0,0,0,
1439 hwnd,0,hInst,0);
1440 if(pobj_nv->bClipProjectView==0){
1441 SetWindowLongPtr(hProjectView,GWL_EXSTYLE,0);
1442 SetParent(hProjectView,hProjectView_ToolWindow);
1443 ResizeProjectView_ToolWindow();
1444 }
1445
1446 //メニュー状態を設定
1447 ResetState_DocMenu();
1448
1449
1450 //SideWebを生成
1451 pobj_SideWeb=new CSideWeb(hwnd);
1452}
1453
1454//実行コマンド
1455BOOL SetRunning(HWND hChild){
1456 extern MDIINFO MdiInfo[MAX_WNDNUM];
1457 extern LPSTR DefFileFilter;
1458 int WndNum;
1459 char temporary[MAX_PATH],temp2[MAX_PATH];
1460 HANDLE hFind;
1461 WIN32_FIND_DATA wfd;
1462
1463 extern char *lpszCompilerName;
1464 sprintf(temporary,"%s%s",pj_editor_Dir,lpszCompilerName);
1465 hFind=FindFirstFile(temporary,&wfd);
1466 if(hFind==INVALID_HANDLE_VALUE){
1467 //"BasicCompiler.exe が見つかりません"
1468 MessageBox(hOwner,STRING_ERROR_NOBASICCOMPILER,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
1469 return FALSE;
1470 }
1471 FindClose(hFind);
1472
1473 WndNum=GetWndNum(hChild);
1474 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1475 if(MdiInfo[WndNum].path[0]=='\0'){
1476 //"保存先のファイルを指定してください"
1477 if(!GetFilePathDialog(hOwner,temp2,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,0)) return FALSE;
1478
1479 if(!SaveDocument(hChild,temp2)) return 0;
1480 }
1481 else{
1482 if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ){
1483 if(!SaveDocument(hChild,NULL)) return 0;
1484 }
1485 else{
1486 if(hFind=FindFirstFile(MdiInfo[WndNum].path,&wfd)){
1487 if(hFind==INVALID_HANDLE_VALUE){
1488 if(!SaveDocument(hChild,NULL)) return 0;
1489 }
1490 else FindClose(hFind);
1491 }
1492 }
1493 }
1494 }
1495 return 1;
1496}
1497
1498BOOL IsNeedCompile(char *FileName,BOOL bDebug){
1499 char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH];
1500 HANDLE hFind,hFile;
1501 WIN32_FIND_DATA wfd;
1502 FILETIME SourceTime,ExeTime;
1503
1504 _splitpath(FileName,temporary,temp2,temp3,NULL);
1505 lstrcat(temporary,temp2);
1506 lstrcat(temporary,temp3);
1507 if(bDebug) lstrcat(temporary,"_debug.exe");
1508 else lstrcat(temporary,".exe");
1509
1510 hFind=FindFirstFile(temporary,&wfd);
1511 if(hFind==INVALID_HANDLE_VALUE) return 1;
1512 FindClose(hFind);
1513
1514 hFile=CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1515 GetFileTime(hFile,NULL,NULL,&SourceTime);
1516 CloseHandle(hFile);
1517
1518 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1519 GetFileTime(hFile,NULL,NULL,&ExeTime);
1520 CloseHandle(hFile);
1521
1522 if(SourceTime.dwHighDateTime<ExeTime.dwHighDateTime) return 0;
1523 else if(SourceTime.dwHighDateTime==ExeTime.dwHighDateTime&&
1524 SourceTime.dwLowDateTime<=ExeTime.dwLowDateTime) return 0;
1525 return 1;
1526}
1527
1528string GetLastErrorString(){
1529 char *lpMsgBuf;
1530
1531 FormatMessage(
1532 FORMAT_MESSAGE_ALLOCATE_BUFFER |
1533 FORMAT_MESSAGE_FROM_SYSTEM |
1534 FORMAT_MESSAGE_IGNORE_INSERTS,
1535 NULL,
1536 GetLastError(),
1537 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト言語
1538 (LPTSTR) &lpMsgBuf,
1539 0,
1540 NULL
1541 );
1542
1543 string result = lpMsgBuf;
1544
1545 LocalFree( lpMsgBuf );
1546
1547 return result;
1548}
Note: See TracBrowser for help on using the repository browser.