diff 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
line wrap: on
line diff
--- a/dw.hpp	Fri Dec 30 12:15:19 2022 +0000
+++ b/dw.hpp	Fri Dec 30 14:35:45 2022 +0000
@@ -82,7 +82,7 @@
     void SetPointer(int cursortype) { dw_window_set_pointer(hwnd, cursortype); }
     void SetStyle(unsigned long flags, unsigned long mask) { dw_window_set_style(hwnd, flags, mask); }
     void SetStyle(unsigned long flags) { dw_window_set_style(hwnd, flags, flags); }
-    void SetTooltip(char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); }
+    void SetTooltip(const char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); }
     int Unpack() { return dw_box_unpack(hwnd); }
 };
 
@@ -479,8 +479,17 @@
     Button() { SetHWND(dw_button_new("", 0)); Setup(); }
 };
 
+class BitmapWidget : virtual public Widget
+{
+public:
+    // User functions
+    void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); }
+    void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); }
+    void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
+};
+
 // Image based button
-class BitmapButton : public Clickable, public Focusable
+class BitmapButton : public Clickable, public Focusable, public BitmapWidget
 {
 public:
     // Constructors
@@ -553,7 +562,7 @@
 };
 
 // Class for handing static image widget
-class Bitmap : public Widget
+class Bitmap : public BitmapWidget
 {
 public:
     // Constructors
@@ -561,11 +570,6 @@
     Bitmap(const char *file) { SetHWND(dw_bitmap_new(0)); dw_window_set_bitmap(hwnd, 0, file); }
     Bitmap(unsigned long id) { SetHWND(dw_bitmap_new(id)); }
     Bitmap() { SetHWND(dw_bitmap_new(0)); }
-
-    // User functions
-    void Set(unsigned long id) { dw_window_set_bitmap(hwnd, id, DW_NULL); }
-    void Set(const char *file) { dw_window_set_bitmap(hwnd, 0, file); }
-    void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
 };
 
 // Class for handing calendar widget
@@ -1259,6 +1263,17 @@
     }    
 };
 
+class Percent : public Widget
+{
+public:
+    // Constructors
+    Percent(unsigned long id) { SetHWND(dw_percent_new(id)); }
+    Percent() { SetHWND(dw_percent_new(0)); }
+
+    // User functions
+    void SetPos(unsigned int position) { dw_percent_set_pos(hwnd, position); }
+};
+
 class Slider : public Ranged
 {
 public: