Mercurial > dwindows
comparison dwtestoo.cpp @ 2940:60e90b783cb1
C++: ListBox and ComboBoxes need to call Setup() to configure the handlers.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 01 Jan 2023 01:14:55 +0000 |
parents | ebbc5b16899e |
children | 63d7baebb0d4 |
comparison
equal
deleted
inserted
replaced
2939:ebbc5b16899e | 2940:60e90b783cb1 |
---|---|
209 else if((mask & KC_ALT)) | 209 else if((mask & KC_ALT)) |
210 return "KC_ALT"; | 210 return "KC_ALT"; |
211 else return "none"; | 211 else return "none"; |
212 } | 212 } |
213 | 213 |
214 char *ReadFile(char *filename) | 214 char *ReadFile(char *filename) { |
215 { | |
216 char *errors = NULL; | 215 char *errors = NULL; |
217 FILE *fp=NULL; | 216 FILE *fp=NULL; |
218 #ifdef __ANDROID__ | 217 #ifdef __ANDROID__ |
219 int fd = -1; | 218 int fd = -1; |
220 | 219 |
261 #endif | 260 #endif |
262 return errors; | 261 return errors; |
263 } | 262 } |
264 | 263 |
265 // When hpm is not NULL we are printing.. so handle things differently | 264 // When hpm is not NULL we are printing.. so handle things differently |
266 void DrawFile(int row, int col, int nrows, int fheight, DW::Pixmap *hpm) | 265 void DrawFile(int row, int col, int nrows, int fheight, DW::Pixmap *hpm) { |
267 { | |
268 DW::Pixmap *pixmap = hpm ? hpm : pixmap2; | 266 DW::Pixmap *pixmap = hpm ? hpm : pixmap2; |
269 char buf[16] = {0}; | 267 char buf[16] = {0}; |
270 int i,y,fileline; | 268 int i,y,fileline; |
271 char *pLine; | 269 char *pLine; |
272 | 270 |
292 } | 290 } |
293 } | 291 } |
294 } | 292 } |
295 | 293 |
296 // When hpm is not NULL we are printing.. so handle things differently | 294 // When hpm is not NULL we are printing.. so handle things differently |
297 void DrawShapes(int direct, DW::Pixmap *hpm) | 295 void DrawShapes(int direct, DW::Pixmap *hpm) { |
298 { | |
299 DW::Pixmap *pixmap = hpm ? hpm : pixmap2; | 296 DW::Pixmap *pixmap = hpm ? hpm : pixmap2; |
300 int width = (int)pixmap->GetWidth(), height = (int)pixmap->GetHeight(); | 297 int width = (int)pixmap->GetWidth(), height = (int)pixmap->GetHeight(); |
301 int x[7] = { 20, 180, 180, 230, 180, 180, 20 }; | 298 int x[7] = { 20, 180, 180, 230, 180, 180, 20 }; |
302 int y[7] = { 50, 50, 20, 70, 120, 90, 90 }; | 299 int y[7] = { 50, 50, 20, 70, 120, 90, 90 }; |
303 DW::Drawable *drawable = direct ? static_cast<DW::Drawable *>(render2) : static_cast<DW::Drawable *>(pixmap); | 300 DW::Drawable *drawable = direct ? static_cast<DW::Drawable *>(render2) : static_cast<DW::Drawable *>(pixmap); |
330 else | 327 else |
331 drawable->BitBlt(imagexspin->GetPos(), imageyspin->GetPos(), (int)image->GetWidth(), (int)image->GetHeight(), image, 0, 0); | 328 drawable->BitBlt(imagexspin->GetPos(), imageyspin->GetPos(), (int)image->GetWidth(), (int)image->GetHeight(), image, 0, 0); |
332 } | 329 } |
333 } | 330 } |
334 | 331 |
335 void UpdateRender(void) | 332 void UpdateRender(void) { |
336 { | |
337 switch(render_type) | 333 switch(render_type) |
338 { | 334 { |
339 case SHAPES_DOUBLE_BUFFERED: | 335 case SHAPES_DOUBLE_BUFFERED: |
340 DrawShapes(FALSE, NULL); | 336 DrawShapes(FALSE, NULL); |
341 break; | 337 break; |
359 // Trigger expose event | 355 // Trigger expose event |
360 render1->Redraw(); | 356 render1->Redraw(); |
361 render2->Redraw(); | 357 render2->Redraw(); |
362 } | 358 } |
363 | 359 |
364 DW::Menu *ItemContextMenu(DW::StatusText *status_text, const char *text) | 360 DW::Menu *ItemContextMenu(DW::StatusText *status_text, const char *text) { |
365 { | |
366 DW::Menu *menu = new DW::Menu(); | 361 DW::Menu *menu = new DW::Menu(); |
367 DW::Menu *submenu = new DW::Menu(); | 362 DW::Menu *submenu = new DW::Menu(); |
368 DW::MenuItem *menuitem = submenu->AppendItem("File", 0L, TRUE); | 363 DW::MenuItem *menuitem = submenu->AppendItem("File", 0L, TRUE); |
369 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); | 364 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); |
370 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); | 365 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); |
392 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); | 387 menuitem->ConnectClicked([status_text, text]() -> int { status_text->SetText(text); return TRUE; }); |
393 | 388 |
394 return menu; | 389 return menu; |
395 } | 390 } |
396 | 391 |
397 DW::ComboBox *ColorCombobox(void) | 392 DW::ComboBox *ColorCombobox(void) { |
398 { | |
399 DW::ComboBox *combobox = new DW::ComboBox("DW_CLR_DEFAULT"); | 393 DW::ComboBox *combobox = new DW::ComboBox("DW_CLR_DEFAULT"); |
400 | 394 |
401 combobox->Append("DW_CLR_DEFAULT"); | 395 combobox->Append("DW_CLR_DEFAULT"); |
402 combobox->Append("DW_CLR_BLACK"); | 396 combobox->Append("DW_CLR_BLACK"); |
403 combobox->Append("DW_CLR_DARKRED"); | 397 combobox->Append("DW_CLR_DARKRED"); |
416 combobox->Append("DW_CLR_CYAN"); | 410 combobox->Append("DW_CLR_CYAN"); |
417 combobox->Append("DW_CLR_WHITE"); | 411 combobox->Append("DW_CLR_WHITE"); |
418 return combobox; | 412 return combobox; |
419 } | 413 } |
420 | 414 |
421 unsigned long ComboboxColor(const char *colortext) | 415 unsigned long ComboboxColor(const char *colortext) { |
422 { | |
423 unsigned long color = DW_CLR_DEFAULT; | 416 unsigned long color = DW_CLR_DEFAULT; |
424 | 417 |
425 if(strcmp(colortext, "DW_CLR_BLACK") == 0) | 418 if(strcmp(colortext, "DW_CLR_BLACK") == 0) |
426 color = DW_CLR_BLACK; | 419 color = DW_CLR_BLACK; |
427 else if(strcmp(colortext, "DW_CLR_DARKRED") == 0) | 420 else if(strcmp(colortext, "DW_CLR_DARKRED") == 0) |
456 color = DW_CLR_WHITE; | 449 color = DW_CLR_WHITE; |
457 | 450 |
458 return color; | 451 return color; |
459 } | 452 } |
460 | 453 |
461 void MLESetFont(DW::MLE *mle, int fontsize, char *fontname) | 454 void MLESetFont(DW::MLE *mle, int fontsize, char *fontname) { |
462 { | |
463 char font[101] = {0}; | 455 char font[101] = {0}; |
464 | 456 |
465 if(fontname) | 457 if(fontname) |
466 snprintf(font, 100, "%d.%s", fontsize, fontname); | 458 snprintf(font, 100, "%d.%s", fontsize, fontname); |
467 mle->SetFont(fontname ? font : NULL); | 459 mle->SetFont(fontname ? font : NULL); |
468 } | 460 } |
469 | 461 |
470 // Thread and Event functions | 462 // Thread and Event functions |
471 void UpdateMLE(DW::MLE *threadmle, const char *text, DW::Mutex *mutex) | 463 void UpdateMLE(DW::MLE *threadmle, const char *text, DW::Mutex *mutex) { |
472 { | |
473 static unsigned int pos = 0; | 464 static unsigned int pos = 0; |
474 | 465 |
475 // Protect pos from being changed by different threads | 466 // Protect pos from being changed by different threads |
476 if(mutex) | 467 if(mutex) |
477 mutex->Lock(); | 468 mutex->Lock(); |
646 // Add the "Help" menu to the menubar... | 637 // Add the "Help" menu to the menubar... |
647 menubar->AppendItem("~Help", menu); | 638 menubar->AppendItem("~Help", menu); |
648 } | 639 } |
649 | 640 |
650 // Notebook page 1 | 641 // Notebook page 1 |
651 void CreateInput(DW::Box *notebookbox) | 642 void CreateInput(DW::Box *notebookbox) { |
652 { | |
653 DW::Box *lbbox = new DW::Box(DW_VERT, 10); | 643 DW::Box *lbbox = new DW::Box(DW_VERT, 10); |
654 | 644 |
655 notebookbox->PackStart(lbbox, 150, 70, TRUE, TRUE, 0); | 645 notebookbox->PackStart(lbbox, 150, 70, TRUE, TRUE, 0); |
656 | 646 |
657 // Copy and Paste | 647 // Copy and Paste |
1168 | 1158 |
1169 app->TaskBarInsert(render1, fileicon, "DWTest"); | 1159 app->TaskBarInsert(render1, fileicon, "DWTest"); |
1170 } | 1160 } |
1171 | 1161 |
1172 // Notebook page 3 | 1162 // Notebook page 3 |
1173 void CreateTree(DW::Box *notebookbox) | 1163 void CreateTree(DW::Box *notebookbox) { |
1174 { | |
1175 // create a box to pack into the notebook page | 1164 // create a box to pack into the notebook page |
1176 DW::ListBox *listbox = new DW::ListBox(TRUE); | 1165 DW::ListBox *listbox = new DW::ListBox(TRUE); |
1177 notebookbox->PackStart(listbox, 500, 200, TRUE, TRUE, 0); | 1166 notebookbox->PackStart(listbox, 500, 200, TRUE, TRUE, 0); |
1178 listbox->Append("Test 1"); | 1167 listbox->Append("Test 1"); |
1179 listbox->Append("Test 2"); | 1168 listbox->Append("Test 2"); |
1232 notebookbox->PackStart(text, 500, 200, TRUE, TRUE, 1); | 1221 notebookbox->PackStart(text, 500, 200, TRUE, TRUE, 1); |
1233 } | 1222 } |
1234 } | 1223 } |
1235 | 1224 |
1236 // Page 4 - Container | 1225 // Page 4 - Container |
1237 void CreateContainer(DW::Box *notebookbox) | 1226 void CreateContainer(DW::Box *notebookbox) { |
1238 { | |
1239 char buffer[101] = {0}; | 1227 char buffer[101] = {0}; |
1240 CTIME time; | 1228 CTIME time; |
1241 CDATE date; | 1229 CDATE date; |
1242 | 1230 |
1243 // create a box to pack into the notebook page | 1231 // create a box to pack into the notebook page |
1494 return FALSE; | 1482 return FALSE; |
1495 }); | 1483 }); |
1496 } | 1484 } |
1497 | 1485 |
1498 // Page 5 - Buttons | 1486 // Page 5 - Buttons |
1499 void CreateButtons(DW::Box *notebookbox) | 1487 void CreateButtons(DW::Box *notebookbox) { |
1500 { | |
1501 // create a box to pack into the notebook page | 1488 // create a box to pack into the notebook page |
1502 DW::Box *buttonsbox = new DW::Box(DW_VERT, 2); | 1489 DW::Box *buttonsbox = new DW::Box(DW_VERT, 2); |
1503 notebookbox->PackStart(buttonsbox, 25, 200, TRUE, TRUE, 0); | 1490 notebookbox->PackStart(buttonsbox, 25, 200, TRUE, TRUE, 0); |
1504 buttonsbox->SetColor(DW_CLR_RED, DW_CLR_RED); | 1491 buttonsbox->SetColor(DW_CLR_RED, DW_CLR_RED); |
1505 | 1492 |
1656 return TRUE; | 1643 return TRUE; |
1657 }); | 1644 }); |
1658 } | 1645 } |
1659 | 1646 |
1660 // Page 6 - HTML | 1647 // Page 6 - HTML |
1661 void CreateHTML(DW::Box *notebookbox) | 1648 void CreateHTML(DW::Box *notebookbox) { |
1662 { | |
1663 DW::HTML *rawhtml = new DW::HTML(); | 1649 DW::HTML *rawhtml = new DW::HTML(); |
1664 if(rawhtml && rawhtml->GetHWND()) | 1650 if(rawhtml && rawhtml->GetHWND()) |
1665 { | 1651 { |
1666 DW::Box *hbox = new DW::Box(DW_HORZ, 0); | 1652 DW::Box *hbox = new DW::Box(DW_HORZ, 0); |
1667 DW::ComboBox *javascript = new DW::ComboBox(); | 1653 DW::ComboBox *javascript = new DW::ComboBox(); |
1755 notebookbox->PackStart(htmltext, 0, 100, TRUE, TRUE, 0); | 1741 notebookbox->PackStart(htmltext, 0, 100, TRUE, TRUE, 0); |
1756 } | 1742 } |
1757 } | 1743 } |
1758 | 1744 |
1759 // Page 7 - ScrollBox | 1745 // Page 7 - ScrollBox |
1760 void CreateScrollBox(DW::Box *notebookbox) | 1746 void CreateScrollBox(DW::Box *notebookbox) { |
1761 { | |
1762 char buf[101] = {0}; | 1747 char buf[101] = {0}; |
1763 | 1748 |
1764 // create a box to pack into the notebook page | 1749 // create a box to pack into the notebook page |
1765 DW::ScrollBox *scrollbox = new DW::ScrollBox(DW_VERT, 0); | 1750 DW::ScrollBox *scrollbox = new DW::ScrollBox(DW_VERT, 0); |
1766 notebookbox->PackStart(scrollbox, 0, 0, TRUE, TRUE, 1); | 1751 notebookbox->PackStart(scrollbox, 0, 0, TRUE, TRUE, 1); |
1787 tmpbox->PackStart(entry, 0, DW_SIZE_AUTO, TRUE, FALSE, 0); | 1772 tmpbox->PackStart(entry, 0, DW_SIZE_AUTO, TRUE, FALSE, 0); |
1788 } | 1773 } |
1789 } | 1774 } |
1790 | 1775 |
1791 // Page 8 - Thread and Event | 1776 // Page 8 - Thread and Event |
1792 void CreateThreadEvent(DW::Box *notebookbox) | 1777 void CreateThreadEvent(DW::Box *notebookbox) { |
1793 { | |
1794 // create a box to pack into the notebook page | 1778 // create a box to pack into the notebook page |
1795 DW::Box *tmpbox = new DW::Box(DW_VERT, 0); | 1779 DW::Box *tmpbox = new DW::Box(DW_VERT, 0); |
1796 notebookbox->PackStart(tmpbox, 0, 0, TRUE, TRUE, 1); | 1780 notebookbox->PackStart(tmpbox, 0, 0, TRUE, TRUE, 1); |
1797 | 1781 |
1798 DW::Button *startbutton = new DW::Button("Start Threads"); | 1782 DW::Button *startbutton = new DW::Button("Start Threads"); |