source: dev/ProjectEditor/SubOperation.cpp@ 62

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

TheTextのコンパイルを通るようにした。

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