changeset 2879:ec7f6e28166d

C++: Add Calendar widget and fix an issue in that last commit.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 20 Dec 2022 18:06:51 +0000
parents a290573a8b7c
children 2ba0959eb3cf
files dw.hpp
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dw.hpp	Tue Dec 20 05:50:15 2022 +0000
+++ b/dw.hpp	Tue Dec 20 18:06:51 2022 +0000
@@ -279,6 +279,20 @@
     void Set(const char *data, int len) { dw_window_set_bitmap_from_data(hwnd, 0, data, len); }
 };
 
+// Class for handing calendar widget
+class Calendar : public Widget
+{
+public:
+    // Constructors
+    Calendar(unsigned long id) { SetHWND(dw_calendar_new(id)); }
+    Calendar() { SetHWND(dw_calendar_new(0)); }
+
+    // User functions
+    void GetData(unsigned int *year, unsigned int *month, unsigned int *day) { dw_calendar_get_date(hwnd, year, month, day); }
+    void SetData(unsigned int year, unsigned int month, unsigned int day) { dw_calendar_set_date(hwnd, year, month, day); }
+};
+
+
 // Forward declare these so our Drawable abstract class can reference
 class Render;
 class Pixmap;
@@ -426,7 +440,7 @@
 {
 public:
     // User functions
-    void ClickDefault(Focusable *next) { dw_window_click_default(hwnd, next); }
+    void ClickDefault(Focusable *next) { if(next) dw_window_click_default(hwnd, next->GetHWND()); }
 };
 
 class Entryfield : public TextEntry