1 | #include "common.h"
|
---|
2 |
|
---|
3 | char *GetIconEditToolName(DWORD id){
|
---|
4 | char *pTemp=0;
|
---|
5 |
|
---|
6 | #if defined(JPN)
|
---|
7 | //日本語
|
---|
8 | if(id==IDC_TOOL_SELECT) pTemp="選択";
|
---|
9 | else if(id==IDC_TOOL_PEN) pTemp="ペン";
|
---|
10 | else if(id==IDC_TOOL_LINE) pTemp="線";
|
---|
11 | else if(id==IDC_TOOL_FILL) pTemp="塗りつぶし";
|
---|
12 | else if(id==IDC_TOOL_RECTANGLE) pTemp="四角形";
|
---|
13 | else if(id==IDC_TOOL_FILLRECT) pTemp="縁付き四角形";
|
---|
14 | else if(id==IDC_TOOL_FILLRECT2) pTemp="塗りつぶし四角形";
|
---|
15 | else if(id==IDC_TOOL_ELLIPSE) pTemp="楕円";
|
---|
16 | #else
|
---|
17 | //英語
|
---|
18 | if(id==IDC_TOOL_SELECT) pTemp="Tool";
|
---|
19 | else if(id==IDC_TOOL_PEN) pTemp="Pen";
|
---|
20 | else if(id==IDC_TOOL_LINE) pTemp="Line";
|
---|
21 | else if(id==IDC_TOOL_FILL) pTemp="Fill";
|
---|
22 | else if(id==IDC_TOOL_RECTANGLE) pTemp="Rectangle";
|
---|
23 | else if(id==IDC_TOOL_FILLRECT) pTemp="Rectangle with edge";
|
---|
24 | else if(id==IDC_TOOL_FILLRECT2) pTemp="Fill Rectangle";
|
---|
25 | else if(id==IDC_TOOL_ELLIPSE) pTemp="Ellipse";
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | return pTemp;
|
---|
29 | }
|
---|
30 |
|
---|
31 | BOOL CALLBACK DlgIconButtons(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
32 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
33 | extern PROJECTINFO ProjectInfo;
|
---|
34 | int WndNum;
|
---|
35 | RECT rect;
|
---|
36 | #define BMPNUM_ICONTOOLBAR 8
|
---|
37 | TBBUTTON IconToolBar[]={
|
---|
38 | {0,IDC_TOOL_SELECT,TBSTATE_ENABLED|TBSTATE_WRAP,TBSTYLE_CHECKGROUP,0,0},
|
---|
39 | {1,IDC_TOOL_PEN,TBSTATE_ENABLED|TBSTATE_CHECKED,TBSTYLE_CHECKGROUP,0,0},
|
---|
40 | {2,IDC_TOOL_LINE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0},
|
---|
41 | {3,IDC_TOOL_FILL,TBSTATE_ENABLED|TBSTATE_WRAP,TBSTYLE_CHECKGROUP,0,0},
|
---|
42 | {4,IDC_TOOL_RECTANGLE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0},
|
---|
43 | {5,IDC_TOOL_FILLRECT,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0},
|
---|
44 | {6,IDC_TOOL_FILLRECT2,TBSTATE_ENABLED|TBSTATE_WRAP,TBSTYLE_CHECKGROUP,0,0},
|
---|
45 | {7,IDC_TOOL_ELLIPSE,TBSTATE_ENABLED,TBSTYLE_CHECKGROUP,0,0},
|
---|
46 | };
|
---|
47 | TOOLTIPTEXT *pTipText;
|
---|
48 | static HWND hToolBar;
|
---|
49 |
|
---|
50 | switch(message){
|
---|
51 | case WM_INITDIALOG:
|
---|
52 | MoveWindow(hwnd,20,120,80,200,1);
|
---|
53 |
|
---|
54 | hToolBar=CreateToolbarEx(hwnd,WS_CHILD|WS_VISIBLE|CCS_NODIVIDER|TBSTYLE_FLAT|TBSTYLE_TOOLTIPS,
|
---|
55 | NULL,
|
---|
56 | BMPNUM_ICONTOOLBAR, /*ビットマップの個数*/
|
---|
57 | hResInst,(unsigned int)MAKEINTRESOURCE(IDR_ICONTOOLBAR),IconToolBar,
|
---|
58 | BMPNUM_ICONTOOLBAR, /*アイテムの個数*/
|
---|
59 | 0,0,16,15,sizeof(TBBUTTON));
|
---|
60 |
|
---|
61 |
|
---|
62 | //Windows9x系OSでの不具合を防ぐため
|
---|
63 | PostMessage(hwnd,WM_USER+120,0,0);
|
---|
64 |
|
---|
65 | break;
|
---|
66 | case WM_USER+120:
|
---|
67 | GetClientRect(hwnd,&rect);
|
---|
68 | MoveWindow(hToolBar,0,0,rect.right,rect.bottom,1);
|
---|
69 | return 1;
|
---|
70 | case WM_COMMAND:
|
---|
71 | switch(LOWORD(wParam)){
|
---|
72 | case IDC_TOOL_SELECT:
|
---|
73 | case IDC_TOOL_PEN:
|
---|
74 | case IDC_TOOL_LINE:
|
---|
75 | case IDC_TOOL_FILL:
|
---|
76 | case IDC_TOOL_RECTANGLE:
|
---|
77 | case IDC_TOOL_FILLRECT:
|
---|
78 | case IDC_TOOL_FILLRECT2:
|
---|
79 | case IDC_TOOL_ELLIPSE:
|
---|
80 | WndNum=GetWndNum(GetParent(GetParent(hwnd)));
|
---|
81 | if(LOWORD(wParam)!=IDC_TOOL_SELECT&&
|
---|
82 | MdiInfo[WndNum].MdiIconEditInfo->NowTool==IDC_TOOL_SELECT){
|
---|
83 | MdiInfo[WndNum].MdiIconEditInfo->NowTool=LOWORD(wParam);
|
---|
84 | if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel){
|
---|
85 | if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
|
---|
86 | DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
|
---|
87 | MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
|
---|
88 | }
|
---|
89 | InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,0);
|
---|
90 | }
|
---|
91 | else MdiInfo[WndNum].MdiIconEditInfo->NowTool=LOWORD(wParam);
|
---|
92 | return 1;
|
---|
93 | }
|
---|
94 | break;
|
---|
95 | case WM_NOTIFY:
|
---|
96 | pTipText=(TOOLTIPTEXT *)lParam;
|
---|
97 | if(pTipText->hdr.code==TTN_NEEDTEXT){
|
---|
98 | //ツールチップを表示
|
---|
99 | pTipText->lpszText=GetIconEditToolName(pTipText->hdr.idFrom);
|
---|
100 | }
|
---|
101 | break;
|
---|
102 | }
|
---|
103 | return 0;
|
---|
104 | }
|
---|
105 | BOOL CALLBACK DlgIconType(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
106 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
107 | int i,WndNum;
|
---|
108 | HWND hList;
|
---|
109 | BOOL bExist[4];
|
---|
110 | char temporary[32];
|
---|
111 |
|
---|
112 | switch(message){
|
---|
113 | case WM_INITDIALOG:
|
---|
114 | SetPosCenter(hwnd);
|
---|
115 |
|
---|
116 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
117 |
|
---|
118 | memset(bExist,0,sizeof(BOOL)*4);
|
---|
119 | for(i=0;i<MdiInfo[WndNum].MdiIconEditInfo->num;i++){
|
---|
120 | if(MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biWidth==16&&
|
---|
121 | MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biBitCount==4){
|
---|
122 | bExist[0]=1;
|
---|
123 | }
|
---|
124 | if(MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biWidth==16&&
|
---|
125 | MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biBitCount==8){
|
---|
126 | bExist[1]=1;
|
---|
127 | }
|
---|
128 | if(MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biWidth==32&&
|
---|
129 | MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biBitCount==4){
|
---|
130 | bExist[2]=1;
|
---|
131 | }
|
---|
132 | if(MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biWidth==32&&
|
---|
133 | MdiInfo[WndNum].MdiIconEditInfo->pBmpHdr[i]->biBitCount==8){
|
---|
134 | bExist[3]=1;
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | hList=GetDlgItem(hwnd,IDC_TYPELIST);
|
---|
139 | if(bExist[0]==0){
|
---|
140 | //"16*16 (16色)"
|
---|
141 | sprintf(temporary,"16*16 (16%s)",STRING_UNIT_COLORS);
|
---|
142 | SendMessage(hList,LB_ADDSTRING,0,(long)temporary);
|
---|
143 | }
|
---|
144 | if(bExist[1]==0){
|
---|
145 | //"16*16 (256色)"
|
---|
146 | sprintf(temporary,"16*16 (256%s)",STRING_UNIT_COLORS);
|
---|
147 | SendMessage(hList,LB_ADDSTRING,0,(long)temporary);
|
---|
148 | }
|
---|
149 | if(bExist[2]==0){
|
---|
150 | //"32*32 (16色)"
|
---|
151 | sprintf(temporary,"32*32 (16%s)",STRING_UNIT_COLORS);
|
---|
152 | SendMessage(hList,LB_ADDSTRING,0,(long)temporary);
|
---|
153 | }
|
---|
154 | if(bExist[3]==0){
|
---|
155 | //"32*32 (256色)"
|
---|
156 | sprintf(temporary,"32*32 (256%s)",STRING_UNIT_COLORS);
|
---|
157 | SendMessage(hList,LB_ADDSTRING,0,(long)temporary);
|
---|
158 | }
|
---|
159 | break;
|
---|
160 | case WM_COMMAND:
|
---|
161 | switch(LOWORD(wParam)){
|
---|
162 | case IDOK:
|
---|
163 | hList=GetDlgItem(hwnd,IDC_TYPELIST);
|
---|
164 | SendMessage(hList,LB_GETTEXT,SendMessage(hList,LB_GETCURSEL,0,0),(long)temporary);
|
---|
165 |
|
---|
166 | if(temporary[0]=='1'&&temporary[7]=='1') i=ICONTYPE_16_16;
|
---|
167 | if(temporary[0]=='1'&&temporary[7]=='2') i=ICONTYPE_16_256;
|
---|
168 | if(temporary[0]=='3'&&temporary[7]=='1') i=ICONTYPE_32_16;
|
---|
169 | if(temporary[0]=='3'&&temporary[7]=='2') i=ICONTYPE_32_256;
|
---|
170 | EndDialog(hwnd,i);
|
---|
171 | return 1;
|
---|
172 | case IDCANCEL:
|
---|
173 | EndDialog(hwnd,-1);
|
---|
174 | return 1;
|
---|
175 | }
|
---|
176 | break;
|
---|
177 | }
|
---|
178 | return 0;
|
---|
179 | }
|
---|
180 | BOOL CALLBACK DlgIconToolProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
181 | extern MDIINFO MdiInfo[MAX_WNDNUM];
|
---|
182 | int i,WndNum;
|
---|
183 |
|
---|
184 | switch(message){
|
---|
185 | case WM_COMMAND:
|
---|
186 | switch(LOWORD(wParam)){
|
---|
187 | case IDC_ADD_ICONTYPE:
|
---|
188 | i=DialogBox(hResInst,MAKEINTRESOURCE(IDD_ICONEDIT_ICONTYPE),GetParent(hwnd),(DLGPROC)DlgIconType);
|
---|
189 | if(i==-1) return 1;
|
---|
190 |
|
---|
191 | WndNum=GetWndNum(GetParent(hwnd));
|
---|
192 | AddIconType(WndNum,i);
|
---|
193 |
|
---|
194 | EnableWindow(GetDlgItem(hwnd,IDC_DELETE_ICONTYPE),1);
|
---|
195 | return 1;
|
---|
196 | case IDC_DELETE_ICONTYPE:
|
---|
197 | WndNum=GetWndNum(GetParent(hwnd));
|
---|
198 | DeleteIconType(WndNum);
|
---|
199 |
|
---|
200 | if(MdiInfo[WndNum].MdiIconEditInfo->num<=1)
|
---|
201 | EnableWindow(GetDlgItem(hwnd,IDC_DELETE_ICONTYPE),0);
|
---|
202 | return 1;
|
---|
203 | case IDC_ICONTYPECOMBO:
|
---|
204 | if(HIWORD(wParam)==CBN_SELCHANGE){
|
---|
205 | WndNum=GetWndNum(GetParent(hwnd));
|
---|
206 |
|
---|
207 | //イメージ選択用のメモリを解放
|
---|
208 | if(MdiInfo[WndNum].MdiIconEditInfo->SelectLevel==2)
|
---|
209 | DeleteObject(MdiInfo[WndNum].MdiIconEditInfo->hSelectingBmp);
|
---|
210 | MdiInfo[WndNum].MdiIconEditInfo->SelectLevel=0;
|
---|
211 |
|
---|
212 | MdiInfo[WndNum].MdiIconEditInfo->SelectIconNum=
|
---|
213 | SendDlgItemMessage(hwnd,IDC_ICONTYPECOMBO,CB_GETCURSEL,0,0);
|
---|
214 |
|
---|
215 | HBRUSH hOldBrush;
|
---|
216 | hOldBrush=(HBRUSH)SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,GetStockObject(WHITE_BRUSH));
|
---|
217 | PatBlt(MdiInfo[WndNum].MdiIconEditInfo->memdc,0,0,400,400,PATCOPY);
|
---|
218 | SelectObject(MdiInfo[WndNum].MdiIconEditInfo->memdc,hOldBrush);
|
---|
219 | DrawIconToMemBmp(WndNum,0);
|
---|
220 |
|
---|
221 | InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hMain,NULL,1);
|
---|
222 | InvalidateRect(MdiInfo[WndNum].MdiIconEditInfo->hColorDlg,NULL,0);
|
---|
223 | }
|
---|
224 | return 1;
|
---|
225 | }
|
---|
226 | break;
|
---|
227 | }
|
---|
228 | return 0;
|
---|
229 | }
|
---|