Mercurial > dwindows
comparison dwtest.c @ 2247:703023e1a644
Win: Implement dw_window_set_font() support for Rich Edit based MLEs.
Also add font size and name support for changing MLE in dwtest.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 23 Jan 2021 00:48:12 +0000 |
parents | 6f28c68642f5 |
children | 4fb54b9fcf78 |
comparison
equal
deleted
inserted
replaced
2246:471cdeaef7ac | 2247:703023e1a644 |
---|---|
1307 | 1307 |
1308 dw_window_set_color(container_mle, fore, back); | 1308 dw_window_set_color(container_mle, fore, back); |
1309 return 0; | 1309 return 0; |
1310 } | 1310 } |
1311 | 1311 |
1312 void mle_font_set(HWND mle, int fontsize, char *fontname) | |
1313 { | |
1314 char font[101] = {0}; | |
1315 | |
1316 if(fontname) | |
1317 snprintf(font, 100, "%d.%s", fontsize, fontname); | |
1318 dw_window_set_font(mle, fontname ? font : NULL); | |
1319 } | |
1320 | |
1321 int DWSIGNAL mle_fontname_cb(HWND hwnd, int pos, void *data) | |
1322 { | |
1323 HWND hbox = (HWND)data; | |
1324 HWND fontsize = (HWND)dw_window_get_data(hbox, "fontsize"); | |
1325 HWND fontname = (HWND)dw_window_get_data(hbox, "fontname"); | |
1326 char font[101] = {0}; | |
1327 | |
1328 dw_listbox_get_text(fontname, pos, font, 100); | |
1329 mle_font_set(container_mle, (int)dw_spinbutton_get_pos(fontsize), strcmp(font, "Default") == 0 ? NULL : font); | |
1330 return 0; | |
1331 } | |
1332 | |
1333 int mle_fontsize_cb(HWND hwnd, int size, void *data) | |
1334 { | |
1335 HWND hbox = (HWND)data; | |
1336 HWND fontsize = (HWND)dw_window_get_data(hbox, "fontsize"); | |
1337 HWND fontname = (HWND)dw_window_get_data(hbox, "fontname"); | |
1338 char *font = dw_window_get_text(fontname); | |
1339 | |
1340 if(font) | |
1341 { | |
1342 mle_font_set(container_mle, size, strcmp(font, "Default") == 0 ? NULL : font); | |
1343 dw_free(font); | |
1344 } | |
1345 else | |
1346 mle_font_set(container_mle, size, NULL); | |
1347 return 0; | |
1348 } | |
1349 | |
1312 void container_add(void) | 1350 void container_add(void) |
1313 { | 1351 { |
1314 char *titles[4]; | 1352 char *titles[4]; |
1315 char buffer[100]; | 1353 char buffer[100]; |
1316 unsigned long flags[4] = { DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, | 1354 unsigned long flags[4] = { DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, |
1320 int z; | 1358 int z; |
1321 CTIME time; | 1359 CTIME time; |
1322 CDATE date; | 1360 CDATE date; |
1323 unsigned long size, newpoint; | 1361 unsigned long size, newpoint; |
1324 HICN thisicon; | 1362 HICN thisicon; |
1325 HWND checkbox, mlefore, mleback, hbox; | 1363 HWND checkbox, mlefore, mleback, fontsize, fontname, hbox; |
1326 | 1364 |
1327 /* create a box to pack into the notebook page */ | 1365 /* create a box to pack into the notebook page */ |
1328 containerbox = dw_box_new(DW_HORZ, 2); | 1366 containerbox = dw_box_new(DW_HORZ, 2); |
1329 dw_box_pack_start(notebookbox4, containerbox, 500, 200, TRUE, TRUE, 0); | 1367 dw_box_pack_start(notebookbox4, containerbox, 500, 200, TRUE, TRUE, 0); |
1330 | 1368 |
1345 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); | 1383 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); |
1346 dw_box_pack_start(hbox, text, -1, -1, FALSE, TRUE, 1); | 1384 dw_box_pack_start(hbox, text, -1, -1, FALSE, TRUE, 1); |
1347 mleback = color_combobox(); | 1385 mleback = color_combobox(); |
1348 dw_box_pack_start(hbox, mleback, 150, -1, TRUE, FALSE, 1); | 1386 dw_box_pack_start(hbox, mleback, 150, -1, TRUE, FALSE, 1); |
1349 dw_checkbox_set(checkbox, TRUE); | 1387 dw_checkbox_set(checkbox, TRUE); |
1350 dw_box_pack_start(notebookbox4, hbox, -1, -1, FALSE, FALSE, 1); | 1388 text = dw_text_new("Font:", 0); |
1389 dw_window_set_style(text, DW_DT_VCENTER, DW_DT_VCENTER); | |
1390 dw_box_pack_start(hbox, text, -1, -1, FALSE, TRUE, 1); | |
1391 fontsize = dw_spinbutton_new("9", 0); | |
1392 dw_spinbutton_set_limits(fontsize, 5, 100); | |
1393 dw_box_pack_start(hbox, fontname, 50, -1, TRUE, FALSE, 1); | |
1394 fontname = dw_combobox_new("Default", 0); | |
1395 dw_listbox_append(fontname, "Default"); | |
1396 dw_listbox_append(fontname, "Helv"); | |
1397 dw_listbox_append(fontname, "Arial"); | |
1398 dw_box_pack_start(hbox, fontname, 150, -1, TRUE, FALSE, 1); | |
1399 dw_box_pack_start(notebookbox4, hbox, -1, -1, TRUE, FALSE, 1); | |
1351 | 1400 |
1352 dw_window_set_data(hbox, "mlefore", DW_POINTER(mlefore)); | 1401 dw_window_set_data(hbox, "mlefore", DW_POINTER(mlefore)); |
1353 dw_window_set_data(hbox, "mleback", DW_POINTER(mleback)); | 1402 dw_window_set_data(hbox, "mleback", DW_POINTER(mleback)); |
1403 dw_window_set_data(hbox, "fontsize", DW_POINTER(fontsize)); | |
1404 dw_window_set_data(hbox, "fontname", DW_POINTER(fontname)); | |
1354 } | 1405 } |
1355 | 1406 |
1356 /* now a container area under this box */ | 1407 /* now a container area under this box */ |
1357 container = dw_container_new(100, TRUE); | 1408 container = dw_container_new(100, TRUE); |
1358 dw_box_pack_start( notebookbox4, container, 500, 200, TRUE, FALSE, 1); | 1409 dw_box_pack_start( notebookbox4, container, 500, 200, TRUE, FALSE, 1); |
1435 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), DW_POINTER(container_status)); | 1486 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), DW_POINTER(container_status)); |
1436 dw_signal_connect(container, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(column_click_cb), DW_POINTER(container_status)); | 1487 dw_signal_connect(container, DW_SIGNAL_COLUMN_CLICK, DW_SIGNAL_FUNC(column_click_cb), DW_POINTER(container_status)); |
1437 dw_signal_connect(checkbox, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(word_wrap_click_cb), DW_POINTER(container_mle)); | 1488 dw_signal_connect(checkbox, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(word_wrap_click_cb), DW_POINTER(container_mle)); |
1438 dw_signal_connect(mlefore, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(mle_color_cb), DW_POINTER(hbox)); | 1489 dw_signal_connect(mlefore, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(mle_color_cb), DW_POINTER(hbox)); |
1439 dw_signal_connect(mleback, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(mle_color_cb), DW_POINTER(hbox)); | 1490 dw_signal_connect(mleback, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(mle_color_cb), DW_POINTER(hbox)); |
1491 dw_signal_connect(fontname, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(mle_fontname_cb), DW_POINTER(hbox)); | |
1492 dw_signal_connect(fontsize, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(mle_fontsize_cb), DW_POINTER(hbox)); | |
1440 } | 1493 } |
1441 | 1494 |
1442 /* Beep every second */ | 1495 /* Beep every second */ |
1443 int DWSIGNAL timer_callback(void *data) | 1496 int DWSIGNAL timer_callback(void *data) |
1444 { | 1497 { |