source: dev/trunk/ab5.0/abdev/ProjectEditor/SubOperation.cpp@ 477

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

構成管理を大幅に改良。

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