source: dev/trunk/ab5.0/abdev/ProjectEditor/IconEditor_Tool.cpp@ 479

Last change on this file since 479 was 475, checked in by dai_9181, 17 years ago

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

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