comparison dw.hpp @ 2931:30c1f37713b6

C++: Add page 5 - Buttons to dwtestoo.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 30 Dec 2022 14:35:45 +0000
parents d8117d36ed27
children 3f660f47a45f
comparison
equal deleted inserted replaced
2930:d8117d36ed27 2931:30c1f37713b6
80 void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); } 80 void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); }
81 void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); } 81 void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); }
82 void SetPointer(int cursortype) { dw_window_set_pointer(hwnd, cursortype); } 82 void SetPointer(int cursortype) { dw_window_set_pointer(hwnd, cursortype); }
83 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); } 83 void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); }
84 void SetStyle(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); } 84 void SetStyle(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); }
85 void SetTooltip(char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); } 85 void SetTooltip(const char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); }
86 int Unpack() { return dw_box_unpack(hwnd); } 86 int Unpack() { return dw_box_unpack(hwnd); }
87 }; 87 };
88 88
89 // Box class is a packable object 89 // Box class is a packable object
90 class Boxes : virtual public Widget 90 class Boxes : virtual public Widget
477 Button(unsigned long id) { SetHWND(dw_button_new("", id)); Setup(); } 477 Button(unsigned long id) { SetHWND(dw_button_new("", id)); Setup(); }
478 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); } 478 Button(const char *text) { SetHWND(dw_button_new(text, 0)); Setup(); }
479 Button() { SetHWND(dw_button_new("", 0)); Setup(); } 479 Button() { SetHWND(dw_button_new("", 0)); Setup(); }
480 }; 480 };
481 481
482 class BitmapWidget : virtual public Widget
483 {
484 public:
485 // User functions
486 void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); }
487 void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); }
488 void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
489 };
490
482 // Image based button 491 // Image based button
483 class BitmapButton : public Clickable, public Focusable 492 class BitmapButton : public Clickable, public Focusable, public BitmapWidget
484 { 493 {
485 public: 494 public:
486 // Constructors 495 // Constructors
487 BitmapButton(const char *text, unsigned long id) { SetHWND(dw_bitmapbutton_new(text, id)); Setup(); } 496 BitmapButton(const char *text, unsigned long id) { SetHWND(dw_bitmapbutton_new(text, id)); Setup(); }
488 BitmapButton(unsigned long id) { SetHWND(dw_bitmapbutton_new("", id)); Setup(); } 497 BitmapButton(unsigned long id) { SetHWND(dw_bitmapbutton_new("", id)); Setup(); }
551 StatusText(unsigned long id) { SetHWND(dw_status_text_new("", id)); } 560 StatusText(unsigned long id) { SetHWND(dw_status_text_new("", id)); }
552 StatusText() { SetHWND(dw_status_text_new("", 0)); } 561 StatusText() { SetHWND(dw_status_text_new("", 0)); }
553 }; 562 };
554 563
555 // Class for handing static image widget 564 // Class for handing static image widget
556 class Bitmap : public Widget 565 class Bitmap : public BitmapWidget
557 { 566 {
558 public: 567 public:
559 // Constructors 568 // Constructors
560 Bitmap(const char *data, int len) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap_from_data(hwnd, 0, data, len); } 569 Bitmap(const char *data, int len) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
561 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); } 570 Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); }
562 Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); } 571 Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); }
563 Bitmap() { SetHWND(dw_bitmap_new(0)); } 572 Bitmap() { SetHWND(dw_bitmap_new(0)); }
564
565 // User functions
566 void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); }
567 void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); }
568 void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
569 }; 573 };
570 574
571 // Class for handing calendar widget 575 // Class for handing calendar widget
572 class Calendar : public Widget 576 class Calendar : public Widget
573 { 577 {
1257 ValueChangedConnected = true; 1261 ValueChangedConnected = true;
1258 } 1262 }
1259 } 1263 }
1260 }; 1264 };
1261 1265
1266 class Percent : public Widget
1267 {
1268 public:
1269 // Constructors
1270 Percent(unsigned long id) { SetHWND(dw_percent_new(id)); }
1271 Percent() { SetHWND(dw_percent_new(0)); }
1272
1273 // User functions
1274 void SetPos(unsigned int position) { dw_percent_set_pos(hwnd, position); }
1275 };
1276
1262 class Slider : public Ranged 1277 class Slider : public Ranged
1263 { 1278 {
1264 public: 1279 public:
1265 // Constructors 1280 // Constructors
1266 Slider(int orient, int increments, unsigned long id) { SetHWND(dw_slider_new(orient, increments, id)); Setup(); } 1281 Slider(int orient, int increments, unsigned long id) { SetHWND(dw_slider_new(orient, increments, id)); Setup(); }