source: dev/trunk/abdev/ProjectEditor/IconEditor_Main.cpp@ 154

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

未対応形式のアイコンファイルを開けないようにした。

File size: 46.6 KB
Line 
1#include "Common.h"
2
3#define ZOOMED_XPOS 100
4#define PIXEL_WIDTH 10
5
6RGBQUAD TransparentRgbq={230,230,255}; //blue,green,red(透明色)
7COLORREF TransparentClrRef=RGB(255,230,230); //red,green,blue(透明色)
8
9void IconEdit_SelectImage(int WndNum);
10
11void LimitRectFormat(int WndNum,RECT *pRect){
12 //はみ出した場合は範囲内におさめる
13 extern MDIINFO MdiInfo[MAX_WNDNUM];
14 if(pRect->left<0) pRect->left=0;
15 if(pRect->top<0) pRect->top=0;
16 if(pRect->left>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth)
17 pRect->left=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth-1;
18 if(pRect->top>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
19 pRect->top=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2-1;
20
21 if(pRect->right<0) pRect->right=0;
22 if(pRect->bottom<0) pRect->bottom=0;
23 if(pRect->right>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth)
24 pRect->right=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth-1;
25 if(pRect->bottom>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
26 pRect->bottom=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2-1;
27}
28void GetZoomedPos(POINT *pPos){
29 pPos->x=pPos->x*PIXEL_WIDTH+ZOOMED_XPOS;
30 pPos->y*=PIXEL_WIDTH;
31}
32void SetZoomedPixel(HDC hdc,int WndNum,int x,int y){
33 extern MDIINFO MdiInfo[MAX_WNDNUM];
34 POINT pos;
35
36 if(x<0||y<0||
37 x>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth||
38 y>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
39 return;
40
41 pos.x=x;
42 pos.y=y;
43 GetZoomedPos(&pos);
44 Rectangle(hdc,pos.x,pos.y,pos.x+11,pos.y+11);
45}
46DWORD GetColorCode(int WndNum,COLORREF ColorRef){
47 extern MDIINFO MdiInfo[MAX_WNDNUM];
48 int i,i2;
49 RGBQUAD *pRgbq;
50
51 //透明色の場合
52 if(ColorRef==TransparentClrRef) return -1;
53
54 //カラーテーブルを取得
55 pRgbq=(RGBQUAD *)(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+sizeof(BITMAPINFOHEADER));
56
57 i2=(int)pow((double)2,(double)MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biBitCount);
58 for(i=0;i<i2;i++){
59 if(ColorRef==RGB(pRgbq[i].rgbRed,pRgbq[i].rgbGreen,pRgbq[i].rgbBlue)) break;
60 }
61 if(i==i2) i=0;
62
63 return i;
64}
65HGLOBAL IconEdit_GetChildInfoClipboardData(int WndNum){
66 //////////////////////////////////////////////
67 // 選択中のイメージをクリップボードへ保存する
68 //////////////////////////////////////////////
69
70 extern MDIINFO MdiInfo[MAX_WNDNUM];
71 HDC hDC;
72 HBITMAP hBmp;
73 SIZE size;
74 int sw;
75
76 //何も選択されていない場合は0を返す
77 sw=0;
78 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==0) return 0;
79 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==1){
80 IconEdit_SelectImage(WndNum);
81 sw=1;
82 }
83
84 size.cx=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left+1;
85 size.cy=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top+1;
86
87 hDC=CreateCompatibleDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
88 hBmp=CreateCompatibleBitmap(
89 MdiInfo[WndNum].MdiIconEditInfo->memdc,
90 size.cx,
91 size.cy);
92 SelectObject(hDC,hBmp);
93
94 BitBlt(hDC,0,0,size.cx,size.cy,
95 MdiInfo[WndNum].MdiIconEditInfo->memdc,
96 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left,
97 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top,
98 SRCCOPY);
99
100 DeleteDC(hDC);
101
102 if(sw){
103 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
104 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=1;
105 }
106
107 return hBmp;
108}
109void IconEdit_PasteChildInfoClipboardData(int WndNum,HBITMAP hBmp){
110 ////////////////////////////////////
111 // クリップボードの内容を貼り付ける
112 ////////////////////////////////////
113
114 extern MDIINFO MdiInfo[MAX_WNDNUM];
115 HDC hDC,hDC2;
116 BITMAP Bitmap;
117
118 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
119 IconEdit_PasteImage(WndNum);
120
121 GetObject(hBmp,sizeof(Bitmap),&Bitmap);
122
123 hDC=CreateCompatibleDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
124 MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp=
125 CreateCompatibleBitmap(MdiInfo[WndNum].MdiIconEditInfo->memdc,Bitmap.bmWidth,Bitmap.bmHeight);
126 SelectObject(hDC,MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
127 hDC2=CreateCompatibleDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
128 SelectObject(hDC2,hBmp);
129
130 BitBlt(hDC,0,0,Bitmap.bmWidth,Bitmap.bmHeight,
131 hDC2,0,0,SRCCOPY);
132
133 DeleteDC(hDC);
134 DeleteDC(hDC2);
135
136 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left=0;
137 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top=0;
138 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right=Bitmap.bmWidth-1;
139 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom=Bitmap.bmHeight-1;
140
141 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
142
143 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=2;
144}
145
146void IconEdit_SelectImage(int WndNum){
147 extern MDIINFO MdiInfo[MAX_WNDNUM];
148 SIZE size;
149 HDC hDC;
150
151 size.cx=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left+1;
152 size.cy=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top+1;
153
154 hDC=CreateCompatibleDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
155 MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp=
156 CreateCompatibleBitmap(MdiInfo[WndNum].MdiIconEditInfo->memdc,size.cx,size.cy);
157 SelectObject(hDC,MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
158 BitBlt(hDC,0,0,size.cx,size.cy,
159 MdiInfo[WndNum].MdiIconEditInfo->memdc,
160 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left,
161 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top,
162 SRCCOPY);
163 DeleteDC(hDC);
164
165 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=2;
166}
167void IconEdit_PasteImage(int WndNum){
168 extern HANDLE hHeap;
169 extern MDIINFO MdiInfo[MAX_WNDNUM];
170 int i,i2,i3,x,y,y2,selecting_x,selecting_y;
171 DWORD dwRgbq;
172
173 //コピー先
174 RGBQUAD *pRgbq;
175 BYTE *pBuffer,*pMaskBuf;
176 BITMAPINFOHEADER *pBmpInfoHdr;
177
178 //コピー元
179 BITMAP Bitmap;
180 BITMAPINFO SelectingBitmapInfo;
181 COLORREF *pSelectingBuffer;
182
183 //変更情報
184 IconEdit_NoticeChanging(WndNum);
185
186 GetObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp,sizeof(BITMAP),&Bitmap);
187 pSelectingBuffer=(COLORREF *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
188 SelectingBitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
189 SelectingBitmapInfo.bmiHeader.biWidth=Bitmap.bmWidth;
190 SelectingBitmapInfo.bmiHeader.biHeight=Bitmap.bmHeight;
191 SelectingBitmapInfo.bmiHeader.biPlanes=1;
192 SelectingBitmapInfo.bmiHeader.biBitCount=32;
193 SelectingBitmapInfo.bmiHeader.biCompression=BI_RGB;
194 GetDIBits(MdiInfo[WndNum].MdiIconEditInfo->memdc,
195 MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp,
196 0,Bitmap.bmHeight,
197 pSelectingBuffer,&SelectingBitmapInfo,DIB_RGB_COLORS);
198
199 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
200
201 //カラーテーブルを取得
202 pRgbq=(RGBQUAD *)(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+sizeof(BITMAPINFOHEADER));
203
204 //ビットバッファを取得
205 pBuffer=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+
206 sizeof(BITMAPINFOHEADER);
207 if(pBmpInfoHdr->biBitCount<=8)
208 pBuffer+=sizeof(DWORD)*(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
209
210 //マスクバッファを取得
211 pMaskBuf=pBuffer+pBmpInfoHdr->biBitCount*pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
212
213 for(y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom;y>=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;y--){
214 for(x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;x<=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right;x++){
215 if(x<0||y<0||
216 x>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth||
217 y>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2){
218 //範囲外の場合
219 continue;
220 }
221
222 selecting_x=x-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;
223 selecting_y=y-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;
224 dwRgbq=pSelectingBuffer[(Bitmap.bmHeight-1-selecting_y)*Bitmap.bmWidth+selecting_x];
225
226 if(pBmpInfoHdr->biBitCount==4||pBmpInfoHdr->biBitCount==8){
227 i=(pBmpInfoHdr->biHeight/2-1-y)*pBmpInfoHdr->biWidth+x;
228 if(dwRgbq==*(DWORD *)&TransparentRgbq){
229 //////////////////
230 // 透明色にセット
231 if(pBmpInfoHdr->biWidth==16){
232 //一行の4バイト境界を考慮
233 y2=(pBmpInfoHdr->biHeight/2-1)-y;
234 pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]|=0x01<<(8-(i%8+1));
235 }
236 else pMaskBuf[i/8]|=0x01<<(8-(i%8+1));
237
238 /////////////////
239 // 色を0にセット
240 i3=(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
241 for(i2=0;i2<i3;i2++){
242 if(dwRgbq==((DWORD *)pRgbq)[i2]) break;
243 }
244 switch(pBmpInfoHdr->biBitCount){
245 case 4: //16色
246 if(i%2==0) *(pBuffer+i/2)&=0x0F;
247 else *(pBuffer+i/2)&=0xF0;
248 break;
249 case 8: //256色
250 pBuffer[i]=0;
251 break;
252 }
253 }
254 else{
255 ////////////////////
256 // 無透明色にセット
257 if(pBmpInfoHdr->biWidth==16){
258 //一行の4バイト境界を考慮
259 y2=(pBmpInfoHdr->biHeight/2-1)-y;
260 pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]&=~(0x01<<(8-(i%8+1)));
261 }
262 else pMaskBuf[i/8]&=~(0x01<<(8-(i%8+1)));
263
264 //////////////
265 // 色をセット
266 i3=(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
267 for(i2=0;i2<i3;i2++){
268 if(dwRgbq==((DWORD *)pRgbq)[i2]) break;
269 }
270 switch(pBmpInfoHdr->biBitCount){
271 case 4: //16色
272 if(i%2==0){
273 *(pBuffer+i/2)&=0x0F;
274 *(pBuffer+i/2)|=i2<<4;
275 }
276 else{
277 *(pBuffer+i/2)&=0xF0;
278 *(pBuffer+i/2)|=i2;
279 }
280 break;
281 case 8: //256色
282 pBuffer[i]=i2;
283 break;
284 }
285 }
286 }
287 }
288 }
289 HeapDefaultFree(pSelectingBuffer);
290
291 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
292 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
293
294 DrawIconToMemBmp(WndNum,0);
295 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
296}
297
298void DrawIconToMemBmp(int WndNum,RECT *pRect){
299 extern MDIINFO MdiInfo[MAX_WNDNUM];
300 HPEN hPen,hOldPen;
301 HBRUSH hBrush,hOldBrush;
302 int i,i2,i3,x,y,y2;
303 POINT pos;
304 RGBQUAD *pRgbq;
305 COLORREF ColorRef;
306 BYTE *pBuffer,*pMaskBuf;
307 BITMAPINFOHEADER *pBmpInfoHdr;
308
309 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
310
311 if( !(pBmpInfoHdr->biBitCount == 4 || pBmpInfoHdr->biBitCount == 8 ) ){
312 //16色、256色以外の場合
313 //未対応
314 return;
315 }
316
317 hPen=CreatePen(PS_SOLID,0,RGB(200,200,200));
318 hOldPen=(HPEN)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hPen);
319
320 //カラーテーブルを取得
321 pRgbq=(RGBQUAD *)(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+sizeof(BITMAPINFOHEADER));
322
323 //ビットバッファを取得
324 pBuffer=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+
325 sizeof(BITMAPINFOHEADER);
326 if(pBmpInfoHdr->biBitCount<=8)
327 pBuffer+=sizeof(DWORD)*(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
328
329 //マスクバッファを取得
330 pMaskBuf=pBuffer+pBmpInfoHdr->biBitCount*pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
331
332 i=0; //標準ピクセルのバイトカウンタ
333 i3=0; //透明ピクセルのバイトカウンタ
334 for(y=pBmpInfoHdr->biHeight/2-1;y>=0;y--){
335 for(x=0;x<pBmpInfoHdr->biWidth;x++,i++,i3++){
336 if(pRect){
337 //メモリへの再描画が必要ない場合を検証(実行速度向上のため)
338 if(!(pRect->left<=x&&x<=pRect->right&&
339 pRect->top<=y&&y<=pRect->bottom)) continue;
340 }
341
342 //////////////////////
343 // マスクビットの確認
344 if(pBmpInfoHdr->biWidth==16){
345 //一行の4バイト境界を考慮
346 y2=(pBmpInfoHdr->biHeight/2-1)-y;
347 i2=(pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]>>(8-(i%8+1)))&0x01;
348 }
349 else i2=(pMaskBuf[i/8]>>(8-(i%8+1)))&0x01;
350 if(i2){
351 hBrush=CreateSolidBrush(TransparentClrRef);
352 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hBrush);
353 pos.x=x;
354 pos.y=y;
355 GetZoomedPos(&pos);
356 Rectangle(MdiInfo[WndNum].MdiIconEditInfo->memdc,
357 pos.x,
358 pos.y,
359 pos.x+11,
360 pos.y+11);
361 SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldBrush);
362 DeleteObject(hBrush);
363
364 SetPixel(MdiInfo[WndNum].MdiIconEditInfo->memdc,x,y,TransparentClrRef);
365 continue;
366 }
367
368 ////////////////
369 // 通常ピクセル
370 if( pBmpInfoHdr->biBitCount == 4 ){
371 //16色
372 i2=*(pBuffer+i/2);
373 if(i%2==0) i2>>=4;
374 i2&=0x0F;
375 ColorRef=RGB(pRgbq[i2].rgbRed,pRgbq[i2].rgbGreen,pRgbq[i2].rgbBlue);
376 }
377 else if( pBmpInfoHdr->biBitCount == 8 ){
378 //256色
379 i2=pBuffer[i];
380 ColorRef=RGB(pRgbq[i2].rgbRed,pRgbq[i2].rgbGreen,pRgbq[i2].rgbBlue);
381 break;
382 }
383
384 hBrush=CreateSolidBrush(ColorRef);
385 hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hBrush);
386 pos.x=x;
387 pos.y=y;
388 GetZoomedPos(&pos);
389 Rectangle(MdiInfo[WndNum].MdiIconEditInfo->memdc,
390 pos.x,
391 pos.y,
392 pos.x+11,
393 pos.y+11);
394 SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldBrush);
395 DeleteObject(hBrush);
396
397 SetPixel(MdiInfo[WndNum].MdiIconEditInfo->memdc,x,y,ColorRef);
398 }
399 }
400
401 SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldPen);
402 DeleteObject(hPen);
403}
404
405void PixelChange(int WndNum,int x,int y,DWORD ColorCode){
406 extern MDIINFO MdiInfo[MAX_WNDNUM];
407 int i;
408 int y2;
409 BYTE *pBuffer,*pMaskBuf;
410 BITMAPINFOHEADER *pBmpInfoHdr;
411
412 if(x<0||y<0) return;
413 if(x>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth||
414 y>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
415 return;
416
417 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
418
419 pBuffer=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+
420 sizeof(BITMAPINFOHEADER);
421 pBuffer+=sizeof(DWORD)*(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
422
423 pMaskBuf=pBuffer+pBmpInfoHdr->biBitCount*pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
424
425 if(x>=pBmpInfoHdr->biWidth||y>=pBmpInfoHdr->biHeight/2) return;
426 y2=(pBmpInfoHdr->biHeight/2-1)-y;
427 i=pBmpInfoHdr->biWidth*y2+x;
428
429 //////////////////
430 // マスクピクセル
431 if(ColorCode==-1){
432 //透明色に指定
433 if(pBmpInfoHdr->biWidth==16){
434 //一行の4バイト境界を考慮
435 pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]|=0x01<<(8-(i%8+1));
436 }
437 else pMaskBuf[i/8]|=0x01<<(8-(i%8+1));
438
439 ColorCode=0;
440 }
441 else{
442 //無透明色に指定
443 if(pBmpInfoHdr->biWidth==16){
444 //一行の4バイト境界を考慮
445 pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]&=~(0x01<<(8-(i%8+1)));
446 }
447 else pMaskBuf[i/8]&=~(0x01<<(8-(i%8+1)));
448 }
449
450 ////////////////
451 // 通常ピクセル
452 switch(pBmpInfoHdr->biBitCount){
453 case 4:
454 ////////
455 // 16色
456 if(i%2) *(pBuffer+i/2)=(*(pBuffer+i/2)&0xF0)|(BYTE)ColorCode;
457 else *(pBuffer+i/2)=(*(pBuffer+i/2)&0x0F)|(BYTE)ColorCode<<4;
458 break;
459 case 8:
460 /////////
461 // 256色
462 pBuffer[i]=(BYTE)ColorCode;
463 break;
464 }
465}
466COLORREF IconEdit_GetPixel(int WndNum,int x,int y){
467 extern MDIINFO MdiInfo[MAX_WNDNUM];
468 int i,i2;
469 int y2;
470 BYTE *pBuffer,*pMaskBuf;
471 BITMAPINFOHEADER *pBmpInfoHdr;
472 RGBQUAD *pRgbq;
473 COLORREF ColorRef;
474
475 if(x<0||y<0) return 0;
476 if(x>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth||
477 y>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
478 return 0;
479
480 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
481
482 //カラーテーブルを取得
483 pRgbq=(RGBQUAD *)(MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+sizeof(BITMAPINFOHEADER));
484
485 //通常バッファを取得
486 pBuffer=MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]+
487 sizeof(BITMAPINFOHEADER)+
488 sizeof(DWORD)*(int)pow((double)2,(double)pBmpInfoHdr->biBitCount);
489
490 //マスクバッファを取得
491 pMaskBuf=pBuffer+pBmpInfoHdr->biBitCount*pBmpInfoHdr->biWidth*(pBmpInfoHdr->biHeight/2)/8;
492
493 if(x>=pBmpInfoHdr->biWidth||y>=pBmpInfoHdr->biHeight/2) return 0;
494 y2=(pBmpInfoHdr->biHeight/2-1)-y;
495 i=pBmpInfoHdr->biWidth*y2+x;
496
497 //////////////////
498 // マスクピクセル
499 if(pBmpInfoHdr->biWidth==16){
500 //一行の4バイト境界を考慮
501 if((pMaskBuf[(i+pBmpInfoHdr->biWidth*y2)/8]>>(8-(i%8+1)))&0x01)
502 return TransparentClrRef;
503 }
504 else{
505 if((pMaskBuf[i/8]>>(8-(i%8+1)))&0x01)
506 return TransparentClrRef;
507 }
508
509 ////////////////
510 // 通常ピクセル
511 switch(pBmpInfoHdr->biBitCount){
512 case 4: //16色
513 if(i%2) i2=*(pBuffer+i/2)&0x0F;
514 else i2=(*(pBuffer+i/2)>>4)&0x0F;
515 ColorRef=RGB(pRgbq[i2].rgbRed,pRgbq[i2].rgbGreen,pRgbq[i2].rgbBlue);
516 break;
517 case 8: //256色
518 i2=pBuffer[i];
519 ColorRef=RGB(pRgbq[i2].rgbRed,pRgbq[i2].rgbGreen,pRgbq[i2].rgbBlue);
520 break;
521 }
522 return ColorRef;
523}
524void IconEdit_DrawLine(int WndNum,int x1,int y1,int x2,int y2,DWORD ColorCode){
525 extern MDIINFO MdiInfo[MAX_WNDNUM];
526 int dx,dy,s,step;
527
528 dx=abs(x2-x1);
529 dy=abs(y2-y1);
530 if(dx>dy){
531 if(x1>x2){
532 step=(y1>y2)?1:-1;
533 s=x1;
534 x1=x2;
535 x2=s;
536 y1=y2;
537 }
538 else step=(y1<y2)?1:-1;
539
540 PixelChange(WndNum,x1,y1,ColorCode);
541
542 s=dx>>1;
543 while(++x1<=x2){
544 if((s-=dy)<0){
545 s+=dx;
546 y1+=step;
547 }
548
549 PixelChange(WndNum,x1,y1,ColorCode);
550 }
551 }
552 else{
553 if(y1>y2){
554 step=(x1>x2)?1:-1;
555 s=y1;
556 y1=y2;
557 y2=s;
558 x1=x2;
559 }
560 else step=(x1<x2)?1:-1;
561
562 PixelChange(WndNum,x1,y1,ColorCode);
563
564 s=dy>>1;
565 while(++y1<=y2){
566 if((s-=dx)<0){
567 s+=dy;
568 x1+=step;
569 }
570
571 PixelChange(WndNum,x1,y1,ColorCode);
572 }
573 }
574}
575void IconEdit_FloodFill(int WndNum,int x,int y,COLORREF FilledColor,DWORD ColorCode){
576 extern MDIINFO MdiInfo[MAX_WNDNUM];
577
578 if(x<0||y<0) return;
579 if(x>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biWidth||
580 y>=MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum]->biHeight/2)
581 return;
582
583 PixelChange(WndNum,x,y,ColorCode);
584
585 if(IconEdit_GetPixel(WndNum,x,y+1)==FilledColor)
586 IconEdit_FloodFill(WndNum,x,y+1,FilledColor,ColorCode);
587 if(IconEdit_GetPixel(WndNum,x+1,y)==FilledColor)
588 IconEdit_FloodFill(WndNum,x+1,y,FilledColor,ColorCode);
589 if(IconEdit_GetPixel(WndNum,x,y-1)==FilledColor)
590 IconEdit_FloodFill(WndNum,x,y-1,FilledColor,ColorCode);
591 if(IconEdit_GetPixel(WndNum,x-1,y)==FilledColor)
592 IconEdit_FloodFill(WndNum,x-1,y,FilledColor,ColorCode);
593}
594void IconEdit_DrawRectangle(int WndNum,int x1,int y1,int x2,int y2,DWORD ColorCode,DWORD FillClrCode,BOOL bFill){
595 RectNaturalFormat(&x1,&y1,&x2,&y2);
596
597 IconEdit_DrawLine(WndNum,x1,y1,x1,y2,ColorCode);
598 IconEdit_DrawLine(WndNum,x2,y1,x2,y2,ColorCode);
599 IconEdit_DrawLine(WndNum,x1+1,y1,x2-1,y1,ColorCode);
600 IconEdit_DrawLine(WndNum,x1+1,y2,x2-1,y2,ColorCode);
601
602 if(bFill){
603 int x,y;
604 for(x=x1+1;x<x2;x++){
605 for(y=y1+1;y<y2;y++) PixelChange(WndNum,x,y,FillClrCode);
606 }
607 }
608}
609void IconEdit_DrawEllipse(int WndNum,int x1,int y1,int x2,int y2,DWORD ColorCode){
610 extern MDIINFO MdiInfo[MAX_WNDNUM];
611 RECT rect,rc2;
612
613 rect.left=x1;
614 rect.top=y1;
615 rect.right=x2;
616 rect.bottom=y2;
617 RectNaturalFormat(&rect,&rc2);
618
619 int xc,yc,rx,ry;
620 int x,y,r;
621
622 rx=(rc2.right-rc2.left)/2;
623 ry=(rc2.bottom-rc2.top)/2;
624 xc=rc2.left+rx;
625 yc=rc2.top+ry;
626 if(rx==0&&ry==0){
627 if(rc2.bottom-rc2.top==1&&rc2.bottom-rc2.top==1)
628 IconEdit_DrawRectangle(WndNum,x1,y1,x2,y2,ColorCode,0,0);
629 else IconEdit_DrawLine(WndNum,x1,y1,x2,y2,ColorCode);
630 return;
631 }
632
633 int bX,bY;
634 if((rc2.right-rc2.left)%2) bX=1;
635 else bX=0;
636 if((rc2.bottom-rc2.top)%2) bY=1;
637 else bY=0;
638
639 if(rx>ry){
640 x=r=rx;
641 y=0;
642 while(x>=y){
643 x1=x*ry/rx;
644 y1=y*ry/rx;
645
646 PixelChange(WndNum,xc+x+bX,yc+y1+bY,ColorCode);
647 PixelChange(WndNum,xc+x+bX,yc-y1,ColorCode);
648 PixelChange(WndNum,xc-x,yc+y1+bY,ColorCode);
649 PixelChange(WndNum,xc-x,yc-y1,ColorCode);
650 PixelChange(WndNum,xc+y+bX,yc+x1+bY,ColorCode);
651 PixelChange(WndNum,xc+y+bX,yc-x1,ColorCode);
652 PixelChange(WndNum,xc-y,yc+x1+bY,ColorCode);
653 PixelChange(WndNum,xc-y,yc-x1,ColorCode);
654
655 if((r-=(y++<<1)+1)<=0) r+=(x-- -1)<<1;
656 }
657 }
658 else{
659 x=r=ry;
660 y=0;
661 while(x>=y){
662 x1=x*rx/ry;
663 y1=y*rx/ry;
664
665 PixelChange(WndNum,xc+x1+bX,yc+y+bY,ColorCode);
666 PixelChange(WndNum,xc+x1+bX,yc-y,ColorCode);
667 PixelChange(WndNum,xc-x1,yc+y+bY,ColorCode);
668 PixelChange(WndNum,xc-x1,yc-y,ColorCode);
669 PixelChange(WndNum,xc+y1+bX,yc+x+bY,ColorCode);
670 PixelChange(WndNum,xc+y1+bX,yc-x,ColorCode);
671 PixelChange(WndNum,xc-y1,yc+x+bY,ColorCode);
672 PixelChange(WndNum,xc-y1,yc-x,ColorCode);
673
674 if((r-=(y++<<1)+1)<=0) r+=(x-- -1)<<1;
675 }
676 }
677}
678
679void IconEdit_EraseRect(int WndNum,RECT *pRect){
680 extern MDIINFO MdiInfo[MAX_WNDNUM];
681
682 //変更情報
683 IconEdit_NoticeChanging(WndNum);
684
685 IconEdit_DrawRectangle(WndNum,
686 pRect->left,
687 pRect->top,
688 pRect->right,
689 pRect->bottom,
690 GetColorCode(WndNum,MdiInfo[WndNum].MdiIconEditInfo->SubColor),
691 GetColorCode(WndNum,MdiInfo[WndNum].MdiIconEditInfo->SubColor),1);
692
693 DrawIconToMemBmp(WndNum,0);
694 InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
695}
696
697void IconEdit_DrawFrame(HWND hwnd,int WndNum,RECT *pRect){
698 extern MDIINFO MdiInfo[MAX_WNDNUM];
699 HDC hdc;
700 HPEN hPen,hOldPen;
701 HBRUSH hOldBrush;
702 RECT rect;
703 POINT pos;
704
705 //////////////////////
706 // 選択フレームの描画
707
708 hdc=GetDC(hwnd);
709
710 //以前の選択フレームを消去
711 BITMAPINFOHEADER *pBmpInfoHdr;
712 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
713 pos.x=pBmpInfoHdr->biWidth;
714 pos.y=pBmpInfoHdr->biHeight/2;
715 GetZoomedPos(&pos);
716 BitBlt(hdc,0,0,pos.x,pos.y,MdiInfo[WndNum].MdiIconEditInfo->memdc,0,0,SRCCOPY);
717
718
719 hPen=CreatePen(PS_DOT,0,RGB(0,0,0));
720 SetBkMode(hdc,TRANSPARENT);
721 hOldPen=(HPEN)SelectObject(hdc,hPen);
722 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(NULL_BRUSH));
723
724 pos.x=pRect->left;
725 pos.y=pRect->top;
726 GetZoomedPos(&pos);
727 rect.left=pos.x;
728 rect.top=pos.y;
729
730 pos.x=pRect->right+1;
731 pos.y=pRect->bottom+1;
732 GetZoomedPos(&pos);
733 rect.right=pos.x+1;
734 rect.bottom=pos.y+1;
735
736 Rectangle(hdc,rect.left,rect.top,rect.right,rect.bottom);
737 SelectObject(hdc,hOldBrush);
738 SelectObject(hdc,hOldPen);
739 DeleteObject(hPen);
740
741 ReleaseDC(hwnd,hdc);
742}
743void IconEdit_DrawSelectingRect(HDC hdc,int WndNum){
744 extern MDIINFO MdiInfo[MAX_WNDNUM];
745 int i2,i3;
746 HPEN hPen,hOldPen;
747 HBRUSH hOldBrush;
748 COLORREF rgb;
749 RECT rect;
750
751 rect.left=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left*PIXEL_WIDTH+ZOOMED_XPOS;
752 rect.top=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top*PIXEL_WIDTH;
753 rect.right=(MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right+1)*PIXEL_WIDTH+ZOOMED_XPOS+1;
754 rect.bottom=(MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom+1)*PIXEL_WIDTH+1;
755
756 SetBkMode(hdc,TRANSPARENT);
757
758 //主線
759 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(NULL_BRUSH));
760 hPen=CreatePen(PS_SOLID,0,RGB(0,0,0));
761 hOldPen=(HPEN)SelectObject(hdc,hPen);
762 Rectangle(hdc,
763 rect.left+2, rect.top+2,
764 rect.right-2, rect.bottom-2);
765 SelectObject(hdc,hOldPen);
766 DeleteObject(hPen);
767 hPen=CreatePen(PS_SOLID,0,RGB(255,255,255));
768 hOldPen=(HPEN)SelectObject(hdc,hPen);
769 Rectangle(hdc,
770 rect.left+1, rect.top+1,
771 rect.right-1, rect.bottom-1);
772 SelectObject(hdc,hOldPen);
773 DeleteObject(hPen);
774 SelectObject(hdc,hOldBrush);
775
776 rgb=RGB(255,60,30);
777 hPen=CreatePen(PS_SOLID,0,rgb);
778 hOldPen=(HPEN)SelectObject(hdc,hPen);
779
780 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(WHITE_BRUSH));
781
782 Rectangle(hdc,
783 rect.left,rect.top,
784 rect.left+5,rect.top+5);
785 Rectangle(hdc,
786 rect.left,rect.bottom-5,
787 rect.left+5,rect.bottom);
788 Rectangle(hdc,
789 rect.right-5,rect.top,
790 rect.right,rect.top+5);
791 Rectangle(hdc,
792 rect.right-5,rect.bottom-5,
793 rect.right,rect.bottom);
794
795 i2=(rect.right-rect.left)/2;
796 i3=(rect.bottom-rect.top)/2;
797 Rectangle(hdc,
798 rect.left+i2-2,rect.top,
799 rect.left+i2+3,rect.top+5);
800 Rectangle(hdc,
801 rect.left+i2-2,rect.bottom-5,
802 rect.left+i2+3,rect.bottom);
803 Rectangle(hdc,
804 rect.left,rect.top+i3-2,
805 rect.left+5,rect.top+i3+3);
806 Rectangle(hdc,
807 rect.right-5,rect.top+i3-2,
808 rect.right,rect.top+i3+3);
809
810 SelectObject(hdc,hOldBrush);
811
812 SelectObject(hdc,hOldPen);
813 DeleteObject(hPen);
814}
815void DrawZoomedBitmap(HDC hdc,int WndNum,POINT *pPos){
816 extern HANDLE hHeap;
817 extern MDIINFO MdiInfo[MAX_WNDNUM];
818 int x,y;
819 RGBQUAD rgbq;
820 HPEN hPen,hOldPen;
821 POINT pos;
822
823 BITMAP Bitmap;
824 BITMAPINFO SelectingBitmapInfo;
825 COLORREF *pSelectingBuffer;
826
827 GetObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp,sizeof(BITMAP),&Bitmap);
828 pSelectingBuffer=(COLORREF *)HeapAlloc(hHeap,0,Bitmap.bmWidth*Bitmap.bmHeight*sizeof(COLORREF));
829 SelectingBitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
830 SelectingBitmapInfo.bmiHeader.biWidth=Bitmap.bmWidth;
831 SelectingBitmapInfo.bmiHeader.biHeight=Bitmap.bmHeight;
832 SelectingBitmapInfo.bmiHeader.biPlanes=1;
833 SelectingBitmapInfo.bmiHeader.biBitCount=32;
834 SelectingBitmapInfo.bmiHeader.biCompression=BI_RGB;
835 GetDIBits(MdiInfo[WndNum].MdiIconEditInfo->memdc,
836 MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp,
837 0,Bitmap.bmHeight,
838 pSelectingBuffer,&SelectingBitmapInfo,DIB_RGB_COLORS);
839
840 hPen=CreatePen(PS_SOLID,0,RGB(200,200,200));
841 hOldPen=(HPEN)SelectObject(hdc,hPen);
842
843 for(y=Bitmap.bmHeight-1;y>=0;y--){
844 for(x=0;x<Bitmap.bmWidth;x++){
845 memcpy(&rgbq,
846 &pSelectingBuffer[(Bitmap.bmHeight-y-1)*Bitmap.bmWidth+x],
847 sizeof(RGBQUAD));
848
849 HBRUSH hBrush,hOldBrush;
850 hBrush=CreateSolidBrush(RGB(rgbq.rgbRed,rgbq.rgbGreen,rgbq.rgbBlue));
851 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
852
853 pos.x=pPos->x+x;
854 pos.y=pPos->y+y;
855 GetZoomedPos(&pos);
856 Rectangle(hdc,pos.x,pos.y,pos.x+11,pos.y+11);
857
858 SelectObject(hdc,hOldBrush);
859 DeleteObject(hBrush);
860 }
861 }
862
863 SelectObject(hdc,hOldPen);
864 DeleteObject(hPen);
865
866 HeapDefaultFree(pSelectingBuffer);
867}
868int IconEdit_GetStateOfDraggingFrame(int WndNum,int x,int y){
869 extern MDIINFO MdiInfo[MAX_WNDNUM];
870 POINT pos;
871 RECT rect;
872
873 pos.x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;
874 pos.y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;
875 GetZoomedPos(&pos);
876 rect.left=pos.x;
877 rect.top=pos.y;
878 pos.x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right+1;
879 pos.y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom+1;
880 GetZoomedPos(&pos);
881 rect.right=pos.x;
882 rect.bottom=pos.y;
883
884 if(rect.left<x&&x<rect.right&&
885 rect.top<y&&y<rect.bottom) return FRAME_INSIDE;
886 return 0;
887}
888void DrawSelectingImage(HDC hdc,int WndNum){
889 /////////////////////////////////
890 // 選択されているイメージを表示
891
892 extern MDIINFO MdiInfo[MAX_WNDNUM];
893 HDC hDC2;
894 SIZE size;
895 POINT pos;
896
897 size.cx=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;
898 size.cy=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom-MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;
899 hDC2=CreateCompatibleDC(MdiInfo[WndNum].MdiIconEditInfo->memdc);
900 SelectObject(hDC2,MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
901 BitBlt(hdc,
902 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left,
903 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top,
904 size.cx,size.cy,
905 hDC2,0,0,SRCCOPY);
906 DeleteDC(hDC2);
907
908 //拡大選択イメージを表示
909 pos.x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;
910 pos.y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;
911 DrawZoomedBitmap(hdc,WndNum,&pos);
912}
913void TempLine(HDC hdc,int WndNum,int x1,int y1,int x2,int y2,COLORREF ColorRef){
914 extern MDIINFO MdiInfo[MAX_WNDNUM];
915 int dx,dy,s,step;
916 HPEN hPen,hOldPen;
917 HBRUSH hBrush,hOldBrush;
918
919 hPen=CreatePen(PS_SOLID,0,RGB(200,200,200));
920 hOldPen=(HPEN)SelectObject(hdc,hPen);
921 hBrush=CreateSolidBrush(ColorRef);
922 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
923
924 dx=abs(x2-x1);
925 dy=abs(y2-y1);
926 if(dx>dy){
927 if(x1>x2){
928 step=(y1>y2)?1:-1;
929 s=x1;
930 x1=x2;
931 x2=s;
932 y1=y2;
933 }
934 else step=(y1<y2)?1:-1;
935
936 SetZoomedPixel(hdc,WndNum,x1,y1);
937
938 s=dx>>1;
939 while(++x1<=x2){
940 if((s-=dy)<0){
941 s+=dx;
942 y1+=step;
943 }
944
945 SetZoomedPixel(hdc,WndNum,x1,y1);
946 }
947 }
948 else{
949 if(y1>y2){
950 step=(x1>x2)?1:-1;
951 s=y1;
952 y1=y2;
953 y2=s;
954 x1=x2;
955 }
956 else step=(x1<x2)?1:-1;
957
958 SetZoomedPixel(hdc,WndNum,x1,y1);
959
960 s=dy>>1;
961 while(++y1<=y2){
962 if((s-=dx)<0){
963 s+=dy;
964 x1+=step;
965 }
966
967 SetZoomedPixel(hdc,WndNum,x1,y1);
968 }
969 }
970
971 SelectObject(hdc,hOldBrush);
972 SelectObject(hdc,hOldPen);
973 DeleteObject(hPen);
974 DeleteObject(hBrush);
975}
976void TempRectangle(HDC hdc,int WndNum,int x1,int y1,int x2,int y2,COLORREF ColorRef,COLORREF FillClrRef,BOOL bFill){
977 extern MDIINFO MdiInfo[MAX_WNDNUM];
978 int x,y;
979 HPEN hPen,hOldPen;
980 HBRUSH hBrush,hOldBrush;
981 RECT rect,rc2;
982
983 hPen=CreatePen(PS_SOLID,0,ColorRef);
984 hOldPen=(HPEN)SelectObject(hdc,hPen);
985 if(!bFill) hBrush=(HBRUSH)GetStockObject(NULL_BRUSH);
986 else hBrush=CreateSolidBrush(FillClrRef);
987 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
988 Rectangle(hdc,x1,y1,x2,y2);
989 SelectObject(hdc,hOldBrush);
990 SelectObject(hdc,hOldPen);
991 DeleteObject(hPen);
992 if(bFill) DeleteObject(hBrush);
993
994 rect.left=x1;
995 rect.top=y1;
996 rect.right=x2;
997 rect.bottom=y2;
998 RectNaturalFormat(&rect,&rc2);
999
1000 hPen=CreatePen(PS_SOLID,0,RGB(200,200,200));
1001 hOldPen=(HPEN)SelectObject(hdc,hPen);
1002 hBrush=CreateSolidBrush(ColorRef);
1003 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
1004
1005 x=rc2.left;
1006 for(y=rc2.top;y<=rc2.bottom;y++)
1007 SetZoomedPixel(hdc,WndNum,x,y);
1008
1009 x=rc2.right;
1010 for(y=rc2.top;y<=rc2.bottom;y++)
1011 SetZoomedPixel(hdc,WndNum,x,y);
1012
1013 y=rc2.top;
1014 for(x=rc2.left+1;x<rc2.right;x++)
1015 SetZoomedPixel(hdc,WndNum,x,y);
1016
1017 y=rc2.bottom;
1018 for(x=rc2.left+1;x<rc2.right;x++)
1019 SetZoomedPixel(hdc,WndNum,x,y);
1020
1021 SelectObject(hdc,hOldBrush);
1022 DeleteObject(hBrush);
1023
1024 if(bFill){
1025 hBrush=CreateSolidBrush(FillClrRef);
1026 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
1027 for(x=rc2.left+1;x<rc2.right;x++){
1028 for(y=rc2.top+1;y<rc2.bottom;y++) SetZoomedPixel(hdc,WndNum,x,y);
1029 }
1030 SelectObject(hdc,hOldBrush);
1031 DeleteObject(hBrush);
1032 }
1033
1034 SelectObject(hdc,hOldPen);
1035 DeleteObject(hPen);
1036}
1037void TempEllipse(HDC hdc,int WndNum,int x1,int y1,int x2,int y2,COLORREF ColorRef){
1038 extern MDIINFO MdiInfo[MAX_WNDNUM];
1039 HPEN hPen,hOldPen;
1040 HBRUSH hBrush,hOldBrush;
1041 RECT rect,rc2;
1042
1043 rect.left=x1;
1044 rect.top=y1;
1045 rect.right=x2;
1046 rect.bottom=y2;
1047 RectNaturalFormat(&rect,&rc2);
1048
1049 int xc,yc,rx,ry;
1050 int x,y,r;
1051
1052 rx=(rc2.right-rc2.left)/2;
1053 ry=(rc2.bottom-rc2.top)/2;
1054 xc=rc2.left+rx;
1055 yc=rc2.top+ry;
1056 if(rx==0&&ry==0){
1057 if(rc2.bottom-rc2.top==1&&rc2.bottom-rc2.top==1)
1058 TempRectangle(hdc,WndNum,x1,y1,x2,y2,ColorRef,0,0);
1059 else TempLine(hdc,WndNum,x1,y1,x2,y2,ColorRef);
1060 return;
1061 }
1062
1063 int bX,bY;
1064 if((rc2.right-rc2.left)%2) bX=1;
1065 else bX=0;
1066 if((rc2.bottom-rc2.top)%2) bY=1;
1067 else bY=0;
1068
1069 hPen=CreatePen(PS_SOLID,0,RGB(200,200,200));
1070 hOldPen=(HPEN)SelectObject(hdc,hPen);
1071 hBrush=CreateSolidBrush(ColorRef);
1072 hOldBrush=(HBRUSH)SelectObject(hdc,hBrush);
1073
1074 if(rx>ry){
1075 x=r=rx;
1076 y=0;
1077 while(x>=y){
1078 x1=x*ry/rx;
1079 y1=y*ry/rx;
1080
1081 SetZoomedPixel(hdc,WndNum,xc+x+bX,yc+y1+bY);
1082 SetZoomedPixel(hdc,WndNum,xc+x+bX,yc-y1);
1083 SetZoomedPixel(hdc,WndNum,xc-x,yc+y1+bY);
1084 SetZoomedPixel(hdc,WndNum,xc-x,yc-y1);
1085 SetZoomedPixel(hdc,WndNum,xc+y+bX,yc+x1+bY);
1086 SetZoomedPixel(hdc,WndNum,xc+y+bX,yc-x1);
1087 SetZoomedPixel(hdc,WndNum,xc-y,yc+x1+bY);
1088 SetZoomedPixel(hdc,WndNum,xc-y,yc-x1);
1089
1090 SetPixel(hdc,xc+x+bX,yc+y1+bY,ColorRef);
1091 SetPixel(hdc,xc+x+bX,yc-y1,ColorRef);
1092 SetPixel(hdc,xc-x,yc+y1+bY,ColorRef);
1093 SetPixel(hdc,xc-x,yc-y1,ColorRef);
1094 SetPixel(hdc,xc+y+bX,yc+x1+bY,ColorRef);
1095 SetPixel(hdc,xc+y+bX,yc-x1,ColorRef);
1096 SetPixel(hdc,xc-y,yc+x1+bY,ColorRef);
1097 SetPixel(hdc,xc-y,yc-x1,ColorRef);
1098
1099 if((r-=(y++<<1)+1)<=0) r+=(x-- -1)<<1;
1100 }
1101 }
1102 else{
1103 x=r=ry;
1104 y=0;
1105 while(x>=y){
1106 x1=x*rx/ry;
1107 y1=y*rx/ry;
1108
1109 SetZoomedPixel(hdc,WndNum,xc+x1+bX,yc+y+bY);
1110 SetZoomedPixel(hdc,WndNum,xc+x1+bX,yc-y);
1111 SetZoomedPixel(hdc,WndNum,xc-x1,yc+y+bY);
1112 SetZoomedPixel(hdc,WndNum,xc-x1,yc-y);
1113 SetZoomedPixel(hdc,WndNum,xc+y1+bX,yc+x+bY);
1114 SetZoomedPixel(hdc,WndNum,xc+y1+bX,yc-x);
1115 SetZoomedPixel(hdc,WndNum,xc-y1,yc+x+bY);
1116 SetZoomedPixel(hdc,WndNum,xc-y1,yc-x);
1117
1118 SetPixel(hdc,xc+x1+bX,yc+y+bY,ColorRef);
1119 SetPixel(hdc,xc+x1+bX,yc-y,ColorRef);
1120 SetPixel(hdc,xc-x1,yc+y+bY,ColorRef);
1121 SetPixel(hdc,xc-x1,yc-y,ColorRef);
1122 SetPixel(hdc,xc+y1+bX,yc+x+bY,ColorRef);
1123 SetPixel(hdc,xc+y1+bX,yc-x,ColorRef);
1124 SetPixel(hdc,xc-y1,yc+x+bY,ColorRef);
1125 SetPixel(hdc,xc-y1,yc-x,ColorRef);
1126
1127 if((r-=(y++<<1)+1)<=0) r+=(x-- -1)<<1;
1128 }
1129 }
1130
1131 SelectObject(hdc,hOldBrush);
1132 SelectObject(hdc,hOldPen);
1133 DeleteObject(hPen);
1134 DeleteObject(hBrush);
1135}
1136LRESULT CALLBACK IconEditWindowProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
1137 extern MDIINFO MdiInfo[MAX_WNDNUM];
1138 int WndNum,dx,dy;
1139 BOOL bRedrawMemBmp;
1140 HDC hdc;
1141 POINT pos,p2;
1142 RECT rect,rc2;
1143 COLORREF ColorRef,MainClrRef,SubClrRef;
1144 static DWORD dwDrag; //左クリック時は1、右クリック時は2、それ以外は0
1145 static int NowDragging;
1146 static POINT LastPos;
1147 static RECT OldRect;
1148
1149 switch(message){
1150 case WM_LBUTTONDOWN:
1151 case WM_RBUTTONDOWN:
1152 if(dwDrag) return 0;
1153
1154 pos.x=(short)(LOWORD(lParam)-ZOOMED_XPOS)/PIXEL_WIDTH;
1155 pos.y=(short)HIWORD(lParam)/PIXEL_WIDTH;
1156
1157 SetFocus(hwnd);
1158 WndNum=GetWndNum(GetParent(hwnd));
1159
1160 SetCapture(hwnd);
1161 if(message==WM_LBUTTONDOWN){
1162 dwDrag=1;
1163 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1164 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1165 }
1166 else{
1167 dwDrag=2;
1168 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1169 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1170 }
1171
1172 if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_SELECT){
1173 if(dwDrag==2){
1174 dwDrag=0;
1175 ReleaseCapture();
1176 break;
1177 }
1178
1179 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel){
1180 NowDragging=IconEdit_GetStateOfDraggingFrame(WndNum,LOWORD(lParam),HIWORD(lParam));
1181 if(NowDragging==0){
1182 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==1){
1183 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
1184 InvalidateRect(hwnd,NULL,0);
1185 }
1186 else if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
1187 IconEdit_PasteImage(WndNum);
1188
1189 NowDragging=SELECTING_FRAME;
1190 }
1191 else if(NowDragging==FRAME_INSIDE){
1192 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==1){
1193 IconEdit_SelectImage(WndNum);
1194 IconEdit_EraseRect(WndNum,&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
1195 }
1196
1197 OldRect=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect;
1198 }
1199 }
1200 else{
1201 NowDragging=SELECTING_FRAME;
1202 SetCursor(LoadCursor(NULL,IDC_CROSS));
1203 }
1204
1205 LastPos=pos;
1206 InvalidateRect(hwnd,NULL,0);
1207 }
1208 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_PEN){
1209 //変更情報
1210 IconEdit_NoticeChanging(WndNum);
1211
1212 PixelChange(WndNum,pos.x,pos.y,GetColorCode(WndNum,MainClrRef));
1213 LastPos=pos;
1214
1215 rect.left=pos.x;
1216 rect.top=pos.y;
1217 rect.right=pos.x;
1218 rect.bottom=pos.y;
1219 DrawIconToMemBmp(WndNum,&rect);
1220 InvalidateRect(hwnd,NULL,0);
1221
1222 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_PEN)));
1223 }
1224 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILL){
1225 //変更情報
1226 IconEdit_NoticeChanging(WndNum);
1227
1228 hdc=GetDC(hwnd);
1229 ColorRef=GetPixel(hdc,pos.x,pos.y);
1230 ReleaseDC(hwnd,hdc);
1231 if(ColorRef!=MainClrRef){
1232 IconEdit_FloodFill(WndNum,pos.x,pos.y,ColorRef,GetColorCode(WndNum,MainClrRef));
1233
1234 DrawIconToMemBmp(WndNum,0);
1235 InvalidateRect(hwnd,NULL,0);
1236 }
1237 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_FILL)));
1238 }
1239 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_LINE||
1240 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_RECTANGLE||
1241 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT||
1242 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT2||
1243 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_ELLIPSE){
1244 hdc=GetDC(hwnd);
1245 TempLine(hdc,WndNum,pos.x,pos.y,pos.x,pos.y,MainClrRef);
1246 ReleaseDC(hwnd,hdc);
1247
1248 LastPos=pos;
1249
1250 SetCursor(LoadCursor(NULL,IDC_CROSS));
1251 }
1252 return 0;
1253 case WM_LBUTTONUP:
1254 case WM_RBUTTONUP:
1255 if(dwDrag==0) return 0;
1256 if(dwDrag==1&&message==WM_RBUTTONUP||
1257 dwDrag==2&&message==WM_LBUTTONUP) return 0;
1258
1259 WndNum=GetWndNum(GetParent(hwnd));
1260
1261 pos.x=(short)(LOWORD(lParam)-ZOOMED_XPOS)/PIXEL_WIDTH;
1262 pos.y=(short)HIWORD(lParam)/PIXEL_WIDTH;
1263
1264 if(dwDrag==1){
1265 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1266 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1267 }
1268 else{
1269 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1270 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1271 }
1272
1273 ReleaseCapture();
1274 dwDrag=0;
1275
1276 bRedrawMemBmp=0;
1277 if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_SELECT){
1278 if(NowDragging==SELECTING_FRAME){
1279 if(LastPos.x==pos.x&&LastPos.y==pos.y){
1280 ResetState_EditMenu();
1281 return 0;
1282 }
1283 rect.left=LastPos.x;
1284 rect.top=LastPos.y;
1285 rect.right=pos.x;
1286 rect.bottom=pos.y;
1287
1288 RectNaturalFormat(&rect,&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
1289 LimitRectFormat(WndNum,&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
1290 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=1;
1291 InvalidateRect(hwnd,NULL,0);
1292 }
1293 else if(NowDragging==FRAME_INSIDE)
1294 InvalidateRect(hwnd,NULL,0);
1295 }
1296 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_LINE){
1297 //変更情報
1298 IconEdit_NoticeChanging(WndNum);
1299
1300 IconEdit_DrawLine(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,GetColorCode(WndNum,MainClrRef));
1301
1302 bRedrawMemBmp=1;
1303 }
1304 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_RECTANGLE){
1305 //変更情報
1306 IconEdit_NoticeChanging(WndNum);
1307
1308 IconEdit_DrawRectangle(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,GetColorCode(WndNum,MainClrRef),0,0);
1309
1310 bRedrawMemBmp=1;
1311 }
1312 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT){
1313 //変更情報
1314 IconEdit_NoticeChanging(WndNum);
1315
1316 IconEdit_DrawRectangle(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,
1317 GetColorCode(WndNum,MainClrRef),
1318 GetColorCode(WndNum,SubClrRef),1);
1319
1320 bRedrawMemBmp=1;
1321 }
1322 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT2){
1323 //変更情報
1324 IconEdit_NoticeChanging(WndNum);
1325
1326 IconEdit_DrawRectangle(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,
1327 GetColorCode(WndNum,MainClrRef),
1328 GetColorCode(WndNum,MainClrRef),1);
1329
1330 bRedrawMemBmp=1;
1331 }
1332 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_ELLIPSE){
1333 //変更情報
1334 IconEdit_NoticeChanging(WndNum);
1335
1336 IconEdit_DrawEllipse(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,GetColorCode(WndNum,MainClrRef));
1337
1338 bRedrawMemBmp=1;
1339 }
1340
1341 if(bRedrawMemBmp){
1342 rect.left=LastPos.x;
1343 rect.top=LastPos.y;
1344 rect.right=pos.x;
1345 rect.bottom=pos.y;
1346 RectNaturalFormat(&rect,&rc2);
1347 DrawIconToMemBmp(WndNum,&rc2);
1348 InvalidateRect(hwnd,NULL,0);
1349 }
1350
1351 ResetState_EditMenu();
1352 return 0;
1353 case WM_MOUSEMOVE:
1354 WndNum=GetWndNum(GetParent(hwnd));
1355
1356 pos.x=(short)(LOWORD(lParam)-ZOOMED_XPOS)/PIXEL_WIDTH;
1357 pos.y=(short)HIWORD(lParam)/PIXEL_WIDTH;
1358
1359 if(dwDrag==1){
1360 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1361 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1362 }
1363 else{
1364 MainClrRef=MdiInfo[WndNum].MdiIconEditInfo->SubColor;
1365 SubClrRef=MdiInfo[WndNum].MdiIconEditInfo->MainColor;
1366 }
1367
1368 if(dwDrag){
1369 if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_SELECT){
1370 if(NowDragging==SELECTING_FRAME){
1371 //範囲選択中
1372 rect.left=LastPos.x;
1373 rect.top=LastPos.y;
1374 rect.right=pos.x;
1375 rect.bottom=pos.y;
1376 RectNaturalFormat(&rect,&rc2);
1377 LimitRectFormat(WndNum,&rc2);
1378 IconEdit_DrawFrame(hwnd,WndNum,&rc2);
1379 }
1380 else if(NowDragging==FRAME_INSIDE){
1381 //移動中
1382 dx=pos.x-LastPos.x;
1383 dy=pos.y-LastPos.y;
1384 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left+=dx;
1385 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right+=dx;
1386 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top+=dy;
1387 MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom+=dy;
1388 LastPos=pos;
1389
1390
1391 ////////////////////////
1392 // 古い選択範囲を再描画
1393 HRGN hRgn,hRgn2;
1394
1395 OldRect.right++;
1396 OldRect.bottom++;
1397
1398 hRgn=CreateRectRgnIndirect(&OldRect);
1399 hRgn2=CreateRectRgnIndirect(&MdiInfo[WndNum].MdiIconEditInfo->DraggingRect);
1400 CombineRgn(hRgn,hRgn,hRgn2,RGN_XOR);
1401 DeleteObject(hRgn2);
1402
1403 p2.x=OldRect.left;
1404 p2.y=OldRect.top;
1405 GetZoomedPos(&p2);
1406 rect.left=p2.x;
1407 rect.top=p2.y;
1408 p2.x=OldRect.right;
1409 p2.y=OldRect.bottom;
1410 GetZoomedPos(&p2);
1411 rect.right=p2.x+1;
1412 rect.bottom=p2.y+1;
1413 hRgn2=CreateRectRgnIndirect(&rect);
1414 CombineRgn(hRgn,hRgn,hRgn2,RGN_OR);
1415 DeleteObject(hRgn2);
1416
1417 p2.x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.left;
1418 p2.y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.top;
1419 GetZoomedPos(&p2);
1420 rect.left=p2.x;
1421 rect.top=p2.y;
1422 p2.x=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.right;
1423 p2.y=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect.bottom;
1424 GetZoomedPos(&p2);
1425 rect.right=p2.x+1;
1426 rect.bottom=p2.y+1;
1427 hRgn2=CreateRectRgnIndirect(&rect);
1428 CombineRgn(hRgn,hRgn,hRgn2,RGN_XOR);
1429 DeleteObject(hRgn2);
1430
1431 InvalidateRgn(hwnd,hRgn,0);
1432 DeleteObject(hRgn);
1433 UpdateWindow(hwnd);
1434 hdc=GetDC(hwnd);
1435 DrawSelectingImage(hdc,WndNum);
1436 ReleaseDC(hwnd,hdc);
1437
1438 OldRect=MdiInfo[WndNum].MdiIconEditInfo->DraggingRect;
1439 }
1440 }
1441 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_PEN){
1442 if(abs(pos.x-LastPos.x)>1||abs(pos.y-LastPos.y)>1){
1443 IconEdit_DrawLine(WndNum,LastPos.x,LastPos.y,pos.x,pos.y,GetColorCode(WndNum,MainClrRef));
1444
1445 rect.left=LastPos.x;
1446 rect.top=LastPos.y;
1447 rect.right=pos.x;
1448 rect.bottom=pos.y;
1449 RectNaturalFormat(&rect,&rc2);
1450 DrawIconToMemBmp(WndNum,&rc2);
1451 InvalidateRect(hwnd,NULL,0);
1452 }
1453 else{
1454 PixelChange(WndNum,pos.x,pos.y,GetColorCode(WndNum,MainClrRef));
1455
1456 rect.left=pos.x;
1457 rect.top=pos.y;
1458 rect.right=pos.x;
1459 rect.bottom=pos.y;
1460 DrawIconToMemBmp(WndNum,&rect);
1461 InvalidateRect(hwnd,NULL,0);
1462 }
1463 LastPos=pos;
1464 }
1465 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_LINE){
1466 InvalidateRect(hwnd,NULL,0);
1467 UpdateWindow(hwnd);
1468
1469 hdc=GetDC(hwnd);
1470 TempLine(hdc,WndNum,LastPos.x,LastPos.y,pos.x,pos.y,MainClrRef);
1471 ReleaseDC(hwnd,hdc);
1472 }
1473 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_RECTANGLE){
1474 InvalidateRect(hwnd,NULL,0);
1475 UpdateWindow(hwnd);
1476
1477 hdc=GetDC(hwnd);
1478 TempRectangle(hdc,WndNum,LastPos.x,LastPos.y,pos.x,pos.y,MainClrRef,0,0);
1479 ReleaseDC(hwnd,hdc);
1480 }
1481 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT){
1482 InvalidateRect(hwnd,NULL,0);
1483 UpdateWindow(hwnd);
1484
1485 hdc=GetDC(hwnd);
1486 TempRectangle(hdc,WndNum,LastPos.x,LastPos.y,pos.x,pos.y,
1487 MainClrRef,
1488 SubClrRef,1);
1489 ReleaseDC(hwnd,hdc);
1490 }
1491 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT2){
1492 InvalidateRect(hwnd,NULL,0);
1493 UpdateWindow(hwnd);
1494
1495 hdc=GetDC(hwnd);
1496 TempRectangle(hdc,WndNum,LastPos.x,LastPos.y,pos.x,pos.y,
1497 MainClrRef,
1498 MainClrRef,1);
1499 ReleaseDC(hwnd,hdc);
1500 }
1501 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_ELLIPSE){
1502 InvalidateRect(hwnd,NULL,0);
1503 UpdateWindow(hwnd);
1504
1505 hdc=GetDC(hwnd);
1506 TempEllipse(hdc,WndNum,LastPos.x,LastPos.y,pos.x,pos.y,MainClrRef);
1507 ReleaseDC(hwnd,hdc);
1508 }
1509 }
1510 else{
1511 //ドラッグ中でないとき
1512 if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_SELECT){
1513 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel)
1514 SetCursorByState(IconEdit_GetStateOfDraggingFrame(WndNum,LOWORD(lParam),HIWORD(lParam)));
1515 else
1516 SetCursor(LoadCursor(NULL,IDC_CROSS));
1517 }
1518 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_PEN)
1519 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_PEN)));
1520 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILL)
1521 SetCursor(LoadCursor(hResInst,MAKEINTRESOURCE(IDC_CURSOR_FILL)));
1522 else if(MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_LINE||
1523 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_RECTANGLE||
1524 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT||
1525 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_FILLRECT2||
1526 MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_ELLIPSE){
1527 SetCursor(LoadCursor(NULL,IDC_CROSS));
1528 }
1529 }
1530 return 0;
1531 case WM_KEYDOWN:
1532 switch(wParam){
1533 case VK_ESCAPE:
1534 WndNum=GetWndNum(GetParent(hwnd));
1535 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2){
1536 DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
1537 MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
1538 }
1539 InvalidateRect(hwnd,NULL,0);
1540 return 0;
1541 }
1542 break;
1543 case WM_PAINT:
1544 PAINTSTRUCT ps;
1545 SIZE size;
1546
1547 WndNum=GetWndNum(GetParent(hwnd));
1548 BITMAPINFOHEADER *pBmpInfoHdr;
1549 pBmpInfoHdr=(BITMAPINFOHEADER *)MdiInfo[WndNum].MdiIconEditInfo->pIconImage[MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum];
1550
1551 hdc=BeginPaint(hwnd,&ps);
1552
1553 size.cx=ZOOMED_XPOS+pBmpInfoHdr->biWidth*PIXEL_WIDTH+1;
1554 size.cy=pBmpInfoHdr->biWidth*PIXEL_WIDTH+1;
1555
1556 BitBlt(hdc,
1557 0,0,
1558 size.cx,
1559 size.cy,
1560 MdiInfo[WndNum].MdiIconEditInfo->memdc,0,0,SRCCOPY);
1561
1562 HBRUSH hOldBrush;
1563 hOldBrush=(HBRUSH)SelectObject(hdc,GetStockObject(WHITE_BRUSH));
1564 PatBlt(hdc,
1565 0,size.cy,
1566 ScreenX,ScreenY-size.cy,
1567 PATCOPY);
1568 PatBlt(hdc,
1569 size.cx,0,
1570 ScreenX-size.cx,size.cy,
1571 PATCOPY);
1572
1573 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==1)
1574 IconEdit_DrawSelectingRect(hdc,WndNum);
1575 if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2){
1576 DrawSelectingImage(hdc,WndNum);
1577 if(dwDrag==0) IconEdit_DrawSelectingRect(hdc,WndNum);
1578 }
1579
1580 EndPaint(hwnd,&ps);
1581 return 0;
1582 }
1583 return DefWindowProc(hwnd,message,wParam,lParam);
1584}
Note: See TracBrowser for help on using the repository browser.