source: dev/ProjectEditor/SubOperation.cpp@ 80

Last change on this file since 80 was 80, checked in by dai_9181, 18 years ago

TheText用のリソースを追加。
単語単位での検索を可能にした。

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