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