# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1671511513 0 # Node ID 6f31b7991fa023d4fde48203b83d66bac07d8efb # Parent e201a984d855fc9328ca223de059e932b8cac560 C++: Fix Combobox class by making the parent classes virtual. Also some minor source code cleanup, make sure visibility is explicit. diff -r e201a984d855 -r 6f31b7991fa0 dw.hpp --- a/dw.hpp Tue Dec 20 01:44:15 2022 +0000 +++ b/dw.hpp Tue Dec 20 04:45:13 2022 +0000 @@ -50,10 +50,12 @@ void SetStyle(unsigned long style, unsigned long mask) { dw_window_set_style(hwnd, style, mask); } void SetTooltip(char *bubbletext) { dw_window_set_tooltip(hwnd, bubbletext); } int SetColor(unsigned long fore, unsigned long back) { return dw_window_set_color(hwnd, fore, back); } + void SetData(const char *dataname, void *data) { dw_window_set_data(hwnd, dataname, data); } + void *GetData(const char *dataname) { return dw_window_get_data(hwnd, dataname); } }; // Box class is a packable object -class Boxes : public Widget +class Boxes : virtual public Widget { public: // User functions @@ -71,6 +73,7 @@ class Box : public Boxes { +public: // Constructors Box(int type, int pad) { SetHWND(dw_box_new(type, pad)); } Box(int type) { SetHWND(dw_box_new(type, 0)); } @@ -133,7 +136,7 @@ }; // Base class for several types of buttons -class Buttons : public Widget +class Buttons : virtual public Widget { private: static int _OnClicked(HWND window, void *data) { return reinterpret_cast(data)->OnClicked(); } @@ -179,7 +182,7 @@ BitmapButton(const char *text, const char *data, int len) { SetHWND(dw_bitmapbutton_new_from_data(text, 0, data, len)); Setup(); } }; -class CheckBoxes : public TextButton +class CheckBoxes : virtual public TextButton { public: // User functions @@ -189,6 +192,7 @@ class CheckBox : public CheckBoxes { +public: // Constructors CheckBox(const char *text, unsigned long id) { SetHWND(dw_checkbox_new(text, id)); Setup(); } CheckBox(unsigned long id) { SetHWND(dw_checkbox_new("", id)); Setup(); } @@ -198,6 +202,7 @@ class RadioButton : public CheckBoxes { +public: // Constructors RadioButton(const char *text, unsigned long id) { SetHWND(dw_radiobutton_new(text, id)); Setup(); } RadioButton(unsigned long id) { SetHWND(dw_radiobutton_new("", id)); Setup(); } @@ -303,7 +308,7 @@ class Pixmap : public Drawable, public Handle { -protected: +private: void SetHPIXMAP(HPIXMAP newpixmap) { hpixmap = newpixmap; SetHandle(reinterpret_cast(newpixmap)); @@ -336,7 +341,6 @@ } int SetFont(const char *fontname) { return dw_pixmap_set_font(hpixmap, fontname); } void GetTextExtents(const char *text, int *width, int *height) { dw_font_text_extents_get(DW_NOHWND, hpixmap, text, width, height); } - }; // Need to declare these here after Pixmap is defined @@ -380,7 +384,7 @@ }; // Base class for several widgets that allow text entry -class TextEntry : public Widget +class TextEntry : virtual public Widget { public: // User functions @@ -409,7 +413,7 @@ }; // Base class for several widgets that have a list of elements -class ListBoxes : public Widget +class ListBoxes : virtual public Widget { private: void Setup() { @@ -437,7 +441,6 @@ virtual int OnListSelect(int index) { dw_signal_disconnect_by_name(hwnd, DW_SIGNAL_LIST_SELECT); return FALSE; } }; -#if 0 class Combobox : public TextEntry, public ListBoxes { public: @@ -447,7 +450,6 @@ Combobox(const char *text) { SetHWND(dw_combobox_new(text, 0)); } Combobox() { SetHWND(dw_combobox_new("", 0)); } }; -#endif class Listbox : public ListBoxes {