From d7d6ae1479e7c1f6d7743b0a18c96245ae5b49b1 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Fri, 17 Apr 2026 22:25:28 +0900 Subject: [PATCH] seems to work --- Makefile | 2 +- bindgen.cxx | 290 +++++++++++++++++++++++------ include/MwCXX/Core.h | 2 +- include/MwCXX/Widget/Base.h | 2 + include/MwCXX/Widget/BaseAuto.h | 12 ++ include/MwCXX/Widget/Box.h | 3 + include/MwCXX/Widget/Button.h | 6 + include/MwCXX/Widget/CheckBox.h | 5 + include/MwCXX/Widget/ComboBox.h | 5 + include/MwCXX/Widget/Entry.h | 6 + include/MwCXX/Widget/Frame.h | 3 + include/MwCXX/Widget/Image.h | 3 + include/MwCXX/Widget/Label.h | 3 + include/MwCXX/Widget/ListBox.h | 5 + include/MwCXX/Widget/Menu.h | 5 + include/MwCXX/Widget/NumberEntry.h | 6 + include/MwCXX/Widget/OpenGL.h | 3 + include/MwCXX/Widget/ProgressBar.h | 3 + include/MwCXX/Widget/RadioBox.h | 5 + include/MwCXX/Widget/ScrollBar.h | 5 + include/MwCXX/Widget/SubMenu.h | 3 + include/MwCXX/Widget/TreeView.h | 5 + include/MwCXX/Widget/Viewport.h | 3 + include/MwCXX/Widget/Vulkan.h | 3 + include/MwCXX/Widget/Window.h | 3 + src/widget/base.cxx | 2 + src/widget/baseauto.cxx | 59 +++++- src/widget/box.cxx | 5 + src/widget/button.cxx | 15 ++ src/widget/checkbox.cxx | 10 + src/widget/combobox.cxx | 10 + src/widget/entry.cxx | 15 ++ src/widget/frame.cxx | 5 + src/widget/image.cxx | 5 + src/widget/label.cxx | 5 + src/widget/listbox.cxx | 10 + src/widget/menu.cxx | 10 + src/widget/numberentry.cxx | 15 ++ src/widget/opengl.cxx | 5 + src/widget/progressbar.cxx | 5 + src/widget/radiobox.cxx | 10 + src/widget/scrollbar.cxx | 10 + src/widget/submenu.cxx | 5 + src/widget/treeview.cxx | 10 + src/widget/viewport.cxx | 5 + src/widget/vulkan.cxx | 5 + src/widget/window.cxx | 5 + 47 files changed, 556 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index 882e2cd..b0bc06b 100644 --- a/Makefile +++ b/Makefile @@ -31,4 +31,4 @@ libMwCXX$(SO): $(OBJS) $(CXX) -fPIC -c -Iinclude -I$(MILSKO)/include -I$(XEMIL)/include -o $@ $< clean: - rm -f *.so *.dll *.o */*.o */*/*.o *.exe bindgen.exe + rm -f *.so *.dll *.o */*.o */*/*.o *.exe bindgen.exe bindgen diff --git a/bindgen.cxx b/bindgen.cxx index c550d49..242f421 100644 --- a/bindgen.cxx +++ b/bindgen.cxx @@ -16,16 +16,22 @@ struct typeinfo { struct property { typeinfo type; int common; +}; + +struct handler { + int common; + int has_arg; typeinfo arg_type; }; std::map files; std::map props; +std::map handlers; std::locale locale; -static std::string get_ctype(typeinfo type, int name = 1) { +static std::string get_ctype(typeinfo type, int name = 1, int do_ptr = 1) { std::string ret = ""; if(type.type == "integer") { @@ -40,7 +46,7 @@ static std::string get_ctype(typeinfo type, int name = 1) { ret += type.struct_name; } - if(type.pointer) ret += "*"; + if(do_ptr && type.pointer) ret += "*"; if(name && type.name != "") { ret += " " + type.name; @@ -93,26 +99,19 @@ static typeinfo xml_to_type(xl_node_t* node) { return ret; } -static std::string first_upper(std::string str) { +static std::string upperfirst(std::string str) { return uppercase(str.substr(0, 1)) + str.substr(1); } static void scan_property(xl_node_t* node) { - property prop; - char* s; - xl_node_t* child = node->first_child; + property prop; + char* s; if(node->type != XL_NODE_NODE) return; prop.type = xml_to_type(node); prop.common = ATTR_TO_BOOL(node, "common"); - while(child != NULL) { - if(child->type == XL_NODE_NODE) prop.arg_type = xml_to_type(child); - - child = child->next; - } - props[xl_get_attribute(node, "name")] = prop; } @@ -126,38 +125,43 @@ static void scan_properties(xl_node_t* node) { } } +static void scan_handler(xl_node_t* node) { + handler handl; + char* s; + xl_node_t* child = node->first_child; + + if(node->type != XL_NODE_NODE) return; + + handl.common = ATTR_TO_BOOL(node, "common"); + handl.has_arg = 0; + + while(child != NULL) { + if(child->type == XL_NODE_NODE) { + handl.has_arg = 1; + handl.arg_type = xml_to_type(child); + } + + child = child->next; + } + + handlers[xl_get_attribute(node, "name")] = handl; +} + +static void scan_handlers(xl_node_t* node) { + xl_node_t* child = node->first_child; + + while(child != NULL) { + scan_handler(child); + + child = child->next; + } +} + static std::string widget_property_header(std::string name, std::string indent = "") { std::stringstream strm; - strm << indent + get_ctype(props[name].type, 0) + " Get" + first_upper(name) + "();" << std::endl; - strm << indent + "void Set" + first_upper(name) + "(" + get_ctype(props[name].type, 0) + " value);" << std::endl; - - return strm.str(); -} - -static std::string widget_property_source(std::string widget, std::string name) { - std::stringstream strm; - - strm << get_ctype(props[name].type, 0) + " MwCXX::" + widget + "::Get" + first_upper(name) + "() {" << std::endl; - strm << " return (" + get_ctype(props[name].type, 0) + ")MwGet" + get_type(props[name].type) + "(this->widget, MwN" + name + ");" << std::endl; - strm << "}" << std::endl; - strm << std::endl; - strm << "void MwCXX::" + widget + "::Set" + first_upper(name) + "(" + get_ctype(props[name].type, 0) + " value) {" << std::endl; - - if(props[name].type.type == "string") { - strm << "#ifndef MWCXX_USE_C_STRING" << std::endl; - strm << " MwSetText(this->widget, MwN" + name + ", value.c_str());" << std::endl; - strm << "#else" << std::endl; - } - - strm << " MwSet" + get_type(props[name].type) + "(this->widget, MwN" + name + ", (" + get_ctype(props[name].type, 0) + ")value);" << std::endl; - - if(props[name].type.type == "string") { - strm << "#endif" << std::endl; - } - - strm << "}" << std::endl; - strm << std::endl; + strm << indent + get_ctype(props[name].type, 0) + " Get" + upperfirst(name) + "();" << std::endl; + strm << indent + "void Set" + upperfirst(name) + "(" + get_ctype(props[name].type, 0) + " value);" << std::endl; return strm.str(); } @@ -183,20 +187,119 @@ static std::string scan_widget_properties_header(xl_node_t* node, std::string in return r; } -static std::string scan_widget_property_source(xl_node_t* node, std::string name) { +static std::string widget_property_source(std::string widget, std::string name) { + std::stringstream strm; + + strm << get_ctype(props[name].type, 0) + " MwCXX::" + widget + "::Get" + upperfirst(name) + "() {" << std::endl; + strm << " return (" + get_ctype(props[name].type, 0) + ")MwGet" + get_type(props[name].type) + "(this->widget, MwN" + name + ");" << std::endl; + strm << "}" << std::endl; + strm << std::endl; + strm << "void MwCXX::" + widget + "::Set" + upperfirst(name) + "(" + get_ctype(props[name].type, 0) + " value) {" << std::endl; + + if(props[name].type.type == "string") { + strm << "#ifndef MWCXX_USE_C_STRING" << std::endl; + strm << " MwSetText(this->widget, MwN" + name + ", value.c_str());" << std::endl; + strm << "#else" << std::endl; + } + + strm << " MwSet" + get_type(props[name].type) + "(this->widget, MwN" + name + ", (" + get_ctype(props[name].type, 0) + ")value);" << std::endl; + + if(props[name].type.type == "string") { + strm << "#endif" << std::endl; + } + + strm << "}" << std::endl; + strm << std::endl; + + return strm.str(); +} + +static std::string scan_widget_property_source(xl_node_t* node, std::string widget) { xl_node_t* child = node->first_child; if(node->type != XL_NODE_NODE) return ""; - return widget_property_source(name, xl_get_attribute(node, "name")); + return widget_property_source(widget, xl_get_attribute(node, "name")); } -static std::string scan_widget_properties_source(xl_node_t* node, std::string name) { +static std::string scan_widget_properties_source(xl_node_t* node, std::string widget) { std::string r = ""; xl_node_t* child = node->first_child; while(child != NULL) { - r += scan_widget_property_source(child, name); + r += scan_widget_property_source(child, widget); + + child = child->next; + } + + return r; +} + +static std::string widget_handler_header(std::string name, std::string indent = "") { + std::stringstream strm; + + strm << indent + "virtual void On" + upperfirst(name) + "(" + (handlers[name].has_arg ? (get_ctype(handlers[name].arg_type, 0, 0) + " value") : "") + ") {};" << std::endl; + + return strm.str(); +} + +static std::string scan_widget_handler_header(xl_node_t* node, std::string indent) { + xl_node_t* child = node->first_child; + + if(node->type != XL_NODE_NODE) return ""; + + return widget_handler_header(xl_get_attribute(node, "name"), indent); +} + +static std::string scan_widget_handlers_header(xl_node_t* node, std::string indent) { + std::string r = ""; + xl_node_t* child = node->first_child; + + while(child != NULL) { + r += scan_widget_handler_header(child, indent); + + child = child->next; + } + + return r; +} + +static std::string widget_handler_source(std::string widget, std::string name) { + std::stringstream strm; + std::string cast = ""; + + if(handlers[name].has_arg) { + cast = "(" + get_ctype(handlers[name].arg_type, 0) + ")"; + + if(handlers[name].arg_type.pointer) cast = "*" + cast; + + if(handlers[name].arg_type.type == "string") cast += "(char*)"; + + cast += "call"; + } + + strm << "static void __On" + upperfirst(name) + "(MwWidget handle, void* user, void* call) {" << std::endl; + strm << " ((MwCXX::" + widget + "*)user)->On" + upperfirst(name) + "(" + cast + ");" << std::endl; + strm << "}" << std::endl; + strm << std::endl; + + return strm.str(); +} + +static std::string scan_widget_handler_source(xl_node_t* node, std::string widget) { + xl_node_t* child = node->first_child; + + if(node->type != XL_NODE_NODE) return ""; + + return widget_handler_source(widget, xl_get_attribute(node, "name")); +} + +static std::string scan_widget_handlers_source(xl_node_t* node, std::string widget) { + std::string r = ""; + xl_node_t* child = node->first_child; + + while(child != NULL) { + r += scan_widget_handler_source(child, widget); child = child->next; } @@ -206,12 +309,15 @@ static std::string scan_widget_properties_source(xl_node_t* node, std::string na static void scan_widget(xl_node_t* node) { std::string name; - xl_node_t** nodes; + xl_node_t** p_nodes; + xl_node_t** h_nodes; + xl_node_t* child; int i; if(node->type != XL_NODE_NODE) return; - nodes = xl_get_path(node, "properties"); + p_nodes = xl_get_path(node, "properties"); + h_nodes = xl_get_path(node, "handlers"); name = xl_get_attribute(node, "name"); @@ -230,15 +336,29 @@ static void scan_widget(xl_node_t* node) { OFS << "namespace MwCXX {" << std::endl; OFS << " class " + name + " : public MwCXX::Base {" << std::endl; + OFS << " protected:" << std::endl; + OFS << " virtual void RegisterHandlers();" << std::endl; + OFS << std::endl; OFS << " public:" << std::endl; OFS << " " + name + "(MwWidget widget);" << std::endl; OFS << " " + name + "(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height);" << std::endl; - if(nodes != NULL) { + if(p_nodes != NULL) { std::string r = ""; - for(i = 0; nodes[i] != NULL; i++) { - r += scan_widget_properties_header(nodes[i], "\t\t"); + for(i = 0; p_nodes[i] != NULL; i++) { + r += scan_widget_properties_header(p_nodes[i], "\t\t"); + } + + if(r != "") OFS << std::endl + << r; + } + + if(h_nodes != NULL) { + std::string r = ""; + + for(i = 0; h_nodes[i] != NULL; i++) { + r += scan_widget_handlers_header(h_nodes[i], "\t\t"); } if(r != "") OFS << std::endl @@ -263,22 +383,47 @@ static void scan_widget(xl_node_t* node) { OFS << std::endl; OFS << "MwCXX::" + name + "::" + name + "(MwWidget widget) : MwCXX::Base(widget) {" << std::endl; + OFS << " this->RegisterHandlers();" << std::endl; OFS << "}" << std::endl; OFS << std::endl; OFS << "MwCXX::" + name + "::" + name + "(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(Mw" + name + "Class, name, parent, x, y, width, height) {" << std::endl; + OFS << " this->RegisterHandlers();" << std::endl; OFS << "}" << std::endl; OFS << std::endl; - if(nodes != NULL) { - for(i = 0; nodes[i] != NULL; i++) { - OFS << scan_widget_properties_source(nodes[i], name); + if(p_nodes != NULL) { + for(i = 0; p_nodes[i] != NULL; i++) { + OFS << scan_widget_properties_source(p_nodes[i], name); } } + if(h_nodes != NULL) { + for(i = 0; h_nodes[i] != NULL; i++) { + OFS << scan_widget_handlers_source(h_nodes[i], name); + } + } + + OFS << "void MwCXX::" + name + "::RegisterHandlers() {" << std::endl; + if(h_nodes != NULL) { + for(i = 0; h_nodes[i] != NULL; i++) { + for(child = h_nodes[i]->first_child; child != NULL; child = child->next) { + std::string hname; + + if(child->type != XL_NODE_NODE) continue; + + hname = xl_get_attribute(child, "name"); + + OFS << " MwAddUserHandler(this->widget, MwN" + hname + "Handler, __On" + upperfirst(hname) + ", (void*)this);" << std::endl; + } + } + } + OFS << "}" << std::endl; + #undef OFS - if(nodes != NULL) free(nodes); + if(p_nodes != NULL) free(p_nodes); + if(h_nodes != NULL) free(h_nodes); files["objs"] << " src/widget/" + lowercase(name) + ".o"; } @@ -294,16 +439,26 @@ static void scan_widgets(xl_node_t* node) { } static void base_widget() { - std::string r = ""; + int f; #define OFS files["WBaseAuto.h"] OFS = std::ofstream("include/MwCXX/Widget/BaseAuto.h"); + f = 0; for(auto p = props.begin(); p != props.end(); p++) { if(!p->second.common) continue; OFS << widget_property_header(p->first); + f = 1; + } + + if(f) OFS << std::endl; + + for(auto p = handlers.begin(); p != handlers.end(); p++) { + if(!p->second.common) continue; + + OFS << widget_handler_header(p->first); } #undef OFS @@ -317,11 +472,22 @@ static void base_widget() { for(auto p = props.begin(); p != props.end(); p++) { if(!p->second.common) continue; - r += widget_property_source("Base", p->first); + OFS << widget_property_source("Base", p->first); } - if(r != "") OFS << std::endl - << r; + for(auto h = handlers.begin(); h != handlers.end(); h++) { + if(!h->second.common) continue; + + OFS << widget_handler_source("Base", h->first); + } + + OFS << "void MwCXX::Base::RegisterHandlers() {" << std::endl; + for(auto h = handlers.begin(); h != handlers.end(); h++) { + if(!h->second.common) continue; + + OFS << " MwAddUserHandler(this->widget, MwN" + h->first + "Handler, __On" + upperfirst(h->first) + ", (void*)this);" << std::endl; + } + OFS << "}" << std::endl; #undef OFS @@ -359,6 +525,14 @@ int main(int argc, char** argv) { free(nodes); } + if((nodes = xl_get_path(h->root, "handlers")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + scan_handlers(nodes[i]); + } + + free(nodes); + } + base_widget(); if((nodes = xl_get_path(h->root, "widgets")) != NULL) { diff --git a/include/MwCXX/Core.h b/include/MwCXX/Core.h index 5d8dff0..fad03c7 100644 --- a/include/MwCXX/Core.h +++ b/include/MwCXX/Core.h @@ -4,7 +4,7 @@ #include #include -#define MWCXX_CONSTRUCTOR(name, parent_class) name(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : parent_class(name, parent, x, y, width, height) +#define MWCXX_CONSTRUCTOR(this_class, parent_class) this_class(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : parent_class(name, parent, x, y, width, height) namespace MwCXX { void Init(); diff --git a/include/MwCXX/Widget/Base.h b/include/MwCXX/Widget/Base.h index d4e6093..66cc568 100644 --- a/include/MwCXX/Widget/Base.h +++ b/include/MwCXX/Widget/Base.h @@ -6,6 +6,8 @@ namespace MwCXX { class Base { protected: + virtual void RegisterHandlers(); + MwWidget widget; public: diff --git a/include/MwCXX/Widget/BaseAuto.h b/include/MwCXX/Widget/BaseAuto.h index 4692a33..e3b5fa9 100644 --- a/include/MwCXX/Widget/BaseAuto.h +++ b/include/MwCXX/Widget/BaseAuto.h @@ -36,3 +36,15 @@ int GetX(); void SetX(int value); int GetY(); void SetY(int value); + +virtual void OnClipboard(MwCXX::String value) {}; +virtual void OnDarkTheme(int value) {}; +virtual void OnFocusIn() {}; +virtual void OnFocusOut() {}; +virtual void OnKey(int value) {}; +virtual void OnKeyRelease(int value) {}; +virtual void OnMouseDown(MwMouse value) {}; +virtual void OnMouseMove(MwPoint value) {}; +virtual void OnMouseUp(MwMouse value) {}; +virtual void OnResize() {}; +virtual void OnTick() {}; diff --git a/include/MwCXX/Widget/Box.h b/include/MwCXX/Widget/Box.h index 0c6ceae..7fbca55 100644 --- a/include/MwCXX/Widget/Box.h +++ b/include/MwCXX/Widget/Box.h @@ -8,6 +8,9 @@ namespace MwCXX { class Box : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Box(MwWidget widget); Box(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/Button.h b/include/MwCXX/Widget/Button.h index 3cc49fa..fcfe5ed 100644 --- a/include/MwCXX/Widget/Button.h +++ b/include/MwCXX/Widget/Button.h @@ -8,6 +8,9 @@ namespace MwCXX { class Button : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Button(MwWidget widget); Button(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -22,6 +25,9 @@ namespace MwCXX { void SetPadding(int value); int GetFillArea(); void SetFillArea(int value); + + virtual void OnActivate() {}; + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/CheckBox.h b/include/MwCXX/Widget/CheckBox.h index a7e9ecb..023ef8f 100644 --- a/include/MwCXX/Widget/CheckBox.h +++ b/include/MwCXX/Widget/CheckBox.h @@ -8,12 +8,17 @@ namespace MwCXX { class CheckBox : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: CheckBox(MwWidget widget); CheckBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); int GetChecked(); void SetChecked(int value); + + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ComboBox.h b/include/MwCXX/Widget/ComboBox.h index dd20b4e..a4ddbf8 100644 --- a/include/MwCXX/Widget/ComboBox.h +++ b/include/MwCXX/Widget/ComboBox.h @@ -8,6 +8,9 @@ namespace MwCXX { class ComboBox : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: ComboBox(MwWidget widget); ComboBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -16,6 +19,8 @@ namespace MwCXX { void SetAreaShown(int value); int GetValue(); void SetValue(int value); + + virtual void OnComboBoxChanged(int value) {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Entry.h b/include/MwCXX/Widget/Entry.h index 5092b97..9bfeede 100644 --- a/include/MwCXX/Widget/Entry.h +++ b/include/MwCXX/Widget/Entry.h @@ -8,6 +8,9 @@ namespace MwCXX { class Entry : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Entry(MwWidget widget); Entry(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -16,6 +19,9 @@ namespace MwCXX { void SetText(MwCXX::String value); int GetHideInput(); void SetHideInput(int value); + + virtual void OnActivate() {}; + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Frame.h b/include/MwCXX/Widget/Frame.h index 905a199..f97cb54 100644 --- a/include/MwCXX/Widget/Frame.h +++ b/include/MwCXX/Widget/Frame.h @@ -8,6 +8,9 @@ namespace MwCXX { class Frame : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Frame(MwWidget widget); Frame(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/Image.h b/include/MwCXX/Widget/Image.h index 011a57b..58cde81 100644 --- a/include/MwCXX/Widget/Image.h +++ b/include/MwCXX/Widget/Image.h @@ -8,6 +8,9 @@ namespace MwCXX { class Image : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Image(MwWidget widget); Image(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/Label.h b/include/MwCXX/Widget/Label.h index 9a817d9..1d2f6da 100644 --- a/include/MwCXX/Widget/Label.h +++ b/include/MwCXX/Widget/Label.h @@ -8,6 +8,9 @@ namespace MwCXX { class Label : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Label(MwWidget widget); Label(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/ListBox.h b/include/MwCXX/Widget/ListBox.h index de3518d..6083583 100644 --- a/include/MwCXX/Widget/ListBox.h +++ b/include/MwCXX/Widget/ListBox.h @@ -8,6 +8,9 @@ namespace MwCXX { class ListBox : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: ListBox(MwWidget widget); ListBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -18,6 +21,8 @@ namespace MwCXX { void SetHasHeading(int value); int GetSingleClickSelectable(); void SetSingleClickSelectable(int value); + + virtual void OnListBoxActivate(int value) {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Menu.h b/include/MwCXX/Widget/Menu.h index 95aef00..132bbb3 100644 --- a/include/MwCXX/Widget/Menu.h +++ b/include/MwCXX/Widget/Menu.h @@ -8,9 +8,14 @@ namespace MwCXX { class Menu : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Menu(MwWidget widget); Menu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + virtual void OnMenu(void* value) {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/NumberEntry.h b/include/MwCXX/Widget/NumberEntry.h index d86c6ad..1dabc77 100644 --- a/include/MwCXX/Widget/NumberEntry.h +++ b/include/MwCXX/Widget/NumberEntry.h @@ -8,12 +8,18 @@ namespace MwCXX { class NumberEntry : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: NumberEntry(MwWidget widget); NumberEntry(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); MwCXX::String GetText(); void SetText(MwCXX::String value); + + virtual void OnActivate() {}; + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/OpenGL.h b/include/MwCXX/Widget/OpenGL.h index ec3df23..ebd2cf8 100644 --- a/include/MwCXX/Widget/OpenGL.h +++ b/include/MwCXX/Widget/OpenGL.h @@ -8,6 +8,9 @@ namespace MwCXX { class OpenGL : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: OpenGL(MwWidget widget); OpenGL(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/ProgressBar.h b/include/MwCXX/Widget/ProgressBar.h index 030d178..ed21f9c 100644 --- a/include/MwCXX/Widget/ProgressBar.h +++ b/include/MwCXX/Widget/ProgressBar.h @@ -8,6 +8,9 @@ namespace MwCXX { class ProgressBar : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: ProgressBar(MwWidget widget); ProgressBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/RadioBox.h b/include/MwCXX/Widget/RadioBox.h index 8a0cc27..2d26731 100644 --- a/include/MwCXX/Widget/RadioBox.h +++ b/include/MwCXX/Widget/RadioBox.h @@ -8,12 +8,17 @@ namespace MwCXX { class RadioBox : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: RadioBox(MwWidget widget); RadioBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); int GetChecked(); void SetChecked(int value); + + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ScrollBar.h b/include/MwCXX/Widget/ScrollBar.h index e4973c2..f315150 100644 --- a/include/MwCXX/Widget/ScrollBar.h +++ b/include/MwCXX/Widget/ScrollBar.h @@ -8,6 +8,9 @@ namespace MwCXX { class ScrollBar : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: ScrollBar(MwWidget widget); ScrollBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -24,6 +27,8 @@ namespace MwCXX { void SetMaxValue(int value); int GetOrientation(); void SetOrientation(int value); + + virtual void OnChanged() {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/SubMenu.h b/include/MwCXX/Widget/SubMenu.h index 9d45b4d..37104ad 100644 --- a/include/MwCXX/Widget/SubMenu.h +++ b/include/MwCXX/Widget/SubMenu.h @@ -8,6 +8,9 @@ namespace MwCXX { class SubMenu : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: SubMenu(MwWidget widget); SubMenu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/TreeView.h b/include/MwCXX/Widget/TreeView.h index b77048e..0b6e401 100644 --- a/include/MwCXX/Widget/TreeView.h +++ b/include/MwCXX/Widget/TreeView.h @@ -8,6 +8,9 @@ namespace MwCXX { class TreeView : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: TreeView(MwWidget widget); TreeView(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); @@ -16,6 +19,8 @@ namespace MwCXX { void SetLeftPadding(int value); int GetSingleClickSelectable(); void SetSingleClickSelectable(int value); + + virtual void OnTreeViewActivate(void* value) {}; }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Viewport.h b/include/MwCXX/Widget/Viewport.h index b8b9898..de5e7e3 100644 --- a/include/MwCXX/Widget/Viewport.h +++ b/include/MwCXX/Widget/Viewport.h @@ -8,6 +8,9 @@ namespace MwCXX { class Viewport : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Viewport(MwWidget widget); Viewport(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/Vulkan.h b/include/MwCXX/Widget/Vulkan.h index cc4ee4e..3280def 100644 --- a/include/MwCXX/Widget/Vulkan.h +++ b/include/MwCXX/Widget/Vulkan.h @@ -8,6 +8,9 @@ namespace MwCXX { class Vulkan : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Vulkan(MwWidget widget); Vulkan(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/include/MwCXX/Widget/Window.h b/include/MwCXX/Widget/Window.h index a87d830..cff5e45 100644 --- a/include/MwCXX/Widget/Window.h +++ b/include/MwCXX/Widget/Window.h @@ -8,6 +8,9 @@ namespace MwCXX { class Window : public MwCXX::Base { + protected: + virtual void RegisterHandlers(); + public: Window(MwWidget widget); Window(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); diff --git a/src/widget/base.cxx b/src/widget/base.cxx index f82c8a7..0bc9d3c 100644 --- a/src/widget/base.cxx +++ b/src/widget/base.cxx @@ -2,6 +2,8 @@ MwCXX::Base::Base(MwWidget widget) { this->widget = widget; + + this->RegisterHandlers(); } MwCXX::Base::Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) { diff --git a/src/widget/baseauto.cxx b/src/widget/baseauto.cxx index f941e43..80ea781 100644 --- a/src/widget/baseauto.cxx +++ b/src/widget/baseauto.cxx @@ -1,5 +1,4 @@ #include - MwCXX::String MwCXX::Base::GetBackground() { return (MwCXX::String)MwGetText(this->widget, MwNbackground); } @@ -167,3 +166,61 @@ int MwCXX::Base::GetY() { void MwCXX::Base::SetY(int value) { MwSetInteger(this->widget, MwNy, (int)value); } + +static void __OnClipboard(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnClipboard((MwCXX::String)(char*)call); +} + +static void __OnDarkTheme(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnDarkTheme(*(int*)call); +} + +static void __OnFocusIn(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnFocusIn(); +} + +static void __OnFocusOut(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnFocusOut(); +} + +static void __OnKey(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnKey(*(int*)call); +} + +static void __OnKeyRelease(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnKeyRelease(*(int*)call); +} + +static void __OnMouseDown(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnMouseDown(*(MwMouse*)call); +} + +static void __OnMouseMove(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnMouseMove(*(MwPoint*)call); +} + +static void __OnMouseUp(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnMouseUp(*(MwMouse*)call); +} + +static void __OnResize(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnResize(); +} + +static void __OnTick(MwWidget handle, void* user, void* call) { + ((MwCXX::Base*)user)->OnTick(); +} + +void MwCXX::Base::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNclipboardHandler, __OnClipboard, (void*)this); + MwAddUserHandler(this->widget, MwNdarkThemeHandler, __OnDarkTheme, (void*)this); + MwAddUserHandler(this->widget, MwNfocusInHandler, __OnFocusIn, (void*)this); + MwAddUserHandler(this->widget, MwNfocusOutHandler, __OnFocusOut, (void*)this); + MwAddUserHandler(this->widget, MwNkeyHandler, __OnKey, (void*)this); + MwAddUserHandler(this->widget, MwNkeyReleaseHandler, __OnKeyRelease, (void*)this); + MwAddUserHandler(this->widget, MwNmouseDownHandler, __OnMouseDown, (void*)this); + MwAddUserHandler(this->widget, MwNmouseMoveHandler, __OnMouseMove, (void*)this); + MwAddUserHandler(this->widget, MwNmouseUpHandler, __OnMouseUp, (void*)this); + MwAddUserHandler(this->widget, MwNresizeHandler, __OnResize, (void*)this); + MwAddUserHandler(this->widget, MwNtickHandler, __OnTick, (void*)this); +} diff --git a/src/widget/box.cxx b/src/widget/box.cxx index 5255e71..583f90f 100644 --- a/src/widget/box.cxx +++ b/src/widget/box.cxx @@ -2,10 +2,12 @@ MwCXX::Box::Box(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Box::Box(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwBoxClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::Box::GetOrientation() { @@ -47,3 +49,6 @@ int MwCXX::Box::GetInverted() { void MwCXX::Box::SetInverted(int value) { MwSetInteger(this->widget, MwNinverted, (int)value); } + +void MwCXX::Box::RegisterHandlers() { +} diff --git a/src/widget/button.cxx b/src/widget/button.cxx index 31ab03a..ddf6135 100644 --- a/src/widget/button.cxx +++ b/src/widget/button.cxx @@ -2,10 +2,12 @@ MwCXX::Button::Button(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Button::Button(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwButtonClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwLLPixmap MwCXX::Button::GetPixmap() { @@ -51,3 +53,16 @@ int MwCXX::Button::GetFillArea() { void MwCXX::Button::SetFillArea(int value) { MwSetInteger(this->widget, MwNfillArea, (int)value); } + +static void __OnActivate(MwWidget handle, void* user, void* call) { + ((MwCXX::Button*)user)->OnActivate(); +} + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::Button*)user)->OnChanged(); +} + +void MwCXX::Button::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/checkbox.cxx b/src/widget/checkbox.cxx index 8c7e4bb..9adf16b 100644 --- a/src/widget/checkbox.cxx +++ b/src/widget/checkbox.cxx @@ -2,10 +2,12 @@ MwCXX::CheckBox::CheckBox(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::CheckBox::CheckBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwCheckBoxClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::CheckBox::GetChecked() { @@ -15,3 +17,11 @@ int MwCXX::CheckBox::GetChecked() { void MwCXX::CheckBox::SetChecked(int value) { MwSetInteger(this->widget, MwNchecked, (int)value); } + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::CheckBox*)user)->OnChanged(); +} + +void MwCXX::CheckBox::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/combobox.cxx b/src/widget/combobox.cxx index 17e31ea..4de6f04 100644 --- a/src/widget/combobox.cxx +++ b/src/widget/combobox.cxx @@ -2,10 +2,12 @@ MwCXX::ComboBox::ComboBox(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::ComboBox::ComboBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwComboBoxClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::ComboBox::GetAreaShown() { @@ -23,3 +25,11 @@ int MwCXX::ComboBox::GetValue() { void MwCXX::ComboBox::SetValue(int value) { MwSetInteger(this->widget, MwNvalue, (int)value); } + +static void __OnComboBoxChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::ComboBox*)user)->OnComboBoxChanged(*(int*)call); +} + +void MwCXX::ComboBox::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNcomboBoxChangedHandler, __OnComboBoxChanged, (void*)this); +} diff --git a/src/widget/entry.cxx b/src/widget/entry.cxx index 2809291..1ac8000 100644 --- a/src/widget/entry.cxx +++ b/src/widget/entry.cxx @@ -2,10 +2,12 @@ MwCXX::Entry::Entry(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Entry::Entry(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwEntryClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwCXX::String MwCXX::Entry::GetText() { @@ -27,3 +29,16 @@ int MwCXX::Entry::GetHideInput() { void MwCXX::Entry::SetHideInput(int value) { MwSetInteger(this->widget, MwNhideInput, (int)value); } + +static void __OnActivate(MwWidget handle, void* user, void* call) { + ((MwCXX::Entry*)user)->OnActivate(); +} + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::Entry*)user)->OnChanged(); +} + +void MwCXX::Entry::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/frame.cxx b/src/widget/frame.cxx index 4acc16a..2fbac27 100644 --- a/src/widget/frame.cxx +++ b/src/widget/frame.cxx @@ -2,10 +2,12 @@ MwCXX::Frame::Frame(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Frame::Frame(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwFrameClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::Frame::GetHasBorder() { @@ -23,3 +25,6 @@ int MwCXX::Frame::GetInverted() { void MwCXX::Frame::SetInverted(int value) { MwSetInteger(this->widget, MwNinverted, (int)value); } + +void MwCXX::Frame::RegisterHandlers() { +} diff --git a/src/widget/image.cxx b/src/widget/image.cxx index 31a268c..930d1c7 100644 --- a/src/widget/image.cxx +++ b/src/widget/image.cxx @@ -2,10 +2,12 @@ MwCXX::Image::Image(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Image::Image(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwImageClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwLLPixmap MwCXX::Image::GetPixmap() { @@ -39,3 +41,6 @@ int MwCXX::Image::GetFillArea() { void MwCXX::Image::SetFillArea(int value) { MwSetInteger(this->widget, MwNfillArea, (int)value); } + +void MwCXX::Image::RegisterHandlers() { +} diff --git a/src/widget/label.cxx b/src/widget/label.cxx index eb31523..ab990b9 100644 --- a/src/widget/label.cxx +++ b/src/widget/label.cxx @@ -2,10 +2,12 @@ MwCXX::Label::Label(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Label::Label(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwLabelClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwCXX::String MwCXX::Label::GetText() { @@ -59,3 +61,6 @@ int MwCXX::Label::GetLeftPadding() { void MwCXX::Label::SetLeftPadding(int value) { MwSetInteger(this->widget, MwNleftPadding, (int)value); } + +void MwCXX::Label::RegisterHandlers() { +} diff --git a/src/widget/listbox.cxx b/src/widget/listbox.cxx index 22cfb24..9ffc224 100644 --- a/src/widget/listbox.cxx +++ b/src/widget/listbox.cxx @@ -2,10 +2,12 @@ MwCXX::ListBox::ListBox(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::ListBox::ListBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwListBoxClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::ListBox::GetLeftPadding() { @@ -31,3 +33,11 @@ int MwCXX::ListBox::GetSingleClickSelectable() { void MwCXX::ListBox::SetSingleClickSelectable(int value) { MwSetInteger(this->widget, MwNsingleClickSelectable, (int)value); } + +static void __OnListBoxActivate(MwWidget handle, void* user, void* call) { + ((MwCXX::ListBox*)user)->OnListBoxActivate(*(int*)call); +} + +void MwCXX::ListBox::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNlistBoxActivateHandler, __OnListBoxActivate, (void*)this); +} diff --git a/src/widget/menu.cxx b/src/widget/menu.cxx index ff467a1..5aeea5b 100644 --- a/src/widget/menu.cxx +++ b/src/widget/menu.cxx @@ -2,8 +2,18 @@ MwCXX::Menu::Menu(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Menu::Menu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwMenuClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); +} + +static void __OnMenu(MwWidget handle, void* user, void* call) { + ((MwCXX::Menu*)user)->OnMenu((void*)call); +} + +void MwCXX::Menu::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNmenuHandler, __OnMenu, (void*)this); } diff --git a/src/widget/numberentry.cxx b/src/widget/numberentry.cxx index 9dc844b..7e6220d 100644 --- a/src/widget/numberentry.cxx +++ b/src/widget/numberentry.cxx @@ -2,10 +2,12 @@ MwCXX::NumberEntry::NumberEntry(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::NumberEntry::NumberEntry(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwNumberEntryClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwCXX::String MwCXX::NumberEntry::GetText() { @@ -19,3 +21,16 @@ void MwCXX::NumberEntry::SetText(MwCXX::String value) { MwSetText(this->widget, MwNtext, (MwCXX::String)value); #endif } + +static void __OnActivate(MwWidget handle, void* user, void* call) { + ((MwCXX::NumberEntry*)user)->OnActivate(); +} + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::NumberEntry*)user)->OnChanged(); +} + +void MwCXX::NumberEntry::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/opengl.cxx b/src/widget/opengl.cxx index f756d71..d9e86b0 100644 --- a/src/widget/opengl.cxx +++ b/src/widget/opengl.cxx @@ -3,8 +3,13 @@ MwCXX::OpenGL::OpenGL(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::OpenGL::OpenGL(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwOpenGLClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); +} + +void MwCXX::OpenGL::RegisterHandlers() { } diff --git a/src/widget/progressbar.cxx b/src/widget/progressbar.cxx index f7596af..1727841 100644 --- a/src/widget/progressbar.cxx +++ b/src/widget/progressbar.cxx @@ -2,10 +2,12 @@ MwCXX::ProgressBar::ProgressBar(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::ProgressBar::ProgressBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwProgressBarClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::ProgressBar::GetMinValue() { @@ -31,3 +33,6 @@ int MwCXX::ProgressBar::GetValue() { void MwCXX::ProgressBar::SetValue(int value) { MwSetInteger(this->widget, MwNvalue, (int)value); } + +void MwCXX::ProgressBar::RegisterHandlers() { +} diff --git a/src/widget/radiobox.cxx b/src/widget/radiobox.cxx index f531bab..123bf61 100644 --- a/src/widget/radiobox.cxx +++ b/src/widget/radiobox.cxx @@ -2,10 +2,12 @@ MwCXX::RadioBox::RadioBox(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::RadioBox::RadioBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwRadioBoxClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::RadioBox::GetChecked() { @@ -15,3 +17,11 @@ int MwCXX::RadioBox::GetChecked() { void MwCXX::RadioBox::SetChecked(int value) { MwSetInteger(this->widget, MwNchecked, (int)value); } + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::RadioBox*)user)->OnChanged(); +} + +void MwCXX::RadioBox::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/scrollbar.cxx b/src/widget/scrollbar.cxx index a3d0da5..644ad65 100644 --- a/src/widget/scrollbar.cxx +++ b/src/widget/scrollbar.cxx @@ -2,10 +2,12 @@ MwCXX::ScrollBar::ScrollBar(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::ScrollBar::ScrollBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwScrollBarClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::ScrollBar::GetShowArrows() { @@ -55,3 +57,11 @@ int MwCXX::ScrollBar::GetOrientation() { void MwCXX::ScrollBar::SetOrientation(int value) { MwSetInteger(this->widget, MwNorientation, (int)value); } + +static void __OnChanged(MwWidget handle, void* user, void* call) { + ((MwCXX::ScrollBar*)user)->OnChanged(); +} + +void MwCXX::ScrollBar::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); +} diff --git a/src/widget/submenu.cxx b/src/widget/submenu.cxx index 401845e..0a6e665 100644 --- a/src/widget/submenu.cxx +++ b/src/widget/submenu.cxx @@ -2,10 +2,12 @@ MwCXX::SubMenu::SubMenu(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::SubMenu::SubMenu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwSubMenuClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::SubMenu::GetLeftPadding() { @@ -15,3 +17,6 @@ int MwCXX::SubMenu::GetLeftPadding() { void MwCXX::SubMenu::SetLeftPadding(int value) { MwSetInteger(this->widget, MwNleftPadding, (int)value); } + +void MwCXX::SubMenu::RegisterHandlers() { +} diff --git a/src/widget/treeview.cxx b/src/widget/treeview.cxx index bb9a442..d9200f0 100644 --- a/src/widget/treeview.cxx +++ b/src/widget/treeview.cxx @@ -2,10 +2,12 @@ MwCXX::TreeView::TreeView(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::TreeView::TreeView(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwTreeViewClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } int MwCXX::TreeView::GetLeftPadding() { @@ -23,3 +25,11 @@ int MwCXX::TreeView::GetSingleClickSelectable() { void MwCXX::TreeView::SetSingleClickSelectable(int value) { MwSetInteger(this->widget, MwNsingleClickSelectable, (int)value); } + +static void __OnTreeViewActivate(MwWidget handle, void* user, void* call) { + ((MwCXX::TreeView*)user)->OnTreeViewActivate((void*)call); +} + +void MwCXX::TreeView::RegisterHandlers() { + MwAddUserHandler(this->widget, MwNtreeViewActivateHandler, __OnTreeViewActivate, (void*)this); +} diff --git a/src/widget/viewport.cxx b/src/widget/viewport.cxx index 0d58569..2b36b61 100644 --- a/src/widget/viewport.cxx +++ b/src/widget/viewport.cxx @@ -2,8 +2,13 @@ MwCXX::Viewport::Viewport(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Viewport::Viewport(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwViewportClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); +} + +void MwCXX::Viewport::RegisterHandlers() { } diff --git a/src/widget/vulkan.cxx b/src/widget/vulkan.cxx index e91c40f..86c85fe 100644 --- a/src/widget/vulkan.cxx +++ b/src/widget/vulkan.cxx @@ -3,8 +3,13 @@ MwCXX::Vulkan::Vulkan(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Vulkan::Vulkan(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwVulkanClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); +} + +void MwCXX::Vulkan::RegisterHandlers() { } diff --git a/src/widget/window.cxx b/src/widget/window.cxx index 6789562..96d5e65 100644 --- a/src/widget/window.cxx +++ b/src/widget/window.cxx @@ -2,10 +2,12 @@ MwCXX::Window::Window(MwWidget widget) : MwCXX::Base(widget) { + this->RegisterHandlers(); } MwCXX::Window::Window(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height) : MwCXX::Base(MwWindowClass, name, parent, x, y, width, height) { + this->RegisterHandlers(); } MwCXX::String MwCXX::Window::GetTitle() { @@ -59,3 +61,6 @@ int MwCXX::Window::GetInverted() { void MwCXX::Window::SetInverted(int value) { MwSetInteger(this->widget, MwNinverted, (int)value); } + +void MwCXX::Window::RegisterHandlers() { +}