source: dev/trunk/ab5.0/abdev/abdev/IconEditor_Main.cpp@ 481

Last change on this file since 481 was 475, checked in by dai_9181, 16 years ago

構成管理を変更中・・・(いったんコミット)

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