comparison dw.hpp @ 2959:cde59690d3dd

C++: Step 1 of the std::string transition. For all API calls that take UTF8 strings, create std::string versions. We can't have the same functions that only differ in return type... So we need to figure out what to do about those API calls. Also need to decide if the class callback functions should be std::string. Our connect versions can handle the conversions as necessary.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 14 Feb 2023 12:42:11 +0000
parents 0577a97fe36d
children 1dabe9c6c67b
comparison
equal deleted inserted replaced
2958:33e77761703f 2959:cde59690d3dd
3 // Recommends a C++11 compatible compiler. 3 // Recommends a C++11 compatible compiler.
4 4
5 #ifndef _HPP_DW 5 #ifndef _HPP_DW
6 #define _HPP_DW 6 #define _HPP_DW
7 #include <dw.h> 7 #include <dw.h>
8 #include <string.h> 8 #include <cstring>
9 #include <string>
9 10
10 // Attempt to support compilers without nullptr type literal 11 // Attempt to support compilers without nullptr type literal
11 #if __cplusplus >= 201103L 12 #if __cplusplus >= 201103L
12 #define DW_CPP11 13 #define DW_CPP11
13 #define DW_NULL nullptr 14 #define DW_NULL nullptr
210 MenuItem *AppendItem(const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu); 211 MenuItem *AppendItem(const char *title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu);
211 MenuItem *AppendItem(const char *title, unsigned long flags, int check, Menus *submenu); 212 MenuItem *AppendItem(const char *title, unsigned long flags, int check, Menus *submenu);
212 MenuItem *AppendItem(const char *title, unsigned long flags, int check); 213 MenuItem *AppendItem(const char *title, unsigned long flags, int check);
213 MenuItem *AppendItem(const char *title, Menus *submenu); 214 MenuItem *AppendItem(const char *title, Menus *submenu);
214 MenuItem *AppendItem(const char *title); 215 MenuItem *AppendItem(const char *title);
216 MenuItem *AppendItem(std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu);
217 MenuItem *AppendItem(std::string title, unsigned long flags, int check, Menus *submenu);
218 MenuItem *AppendItem(std::string title, unsigned long flags, int check);
219 MenuItem *AppendItem(std::string title, Menus *submenu);
220 MenuItem *AppendItem(std::string title);
215 }; 221 };
216 222
217 class Menu : public Menus 223 class Menu : public Menus
218 { 224 {
219 public: 225 public:
249 MenuItem(Menus *menu, const char *title, Menus *submenu) { 255 MenuItem(Menus *menu, const char *title, Menus *submenu) {
250 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup(); 256 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup();
251 } 257 }
252 MenuItem(Menus *menu, const char *title) { 258 MenuItem(Menus *menu, const char *title) {
253 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, DW_NOMENU)); Setup(); 259 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title, DW_MENU_AUTO, 0, TRUE, FALSE, DW_NOMENU)); Setup();
260 }
261 MenuItem(Menus *menu, std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) {
262 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), id, flags, end, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup();
263 }
264 MenuItem(Menus *menu, std::string title, unsigned long flags, int check, Menus *submenu) {
265 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, flags, TRUE, check, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup();
266 }
267 MenuItem(Menus *menu, std::string title, unsigned long flags, int check) {
268 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, flags, TRUE, check, DW_NOMENU)); Setup();
269 }
270 MenuItem(Menus *menu, std::string title, Menus *submenu) {
271 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, 0, TRUE, FALSE, submenu ? submenu->GetHMENUI() : DW_NOMENU)); Setup();
272 }
273 MenuItem(Menus *menu, std::string title) {
274 SetHWND(dw_menu_append_item(menu->GetHMENUI(), title.c_str(), DW_MENU_AUTO, 0, TRUE, FALSE, DW_NOMENU)); Setup();
254 } 275 }
255 276
256 // User functions 277 // User functions
257 void SetState(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } 278 void SetState(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); }
258 }; 279 };
272 MenuItem *Menus::AppendItem(const char *title, Menus *submenu) { 293 MenuItem *Menus::AppendItem(const char *title, Menus *submenu) {
273 return new MenuItem(this, title, submenu); 294 return new MenuItem(this, title, submenu);
274 } 295 }
275 MenuItem *Menus::AppendItem(const char *title) { 296 MenuItem *Menus::AppendItem(const char *title) {
276 return new MenuItem(this, title); 297 return new MenuItem(this, title);
298 }
299
300 MenuItem *Menus::AppendItem(std::string title, unsigned long id, unsigned long flags, int end, int check, Menus *submenu) {
301 return new MenuItem(this, title.c_str(), id, flags, end, check, submenu);
302 }
303
304 MenuItem *Menus::AppendItem(std::string title, unsigned long flags, int check, Menus *submenu) {
305 return new MenuItem(this, title.c_str(), flags, check, submenu);
306 }
307
308 MenuItem *Menus::AppendItem(std::string title, unsigned long flags, int check) {
309 return new MenuItem(this, title.c_str(), flags, check);
310 }
311
312 MenuItem *Menus::AppendItem(std::string title, Menus *submenu) {
313 return new MenuItem(this, title.c_str(), submenu);
314 }
315 MenuItem *Menus::AppendItem(std::string title) {
316 return new MenuItem(this, title.c_str());
277 } 317 }
278 318
279 319
280 // Top-level window class is packable 320 // Top-level window class is packable
281 class Window : public Boxes 321 class Window : public Boxes
330 MenuBar *menu; 370 MenuBar *menu;
331 public: 371 public:
332 // Constructors 372 // Constructors
333 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); } 373 Window(HWND owner, const char *title, unsigned long style) { SetHWND(dw_window_new(owner, title, style)); Setup(); }
334 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); } 374 Window(const char *title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title, style)); Setup(); }
375 Window(HWND owner, std::string title, unsigned long style) { SetHWND(dw_window_new(owner, title.c_str(), style)); Setup(); }
376 Window(std::string title, unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, title.c_str(), style)); Setup(); }
335 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); } 377 Window(unsigned long style) { SetHWND(dw_window_new(HWND_DESKTOP, "", style)); Setup(); }
336 Window(const char *title) { SetHWND(dw_window_new(HWND_DESKTOP, title, DW_FCF_SYSMENU | DW_FCF_TITLEBAR | 378 Window(const char *title) { SetHWND(dw_window_new(HWND_DESKTOP, title, DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
337 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } 379 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); }
338 Window() { SetHWND(dw_window_new(HWND_DESKTOP, "", DW_FCF_SYSMENU | DW_FCF_TITLEBAR | 380 Window() { SetHWND(dw_window_new(HWND_DESKTOP, "", DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
339 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); } 381 DW_FCF_TASKLIST | DW_FCF_SIZEBORDER | DW_FCF_MINMAX)); Setup(); }
340 382
341 // User functions 383 // User functions
342 void SetText(const char *text) { dw_window_set_text(hwnd, text); } 384 void SetText(const char *text) { dw_window_set_text(hwnd, text); }
385 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); }
343 char *GetText() { return dw_window_get_text(hwnd); } 386 char *GetText() { return dw_window_get_text(hwnd); }
344 void SetSize(unsigned long width, unsigned long height) { dw_window_set_size(hwnd, width, height); } 387 void SetSize(unsigned long width, unsigned long height) { dw_window_set_size(hwnd, width, height); }
345 int Show() { return dw_window_show(hwnd); } 388 int Show() { return dw_window_show(hwnd); }
346 int Hide() { return dw_window_hide(hwnd); } 389 int Hide() { return dw_window_hide(hwnd); }
347 void SetGravity(int horz, int vert) { dw_window_set_gravity(hwnd, horz, vert); } 390 void SetGravity(int horz, int vert) { dw_window_set_gravity(hwnd, horz, vert); }
466 class TextButton : public Clickable, public Focusable 509 class TextButton : public Clickable, public Focusable
467 { 510 {
468 public: 511 public:
469 // User functions 512 // User functions
470 void SetText(const char *text) { dw_window_set_text(hwnd, text); } 513 void SetText(const char *text) { dw_window_set_text(hwnd, text); }
514 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); }
471 char *GetText() { return dw_window_get_text(hwnd); } 515 char *GetText() { return dw_window_get_text(hwnd); }
472 }; 516 };
473 517
474 class Button : public TextButton 518 class Button : public TextButton
475 { 519 {
476 public: 520 public:
477 // Constructors 521 // Constructors
478 Button(const char *text, unsigned long id) { SetHWND(dw_button_new(text, id)); Setup(); } 522 Button(const char *text, unsigned long id) { SetHWND(dw_button_new(text, id)); Setup(); }
523 Button(std::string text, unsigned long id) { SetHWND(dw_button_new(text.c_str(), id)); Setup(); }
479 Button(unsigned long id) { SetHWND(dw_button_new("", id)); Setup(); } 524 Button(unsigned long id) { SetHWND(dw_button_new("", id)); Setup(); }
480 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); } 525 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); }
526 Button(std::string text) { SetHWND(dw_button_new(text.c_str(), 0)); Setup(); }
481 Button() { SetHWND(dw_button_new("", 0)); Setup(); } 527 Button() { SetHWND(dw_button_new("", 0)); Setup(); }
482 }; 528 };
483 529
484 class BitmapWidget : virtual public Widget 530 class BitmapWidget : virtual public Widget
485 { 531 {
499 BitmapButton(unsigned long id) { SetHWND(dw_bitmapbutton_new("", id)); Setup(); } 545 BitmapButton(unsigned long id) { SetHWND(dw_bitmapbutton_new("", id)); Setup(); }
500 BitmapButton(const char *text, unsigned long id, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, id, file)); Setup(); } 546 BitmapButton(const char *text, unsigned long id, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, id, file)); Setup(); }
501 BitmapButton(const char *text, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, 0, file)); Setup(); } 547 BitmapButton(const char *text, const char *file) { SetHWND(dw_bitmapbutton_new_from_file(text, 0, file)); Setup(); }
502 BitmapButton(const char *text, unsigned long id, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, id, data, len)); Setup(); } 548 BitmapButton(const char *text, unsigned long id, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, id, data, len)); Setup(); }
503 BitmapButton(const char *text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, 0, data, len)); Setup(); } 549 BitmapButton(const char *text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, 0, data, len)); Setup(); }
550 BitmapButton(std::string text, unsigned long id) { SetHWND(dw_bitmapbutton_new(text.c_str(), id)); Setup(); }
551 BitmapButton(std::string text, unsigned long id, std::string file) { SetHWND(dw_bitmapbutton_new_from_file(text.c_str(), id, file.c_str())); Setup(); }
552 BitmapButton(std::string text, std::string file) { SetHWND(dw_bitmapbutton_new_from_file(text.c_str(), 0, file.c_str())); Setup(); }
553 BitmapButton(std::string text, unsigned long id, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text.c_str(), id, data, len)); Setup(); }
554 BitmapButton(std::string text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text.c_str(), 0, data, len)); Setup(); }
504 }; 555 };
505 556
506 class CheckBoxes : virtual public TextButton 557 class CheckBoxes : virtual public TextButton
507 { 558 {
508 public: 559 public:
514 class CheckBox : public CheckBoxes 565 class CheckBox : public CheckBoxes
515 { 566 {
516 public: 567 public:
517 // Constructors 568 // Constructors
518 CheckBox(const char *text, unsigned long id) { SetHWND(dw_checkbox_new(text, id)); Setup(); } 569 CheckBox(const char *text, unsigned long id) { SetHWND(dw_checkbox_new(text, id)); Setup(); }
570 CheckBox(std::string text, unsigned long id) { SetHWND(dw_checkbox_new(text.c_str(), id)); Setup(); }
519 CheckBox(unsigned long id) { SetHWND(dw_checkbox_new("", id)); Setup(); } 571 CheckBox(unsigned long id) { SetHWND(dw_checkbox_new("", id)); Setup(); }
520 CheckBox(const char *text) { SetHWND(dw_checkbox_new(text, 0)); Setup(); } 572 CheckBox(const char *text) { SetHWND(dw_checkbox_new(text, 0)); Setup(); }
573 CheckBox(std::string text) { SetHWND(dw_checkbox_new(text.c_str(), 0)); Setup(); }
521 CheckBox() { SetHWND(dw_checkbox_new("", 0)); Setup(); } 574 CheckBox() { SetHWND(dw_checkbox_new("", 0)); Setup(); }
522 }; 575 };
523 576
524 class RadioButton : public CheckBoxes 577 class RadioButton : public CheckBoxes
525 { 578 {
526 public: 579 public:
527 // Constructors 580 // Constructors
528 RadioButton(const char *text, unsigned long id) { SetHWND(dw_radiobutton_new(text, id)); Setup(); } 581 RadioButton(const char *text, unsigned long id) { SetHWND(dw_radiobutton_new(text, id)); Setup(); }
582 RadioButton(std::string text, unsigned long id) { SetHWND(dw_radiobutton_new(text.c_str(), id)); Setup(); }
529 RadioButton(unsigned long id) { SetHWND(dw_radiobutton_new("", id)); Setup(); } 583 RadioButton(unsigned long id) { SetHWND(dw_radiobutton_new("", id)); Setup(); }
530 RadioButton(const char *text) { SetHWND(dw_radiobutton_new(text, 0)); Setup(); } 584 RadioButton(const char *text) { SetHWND(dw_radiobutton_new(text, 0)); Setup(); }
585 RadioButton(std::string text) { SetHWND(dw_radiobutton_new(text.c_str(), 0)); Setup(); }
531 RadioButton() { SetHWND(dw_radiobutton_new("", 0)); Setup(); } 586 RadioButton() { SetHWND(dw_radiobutton_new("", 0)); Setup(); }
532 }; 587 };
533 588
534 // Class for handling static text widget 589 // Class for handling static text widget
535 class TextWidget : virtual public Widget 590 class TextWidget : virtual public Widget
536 { 591 {
537 public: 592 public:
538 // User functions 593 // User functions
539 void SetText(const char *text) { dw_window_set_text(hwnd, text); } 594 void SetText(const char *text) { dw_window_set_text(hwnd, text); }
595 void SetText(std::string text) { dw_window_set_text(hwnd, text.c_str()); }
540 char *GetText() { return dw_window_get_text(hwnd); } 596 char *GetText() { return dw_window_get_text(hwnd); }
541 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); } 597 int SetFont(const char *font) { return dw_window_set_font(hwnd, font); }
542 char *GetFont() { return dw_window_get_font(hwnd); } 598 char *GetFont() { return dw_window_get_font(hwnd); }
543 }; 599 };
544 600
547 { 603 {
548 public: 604 public:
549 // Constructors 605 // Constructors
550 Text(const char *text, unsigned long id) { SetHWND(dw_text_new(text, id)); } 606 Text(const char *text, unsigned long id) { SetHWND(dw_text_new(text, id)); }
551 Text(const char *text) { SetHWND(dw_text_new(text, 0)); } 607 Text(const char *text) { SetHWND(dw_text_new(text, 0)); }
608 Text(std::string text, unsigned long id) { SetHWND(dw_text_new(text.c_str(), id)); }
609 Text(std::string text) { SetHWND(dw_text_new(text.c_str(), 0)); }
552 Text(unsigned long id) { SetHWND(dw_text_new("", id)); } 610 Text(unsigned long id) { SetHWND(dw_text_new("", id)); }
553 Text() { SetHWND(dw_text_new("", 0)); } 611 Text() { SetHWND(dw_text_new("", 0)); }
554 }; 612 };
555 613
556 class StatusText : public TextWidget 614 class StatusText : public TextWidget
557 { 615 {
558 public: 616 public:
559 // Constructors 617 // Constructors
560 StatusText(const char *text, unsigned long id) { SetHWND(dw_status_text_new(text, id)); } 618 StatusText(const char *text, unsigned long id) { SetHWND(dw_status_text_new(text, id)); }
561 StatusText(const char *text) { SetHWND(dw_status_text_new(text, 0)); } 619 StatusText(const char *text) { SetHWND(dw_status_text_new(text, 0)); }
620 StatusText(std::string text, unsigned long id) { SetHWND(dw_status_text_new(text.c_str(), id)); }
621 StatusText(std::string text) { SetHWND(dw_status_text_new(text.c_str(), 0)); }
562 StatusText(unsigned long id) { SetHWND(dw_status_text_new("", id)); } 622 StatusText(unsigned long id) { SetHWND(dw_status_text_new("", id)); }
563 StatusText() { SetHWND(dw_status_text_new("", 0)); } 623 StatusText() { SetHWND(dw_status_text_new("", 0)); }
564 }; 624 };
565 625
566 // Class for handing static image widget 626 // Class for handing static image widget
568 { 628 {
569 public: 629 public:
570 // Constructors 630 // Constructors
571 Bitmap(const char *data, int len) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap_from_data(hwnd, 0, data, len); } 631 Bitmap(const char *data, int len) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
572 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); } 632 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); }
633 Bitmap(std::string file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file.c_str()); }
573 Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); } 634 Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); }
574 Bitmap() { SetHWND(dw_bitmap_new(0)); } 635 Bitmap() { SetHWND(dw_bitmap_new(0)); }
575 }; 636 };
576 637
577 // Class for handing calendar widget 638 // Class for handing calendar widget
597 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; 658 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0;
598 virtual void DrawPolygon(int flags, int npoints, int x[], int y[]) = 0; 659 virtual void DrawPolygon(int flags, int npoints, int x[], int y[]) = 0;
599 virtual void DrawRect(int fill, int x, int y, int width, int height) = 0; 660 virtual void DrawRect(int fill, int x, int y, int width, int height) = 0;
600 virtual void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) = 0; 661 virtual void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) = 0;
601 virtual void DrawText(int x, int y, const char *text) = 0; 662 virtual void DrawText(int x, int y, const char *text) = 0;
663 virtual void DrawText(int x, int y, std::string text) = 0;
602 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0; 664 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0;
603 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0; 665 virtual int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) = 0;
604 virtual void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) = 0; 666 virtual void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) = 0;
605 virtual void BitBlt(int xdest, int ydest, int width, int height, Pixmap *srcp, int xsrc, int ysrc) = 0; 667 virtual void BitBlt(int xdest, int ydest, int width, int height, Pixmap *srcp, int xsrc, int ysrc) = 0;
606 void SetColor(unsigned long fore, unsigned long back) { dw_color_foreground_set(fore); dw_color_background_set(back); } 668 void SetColor(unsigned long fore, unsigned long back) { dw_color_foreground_set(fore); dw_color_background_set(back); }
742 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(hwnd, DW_NULL, x1, y1, x2, y2); } 804 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(hwnd, DW_NULL, x1, y1, x2, y2); }
743 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(hwnd, DW_NULL, flags, npoints, x, y); } 805 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(hwnd, DW_NULL, flags, npoints, x, y); }
744 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(hwnd, DW_NULL, fill, x, y, width, height); } 806 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(hwnd, DW_NULL, fill, x, y, width, height); }
745 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(hwnd, DW_NULL, flags, xorigin, yorigin, x1, y1, x2, y2); } 807 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(hwnd, DW_NULL, flags, xorigin, yorigin, x1, y1, x2, y2); }
746 void DrawText(int x, int y, const char *text) { dw_draw_text(hwnd, DW_NULL, x, y, text); } 808 void DrawText(int x, int y, const char *text) { dw_draw_text(hwnd, DW_NULL, x, y, text); }
809 void DrawText(int x, int y, std::string text) { dw_draw_text(hwnd, DW_NULL, x, y, text.c_str()); }
747 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) { 810 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) {
748 return dw_pixmap_stretch_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight); 811 return dw_pixmap_stretch_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight);
749 } 812 }
750 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight); 813 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight);
751 void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) { 814 void BitBlt(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc) {
752 return dw_pixmap_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc); 815 return dw_pixmap_bitblt(hwnd, DW_NULL, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc);
753 } 816 }
754 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc); 817 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc);
755 int SetFont(const char *fontname) { return dw_window_set_font(hwnd, fontname); } 818 int SetFont(const char *fontname) { return dw_window_set_font(hwnd, fontname); }
819 int SetFont(std::string fontname) { return dw_window_set_font(hwnd, fontname.c_str()); }
756 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text, width, height); } 820 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text, width, height); }
821 void GetTextExtents(std::string text, int *width, int *height) { dw_font_text_extents_get(hwnd, DW_NULL, text.c_str(), width, height); }
757 char *GetFont() { return dw_window_get_font(hwnd); } 822 char *GetFont() { return dw_window_get_font(hwnd); }
758 void Redraw() { dw_render_redraw(hwnd); } 823 void Redraw() { dw_render_redraw(hwnd); }
759 void Flush() { dw_flush(); } 824 void Flush() { dw_flush(); }
760 #ifdef DW_LAMBDA 825 #ifdef DW_LAMBDA
761 void ConnectExpose(std::function<int(DWExpose *)> userfunc) 826 void ConnectExpose(std::function<int(DWExpose *)> userfunc)
926 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename)); 991 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename));
927 pwidth = dw_pixmap_get_width(hpixmap); 992 pwidth = dw_pixmap_get_width(hpixmap);
928 pheight = dw_pixmap_get_height(hpixmap); 993 pheight = dw_pixmap_get_height(hpixmap);
929 hpmprot = false; 994 hpmprot = false;
930 } 995 }
996 Pixmap(Render *window, std::string filename) {
997 SetHPIXMAP(dw_pixmap_new_from_file(window ? window->GetHWND() : DW_NOHWND, filename.c_str()));
998 pwidth = dw_pixmap_get_width(hpixmap);
999 pheight = dw_pixmap_get_height(hpixmap);
1000 hpmprot = false;
1001 }
931 Pixmap(HPIXMAP hpm) { 1002 Pixmap(HPIXMAP hpm) {
932 SetHPIXMAP(hpm); 1003 SetHPIXMAP(hpm);
933 pwidth = dw_pixmap_get_width(hpixmap); 1004 pwidth = dw_pixmap_get_width(hpixmap);
934 pheight = dw_pixmap_get_height(hpixmap); 1005 pheight = dw_pixmap_get_height(hpixmap);
935 hpmprot = true; 1006 hpmprot = true;
943 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(DW_NOHWND, hpixmap, x1, y1, x2, y2); } 1014 void DrawLine(int x1, int y1, int x2, int y2) { dw_draw_line(DW_NOHWND, hpixmap, x1, y1, x2, y2); }
944 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(DW_NOHWND, hpixmap, flags, npoints, x, y); } 1015 void DrawPolygon(int flags, int npoints, int x[], int y[]) { dw_draw_polygon(DW_NOHWND, hpixmap, flags, npoints, x, y); }
945 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(DW_NOHWND, hpixmap, fill, x, y, width, height); } 1016 void DrawRect(int fill, int x, int y, int width, int height) { dw_draw_rect(DW_NOHWND, hpixmap, fill, x, y, width, height); }
946 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(DW_NOHWND, hpixmap, flags, xorigin, yorigin, x1, y1, x2, y2); } 1017 void DrawArc(int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) { dw_draw_arc(DW_NOHWND, hpixmap, flags, xorigin, yorigin, x1, y1, x2, y2); }
947 void DrawText(int x, int y, const char *text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text); } 1018 void DrawText(int x, int y, const char *text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text); }
1019 void DrawText(int x, int y, std::string text) { dw_draw_text(DW_NOHWND, hpixmap, x, y, text.c_str()); }
948 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) { 1020 int BitBltStretch(int xdest, int ydest, int width, int height, Render *src, int xsrc, int ysrc, int srcwidth, int srcheight) {
949 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight); 1021 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, src ? src->GetHWND() : DW_NOHWND, DW_NULL, xsrc, ysrc, srcwidth, srcheight);
950 } 1022 }
951 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) { 1023 int BitBltStretch(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc, int srcwidth, int srcheight) {
952 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc, srcwidth, srcheight); 1024 return dw_pixmap_stretch_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc, srcwidth, srcheight);
957 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) { 1029 void BitBlt(int xdest, int ydest, int width, int height, Pixmap *src, int xsrc, int ysrc) {
958 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc); 1030 dw_pixmap_bitblt(DW_NOHWND, hpixmap, xdest, ydest, width, height, DW_NOHWND, src ? src->GetHPIXMAP() : DW_NULL, xsrc, ysrc);
959 } 1031 }
960 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); } 1032 int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); }
961 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } 1033 void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); }
1034 void GetTextExtents(std::string text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text.c_str(), width, height); }
962 void SetTransparentColor(unsigned long color) { dw_pixmap_set_transparent_color(hpixmap, color); } 1035 void SetTransparentColor(unsigned long color) { dw_pixmap_set_transparent_color(hpixmap, color); }
963 unsigned long GetWidth() { return pwidth; } 1036 unsigned long GetWidth() { return pwidth; }
964 unsigned long GetHeight() { return pheight; } 1037 unsigned long GetHeight() { return pheight; }
965 }; 1038 };
966 1039
1033 void Action(int action) { dw_html_action(hwnd, action); } 1106 void Action(int action) { dw_html_action(hwnd, action); }
1034 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); } 1107 int JavascriptRun(const char *script, void *scriptdata) { return dw_html_javascript_run(hwnd, script, scriptdata); }
1035 int JavascriptRun(const char *script) { return dw_html_javascript_run(hwnd, script, NULL); } 1108 int JavascriptRun(const char *script) { return dw_html_javascript_run(hwnd, script, NULL); }
1036 int Raw(const char *buffer) { return dw_html_raw(hwnd, buffer); } 1109 int Raw(const char *buffer) { return dw_html_raw(hwnd, buffer); }
1037 int URL(const char *url) { return dw_html_url(hwnd, url); } 1110 int URL(const char *url) { return dw_html_url(hwnd, url); }
1111 int JavascriptRun(std::string script, void *scriptdata) { return dw_html_javascript_run(hwnd, script.c_str(), scriptdata); }
1112 int JavascriptRun(std::string script) { return dw_html_javascript_run(hwnd, script.c_str(), NULL); }
1113 int Raw(std::string buffer) { return dw_html_raw(hwnd, buffer.c_str()); }
1114 int URL(std::string url) { return dw_html_url(hwnd, url.c_str()); }
1038 #ifdef DW_LAMBDA 1115 #ifdef DW_LAMBDA
1039 void ConnectChanged(std::function<int(int, char *)> userfunc) 1116 void ConnectChanged(std::function<int(int, char *)> userfunc)
1040 { 1117 {
1041 _ConnectChanged = userfunc; 1118 _ConnectChanged = userfunc;
1042 if(!ChangedConnected) { 1119 if(!ChangedConnected) {
1098 class Entryfield : public TextEntry 1175 class Entryfield : public TextEntry
1099 { 1176 {
1100 public: 1177 public:
1101 // Constructors 1178 // Constructors
1102 Entryfield(const char *text, unsigned long id) { SetHWND(dw_entryfield_new(text, id)); } 1179 Entryfield(const char *text, unsigned long id) { SetHWND(dw_entryfield_new(text, id)); }
1180 Entryfield(std::string text, unsigned long id) { SetHWND(dw_entryfield_new(text.c_str(), id)); }
1103 Entryfield(unsigned long id) { SetHWND(dw_entryfield_new("", id)); } 1181 Entryfield(unsigned long id) { SetHWND(dw_entryfield_new("", id)); }
1104 Entryfield(const char *text) { SetHWND(dw_entryfield_new(text, 0)); } 1182 Entryfield(const char *text) { SetHWND(dw_entryfield_new(text, 0)); }
1183 Entryfield(std::string text) { SetHWND(dw_entryfield_new(text.c_str(), 0)); }
1105 Entryfield() { SetHWND(dw_entryfield_new("", 0)); } 1184 Entryfield() { SetHWND(dw_entryfield_new("", 0)); }
1106 }; 1185 };
1107 1186
1108 class EntryfieldPassword : public TextEntry 1187 class EntryfieldPassword : public TextEntry
1109 { 1188 {
1110 public: 1189 public:
1111 // Constructors 1190 // Constructors
1112 EntryfieldPassword(const char *text, unsigned long id) { SetHWND(dw_entryfield_password_new(text, id)); } 1191 EntryfieldPassword(const char *text, unsigned long id) { SetHWND(dw_entryfield_password_new(text, id)); }
1192 EntryfieldPassword(std::string text, unsigned long id) { SetHWND(dw_entryfield_password_new(text.c_str(), id)); }
1113 EntryfieldPassword(unsigned long id) { SetHWND(dw_entryfield_password_new("", id)); } 1193 EntryfieldPassword(unsigned long id) { SetHWND(dw_entryfield_password_new("", id)); }
1114 EntryfieldPassword(const char *text) { SetHWND(dw_entryfield_password_new(text, 0)); } 1194 EntryfieldPassword(const char *text) { SetHWND(dw_entryfield_password_new(text, 0)); }
1195 EntryfieldPassword(std::string text) { SetHWND(dw_entryfield_password_new(text.c_str(), 0)); }
1115 EntryfieldPassword() { SetHWND(dw_entryfield_password_new("", 0)); } 1196 EntryfieldPassword() { SetHWND(dw_entryfield_password_new("", 0)); }
1116 }; 1197 };
1117 1198
1118 // Base class for several widgets that have a list of elements 1199 // Base class for several widgets that have a list of elements
1119 class ListBoxes : virtual public Focusable 1200 class ListBoxes : virtual public Focusable
1135 return classptr->OnListSelect((unsigned int)index); 1216 return classptr->OnListSelect((unsigned int)index);
1136 } 1217 }
1137 public: 1218 public:
1138 // User functions 1219 // User functions
1139 void Append(const char *text) { dw_listbox_append(hwnd, text); } 1220 void Append(const char *text) { dw_listbox_append(hwnd, text); }
1221 void Append(std::string text) { dw_listbox_append(hwnd, text.c_str()); }
1140 void Clear() { dw_listbox_clear(hwnd); } 1222 void Clear() { dw_listbox_clear(hwnd); }
1141 int Count() { return dw_listbox_count(hwnd); } 1223 int Count() { return dw_listbox_count(hwnd); }
1142 void Delete(int index) { dw_listbox_delete(hwnd, index); } 1224 void Delete(int index) { dw_listbox_delete(hwnd, index); }
1143 void GetListText(unsigned int index, char *buffer, unsigned int length) { dw_listbox_get_text(hwnd, index, buffer, length); } 1225 void GetListText(unsigned int index, char *buffer, unsigned int length) { dw_listbox_get_text(hwnd, index, buffer, length); }
1144 void SetListText(unsigned int index, char *buffer) { dw_listbox_set_text(hwnd, index, buffer); } 1226 void SetListText(unsigned int index, char *buffer) { dw_listbox_set_text(hwnd, index, buffer); }
1227 void SetListText(unsigned int index, std::string buffer) { dw_listbox_set_text(hwnd, index, buffer.c_str()); }
1145 void Insert(const char *text, int pos) { dw_listbox_insert(hwnd, text, pos); } 1228 void Insert(const char *text, int pos) { dw_listbox_insert(hwnd, text, pos); }
1146 void ListAppend(char **text, int count) { dw_listbox_list_append(hwnd, text, count); } 1229 void ListAppend(char **text, int count) { dw_listbox_list_append(hwnd, text, count); }
1147 void Select(int index, int state) { dw_listbox_select(hwnd, index, state); } 1230 void Select(int index, int state) { dw_listbox_select(hwnd, index, state); }
1148 int Selected() { return dw_listbox_selected(hwnd); } 1231 int Selected() { return dw_listbox_selected(hwnd); }
1149 int Selected(int where) { return dw_listbox_selected_multi(hwnd, where); } 1232 int Selected(int where) { return dw_listbox_selected_multi(hwnd, where); }
1189 class ComboBox : public TextEntry, public ListBoxes 1272 class ComboBox : public TextEntry, public ListBoxes
1190 { 1273 {
1191 public: 1274 public:
1192 // Constructors 1275 // Constructors
1193 ComboBox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); Setup(); } 1276 ComboBox(const char *text, unsigned long id) { SetHWND(dw_combobox_new(text, id)); Setup(); }
1277 ComboBox(std::string text, unsigned long id) { SetHWND(dw_combobox_new(text.c_str(), id)); Setup(); }
1194 ComboBox(unsigned long id) { SetHWND(dw_combobox_new("", id)); Setup(); } 1278 ComboBox(unsigned long id) { SetHWND(dw_combobox_new("", id)); Setup(); }
1195 ComboBox(const char *text) { SetHWND(dw_combobox_new(text, 0)); Setup(); } 1279 ComboBox(const char *text) { SetHWND(dw_combobox_new(text, 0)); Setup(); }
1280 ComboBox(std::string text) { SetHWND(dw_combobox_new(text.c_str(), 0)); Setup(); }
1196 ComboBox() { SetHWND(dw_combobox_new("", 0)); Setup(); } 1281 ComboBox() { SetHWND(dw_combobox_new("", 0)); Setup(); }
1197 }; 1282 };
1198 1283
1199 class ListBox : public ListBoxes 1284 class ListBox : public ListBoxes
1200 { 1285 {
1305 class SpinButton : public Ranged, public TextEntry 1390 class SpinButton : public Ranged, public TextEntry
1306 { 1391 {
1307 public: 1392 public:
1308 // Constructors 1393 // Constructors
1309 SpinButton(const char *text, unsigned long id) { SetHWND(dw_spinbutton_new(text, id)); Setup(); } 1394 SpinButton(const char *text, unsigned long id) { SetHWND(dw_spinbutton_new(text, id)); Setup(); }
1395 SpinButton(std::string text, unsigned long id) { SetHWND(dw_spinbutton_new(text.c_str(), id)); Setup(); }
1310 SpinButton(unsigned long id) { SetHWND(dw_spinbutton_new("", id)); Setup(); } 1396 SpinButton(unsigned long id) { SetHWND(dw_spinbutton_new("", id)); Setup(); }
1311 SpinButton(const char *text) { SetHWND(dw_spinbutton_new(text, 0)); Setup(); } 1397 SpinButton(const char *text) { SetHWND(dw_spinbutton_new(text, 0)); Setup(); }
1398 SpinButton(std::string text) { SetHWND(dw_spinbutton_new(text.c_str(), 0)); Setup(); }
1312 SpinButton() { SetHWND(dw_spinbutton_new("", 0)); Setup(); } 1399 SpinButton() { SetHWND(dw_spinbutton_new("", 0)); Setup(); }
1313 1400
1314 // User functions 1401 // User functions
1315 long GetPos() { return dw_spinbutton_get_pos(hwnd); } 1402 long GetPos() { return dw_spinbutton_get_pos(hwnd); }
1316 void SetPos(long position) { dw_spinbutton_set_pos(hwnd, position); } 1403 void SetPos(long position) { dw_spinbutton_set_pos(hwnd, position); }
1330 void Thaw() { dw_mle_thaw(hwnd); } 1417 void Thaw() { dw_mle_thaw(hwnd); }
1331 void Clear() { dw_mle_clear(hwnd); } 1418 void Clear() { dw_mle_clear(hwnd); }
1332 void Delete(int startpoint, int length) { dw_mle_delete(hwnd, startpoint, length); } 1419 void Delete(int startpoint, int length) { dw_mle_delete(hwnd, startpoint, length); }
1333 void Export(char *buffer, int startpoint, int length) { dw_mle_export(hwnd, buffer, startpoint, length); } 1420 void Export(char *buffer, int startpoint, int length) { dw_mle_export(hwnd, buffer, startpoint, length); }
1334 int Import(const char *buffer, int startpoint) { return dw_mle_import(hwnd, buffer, startpoint); } 1421 int Import(const char *buffer, int startpoint) { return dw_mle_import(hwnd, buffer, startpoint); }
1422 int Import(std::string buffer, int startpoint) { return dw_mle_import(hwnd, buffer.c_str(), startpoint); }
1335 void GetSize(unsigned long *bytes, unsigned long *lines) { dw_mle_get_size(hwnd, bytes, lines); } 1423 void GetSize(unsigned long *bytes, unsigned long *lines) { dw_mle_get_size(hwnd, bytes, lines); }
1336 void Search(const char *text, int point, unsigned long flags) { dw_mle_search(hwnd, text, point, flags); } 1424 void Search(const char *text, int point, unsigned long flags) { dw_mle_search(hwnd, text, point, flags); }
1425 void Search(std::string text, int point, unsigned long flags) { dw_mle_search(hwnd, text.c_str(), point, flags); }
1337 void SetAutoComplete(int state) { dw_mle_set_auto_complete(hwnd, state); } 1426 void SetAutoComplete(int state) { dw_mle_set_auto_complete(hwnd, state); }
1338 void SetCursor(int point) { dw_mle_set_cursor(hwnd, point); } 1427 void SetCursor(int point) { dw_mle_set_cursor(hwnd, point); }
1339 void SetEditable(int state) { dw_mle_set_editable(hwnd, state); } 1428 void SetEditable(int state) { dw_mle_set_editable(hwnd, state); }
1340 void SetVisible(int line) { dw_mle_set_visible(hwnd, line); } 1429 void SetVisible(int line) { dw_mle_set_visible(hwnd, line); }
1341 void SetWordWrap(int state) { dw_mle_set_word_wrap(hwnd, state); } 1430 void SetWordWrap(int state) { dw_mle_set_word_wrap(hwnd, state); }
1395 unsigned long PageNew(unsigned long flags) { return dw_notebook_page_new(hwnd, flags, FALSE); } 1484 unsigned long PageNew(unsigned long flags) { return dw_notebook_page_new(hwnd, flags, FALSE); }
1396 unsigned long PageNew() { return dw_notebook_page_new(hwnd, 0, FALSE); } 1485 unsigned long PageNew() { return dw_notebook_page_new(hwnd, 0, FALSE); }
1397 void PageSet(unsigned long pageid) { dw_notebook_page_set(hwnd, pageid); } 1486 void PageSet(unsigned long pageid) { dw_notebook_page_set(hwnd, pageid); }
1398 void PageSetStatusText(unsigned long pageid, const char *text) { dw_notebook_page_set_status_text(hwnd, pageid, text); } 1487 void PageSetStatusText(unsigned long pageid, const char *text) { dw_notebook_page_set_status_text(hwnd, pageid, text); }
1399 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); } 1488 void PageSetText(unsigned long pageid, const char *text) { dw_notebook_page_set_text(hwnd, pageid, text); }
1489 void PageSetStatusText(unsigned long pageid, std::string text) { dw_notebook_page_set_status_text(hwnd, pageid, text.c_str()); }
1490 void PageSetText(unsigned long pageid, std::string text) { dw_notebook_page_set_text(hwnd, pageid, text.c_str()); }
1400 #ifdef DW_LAMBDA 1491 #ifdef DW_LAMBDA
1401 void ConnectSwitchPage(std::function<int(unsigned long)> userfunc) 1492 void ConnectSwitchPage(std::function<int(unsigned long)> userfunc)
1402 { 1493 {
1403 _ConnectSwitchPage = userfunc; 1494 _ConnectSwitchPage = userfunc;
1404 if(!SwitchPageConnected) { 1495 if(!SwitchPageConnected) {
1586 } 1677 }
1587 public: 1678 public:
1588 // User functions 1679 // User functions
1589 void Alloc(int rowcount) { allocpointer = dw_container_alloc(hwnd, rowcount); allocrowcount = rowcount; } 1680 void Alloc(int rowcount) { allocpointer = dw_container_alloc(hwnd, rowcount); allocrowcount = rowcount; }
1590 void ChangeRowTitle(int row, char *title) { dw_container_change_row_title(hwnd, row, title); } 1681 void ChangeRowTitle(int row, char *title) { dw_container_change_row_title(hwnd, row, title); }
1682 void ChangeRowTitle(int row, std::string title) { dw_container_change_row_title(hwnd, row, title.c_str()); }
1591 void Clear(int redraw) { dw_container_clear(hwnd, redraw); } 1683 void Clear(int redraw) { dw_container_clear(hwnd, redraw); }
1592 void Clear() { dw_container_clear(hwnd, TRUE); } 1684 void Clear() { dw_container_clear(hwnd, TRUE); }
1593 void Cursor(const char *text) { dw_container_cursor(hwnd, text); } 1685 void Cursor(const char *text) { dw_container_cursor(hwnd, text); }
1686 void Cursor(std::string text) { dw_container_cursor(hwnd, text.c_str()); }
1594 void Cursor(void *data) { dw_container_cursor_by_data(hwnd, data); } 1687 void Cursor(void *data) { dw_container_cursor_by_data(hwnd, data); }
1595 void Delete(int rowcount) { dw_container_delete(hwnd, rowcount); } 1688 void Delete(int rowcount) { dw_container_delete(hwnd, rowcount); }
1596 void DeleteRow(char *title) { dw_container_delete_row(hwnd, title); } 1689 void DeleteRow(char *title) { dw_container_delete_row(hwnd, title); }
1690 void DeleteRow(std::string title) { dw_container_delete_row(hwnd, title.c_str()); }
1597 void DeleteRow(void *data) { dw_container_delete_row_by_data(hwnd, data); } 1691 void DeleteRow(void *data) { dw_container_delete_row_by_data(hwnd, data); }
1598 void Insert() { dw_container_insert(hwnd, allocpointer, allocrowcount); } 1692 void Insert() { dw_container_insert(hwnd, allocpointer, allocrowcount); }
1599 void Optimize() { dw_container_optimize(hwnd); } 1693 void Optimize() { dw_container_optimize(hwnd); }
1600 char *QueryNext(unsigned long flags) { return dw_container_query_next(hwnd, flags); } 1694 char *QueryNext(unsigned long flags) { return dw_container_query_next(hwnd, flags); }
1601 char *QueryStart(unsigned long flags) { return dw_container_query_start(hwnd, flags); } 1695 char *QueryStart(unsigned long flags) { return dw_container_query_start(hwnd, flags); }
1602 void Scroll(int direction, long rows) { dw_container_scroll(hwnd, direction, rows); } 1696 void Scroll(int direction, long rows) { dw_container_scroll(hwnd, direction, rows); }
1603 void SetColumnWidth(int column, int width) { dw_container_set_column_width(hwnd, column, width); } 1697 void SetColumnWidth(int column, int width) { dw_container_set_column_width(hwnd, column, width); }
1604 void SetRowData(int row, void *data) { dw_container_set_row_data(allocpointer, row, data); } 1698 void SetRowData(int row, void *data) { dw_container_set_row_data(allocpointer, row, data); }
1605 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); } 1699 void SetRowTitle(int row, const char *title) { dw_container_set_row_title(allocpointer, row, title); }
1700 void SetRowTitle(int row, const std::string title) { dw_container_set_row_title(allocpointer, row, title.c_str()); }
1606 void SetStripe(unsigned long oddcolor, unsigned long evencolor) { dw_container_set_stripe(hwnd, oddcolor, evencolor); } 1701 void SetStripe(unsigned long oddcolor, unsigned long evencolor) { dw_container_set_stripe(hwnd, oddcolor, evencolor); }
1607 #ifdef DW_LAMBDA 1702 #ifdef DW_LAMBDA
1608 void ConnectItemEnter(std::function<int(char *, void *)> userfunc) 1703 void ConnectItemEnter(std::function<int(char *, void *)> userfunc)
1609 { 1704 {
1610 _ConnectItemEnter = userfunc; 1705 _ConnectItemEnter = userfunc;
1677 } 1772 }
1678 void ChangeFile(int row, const char *filename, HICN icon) { dw_filesystem_change_file(hwnd, row, filename, icon); } 1773 void ChangeFile(int row, const char *filename, HICN icon) { dw_filesystem_change_file(hwnd, row, filename, icon); }
1679 void ChangeItem(int column, int row, void *data) { dw_filesystem_change_item(hwnd, column, row, data); } 1774 void ChangeItem(int column, int row, void *data) { dw_filesystem_change_item(hwnd, column, row, data); }
1680 int GetColumnType(int column) { return dw_filesystem_get_column_type(hwnd, column); } 1775 int GetColumnType(int column) { return dw_filesystem_get_column_type(hwnd, column); }
1681 void SetColumnTitle(const char *title) { dw_filesystem_set_column_title(hwnd, title); } 1776 void SetColumnTitle(const char *title) { dw_filesystem_set_column_title(hwnd, title); }
1777 void SetColumnTitle(std::string title) { dw_filesystem_set_column_title(hwnd, title.c_str()); }
1682 void SetFile(int row, const char *filename, HICN icon) { dw_filesystem_set_file(hwnd, allocpointer, row, filename, icon); } 1778 void SetFile(int row, const char *filename, HICN icon) { dw_filesystem_set_file(hwnd, allocpointer, row, filename, icon); }
1683 void SetItem(int column, int row, void *data) { dw_filesystem_set_item(hwnd, allocpointer, column, row, data); } 1779 void SetItem(int column, int row, void *data) { dw_filesystem_set_item(hwnd, allocpointer, column, row, data); }
1684 }; 1780 };
1685 1781
1686 class Tree : virtual public Focusable, virtual public ObjectView 1782 class Tree : virtual public Focusable, virtual public ObjectView
1734 HTREEITEM Insert(const char *title, HICN icon, HTREEITEM parent) { return dw_tree_insert(hwnd, title, icon, parent, NULL); } 1830 HTREEITEM Insert(const char *title, HICN icon, HTREEITEM parent) { return dw_tree_insert(hwnd, title, icon, parent, NULL); }
1735 HTREEITEM Insert(const char *title, HICN icon) { return dw_tree_insert(hwnd, title, icon, 0, NULL); } 1831 HTREEITEM Insert(const char *title, HICN icon) { return dw_tree_insert(hwnd, title, icon, 0, NULL); }
1736 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(hwnd, item, title, icon, parent, itemdata); } 1832 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(hwnd, item, title, icon, parent, itemdata); }
1737 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent) { return dw_tree_insert_after(hwnd, item, title, icon, parent, NULL); } 1833 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon, HTREEITEM parent) { return dw_tree_insert_after(hwnd, item, title, icon, parent, NULL); }
1738 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title, icon, 0, NULL); } 1834 HTREEITEM InsertAfter(const char *title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title, icon, 0, NULL); }
1835 HTREEITEM Insert(std::string title, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert(hwnd, title.c_str(), icon, parent, itemdata); }
1836 HTREEITEM Insert(std::string title, HICN icon, HTREEITEM parent) { return dw_tree_insert(hwnd, title.c_str(), icon, parent, NULL); }
1837 HTREEITEM Insert(std::string title, HICN icon) { return dw_tree_insert(hwnd, title.c_str(), icon, 0, NULL); }
1838 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon, HTREEITEM parent, void *itemdata) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, parent, itemdata); }
1839 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon, HTREEITEM parent) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, parent, NULL); }
1840 HTREEITEM InsertAfter(std::string title, HTREEITEM item, HICN icon) { return dw_tree_insert_after(hwnd, item, title.c_str(), icon, 0, NULL); }
1739 void Change(HTREEITEM item, const char *title, HICN icon) { dw_tree_item_change(hwnd, item, title, icon); } 1841 void Change(HTREEITEM item, const char *title, HICN icon) { dw_tree_item_change(hwnd, item, title, icon); }
1842 void Change(HTREEITEM item, std::string title, HICN icon) { dw_tree_item_change(hwnd, item, title.c_str(), icon); }
1740 void Collapse(HTREEITEM item) { dw_tree_item_collapse(hwnd, item); } 1843 void Collapse(HTREEITEM item) { dw_tree_item_collapse(hwnd, item); }
1741 void Delete(HTREEITEM item) { dw_tree_item_delete(hwnd, item); } 1844 void Delete(HTREEITEM item) { dw_tree_item_delete(hwnd, item); }
1742 void Expand(HTREEITEM item) { dw_tree_item_expand(hwnd, item); } 1845 void Expand(HTREEITEM item) { dw_tree_item_expand(hwnd, item); }
1743 void *GetData(HTREEITEM item) { return dw_tree_item_get_data(hwnd, item); } 1846 void *GetData(HTREEITEM item) { return dw_tree_item_get_data(hwnd, item); }
1744 void Select(HTREEITEM item) { dw_tree_item_select(hwnd, item); } 1847 void Select(HTREEITEM item) { dw_tree_item_select(hwnd, item); }
1913 public: 2016 public:
1914 // Constructors 2017 // Constructors
1915 Notification(const char *title, const char *imagepath, const char *description) { SetHWND(dw_notification_new(title, imagepath, description)); } 2018 Notification(const char *title, const char *imagepath, const char *description) { SetHWND(dw_notification_new(title, imagepath, description)); }
1916 Notification(const char *title, const char *imagepath) { SetHWND(dw_notification_new(title, imagepath, NULL)); } 2019 Notification(const char *title, const char *imagepath) { SetHWND(dw_notification_new(title, imagepath, NULL)); }
1917 Notification(const char *title) { SetHWND(dw_notification_new(title, NULL, NULL)); } 2020 Notification(const char *title) { SetHWND(dw_notification_new(title, NULL, NULL)); }
2021 Notification(std::string title, std::string imagepath, std::string description) { SetHWND(dw_notification_new(title.c_str(), imagepath.c_str(), description.c_str())); }
2022 Notification(std::string title, std::string imagepath) { SetHWND(dw_notification_new(title.c_str(), imagepath.c_str(), NULL)); }
2023 Notification(std::string title) { SetHWND(dw_notification_new(title.c_str(), NULL, NULL)); }
1918 2024
1919 // User functions 2025 // User functions
1920 int Send() { int retval = dw_notification_send(hwnd); delete this; return retval; } 2026 int Send() { int retval = dw_notification_send(hwnd); delete this; return retval; }
1921 }; 2027 };
1922 2028
2085 static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; } 2191 static App *Init(const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; }
2086 static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, DW_NULL); } return _app; } 2192 static App *Init(const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, 0, DW_NULL); } return _app; }
2087 static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; } 2193 static App *Init(int argc, char *argv[]) { if(!_app) { _app = new App(); dw_init(TRUE, argc, argv); } return _app; }
2088 static App *Init(int argc, char *argv[], const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, argc, argv); } return _app; } 2194 static App *Init(int argc, char *argv[], const char *appid) { if(!_app) { _app = new App(); dw_app_id_set(appid, DW_NULL); dw_init(TRUE, argc, argv); } return _app; }
2089 static App *Init(int argc, char *argv[], const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, argc, argv); } return _app; } 2195 static App *Init(int argc, char *argv[], const char *appid, const char *appname) { if(!_app) { _app = new App(); dw_app_id_set(appid, appname); dw_init(TRUE, argc, argv); } return _app; }
2196 static App *Init(std::string appid) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), DW_NULL); dw_init(TRUE, 0, DW_NULL); } return _app; }
2197 static App *Init(std::string appid, std::string appname) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), appname.c_str()); dw_init(TRUE, 0, DW_NULL); } return _app; }
2198 static App *Init(int argc, char *argv[], std::string appid) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), DW_NULL); dw_init(TRUE, argc, argv); } return _app; }
2199 static App *Init(int argc, char *argv[], std::string appid, std::string appname) { if(!_app) { _app = new App(); dw_app_id_set(appid.c_str(), appname.c_str()); dw_init(TRUE, argc, argv); } return _app; }
2090 // Destrouctor 2200 // Destrouctor
2091 ~App() { dw_exit(0); } 2201 ~App() { dw_exit(0); }
2092 2202
2093 // User functions 2203 // User functions
2094 void Main() { dw_main(); } 2204 void Main() { dw_main(); }
2105 retval = dw_vmessagebox(title, flags, format, args); 2215 retval = dw_vmessagebox(title, flags, format, args);
2106 va_end(args); 2216 va_end(args);
2107 2217
2108 return retval; 2218 return retval;
2109 } 2219 }
2220 int MessageBox(std::string title, int flags, std::string format, ...) {
2221 int retval;
2222 const char *cformat = format.c_str();
2223 va_list args;
2224
2225 va_start(args, format);
2226 retval = dw_vmessagebox(title.c_str(), flags, cformat, args);
2227 va_end(args);
2228
2229 return retval;
2230 }
2110 void Debug(const char *format, ...) { 2231 void Debug(const char *format, ...) {
2111 va_list args; 2232 va_list args;
2112 2233
2113 va_start(args, format); 2234 va_start(args, format);
2114 dw_vdebug(format, args); 2235 dw_vdebug(format, args);
2236 va_end(args);
2237 }
2238 void Debug(std::string format, ...) {
2239 const char *cformat = format.c_str();
2240 va_list args;
2241
2242 va_start(args, format);
2243 dw_vdebug(cformat, args);
2115 va_end(args); 2244 va_end(args);
2116 } 2245 }
2117 void Beep(int freq, int dur) { dw_beep(freq, dur); } 2246 void Beep(int freq, int dur) { dw_beep(freq, dur); }
2118 char *GetDir() { return dw_app_dir(); } 2247 char *GetDir() { return dw_app_dir(); }
2119 void GetEnvironment(DWEnv *env) { dw_environment_query(env); } 2248 void GetEnvironment(DWEnv *env) { dw_environment_query(env); }
2122 void GetPointerPos(long *x, long *y) { dw_pointer_query_pos(x, y); } 2251 void GetPointerPos(long *x, long *y) { dw_pointer_query_pos(x, y); }
2123 unsigned long GetColorDepth() { return dw_color_depth_get(); } 2252 unsigned long GetColorDepth() { return dw_color_depth_get(); }
2124 char *GetClipboard() { return dw_clipboard_get_text(); } 2253 char *GetClipboard() { return dw_clipboard_get_text(); }
2125 void SetClipboard(const char *text) { if(text) dw_clipboard_set_text(text, (int)strlen(text)); } 2254 void SetClipboard(const char *text) { if(text) dw_clipboard_set_text(text, (int)strlen(text)); }
2126 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); } 2255 void SetClipboard(const char *text, int len) { if(text) dw_clipboard_set_text(text, len); }
2256 void SetClipboard(std::string text) { dw_clipboard_set_text(text.c_str(), (int)strlen(text.c_str())); }
2257 void SetClipboard(std::string text, int len) { dw_clipboard_set_text(text.c_str(), len); }
2127 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); } 2258 void SetDefaultFont(const char *fontname) { dw_font_set_default(fontname); }
2259 void SetDefaultFont(std::string fontname) { dw_font_set_default(fontname.c_str()); }
2128 unsigned long ColorChoose(unsigned long initial) { return dw_color_choose(initial); } 2260 unsigned long ColorChoose(unsigned long initial) { return dw_color_choose(initial); }
2129 char *FileBrowse(const char *title, const char *defpath, const char *ext, int flags) { return dw_file_browse(title, defpath, ext, flags); } 2261 char *FileBrowse(const char *title, const char *defpath, const char *ext, int flags) { return dw_file_browse(title, defpath, ext, flags); }
2130 char *FontChoose(const char *currfont) { return dw_font_choose(currfont); } 2262 char *FontChoose(const char *currfont) { return dw_font_choose(currfont); }
2263 std::string FileBrowse(std::string title, std::string defpath, std::string ext, int flags) {
2264 char *retval = dw_file_browse(title.c_str(), defpath.c_str(), ext.c_str(), flags);
2265 return retval ? std::string(retval) : std::string();
2266 }
2267 std::string FontChoose(std::string currfont) {
2268 char *retval = dw_font_choose(currfont.c_str());
2269 return retval ? std::string(retval) : std::string();
2270 }
2131 void Free(void *buff) { dw_free(buff); } 2271 void Free(void *buff) { dw_free(buff); }
2132 int GetFeature(DWFEATURE feature) { return dw_feature_get(feature); } 2272 int GetFeature(DWFEATURE feature) { return dw_feature_get(feature); }
2133 int SetFeature(DWFEATURE feature, int state) { return dw_feature_set(feature, state); } 2273 int SetFeature(DWFEATURE feature, int state) { return dw_feature_set(feature, state); }
2134 HICN LoadIcon(unsigned long id) { return dw_icon_load(0, id); } 2274 HICN LoadIcon(unsigned long id) { return dw_icon_load(0, id); }
2135 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); } 2275 HICN LoadIcon(const char *filename) { return dw_icon_load_from_file(filename); }
2276 HICN LoadIcon(std::string filename) { return dw_icon_load_from_file(filename.c_str()); }
2136 HICN LoadIcon(const char *data, int len) { return dw_icon_load_from_data(data, len); } 2277 HICN LoadIcon(const char *data, int len) { return dw_icon_load_from_data(data, len); }
2137 void FreeIcon(HICN icon) { dw_icon_free(icon); } 2278 void FreeIcon(HICN icon) { dw_icon_free(icon); }
2138 void TaskBarInsert(Widget *handle, HICN icon, const char *bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext); } 2279 void TaskBarInsert(Widget *handle, HICN icon, const char *bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext); }
2280 void TaskBarInsert(Widget *handle, HICN icon, std::string bubbletext) { dw_taskbar_insert(handle ? handle->GetHWND() : DW_NOHWND, icon, bubbletext.c_str()); }
2139 void TaskBarDelete(Widget *handle, HICN icon) { dw_taskbar_delete(handle ? handle->GetHWND() : DW_NOHWND, icon); } 2281 void TaskBarDelete(Widget *handle, HICN icon) { dw_taskbar_delete(handle ? handle->GetHWND() : DW_NOHWND, icon); }
2140 char * WideToUTF8(const wchar_t * wstring) { return dw_wchar_to_utf8(wstring); } 2282 char * WideToUTF8(const wchar_t * wstring) { return dw_wchar_to_utf8(wstring); }
2141 wchar_t *UTF8ToWide(const char * utf8string) { return dw_utf8_to_wchar(utf8string); } 2283 wchar_t *UTF8ToWide(const char * utf8string) { return dw_utf8_to_wchar(utf8string); }
2142 }; 2284 };
2143 2285