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

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

・コンパイルビューへの出力を標準出力にも行うようにした。
#164への対応。コンパイルを中断すると高確率で強制終了してしまうバグを修正。
・ProjectEditorをVista用Microsoft SDKにてビルドできるようにした(WINVER定数を0x0501に指定した)。
#168への対応。エディタ上のDelegateキーワードを青色で表示するようにした。

File size: 43.4 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,"Delegate")==0) return -1;
485 if(lstrcmpi(str,"Delete")==0) return -1;
486 if(lstrcmpi(str,"DelWnd")==0) return COM_DELWND;
487 if(lstrcmpi(str,"Dim")==0) return COM_DIM;
488 if(lstrcmpi(str,"Do")==0) return COM_DO;
489 if(lstrcmp(str,"Double")==0) return -1;
490 if(lstrcmp(str,"DWord")==0) return -1;
491 }
492 else if(str[0]=='e'||str[0]=='E'){
493 if(lstrcmpi(str,"Else")==0) return -1;
494 if(lstrcmpi(str,"ElseIf")==0) return -1;
495 if(lstrcmpi(str,"End")==0) return COM_END;
496 if(lstrcmpi(str,"EndIf")==0) return -1;
497 if(lstrcmpi(str,"EndFunction")==0) return -1;
498 if(lstrcmpi(str,"EndSub")==0) return -1;
499 if(lstrcmpi(str,"EndType")==0) return -1;
500 if(lstrcmpi(str,"EndSelect")==0) return -1;
501 if(lstrcmpi(str,"EndWith")==0) return -1;
502 if(lstrcmpi(str,"Enum")==0) return COM_ENUM;
503 if(lstrcmpi(str,"Exit")==0) return -1;
504 if(lstrcmpi(str,"ExitDo")==0) return -1;
505 if(lstrcmpi(str,"ExitFor")==0) return -1;
506 if(lstrcmpi(str,"ExitFunction")==0) return -1;
507 if(lstrcmpi(str,"ExitSub")==0) return -1;
508 if(lstrcmpi(str,"ExitWhile")==0) return -1;
509 }
510 else if(str[0]=='f'||str[0]=='F'){
511 if(lstrcmp(str,"False")==0) return -1;
512 if(lstrcmpi(str,"Field")==0) return COM_FIELD;
513 if(lstrcmpi(str,"Finally")==0) return -1;
514 if(lstrcmpi(str,"For")==0) return COM_FOR;
515 if(lstrcmpi(str,"Foreach")==0) return -1;
516 if(lstrcmpi(str,"Function")==0) return COM_FUNCTION;
517 }
518 else if(str[0]=='g'||str[0]=='G'){
519 if(lstrcmpi(str,"Get")==0) return COM_GET;
520 if(lstrcmpi(str,"GoSub")==0) return COM_GOSUB;
521 if(lstrcmpi(str,"Goto")==0) return COM_GOTO;
522 }
523 else if(str[0]=='i'||str[0]=='I'){
524 if(lstrcmpi(str,"If")==0) return COM_IF;
525 if(lstrcmpi(str,"Imports")==0) return -1;
526 if(lstrcmpi(str,"Implements")==0) return -1;
527 if(lstrcmpi(str,"In")==0) return -1;
528 if(lstrcmpi(str,"Inherits")==0) return COM_INHERITS;
529 if(lstrcmpi(str,"Input")==0) return COM_INPUT;
530 if(lstrcmp(str,"Int64")==0) return -1;
531 if(lstrcmp(str,"Integer")==0) return -1;
532 if(lstrcmpi(str,"Interface")==0) return COM_INTERFACE;
533 }
534 else if(str[0]=='k'||str[0]=='K'){
535 if(lstrcmpi(str,"Kill")==0) return COM_KILL;
536 }
537 else if(str[0]=='l'||str[0]=='L'){
538 if(lstrcmpi(str,"Let")==0) return COM_LET;
539 if(lstrcmpi(str,"Line")==0) return COM_LINE;
540 if(lstrcmpi(str,"Locate")==0) return COM_LOCATE;
541 if(lstrcmp(str,"Long")==0) return -1;
542 if(lstrcmpi(str,"Loop")==0) return COM_LOOP;
543 }
544 else if(str[0]=='m'||str[0]=='M'){
545 if(lstrcmpi(str,"MkDir")==0) return COM_MKDIR;
546 if(lstrcmpi(str,"MsgBox")==0) return COM_MSGBOX;
547 }
548 else if(str[0]=='n'||str[0]=='N'){
549 if(lstrcmpi(str,"Namespace")==0) return COM_NAMESPACE;
550 if(lstrcmpi(str,"Next")==0) return COM_NEXT;
551 if(lstrcmpi(str,"New")==0) return -1;
552 if(lstrcmpi(str,"Nothing")==0) return -1;
553 }
554 else if(str[0]=='o'||str[0]=='O'){
555 if(lstrcmp(str,"Object")==0) return -1;
556 if(lstrcmpi(str,"Open")==0) return COM_OPEN;
557 if(lstrcmpi(str,"Operator")==0) return -1;
558 if(lstrcmpi(str,"Override")==0) return COM_OVERRIDE;
559 }
560 else if(str[0]=='p'||str[0]=='P'){
561 if(lstrcmpi(str,"Paint")==0) return COM_PAINT;
562 if(lstrcmpi(str,"Print")==0) return COM_PRINT;
563 if(lstrcmpi(str,"Private")==0) return COM_PRIVATE;
564 if(lstrcmpi(str,"Protected")==0) return COM_PROTECTED;
565 if(lstrcmpi(str,"PSet")==0) return COM_PSET;
566 if(lstrcmpi(str,"Put")==0) return COM_PUT;
567 if(lstrcmpi(str,"Public")==0) return COM_PUBLIC;
568 }
569 else if(str[0]=='q'||str[0]=='Q'){
570 if(lstrcmp(str,"QWord")==0) return -1;
571 }
572 else if(str[0]=='r'||str[0]=='R'){
573 if(lstrcmpi(str,"Randomize")==0) return COM_RANDOMIZE;
574 if(lstrcmpi(str,"Rem")==0) return COM_REM;
575 if(lstrcmpi(str,"Return")==0) return COM_RETURN;
576 }
577 else if(str[0]=='s'||str[0]=='S'){
578 if(lstrcmp(str,"SByte")==0) return -1;
579 if(lstrcmpi(str,"Select")==0) return COM_SELECT;
580 if(lstrcmpi(str,"SelectCase")==0) return COM_SELECT;
581 if(lstrcmp(str,"Single")==0) return -1;
582 if(lstrcmpi(str,"Sleep")==0) return COM_SLEEP;
583 if(lstrcmp(str,"Static")==0) return -1;
584 if(lstrcmpi(str,"Step")==0) return -1;
585 if(lstrcmp(str,"String")==0) return -1;
586 if(lstrcmpi(str,"Sub")==0) return COM_SUB;
587 if(lstrcmpi(str,"Super")==0) return -1;
588 }
589 else if(str[0]=='t'||str[0]=='T'){
590 if(lstrcmpi(str,"Then")==0) return -1;
591 if(lstrcmpi(str,"This")==0) return -1;
592 if(lstrcmpi(str,"Throw")==0) return -1;
593 if(lstrcmpi(str,"To")==0) return -1;
594 if(lstrcmp(str,"True")==0) return -1;
595 if(lstrcmp(str,"Try")==0) return COM_TRY;
596 if(lstrcmpi(str,"Type")==0) return COM_TYPE;
597 if(lstrcmpi(str,"TypeDef")==0) return COM_TYPEDEF;
598 }
599 else if(str[0]=='u'||str[0]=='U'){
600 if(lstrcmpi(str,"Until")==0) return -1;
601 }
602 else if(str[0]=='v'||str[0]=='V'){
603 if(lstrcmpi(str,"Virtual")==0) return COM_VIRTUAL;
604 }
605 else if(str[0]=='w'||str[0]=='W'){
606 if(lstrcmpi(str,"Wend")==0) return COM_WEND;
607 if(lstrcmpi(str,"While")==0) return COM_WHILE;
608 if(lstrcmpi(str,"Window")==0) return COM_WINDOW;
609 if(lstrcmpi(str,"With")==0) return COM_WITH;
610 if(lstrcmp(str,"Word")==0) return -1;
611 if(lstrcmpi(str,"Write")==0) return COM_WRITE;
612 }
613 else if(str[0]=='#'){
614 if(lstrcmpi(str,"#include")==0) return -1;
615 if(lstrcmpi(str,"#strict")==0) return -1;
616 if(lstrcmpi(str,"#console")==0) return -1;
617 if(lstrcmpi(str,"#prompt")==0) return -1;
618 if(lstrcmpi(str,"#N88BASIC")==0) return -1;
619 if(lstrcmpi(str,"#define")==0) return -1;
620 if(lstrcmpi(str,"#ifdef")==0) return -1;
621 if(lstrcmpi(str,"#ifndef")==0) return -1;
622 if(lstrcmpi(str,"#else")==0) return -1;
623 if(lstrcmpi(str,"#endif")==0) return -1;
624 }
625 return 0;
626}
627
628HBITMAP CreateGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
629 //グラデーションビットマップを生成
630
631 BITMAPINFO BitmapInfo;
632 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
633 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
634 BitmapInfo.bmiHeader.biWidth=pSize->cx;
635 BitmapInfo.bmiHeader.biHeight=pSize->cy;
636 BitmapInfo.bmiHeader.biPlanes=1;
637 BitmapInfo.bmiHeader.biBitCount=24;
638
639 HDC hdc;
640 hdc=GetDC(GetDesktopWindow());
641
642 HBITMAP hBitmap;
643 BYTE *pByte;
644 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
645
646 int i,i2,x,y;
647 COLORREF rgb;
648 i=BitmapInfo.bmiHeader.biWidth*3;
649 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
650 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
651 if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
652 else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
653 else{
654 double ratio;
655 ratio=((double)y-((double)BitmapInfo.bmiHeader.biHeight/(double)2-(double)2))/(double)4;
656 //ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
657 rgb=RGB(
658 LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
659 HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
660 LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
661 );
662 }
663 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
664 i2=y*i+x*3;
665 pByte[i2+2]=LOBYTE(LOWORD(rgb));
666 pByte[i2+1]=HIBYTE(LOWORD(rgb));
667 pByte[i2]=LOBYTE(HIWORD(rgb));
668 }
669 }
670
671 ReleaseDC(GetDesktopWindow(),hdc);
672
673 return hBitmap;
674}
675HBITMAP CreateVertGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
676 //グラデーションビットマップを生成
677
678 BITMAPINFO BitmapInfo;
679 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
680 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
681 BitmapInfo.bmiHeader.biWidth=pSize->cx;
682 BitmapInfo.bmiHeader.biHeight=pSize->cy;
683 BitmapInfo.bmiHeader.biPlanes=1;
684 BitmapInfo.bmiHeader.biBitCount=24;
685
686 HDC hdc;
687 hdc=GetDC(GetDesktopWindow());
688
689 HBITMAP hBitmap;
690 BYTE *pByte;
691 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
692
693 int i,i2,x,y;
694 COLORREF rgb;
695 i=BitmapInfo.bmiHeader.biWidth*3;
696 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
697 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
698 if(y<BitmapInfo.bmiHeader.biHeight/2-2) rgb=color2;
699 else if(y>BitmapInfo.bmiHeader.biHeight/2+2) rgb=color1;
700 else{
701 double ratio;
702 ratio=(double)y/(double)BitmapInfo.bmiHeader.biHeight;
703 rgb=RGB(
704 LOBYTE(LOWORD(color2))+(int)(double)(LOBYTE(LOWORD(color1))-LOBYTE(LOWORD(color2)))*(ratio), //赤要素
705 HIBYTE(LOWORD(color2))+(int)(double)(HIBYTE(LOWORD(color1))-HIBYTE(LOWORD(color2)))*(ratio), //緑要素
706 LOBYTE(HIWORD(color2))+(int)(double)(LOBYTE(HIWORD(color1))-LOBYTE(HIWORD(color2)))*(ratio) //青要素
707 );
708 }
709 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
710 i2=y*i+x*3;
711 pByte[i2+2]=LOBYTE(LOWORD(rgb));
712 pByte[i2+1]=HIBYTE(LOWORD(rgb));
713 pByte[i2]=LOBYTE(HIWORD(rgb));
714 }
715 }
716
717 ReleaseDC(GetDesktopWindow(),hdc);
718
719 return hBitmap;
720}
721HBITMAP CreateHorzGradationBitmap(SIZE *pSize,COLORREF color1,COLORREF color2){
722 //グラデーションビットマップを生成
723
724 BITMAPINFO BitmapInfo;
725 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
726 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
727 BitmapInfo.bmiHeader.biWidth=pSize->cx;
728 BitmapInfo.bmiHeader.biHeight=pSize->cy;
729 BitmapInfo.bmiHeader.biPlanes=1;
730 BitmapInfo.bmiHeader.biBitCount=24;
731
732 HDC hdc;
733 hdc=GetDC(GetDesktopWindow());
734
735 HBITMAP hBitmap;
736 BYTE *pByte;
737 hBitmap=CreateDIBSection(hdc,&BitmapInfo,DIB_RGB_COLORS,(void **)&pByte,0,0);
738
739 int i,i2,x,y;
740 COLORREF rgb;
741 i=BitmapInfo.bmiHeader.biWidth*3;
742 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
743 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
744 double ratio;
745 ratio=(double)x/(double)BitmapInfo.bmiHeader.biWidth;
746 rgb=RGB(
747 LOBYTE(LOWORD(color1))+(int)(double)(LOBYTE(LOWORD(color2))-LOBYTE(LOWORD(color1)))*(ratio), //赤要素
748 HIBYTE(LOWORD(color1))+(int)(double)(HIBYTE(LOWORD(color2))-HIBYTE(LOWORD(color1)))*(ratio), //緑要素
749 LOBYTE(HIWORD(color1))+(int)(double)(LOBYTE(HIWORD(color2))-LOBYTE(HIWORD(color1)))*(ratio) //青要素
750 );
751 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
752 i2=y*i+x*3;
753 pByte[i2+2]=LOBYTE(LOWORD(rgb));
754 pByte[i2+1]=HIBYTE(LOWORD(rgb));
755 pByte[i2]=LOBYTE(HIWORD(rgb));
756 }
757 }
758
759 ReleaseDC(GetDesktopWindow(),hdc);
760
761 return hBitmap;
762}
763HICON CreateGrayIcon(HICON hBaseIcon){
764 ////////////////////////
765 // 淡色アイコンを生成
766 ////////////////////////
767
768 HICON hGrayIcon;
769
770 ICONINFO IconInfo;
771 GetIconInfo(hBaseIcon,&IconInfo);
772
773
774 //ビットマップを加工
775 BITMAP Bitmap;
776 GetObject(IconInfo.hbmColor,sizeof(Bitmap),&Bitmap);
777
778 BITMAPINFO BitmapInfo;
779 memset(&BitmapInfo.bmiHeader,0,sizeof(BITMAPINFOHEADER));
780 BitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
781 BitmapInfo.bmiHeader.biWidth=Bitmap.bmWidth;
782 BitmapInfo.bmiHeader.biHeight=Bitmap.bmHeight;
783 BitmapInfo.bmiHeader.biPlanes=1;
784 BitmapInfo.bmiHeader.biBitCount=24;
785 BitmapInfo.bmiHeader.biCompression=BI_RGB;
786
787 HDC hdc;
788 hdc=GetDC(GetDesktopWindow());
789
790 BYTE *pByte;
791 pByte=(BYTE *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
792 GetDIBits(hdc,
793 IconInfo.hbmColor,
794 0,
795 Bitmap.bmHeight,
796 (void *)pByte,
797 &BitmapInfo,
798 DIB_RGB_COLORS);
799
800 int i,i2,x,y;
801 i=BitmapInfo.bmiHeader.biWidth*3;
802 if(i%sizeof(LONG)!=0) i+=sizeof(LONG)-(i%sizeof(LONG));
803 for(x=0;x<BitmapInfo.bmiHeader.biWidth;x++){
804 for(y=0;y<BitmapInfo.bmiHeader.biHeight;y++){
805 i2=y*i+x*3;
806 if(pByte[i2+2]==0&&pByte[i2+1]==0&&pByte[i2]==0){
807 //透明色
808 //何もしない
809 }
810 else{
811 double ratio=0.5; //明るさ
812
813 pByte[i2+2]+=(BYTE)((double)(255-pByte[i2+2])*ratio);
814 pByte[i2+1]+=(BYTE)((double)(255-pByte[i2+1])*ratio);
815 pByte[i2]+=(BYTE)((double)(255-pByte[i2])*ratio);
816
817 pByte[i2+2]=(BYTE)(((int)pByte[i2+2]+(int)pByte[i2+1]+(int)pByte[i2])/3);
818 pByte[i2+1]=pByte[i2+2];
819 pByte[i2]=pByte[i2+2];
820 }
821 }
822 }
823
824 SetDIBits(hdc,
825 IconInfo.hbmColor,
826 0,
827 Bitmap.bmHeight,
828 (void *)pByte,
829 &BitmapInfo,
830 DIB_RGB_COLORS);
831
832 HeapDefaultFree(pByte);
833
834 ReleaseDC(GetDesktopWindow(),hdc);
835
836
837 hGrayIcon=CreateIconIndirect(&IconInfo);
838
839 //不要なビットマップを破棄
840 DeleteObject(IconInfo.hbmMask);
841 DeleteObject(IconInfo.hbmColor);
842
843 return hGrayIcon;
844}
845void GetSize(SIZE *pSize,RECT *pRect){
846 pSize->cx=pRect->right-pRect->left;
847 pSize->cy=pRect->bottom-pRect->top;
848}
849BOOL HitTest(RECT *pRect,POINT *pPos){
850 if(pRect->left<=pPos->x&&pPos->x<pRect->right&&
851 pRect->top<=pPos->y&&pPos->y<pRect->bottom) return 1;
852 return 0;
853}
854BOOL Rectangle(HDC hdc,RECT *pRect){
855 return Rectangle(hdc,pRect->left,pRect->top,pRect->right,pRect->bottom);
856}
857
858void ComboBox_SetSelText(HWND hCombo,char *lpszText){
859 SendMessage(hCombo,CB_SETCURSEL,
860 SendMessage(hCombo,CB_FINDSTRINGEXACT,0,(LPARAM)lpszText),
861 0);
862}
863
864void SetCursorByState(int state){
865 if(state==FRAME_UPPER_LEFT||state==FRAME_LOWER_RIGHT) SetCursor(LoadCursor(0,IDC_SIZENWSE));
866 else if(state==FRAME_UPPER_RIGHT||state==FRAME_LOWER_LEFT) SetCursor(LoadCursor(0,IDC_SIZENESW));
867 else if(state==FRAME_LEFT||state==FRAME_RIGHT) SetCursor(LoadCursor(0,IDC_SIZEWE));
868 else if(state==FRAME_UPPER||state==FRAME_LOWER) SetCursor(LoadCursor(0,IDC_SIZENS));
869 else if(state==FRAME_INSIDE) SetCursor(LoadCursor(0,IDC_SIZEALL));
870 else SetCursor(LoadCursor(0,IDC_ARROW));
871}
872
873void SetTextEditColorDesign(TEXTEDIT_COLOR_INFO *pColorInfo,CTheme *pobj_Theme,BOOL bRedraw){
874 pColorInfo->rgbDefault=pobj_Theme->TextColorInfo.rgbDefault;
875 pColorInfo->rgbComment=pobj_Theme->TextColorInfo.rgbComment;
876 pColorInfo->rgbStatement=pobj_Theme->TextColorInfo.rgbStatement;
877 pColorInfo->rgbString=pobj_Theme->TextColorInfo.rgbString;
878 pColorInfo->rgbCursorBack=pobj_Theme->TextColorInfo.rgbCursorBack;
879 pColorInfo->rgbBackground=pobj_Theme->TextColorInfo.rgbBackground;
880
881 //アクティブテーマにセット
882 lstrcpy(pobj_nv->szActiveTheme,pobj_Theme->m_name);
883
884 //テーマ依存の描画リソースを取得
885 pobj_DBTheme->unlock();
886 pobj_DBTheme->lock();
887
888 if(bRedraw){
889 //再描画
890 extern MDIINFO MdiInfo[MAX_WNDNUM];
891 int i;
892 for(i=0;i<MAX_WNDNUM;i++){
893 if(MdiInfo[i].hwnd){
894 if(IS_DOCUMENT_TEXT(MdiInfo[i].DocType)){
895 SetTextEditWordColor(i);
896 InvalidateRect(MdiInfo[i].pMdiTextEdit->hEdit,NULL,0);
897 }
898 }
899 }
900 }
901}
902
903BOOL SetupProjectEditor(void){
904 extern HINSTANCE hInst;
905 int i;
906 char str[MAX_PATH],temporary[MAX_PATH];
907
908
909 //リソース用DLLをマッピング
910#if defined(JPN)
911 //日本語リソース
912 sprintf(temporary,"%sSubOperation\\res.dll",pj_editor_Dir);
913#else
914 //英語リソース
915 sprintf(temporary,"%sSubOperation\\res_e.dll",pj_editor_Dir);
916#endif
917 hResInst=LoadLibrary(temporary);
918
919 //アイコンリソースDLLをマッピング
920 sprintf(temporary,"%sSubOperation\\icon_res.dll",pj_editor_Dir);
921 hIconResInst=LoadLibrary(temporary);
922
923 //LuxCtrl.dllをマッピング
924 sprintf(temporary,"%sSubOperation\\LuxCtrl.dll",pj_editor_Dir);
925 hLib_LuxCtrl=LoadLibrary(temporary);
926 if(!hLib_LuxCtrl){
927 MessageBox(0,"LuxCtrl.dllの読み込みに失敗しました。",APPLICATION_NAME,MB_OK|MB_ICONEXCLAMATION);
928 return 0;
929 }
930 LuxToolbar_CreateInstance=
931 (PROC_LuxToolbar_CreateInstance)GetProcAddress(hLib_LuxCtrl,"LuxToolbar_CreateInstance");
932
933
934 //モジュールディレクトリを取得
935 GetModuleFileName(hInst,temporary,MAX_PATH);
936 _splitpath(temporary,pj_editor_Dir,str,NULL,NULL);
937 lstrcat(pj_editor_Dir,str);
938
939 //ヒープオブジェクトを作成
940 extern HANDLE hHeap;
941 hHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0);
942
943
944 //自動バックアップ用のディレクトリを生成
945 CreateBackupDir();
946
947
948 //COMを初期化
949 CoInitialize(0);
950
951 //スクリーンサイズを取得
952 ScreenX=GetSystemMetrics(SM_CXSCREEN);
953 ScreenY=GetSystemMetrics(SM_CYSCREEN);
954
955 //コンパイラ名をセット(デフォルトはWin32)
956 extern char *lpszCompilerName;
957 lpszCompilerName=WIN32_COMPILER_NAME;
958
959 //不揮発性のデータを取得
960 pobj_nv=new CNonVolatile;
961 pobj_nv->load();
962
963
964 //アルファブレンド用のAPIを取得
965 extern FWINLAYER pSetLayeredWindowAttributes;
966 extern HINSTANCE hUser32Lib;
967 hUser32Lib=LoadLibrary("user32.dll");
968 pSetLayeredWindowAttributes=(FWINLAYER)GetProcAddress(hUser32Lib,"pSetLayeredWindowAttributes");
969
970
971
972
973 /////////////////////
974 // フォントを定義
975 /////////////////////
976
977 //パラメータ ヒント フォント
978 extern METHODCHECKINFO MethodCheckInfo;
979 MethodCheckInfo.hFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
980 i=MethodCheckInfo.LogFont.lfWeight;
981 MethodCheckInfo.LogFont.lfWeight=FW_BOLD;
982 MethodCheckInfo.hBoldFont=CreateFontIndirect(&MethodCheckInfo.LogFont);
983 MethodCheckInfo.LogFont.lfWeight=i;
984
985 //ステータスバー フォント
986 LOGFONT LogFont;
987 extern HFONT hStatusFont;
988 LogFont.lfHeight=-12;
989 LogFont.lfWidth=0;
990 LogFont.lfEscapement=0;
991 LogFont.lfOrientation=0;
992 LogFont.lfWeight=FW_REGULAR;
993 LogFont.lfItalic=NULL;
994 LogFont.lfUnderline=NULL;
995 LogFont.lfStrikeOut=NULL;
996 LogFont.lfCharSet=SHIFTJIS_CHARSET;
997 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
998 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
999 LogFont.lfQuality=DRAFT_QUALITY;
1000 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1001 sprintf(LogFont.lfFaceName,"MS Pゴシック");
1002 hStatusFont=CreateFontIndirect(&LogFont);
1003
1004 //ハイパーリンク フォント
1005 extern HFONT hHyperLinkFont;
1006 LogFont.lfHeight=-12;
1007 LogFont.lfWidth=0;
1008 LogFont.lfEscapement=0;
1009 LogFont.lfOrientation=0;
1010 LogFont.lfWeight=FW_REGULAR;
1011 LogFont.lfItalic=NULL;
1012 LogFont.lfUnderline=TRUE;
1013 LogFont.lfStrikeOut=NULL;
1014 LogFont.lfCharSet=SHIFTJIS_CHARSET;
1015 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1016 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1017 LogFont.lfQuality=DRAFT_QUALITY;
1018 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1019 sprintf(LogFont.lfFaceName,"MS Pゴシック");
1020 hHyperLinkFont=CreateFontIndirect(&LogFont);
1021
1022 //ルーラー フォント
1023 extern HFONT hRulerFont;
1024 LogFont.lfHeight=-10;
1025 LogFont.lfWidth=0;
1026 LogFont.lfEscapement=0;
1027 LogFont.lfOrientation=0;
1028 LogFont.lfWeight=FW_REGULAR;
1029 LogFont.lfItalic=NULL;
1030 LogFont.lfUnderline=0;
1031 LogFont.lfStrikeOut=NULL;
1032 LogFont.lfCharSet=SHIFTJIS_CHARSET;
1033 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1034 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1035 LogFont.lfQuality=DRAFT_QUALITY;
1036 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1037 sprintf(LogFont.lfFaceName,"MS ゴシック");
1038 hRulerFont=CreateFontIndirect(&LogFont);
1039
1040 //行番号の描画用
1041 extern HFONT hFont_LineNumber;
1042 LogFont.lfHeight=-11;
1043 LogFont.lfWidth=0;
1044 LogFont.lfEscapement=0;
1045 LogFont.lfOrientation=0;
1046 LogFont.lfWeight=FW_BOLD;
1047 LogFont.lfItalic=NULL;
1048 LogFont.lfUnderline=NULL;
1049 LogFont.lfStrikeOut=NULL;
1050 LogFont.lfCharSet=ANSI_CHARSET;
1051 LogFont.lfOutPrecision=OUT_STRING_PRECIS;
1052 LogFont.lfClipPrecision=CLIP_STROKE_PRECIS;
1053 LogFont.lfQuality=DRAFT_QUALITY;
1054 LogFont.lfPitchAndFamily=VARIABLE_PITCH;
1055 sprintf(LogFont.lfFaceName,"Courier New");
1056 hFont_LineNumber=CreateFontIndirect(&LogFont);
1057
1058 //メニューフォント
1059 NONCLIENTMETRICS NCMetrics;
1060 int sizeof_NONCLIENTMETRICS = sizeof( NONCLIENTMETRICS );
1061#if WINVER >= 0x0600
1062 sizeof_NONCLIENTMETRICS -= sizeof(int);
1063#endif
1064 NCMetrics.cbSize = sizeof_NONCLIENTMETRICS;
1065 SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof_NONCLIENTMETRICS, &NCMetrics, 0 );
1066 hMenuFont=CreateFontIndirect(&NCMetrics.lfMenuFont);
1067
1068
1069
1070 //背景ブラシ
1071 extern HBRUSH h3DFaceBackBrush;
1072 h3DFaceBackBrush=CreateSolidBrush(GetSysColor(COLOR_3DFACE));
1073
1074 //アイコン
1075 extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
1076 hOwnerIcon=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_MAIN),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1077 hBasicProgramIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_BASICPROGRAM),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1078 hTextDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_TEXTDOCUMENT),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1079 hWindowDocumentIcon=(HICON)LoadImage(hResInst,MAKEINTRESOURCE(IDI_WINDOW),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
1080
1081
1082
1083
1084 //メインメニュー
1085 pobj_MainMenu=new CMenuEx(LoadMenu(hResInst,MAKEINTRESOURCE(IDR_MAINMENU)));
1086
1087 pobj_MainMenu->InitOwnerDraw(1); //オーナー描画の初期化
1088
1089 CSubMenuEx *pobj_FileMenu;
1090 pobj_FileMenu=pobj_MainMenu->ppobj_MenuItemData[0]->pobj_SubMenu;
1091
1092 //未完成
1093 extern HMENU hFirstMainMenu;
1094 hFirstMainMenu=0;
1095
1096 //「最近使ったファイル」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
1097 for(i=0;i<pobj_FileMenu->iMenuItemNum;i++){
1098 if(pobj_FileMenu->ppobj_MenuItemData[i]->str){
1099 if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"FileHistory")==0){
1100 pobj_FileMenu->RenameMenuItem(i,"最近使ったファイル(&F)");
1101
1102 extern CSubMenuEx *pobj_FileHistoryMenu;
1103 pobj_FileHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
1104 }
1105
1106#ifndef THETEXT
1107 //「最近使ったプロジェクト」サブメニューを取得(と同時にも正規のメニュー文字列を指定)
1108 //※ProjectEditorのみ
1109 if(lstrcmp(pobj_FileMenu->ppobj_MenuItemData[i]->str,"ProjectHistory")==0){
1110 pobj_FileMenu->RenameMenuItem(i,"最近使ったプロジェクト(&J)");
1111
1112 extern CSubMenuEx *pobj_ProjectHistoryMenu;
1113 pobj_ProjectHistoryMenu=pobj_FileMenu->ppobj_MenuItemData[i]->pobj_SubMenu;
1114 }
1115#endif
1116 }
1117 }
1118
1119#define ICONSET(itemID,iconID) pobj_MainMenu->SetIcon(itemID,(HICON)LoadImage(hIconResInst,MAKEINTRESOURCE(iconID),IMAGE_ICON,16,16,0));
1120 //メニューアイコンをセット
1121
1122 //ファイル
1123 ICONSET(IDM_NEW,IDI_NEW);
1124 ICONSET(IDM_OPEN,IDI_OPEN);
1125 ICONSET(IDM_SAVE,IDI_SAVE);
1126 ICONSET(IDM_ALLSAVE,IDI_ALLSAVE);
1127 ICONSET(IDM_PREVIEW,IDI_PREVIEW);
1128 ICONSET(IDM_PRINTOUT,IDI_PRINT);
1129
1130 //編集
1131 ICONSET(IDM_CUT,IDI_CUT);
1132 ICONSET(IDM_COPY,IDI_COPY);
1133 ICONSET(IDM_PASTE,IDI_PASTE);
1134 ICONSET(IDM_UNDO,IDI_UNDO);
1135 ICONSET(IDM_REDO,IDI_REDO);
1136 ICONSET(IDM_FIND,IDI_FIND);
1137
1138 //表示
1139 ICONSET(IDM_SET,IDI_OPTION);
1140
1141 //変換
1142 ICONSET(IDM_CONV_ALPHA_SMALL,IDI_CONV_ALPHA_SMALL);
1143 ICONSET(IDM_CONV_ALPHA_BIG,IDI_CONV_ALPHA_BIG);
1144 ICONSET(IDM_CONV_HALF,IDI_CONV_HALF);
1145 ICONSET(IDM_CONV_MULTI,IDI_CONV_MULTI);
1146 ICONSET(IDM_CONV_KATAKANA,IDI_CONV_KATAKANA);
1147 ICONSET(IDM_CONV_HIRAGANA,IDI_CONV_HIRAGANA);
1148
1149 //ヘルプ
1150 ICONSET(IDM_TOPIC,IDI_HELP);
1151
1152#ifdef THETEXT
1153 //TheTextのみの機能
1154 ICONSET(IDM_STRING_COUNT,IDI_STRINGCOUNT);
1155#else
1156 //ProjectEditorのみの機能
1157
1158 //リリース
1159 ICONSET(IDM_RELEASECOMPILE,IDI_RELEASECOMPILE);
1160 ICONSET(IDM_RELEASERUN,IDI_RELEASERUN);
1161
1162 //デバッグ
1163 ICONSET(IDM_ATTACH,IDI_ATTACH);
1164 ICONSET(IDM_DEBUGCOMPILE,IDI_DEBUGCOMPILE);
1165 ICONSET(IDM_DEBUG,IDI_DEBUGRUN);
1166 ICONSET(IDM_BREAKPOINT,IDI_BREAKPOINT);
1167 ICONSET(IDM_STEP_IN,IDI_STEPIN);
1168 ICONSET(IDM_STEP_OVER,IDI_STEPOVER);
1169 ICONSET(IDM_STEP_CURSOR,IDI_STEPTOCURSOR);
1170 ICONSET(IDM_DEBUG_PAUSE,IDI_DEBUGPAUSE);
1171 ICONSET(IDM_DEBUG_STOP,IDI_DEBUGSTOP);
1172
1173 //コミュニティ
1174 ICONSET(IDM_COMMUNITY,IDI_COMMUNITY_MAIN);
1175 ICONSET(IDM_COMMU_SEARCH,IDI_COMMUNITY_FIND);
1176 ICONSET(IDM_COMMU_PM,IDI_COMMUNITY_PRIVATEMSG);
1177 ICONSET(ID_COMMU_FORUM1,IDI_COMMUNITY_FORUM);
1178 ICONSET(ID_COMMU_FORUM2,IDI_COMMUNITY_FORUM);
1179 ICONSET(ID_COMMU_FORUM3,IDI_COMMUNITY_FORUM);
1180 ICONSET(ID_COMMU_FORUM4,IDI_COMMUNITY_FORUM);
1181 ICONSET(ID_COMMU_FORUM5,IDI_COMMUNITY_FORUM);
1182 ICONSET(ID_COMMU_FORUM6,IDI_COMMUNITY_FORUM_SECRET);
1183 ICONSET(ID_COMMU_FORUM7,IDI_COMMUNITY_FORUM);
1184 ICONSET(ID_COMMU_FORUM8,IDI_COMMUNITY_FORUM);
1185#endif
1186
1187#undef ICONSET
1188
1189
1190
1191
1192 extern HMENU hEditMenuBase,hEditMenu;
1193 hEditMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_EDITMENU));
1194 hEditMenu=GetSubMenu(hEditMenuBase,0);
1195
1196 extern HMENU hRebarMenuBase,hRebarMenu;
1197 hRebarMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_REBARMENU));
1198 hRebarMenu=GetSubMenu(hRebarMenuBase,0);
1199
1200 extern HMENU hTabMenuBase,hTabMenu,hTabColorMenu;
1201 hTabMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_TABMENU));
1202 hTabMenu=GetSubMenu(hTabMenuBase,0);
1203 hTabColorMenu=GetSubMenu(hTabMenu,0);
1204
1205 extern HMENU hFileTreeMenuBase;
1206 hFileTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_FILETREEMENU));
1207
1208 extern HMENU hProcedureTreeMenuBase;
1209 hProcedureTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_PROCEDURETREEMENU));
1210
1211 extern HMENU hMaterialTreeMenuBase;
1212 hMaterialTreeMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_PROJECTVIEW_MATERIALTREEMENU));
1213
1214 extern HMENU hRadMenuBase;
1215 hRadMenuBase=LoadMenu(hResInst,MAKEINTRESOURCE(IDR_RADCONTEXTMENU));
1216
1217 //クリップボードのデータ形式(RAD用)を新規登録
1218 extern DWORD dwRadClipboardID;
1219 dwRadClipboardID=RegisterClipboardFormat("ProjectEditor-RAD");
1220
1221 //256色の標準パレットを読み込む
1222 extern RGBQUAD DefaultColorTable256[256];
1223 HANDLE hFile;
1224 DWORD dw;
1225 sprintf(temporary,"%sSubOperation\\8bit.plt",pj_editor_Dir);
1226 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1227 if(hFile==INVALID_HANDLE_VALUE){
1228 //"\"%s\" ファイルの読み込みに失敗しました。"
1229 sprintf(str,STRING_ERROR_CANT_FILEOPEN,temporary);
1230 MessageBox(NULL,str,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
1231 return 0;
1232 }
1233 ReadFile(hFile,DefaultColorTable256,sizeof(RGBQUAD)*256,&dw,NULL);
1234 CloseHandle(hFile);
1235
1236
1237
1238 //デザインテーマオブジェクトを生成
1239 pobj_DBTheme=new CDBTheme();
1240
1241
1242 /////////////////////////
1243 // カラーデザインを設定
1244 CTheme *pobj_Theme;
1245 pobj_Theme=pobj_DBTheme->GetActiveTheme();
1246 if(!pobj_Theme) pobj_Theme=pobj_DBTheme->ppobj_Theme[0];
1247
1248 SetTextEditColorDesign(&tci,pobj_Theme,0);
1249
1250
1251#ifndef THETEXT
1252 /////////////////////////////////////////////////////
1253 // ProjectEditorのみ
1254 /////////////////////////////////////////////////////
1255
1256
1257 //クラスビュー管理オブジェクトを生成
1258 pobj_ClassTreeView=new CClassTreeView();
1259
1260
1261 /////////////////////////
1262 // basic.sbpの内容を取得
1263 /////////////////////////
1264
1265 extern char *pHeaderBuf;
1266 sprintf(temporary,"%sbasic.sbp",pobj_nv->szIncludeDir);
1267 GetFullPath( temporary, pj_editor_Dir );
1268 pHeaderBuf = ReadBuffer_NonErrMsg( temporary );
1269 if( !pHeaderBuf )
1270 {
1271 lstrcpy(temporary,".\\Include\\basic.sbp");
1272 GetFullPath( temporary, pj_editor_Dir );
1273 pHeaderBuf = ReadBuffer( temporary );
1274 if( pHeaderBuf )
1275 {
1276 lstrcpy( pobj_nv->szIncludeDir, ".\\Include\\" );
1277 }
1278 }
1279
1280 if( !pHeaderBuf ){
1281 pHeaderBuf=(char *)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,1);
1282 }
1283
1284 //ファイルをインクルード
1285 pHeaderBuf=IncludeFiles(pHeaderBuf);
1286
1287
1288 //デバッガ管理オブジェクトを生成
1289 pobj_Debugger=new CDebugger();
1290#endif
1291
1292
1293 //ブレークポイント管理オブジェクトを生成
1294 extern CDBBreakPoint *pobj_DBBreakPoint;
1295 pobj_DBBreakPoint=new CDBBreakPoint();
1296
1297
1298 return 1;
1299}
1300void EndProjectEditor(void){
1301
1302#ifndef THETEXT
1303 /////////////////////////////////////////////////////
1304 // ProjectEditorのみ
1305 /////////////////////////////////////////////////////
1306
1307
1308 //クラスビュー管理オブジェクトを破棄
1309 delete pobj_ClassTreeView;
1310 pobj_ClassTreeView=0;
1311
1312 //basic.sbpのソースコードバッファを解放
1313 extern char *pHeaderBuf;
1314 HeapDefaultFree(pHeaderBuf);
1315
1316 //デバッガ管理オブジェクトを破棄
1317 delete pobj_Debugger;
1318#endif
1319
1320 //ブレークポイント管理オブジェクトを破棄
1321 extern CDBBreakPoint *pobj_DBBreakPoint;
1322 delete pobj_DBBreakPoint;
1323
1324 //デザインテーマオブジェクトを破棄
1325 delete pobj_DBTheme;
1326
1327 //不揮発性のデータを保存
1328 pobj_nv->save();
1329 delete pobj_nv;
1330 pobj_nv=0;
1331
1332 //メインメニューオブジェクトを破棄
1333 delete pobj_MainMenu;
1334 pobj_MainMenu=0;
1335
1336 extern HFONT hStatusFont;
1337 DeleteObject(hStatusFont);
1338 extern HFONT hHyperLinkFont;
1339 DeleteObject(hHyperLinkFont);
1340 extern HFONT hRulerFont;
1341 DeleteObject(hRulerFont);
1342 extern HFONT hFont_LineNumber;
1343 DeleteObject(hFont_LineNumber);
1344 extern METHODCHECKINFO MethodCheckInfo;
1345 DeleteObject(MethodCheckInfo.hFont);
1346 DeleteObject(MethodCheckInfo.hBoldFont);
1347 extern HICON hOwnerIcon,hBasicProgramIcon,hTextDocumentIcon,hWindowDocumentIcon;
1348 DestroyIcon(hOwnerIcon);
1349 DestroyIcon(hBasicProgramIcon);
1350 DestroyIcon(hTextDocumentIcon);
1351 DestroyIcon(hWindowDocumentIcon);
1352 extern HMENU hEditMenuBase,hRebarMenuBase,hTabMenuBase;
1353 DestroyMenu(hEditMenuBase);
1354 DestroyMenu(hRebarMenuBase);
1355 DestroyMenu(hTabMenuBase);
1356 extern HMENU hFileTreeMenuBase;
1357 DestroyMenu(hFileTreeMenuBase);
1358 extern HMENU hProcedureTreeMenuBase;
1359 DestroyMenu(hProcedureTreeMenuBase);
1360 extern HMENU hMaterialTreeMenuBase;
1361 DestroyMenu(hMaterialTreeMenuBase);
1362 extern HMENU hRadMenuBase;
1363 DestroyMenu(hRadMenuBase);
1364
1365 //背景ブラシ
1366 extern HBRUSH h3DFaceBackBrush;
1367 DeleteObject(h3DFaceBackBrush);
1368
1369 //スタンダードツールバーを破棄
1370 if(pobj_StandardToolbar){
1371 pobj_StandardToolbar->Release();
1372 pobj_StandardToolbar=0;
1373 }
1374
1375 //ビルドツールバーを破棄
1376 if(pobj_ReleaseToolbar){
1377 pobj_ReleaseToolbar->Release();
1378 pobj_ReleaseToolbar=0;
1379 }
1380
1381 //デバッガ用ツールバーを破棄
1382 if(pobj_DebuggerToolbar){
1383 pobj_DebuggerToolbar->Release();
1384 pobj_DebuggerToolbar=0;
1385 }
1386
1387 //ヒープオブジェクトを解放
1388 extern HANDLE hHeap;
1389 HeapDestroy(hHeap);
1390
1391 //DLLを解放
1392 FreeLibrary(hResInst);
1393 FreeLibrary(hIconResInst);
1394 FreeLibrary(hLib_LuxCtrl);
1395
1396 //アルファブレンド用のAPIを解放
1397 extern HINSTANCE hUser32Lib;
1398 FreeLibrary(hUser32Lib);
1399
1400
1401
1402
1403 //////////////////////////////////////
1404 // バックアップ用ファイルを削除
1405 //////////////////////////////////////
1406 extern char szBackupDirPath[MAX_PATH];
1407 RemoveDirectoryStrong(szBackupDirPath);
1408
1409}
1410
1411//各ウィンドウ生成
1412void SetupWindow(HWND hwnd){
1413 extern HINSTANCE hInst;
1414 extern HMENU hFirstMainMenu;
1415 RECT rect;
1416 CLIENTCREATESTRUCT ccs;
1417
1418 INITCOMMONCONTROLSEX InitCommCtrl;
1419 InitCommCtrl.dwSize=sizeof(INITCOMMONCONTROLSEX);
1420 InitCommCtrl.dwICC=ICC_COOL_CLASSES|ICC_PAGESCROLLER_CLASS|ICC_WIN95_CLASSES|ICC_TAB_CLASSES;
1421 InitCommonControlsEx(&InitCommCtrl);
1422
1423 //タブウィンドウ
1424 pobj_MainTab=new CMainTab(hwnd);
1425
1426 //MDIの親ウィンドウ(クライアントウィンドウ)を作成
1427 ccs.hWindowMenu=hFirstMainMenu;
1428 ccs.idFirstChild=ID_FIRSTCHILD;
1429 GetClientRect(hwnd,&rect);
1430 hClient=CreateWindowEx(WS_EX_CLIENTEDGE,"MDICLIENT",NULL,
1431 WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_VISIBLE,
1432 0,0,0,0,
1433 hwnd,(HMENU)1,hInst,(LPSTR)&ccs);
1434
1435 //レバーオブジェクトを生成
1436 pobj_Rebar=new CMainRebar(hwnd);
1437
1438 //ステータスバー
1439 extern HWND hStatusBar;
1440 extern HFONT hStatusFont;
1441 hStatusBar=CreateStatusWindow(
1442 WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBARS_SIZEGRIP|CCS_BOTTOM,
1443 NULL,hwnd,NULL);
1444 SendMessage(hStatusBar,WM_SETFONT,(long)hStatusFont,0);
1445
1446 //プロジェクト ビュー
1447 extern HWND hProjectView;
1448 extern HWND hProjectView_ToolWindow;
1449 RECT *prc;
1450 prc=&pobj_nv->rectProjectView;
1451 hProjectView_ToolWindow=CreateWindowEx(WS_EX_TOOLWINDOW,"ProjectView_ToolWindow","ProjectView",
1452 WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_CLIPCHILDREN,
1453 prc->left,prc->top,prc->right-prc->left,prc->bottom-prc->top,
1454 hwnd,0,hInst,0);
1455 hProjectView=CreateWindowEx(WS_EX_STATICEDGE,"ProjectView","ProjectView",
1456 WS_CHILD|WS_CLIPCHILDREN,
1457 0,0,0,0,
1458 hwnd,0,hInst,0);
1459 if(pobj_nv->bClipProjectView==0){
1460 SetWindowLongPtr(hProjectView,GWL_EXSTYLE,0);
1461 SetParent(hProjectView,hProjectView_ToolWindow);
1462 ResizeProjectView_ToolWindow();
1463 }
1464
1465 //メニュー状態を設定
1466 ResetState_DocMenu();
1467
1468
1469 //SideWebを生成
1470 //pobj_SideWeb=new CSideWeb(hwnd);
1471}
1472
1473//実行コマンド
1474BOOL SetRunning(HWND hChild){
1475 extern MDIINFO MdiInfo[MAX_WNDNUM];
1476 extern LPSTR DefFileFilter;
1477 int WndNum;
1478 char temporary[MAX_PATH],temp2[MAX_PATH];
1479 HANDLE hFind;
1480 WIN32_FIND_DATA wfd;
1481
1482 extern char *lpszCompilerName;
1483 sprintf(temporary,"%s%s",pj_editor_Dir,lpszCompilerName);
1484 hFind=FindFirstFile(temporary,&wfd);
1485 if(hFind==INVALID_HANDLE_VALUE){
1486 //"BasicCompiler.exe が見つかりません"
1487 MessageBox(hOwner,STRING_ERROR_NOBASICCOMPILER,STRING_ERROR,MB_OK|MB_ICONEXCLAMATION);
1488 return FALSE;
1489 }
1490 FindClose(hFind);
1491
1492 WndNum=GetWndNum(hChild);
1493 if(IS_DOCUMENT_TEXT(MdiInfo[WndNum].DocType)){
1494 if(MdiInfo[WndNum].path[0]=='\0'){
1495 //"保存先のファイルを指定してください"
1496 if(!GetFilePathDialog(hOwner,temp2,DefFileFilter,STRING_FILESAVETITLE_DEFAULT,0)) return FALSE;
1497
1498 if(!SaveDocument(hChild,temp2)) return 0;
1499 }
1500 else{
1501 if( MdiInfo[WndNum].pMdiTextEdit->IsModified() ){
1502 if(!SaveDocument(hChild,NULL)) return 0;
1503 }
1504 else{
1505 if(hFind=FindFirstFile(MdiInfo[WndNum].path,&wfd)){
1506 if(hFind==INVALID_HANDLE_VALUE){
1507 if(!SaveDocument(hChild,NULL)) return 0;
1508 }
1509 else FindClose(hFind);
1510 }
1511 }
1512 }
1513 }
1514 return 1;
1515}
1516
1517BOOL IsNeedCompile(char *FileName,BOOL bDebug){
1518 char temporary[MAX_PATH],temp2[MAX_PATH],temp3[MAX_PATH];
1519 HANDLE hFind,hFile;
1520 WIN32_FIND_DATA wfd;
1521 FILETIME SourceTime,ExeTime;
1522
1523 _splitpath(FileName,temporary,temp2,temp3,NULL);
1524 lstrcat(temporary,temp2);
1525 lstrcat(temporary,temp3);
1526 if(bDebug) lstrcat(temporary,"_debug.exe");
1527 else lstrcat(temporary,".exe");
1528
1529 hFind=FindFirstFile(temporary,&wfd);
1530 if(hFind==INVALID_HANDLE_VALUE) return 1;
1531 FindClose(hFind);
1532
1533 hFile=CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1534 GetFileTime(hFile,NULL,NULL,&SourceTime);
1535 CloseHandle(hFile);
1536
1537 hFile=CreateFile(temporary,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
1538 GetFileTime(hFile,NULL,NULL,&ExeTime);
1539 CloseHandle(hFile);
1540
1541 if(SourceTime.dwHighDateTime<ExeTime.dwHighDateTime) return 0;
1542 else if(SourceTime.dwHighDateTime==ExeTime.dwHighDateTime&&
1543 SourceTime.dwLowDateTime<=ExeTime.dwLowDateTime) return 0;
1544 return 1;
1545}
1546
1547string GetLastErrorString(){
1548 char *lpMsgBuf;
1549
1550 FormatMessage(
1551 FORMAT_MESSAGE_ALLOCATE_BUFFER |
1552 FORMAT_MESSAGE_FROM_SYSTEM |
1553 FORMAT_MESSAGE_IGNORE_INSERTS,
1554 NULL,
1555 GetLastError(),
1556 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // デフォルト言語
1557 (LPTSTR) &lpMsgBuf,
1558 0,
1559 NULL
1560 );
1561
1562 string result = lpMsgBuf;
1563
1564 LocalFree( lpMsgBuf );
1565
1566 return result;
1567}
Note: See TracBrowser for help on using the repository browser.