@@ -24,6 +24,7 @@ BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LP
24
24
label = lb;
25
25
}
26
26
else {
27
+ label = " " ;
27
28
icon_res_dark = ico_res_dark;
28
29
icon_res_light = ico_res_light;
29
30
}
@@ -67,7 +68,7 @@ BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LP
67
68
// ---------------------------------------------------------------------
68
69
// コントロール描画用の関数
69
70
// ---------------------------------------------------------------------
70
- void ce::Button::draw (COLORREF bg, LPRECT rect_wnd)
71
+ void ce::Button::draw (COLORREF bg, LPRECT rect_wnd, LPTSTR content )
71
72
{
72
73
d2d_setup (&canvas, rect_wnd, TO_BGR (bg));
73
74
@@ -78,8 +79,8 @@ void ce::Button::draw(COLORREF bg, LPRECT rect_wnd)
78
79
::SelectObject (canvas.hdc_memory, font);
79
80
::DrawText (
80
81
canvas.hdc_memory,
81
- label ,
82
- strlen (label ),
82
+ content ,
83
+ strlen (content ),
83
84
rect_wnd,
84
85
DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE
85
86
);
@@ -139,7 +140,7 @@ LRESULT ce::Button::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
139
140
tool_info.hwnd = hwnd;
140
141
tool_info.uId = id;
141
142
tool_info.lpszText = description;
142
- SendMessage (hwnd_tooltip, TTM_ADDTOOL, 0 , (LPARAM)&tool_info);
143
+ :: SendMessage (hwnd_tooltip, TTM_ADDTOOL, 0 , (LPARAM)&tool_info);
143
144
}
144
145
145
146
tme.cbSize = sizeof (tme);
@@ -150,14 +151,14 @@ LRESULT ce::Button::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
150
151
font = ::CreateFont (
151
152
CE_CT_FONT_H, 0 ,
152
153
0 , 0 ,
153
- FW_BOLD ,
154
+ FW_REGULAR ,
154
155
FALSE , FALSE , FALSE ,
155
- SHIFTJIS_CHARSET ,
156
+ ANSI_CHARSET ,
156
157
OUT_DEFAULT_PRECIS,
157
158
CLIP_DEFAULT_PRECIS,
158
159
DEFAULT_QUALITY,
159
160
NULL ,
160
- NULL
161
+ CE_FONT_YU
161
162
);
162
163
return 0 ;
163
164
@@ -166,9 +167,9 @@ LRESULT ce::Button::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
166
167
return 0 ;
167
168
168
169
case WM_SIZE:
169
- if (icon_or_str) {
170
+ if (! icon_or_str) {
170
171
tool_info.rect = rect_wnd;
171
- SendMessage (hwnd_tooltip, TTM_NEWTOOLRECT, 0 , (LPARAM)&tool_info);
172
+ :: SendMessage (hwnd_tooltip, TTM_NEWTOOLRECT, 0 , (LPARAM)&tool_info);
172
173
}
173
174
return 0 ;
174
175
@@ -186,21 +187,21 @@ LRESULT ce::Button::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
186
187
187
188
::SetTextColor (canvas.hdc_memory, g_theme[g_config.theme].bt_tx);
188
189
189
- draw (bg, &rect_wnd);
190
+ draw (bg, &rect_wnd, label );
190
191
return 0 ;
191
192
}
192
193
193
194
// マウスが動いたとき
194
195
case WM_MOUSEMOVE:
195
- ::SetCursor (LoadCursor(NULL , IDC_HAND));
196
+ ::SetCursor (:: LoadCursor(NULL , IDC_HAND));
196
197
hovered = TRUE ;
197
198
::InvalidateRect (hwnd, NULL , FALSE );
198
199
::TrackMouseEvent (&tme);
199
200
return 0 ;
200
201
201
202
// 左クリックがされたとき
202
203
case WM_LBUTTONDOWN:
203
- ::SetCursor (LoadCursor(NULL , IDC_HAND));
204
+ ::SetCursor (:: LoadCursor(NULL , IDC_HAND));
204
205
clicked = TRUE ;
205
206
::InvalidateRect (hwnd, NULL , FALSE );
206
207
::TrackMouseEvent (&tme);
@@ -274,7 +275,7 @@ LRESULT ce::Button_Switch::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
274
275
::SetTextColor (canvas.hdc_memory, g_theme[g_config.theme].bt_tx);
275
276
}
276
277
277
- draw (bg, &rect_wnd);
278
+ draw (bg, &rect_wnd, label );
278
279
return 0 ;
279
280
}
280
281
@@ -303,4 +304,71 @@ void ce::Button_Switch::set_status(BOOL bl)
303
304
{
304
305
is_selected = bl;
305
306
::InvalidateRect (hwnd, NULL , FALSE );
307
+ }
308
+
309
+
310
+
311
+ // ---------------------------------------------------------------------
312
+ // ウィンドウプロシージャ(ID)
313
+ // ---------------------------------------------------------------------
314
+ LRESULT ce::Button_ID::wndproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
315
+ {
316
+ RECT rect_wnd;
317
+ POINT cl_pt = { GET_X_LPARAM (lparam), GET_Y_LPARAM (lparam) };
318
+
319
+ ::GetClientRect (hwnd, &rect_wnd);
320
+
321
+ switch (msg) {
322
+ case WM_PAINT:
323
+ {
324
+ COLORREF bg;
325
+ std::string id_str = std::to_string (g_config.current_id );
326
+ LPCTSTR id_lps = id_str.c_str ();
327
+
328
+ if (clicked)
329
+ bg = BRIGHTEN (g_theme[g_config.theme ].bg , CE_CT_BR_CLICKED);
330
+ else if (hovered)
331
+ bg = BRIGHTEN (g_theme[g_config.theme ].bg , CE_CT_BR_HOVERED);
332
+ else
333
+ bg = g_theme[g_config.theme ].bg ;
334
+
335
+ ::SetTextColor (canvas.hdc_memory, g_theme[g_config.theme].bt_tx);
336
+
337
+ draw (bg, &rect_wnd, const_cast <LPTSTR>(id_lps));
338
+ return 0 ;
339
+ }
340
+
341
+ // 左クリックがされたとき
342
+ case WM_LBUTTONDOWN:
343
+ pt_lock = cl_pt;
344
+ id_buffer = g_config.current_id ;
345
+ ::SetCursor (LoadCursor(NULL , IDC_HAND));
346
+ clicked = TRUE ;
347
+ ::InvalidateRect (hwnd, NULL , FALSE );
348
+ ::SetCapture (hwnd);
349
+ return 0 ;
350
+
351
+ // カーソルが動いたとき
352
+ case WM_MOUSEMOVE:
353
+ if (clicked && g_config.mode == 1 ) {
354
+ ::SetCursor (LoadCursor(NULL , IDC_SIZEWE));
355
+ g_config.current_id = MINMAXLIM (id_buffer + (cl_pt.x - pt_lock.x ) / 9 , 0 , CE_CURVE_MAX - 1 );
356
+ ::SendMessage (g_window_editor.hwnd, WM_COMMAND, CE_CM_REDRAW, 0 );
357
+ }
358
+ else ::SetCursor (LoadCursor (NULL , IDC_HAND));
359
+
360
+ hovered = TRUE ;
361
+ InvalidateRect (hwnd, NULL , FALSE );
362
+ TrackMouseEvent (&tme);
363
+ return 0 ;
364
+
365
+ case WM_LBUTTONUP:
366
+ clicked = FALSE ;
367
+ ::ReleaseCapture ();
368
+ ::InvalidateRect (hwnd, NULL , FALSE );
369
+ return 0 ;
370
+
371
+ default :
372
+ return Button::wndproc (hwnd, msg, wparam, lparam);
373
+ }
306
374
}
0 commit comments