From 90e572aad8f387113aa7ef1cf3edfd219ab0297e Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 18 Apr 2026 02:31:46 +0900 Subject: [PATCH] add dialog things --- bindgen.cc | 268 ++++++++++++++++++++---- include/MwCXX/Dialog/ColorChooser.h | 2 + include/MwCXX/Dialog/ColorPicker.h | 10 + include/MwCXX/Dialog/DirectoryChooser.h | 2 + include/MwCXX/Dialog/FileChooser.h | 2 + include/MwCXX/Dialog/MessageBox.h | 4 +- include/MwCXX/MachDep.h | 2 +- include/MwCXX/Widget/All.h | 23 ++ include/MwCXX/Widget/Base.h | 8 +- include/MwCXX/Widget/BaseAuto.h | 80 ++++--- include/MwCXX/Widget/Box.h | 10 +- include/MwCXX/Widget/Button.h | 21 +- include/MwCXX/Widget/CheckBox.h | 4 +- include/MwCXX/Widget/ComboBox.h | 6 +- include/MwCXX/Widget/Entry.h | 9 +- include/MwCXX/Widget/Frame.h | 4 +- include/MwCXX/Widget/Image.h | 14 +- include/MwCXX/Widget/Label.h | 22 +- include/MwCXX/Widget/ListBox.h | 8 +- include/MwCXX/Widget/Menu.h | 2 + include/MwCXX/Widget/NumberEntry.h | 5 +- include/MwCXX/Widget/ProgressBar.h | 6 +- include/MwCXX/Widget/RadioBox.h | 4 +- include/MwCXX/Widget/ScrollBar.h | 14 +- include/MwCXX/Widget/SubMenu.h | 2 +- include/MwCXX/Widget/TreeView.h | 6 +- include/MwCXX/Widget/Window.h | 22 +- objs.mk | 2 +- src/dialog/colorchooser.cc | 12 ++ src/dialog/colorpicker.cc | 12 ++ src/dialog/directorychooser.cc | 12 ++ src/dialog/filechooser.cc | 23 ++ src/dialog/messagebox.cc | 25 +++ src/widget/base.cc | 16 +- src/widget/baseauto.cc | 23 ++ src/widget/box.cc | 6 +- src/widget/button.cc | 11 +- src/widget/checkbox.cc | 9 +- src/widget/combobox.cc | 9 +- src/widget/entry.cc | 11 +- src/widget/frame.cc | 6 +- src/widget/image.cc | 6 +- src/widget/label.cc | 6 +- src/widget/listbox.cc | 9 +- src/widget/menu.cc | 9 +- src/widget/numberentry.cc | 11 +- src/widget/opengl.cc | 6 +- src/widget/progressbar.cc | 6 +- src/widget/radiobox.cc | 9 +- src/widget/scrollbar.cc | 9 +- src/widget/submenu.cc | 6 +- src/widget/treeview.cc | 9 +- src/widget/viewport.cc | 6 +- src/widget/vulkan.cc | 6 +- src/widget/window.cc | 6 +- test.cxx | 10 +- 56 files changed, 658 insertions(+), 193 deletions(-) create mode 100644 include/MwCXX/Dialog/ColorPicker.h create mode 100644 include/MwCXX/Widget/All.h create mode 100644 src/dialog/colorchooser.cc create mode 100644 src/dialog/colorpicker.cc create mode 100644 src/dialog/directorychooser.cc create mode 100644 src/dialog/filechooser.cc create mode 100644 src/dialog/messagebox.cc diff --git a/bindgen.cc b/bindgen.cc index cc0c2df..7b69b30 100644 --- a/bindgen.cc +++ b/bindgen.cc @@ -47,9 +47,9 @@ static std::string get_ctype(typeinfo type, int name = 1, int do_ptr = 1) { } else if(type.type == "struct") { ret += type.struct_name; } else if(type.type == "widget") { - if(type.widget_type == ""){ + if(type.widget_type == "") { ret += "MwCXX::Base*"; - }else{ + } else { ret += "MwCXX::" + type.widget_type + "*"; } } @@ -198,20 +198,35 @@ static std::string scan_widget_property_source(xl_node_t* node, std::string widg return widget_property_source(widget, xl_get_attribute(node, "name")); } -static std::string widget_handler_header(std::string name, std::string indent = "") { +static std::string widget_handler_header(std::string widget, std::string name, std::string indent = "", int func = 1) { std::stringstream strm; + std::string pre = ""; - strm << indent + "virtual void On" + upperfirst(name) + "(" + (handlers[name].has_arg ? (get_ctype(handlers[name].arg_type, 0, 0) + " value") : "") + ") {};" << std::endl; + strm << indent; + if(func) { + strm << "virtual void On" + upperfirst(name); + } else { + strm << "void (*" + upperfirst(name) + "Handler)"; + + pre += "MwCXX::" + widget + "* widget"; + if(handlers[name].has_arg) pre += ", "; + } + + strm << "(" + pre + (handlers[name].has_arg ? (get_ctype(handlers[name].arg_type, 0, 0) + " value") : "") + ")"; + + if(func) strm << " {}"; + + strm << ";" << std::endl; return strm.str(); } -static std::string scan_widget_handler_header(xl_node_t* node, std::string indent) { +static std::string scan_widget_handler_header(xl_node_t* node, std::string widget, std::string indent, int func = 1) { xl_node_t* child = node->first_child; if(node->type != XL_NODE_NODE) return ""; - return widget_handler_header(xl_get_attribute(node, "name"), indent); + return widget_handler_header(widget, xl_get_attribute(node, "name"), indent, func); } static std::string widget_handler_source(std::string widget, std::string name) { @@ -230,6 +245,7 @@ static std::string widget_handler_source(std::string widget, std::string name) { 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 << " if(((MwCXX::" + widget + "*)user)->" + upperfirst(name) + "Handler != NULL) ((MwCXX::" + widget + "*)user)->" + upperfirst(name) + "Handler((MwCXX::" + widget + "*)user" + (handlers[name].has_arg ? (", " + cast) : "") + ");" << std::endl; strm << "}" << std::endl; strm << std::endl; @@ -279,31 +295,42 @@ static void scan_widget(xl_node_t* node) { OFS << " " + name + "(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height);" << std::endl; if(p_nodes != NULL) { - std::string r = ""; + std::string r; + r = ""; for(int i = 0; p_nodes[i] != NULL; i++) { - for(xl_node_t* child = p_nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = p_nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; r += scan_widget_property_header(child, "\t\t"); } } - if(r != "") OFS << std::endl << r; } if(h_nodes != NULL) { - std::string r = ""; + std::string r; + r = ""; for(int i = 0; h_nodes[i] != NULL; i++) { - for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; - r += scan_widget_handler_header(child, "\t\t"); + r += scan_widget_handler_header(child, name, "\t\t"); } } + if(r != "") OFS << std::endl + << r; + r = ""; + for(int i = 0; h_nodes[i] != NULL; i++) { + for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next) { + if(child->type != XL_NODE_NODE) continue; + + r += scan_widget_handler_header(child, name, "\t\t", 0); + } + } if(r != "") OFS << std::endl << r; } @@ -337,7 +364,7 @@ static void scan_widget(xl_node_t* node) { if(p_nodes != NULL) { for(int i = 0; p_nodes[i] != NULL; i++) { - for(xl_node_t* child = p_nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = p_nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; OFS << scan_widget_property_source(child, name); @@ -347,7 +374,7 @@ static void scan_widget(xl_node_t* node) { if(h_nodes != NULL) { for(int i = 0; h_nodes[i] != NULL; i++) { - for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; OFS << scan_widget_handler_source(child, name); @@ -357,6 +384,9 @@ static void scan_widget(xl_node_t* node) { OFS << "void MwCXX::" + name + "::RegisterHandlers() {" << std::endl; if(h_nodes != NULL) { + int f; + + f = 0; for(int i = 0; h_nodes[i] != NULL; i++) { for(xl_node_t* child = h_nodes[i]->first_child; child != NULL; child = child->next) { std::string hname; @@ -366,6 +396,21 @@ static void scan_widget(xl_node_t* node) { hname = xl_get_attribute(child, "name"); OFS << " MwAddUserHandler(this->widget, MwN" + hname + "Handler, __On" + upperfirst(hname) + ", (void*)this);" << std::endl; + f = 1; + } + } + + if(f) OFS << std::endl; + + for(int i = 0; h_nodes[i] != NULL; i++) { + for(xl_node_t* 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 << " this->" + upperfirst(hname) + "Handler = NULL;" << std::endl; } } } @@ -379,49 +424,139 @@ static void scan_widget(xl_node_t* node) { files["objs"] << " src/widget/" + lowercase(name) + ".o"; } -static std::string function_decl(xl_node_t* node, std::string prefix = ""){ - xl_node_t* ret = NULL; +static std::string function_decl(xl_node_t* node, std::string prefix = "") { + xl_node_t* ret = NULL; xl_node_t** nodes; std::string r = ""; - if((nodes = xl_get_path(node, "return")) != NULL){ - for(int i = 0; nodes[i] != NULL; i++){ - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + if((nodes = xl_get_path(node, "return")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type == XL_NODE_NODE) ret = child; } } + + free(nodes); } - if(ret == NULL){ + if(ret == NULL) { r += "void "; - }else{ + } else { r += get_ctype(xml_to_type(ret), 0, 0) + " "; } r += prefix + std::string(xl_get_attribute(node, "name")).substr(2); r += "("; - if((nodes = xl_get_path(node, "arguments")) != NULL){ - for(int i = 0; nodes[i] != NULL; i++){ - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + if((nodes = xl_get_path(node, "arguments")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; if(r.substr(r.size() - 1, 1) != "(") r += ", "; - r += get_ctype(xml_to_type(child), 1, 1); + r += get_ctype(xml_to_type(child), 1, 0); } } + + free(nodes); } r += ")"; return r; } -static std::string function_source(xl_node_t* node){ - return ""; +static std::string function_source(xl_node_t* node) { + std::stringstream strm; + xl_node_t** nodes; + xl_node_t* ret = NULL; + xl_node_t* widget = NULL; + typeinfo type; + int first = 1; + + if((nodes = xl_get_path(node, "return")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { + if(child->type == XL_NODE_NODE) ret = child; + } + } + + free(nodes); + } + + strm << function_decl(node, "MwCXX::") << " {" << std::endl; + + strm << " "; + if(ret != NULL) { + type = xml_to_type(ret); + + if(type.type == "widget") { + std::string str = get_ctype(type, 0); + + strm << "return new " + str.substr(0, str.size() - 1) + "("; + } else if(type.type == "string") { + strm << "const char* _ret = "; + } else { + strm << "return (" + get_ctype(type, 0) + ")"; + } + } + strm << std::string(xl_get_attribute(node, "name")) + "("; + first = 1; + if((nodes = xl_get_path(node, "arguments")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { + typeinfo type2; + + if(child->type != XL_NODE_NODE) continue; + + if(std::string(child->name) == "widget" && widget == NULL) widget = child; + + type2 = xml_to_type(child); + + if(first) { + first = 0; + } else { + strm << ", "; + } + + if(type2.type == "widget") { + strm << type2.name + "->GetWidget()"; + } else { + if(type2.type == "string") { + strm << std::endl; + strm << "#ifdef MWCXX_USE_C_STRING" << std::endl; + strm << type2.name << std::endl; + strm << "#else" << std::endl; + strm << type2.name + ".c_str()" << std::endl; + strm << "#endif" << std::endl; + strm << " "; + } else { + strm << "(" + get_ctype(type2, 0) + ")" + type2.name; + } + } + } + } + + free(nodes); + } + if(ret != NULL && type.type == "widget") { + strm << ")"; + if(widget != NULL) strm << ", " + std::string(xl_get_attribute(widget, "name")); + } + strm << ");" << std::endl; + if(ret != NULL && type.type == "string") { + strm << "#ifdef MWCXX_USE_C_STRING" << std::endl; + strm << " return _ret;" << std::endl; + strm << "#else" << std::endl; + strm << " return MwCXX::String(_ret);" << std::endl; + strm << "#endif" << std::endl; + } + strm << "}" << std::endl; + + return strm.str(); } -static std::string function_header(xl_node_t* node){ +static std::string function_header(xl_node_t* node) { return function_decl(node) + ";"; } @@ -432,7 +567,7 @@ static void scan_header(xl_node_t* node) { name = xl_get_attribute(node, "name"); - if(name.size() >= 7 && name.substr(0, 7) == "Dialog/"){ + if(name.size() >= 7 && name.substr(0, 7) == "Dialog/") { xl_node_t** nodes; #define OFS files["D" + name.substr(7) + ".h"] @@ -443,10 +578,13 @@ static void scan_header(xl_node_t* node) { OFS << "#define __MWCXX_DIALOG_" + uppercase(name.substr(7)) + "_H__" << std::endl; OFS << std::endl; + OFS << "#include " << std::endl; + OFS << std::endl; + OFS << "namespace MwCXX {" << std::endl; - if((nodes = xl_get_path(node, "functions")) != NULL){ - for(int i = 0; nodes[i] != NULL; i++){ - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + if((nodes = xl_get_path(node, "functions")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; OFS << " " + function_header(child) << std::endl; @@ -463,6 +601,26 @@ static void scan_header(xl_node_t* node) { #undef OFS #define OFS files["D" + name.substr(7) + ".cc"] + + OFS = std::ofstream("src/dialog/" + lowercase(name.substr(7)) + ".cc"); + + OFS << "#include " << std::endl; + OFS << std::endl; + + if((nodes = xl_get_path(node, "functions")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { + if(child->type != XL_NODE_NODE) continue; + + OFS << function_source(child); + } + } + + free(nodes); + } + + files["objs"] << " src/dialog/" + lowercase(name.substr(7)) + ".o"; + #undef OFS } } @@ -481,13 +639,21 @@ static void base_widget() { OFS << widget_property_header(p->first); f = 1; } + if(f) OFS << std::endl; + f = 0; + for(auto p = handlers.begin(); p != handlers.end(); p++) { + if(!p->second.common) continue; + + OFS << widget_handler_header("Base", 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); + OFS << widget_handler_header("Base", p->first, "", 0); } #undef OFS @@ -516,6 +682,12 @@ static void base_widget() { OFS << " MwAddUserHandler(this->widget, MwN" + h->first + "Handler, __On" + upperfirst(h->first) + ", (void*)this);" << std::endl; } + OFS << std::endl; + for(auto h = handlers.begin(); h != handlers.end(); h++) { + if(!h->second.common) continue; + + OFS << " this->" + upperfirst(h->first) + "Handler = NULL;" << std::endl; + } OFS << "}" << std::endl; #undef OFS @@ -548,7 +720,7 @@ int main(int argc, char** argv) { if((nodes = xl_get_path(h->root, "properties")) != NULL) { for(int i = 0; nodes[i] != NULL; i++) { - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; scan_property(child); @@ -560,7 +732,7 @@ int main(int argc, char** argv) { if((nodes = xl_get_path(h->root, "handlers")) != NULL) { for(int i = 0; nodes[i] != NULL; i++) { - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; scan_handler(child); @@ -572,7 +744,7 @@ int main(int argc, char** argv) { if((nodes = xl_get_path(h->root, "headers")) != NULL) { for(int i = 0; nodes[i] != NULL; i++) { - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { if(child->type != XL_NODE_NODE) continue; scan_header(child); @@ -584,16 +756,38 @@ int main(int argc, char** argv) { base_widget(); +#define OFS files["AllWidgets.h"] + + OFS = std::ofstream("include/MwCXX/Widget/All.h"); + + OFS << "#ifndef __MWCXX_WIDGET_ALL_H__" << std::endl; + OFS << "#define __MWCXX_WIDGET_ALL_H__" << std::endl; + OFS << std::endl; + if((nodes = xl_get_path(h->root, "widgets")) != NULL) { for(int i = 0; nodes[i] != NULL; i++) { - for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next){ + for(xl_node_t* child = nodes[i]->first_child; child != NULL; child = child->next) { + std::string name; + + if(child->type != XL_NODE_NODE) continue; + scan_widget(child); + + name = xl_get_attribute(child, "name"); + + if(name == "OpenGL" || name == "Vulkan") continue; + OFS << "#include " << std::endl; } } free(nodes); } + OFS << std::endl; + OFS << "#endif" << std::endl; + +#undef OFS + files["objs"] << std::endl; for(auto f = files.begin(); f != files.end(); f++) { diff --git a/include/MwCXX/Dialog/ColorChooser.h b/include/MwCXX/Dialog/ColorChooser.h index 66b886f..b57e654 100644 --- a/include/MwCXX/Dialog/ColorChooser.h +++ b/include/MwCXX/Dialog/ColorChooser.h @@ -1,6 +1,8 @@ #ifndef __MWCXX_DIALOG_COLORCHOOSER_H__ #define __MWCXX_DIALOG_COLORCHOOSER_H__ +#include + namespace MwCXX { MwCXX::Window* ColorChooser(MwCXX::Base* handle, MwCXX::String title); }; // namespace MwCXX diff --git a/include/MwCXX/Dialog/ColorPicker.h b/include/MwCXX/Dialog/ColorPicker.h new file mode 100644 index 0000000..45b2abf --- /dev/null +++ b/include/MwCXX/Dialog/ColorPicker.h @@ -0,0 +1,10 @@ +#ifndef __MWCXX_DIALOG_COLORPICKER_H__ +#define __MWCXX_DIALOG_COLORPICKER_H__ + +#include + +namespace MwCXX { + MwCXX::Window* ColorPicker(MwCXX::Base* handle, MwCXX::String title); +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Dialog/DirectoryChooser.h b/include/MwCXX/Dialog/DirectoryChooser.h index 7f2c015..fb60afb 100644 --- a/include/MwCXX/Dialog/DirectoryChooser.h +++ b/include/MwCXX/Dialog/DirectoryChooser.h @@ -1,6 +1,8 @@ #ifndef __MWCXX_DIALOG_DIRECTORYCHOOSER_H__ #define __MWCXX_DIALOG_DIRECTORYCHOOSER_H__ +#include + namespace MwCXX { MwCXX::Window* DirectoryChooser(MwCXX::Base* handle, MwCXX::String title); }; // namespace MwCXX diff --git a/include/MwCXX/Dialog/FileChooser.h b/include/MwCXX/Dialog/FileChooser.h index 12c0818..eaf9a7b 100644 --- a/include/MwCXX/Dialog/FileChooser.h +++ b/include/MwCXX/Dialog/FileChooser.h @@ -1,6 +1,8 @@ #ifndef __MWCXX_DIALOG_FILECHOOSER_H__ #define __MWCXX_DIALOG_FILECHOOSER_H__ +#include + namespace MwCXX { MwCXX::Window* FileChooser(MwCXX::Base* handle, MwCXX::String title); MwCXX::Window* FileChooserEx(MwCXX::Base* handle, MwCXX::String title, int dir); diff --git a/include/MwCXX/Dialog/MessageBox.h b/include/MwCXX/Dialog/MessageBox.h index 53f02a4..ee95b60 100644 --- a/include/MwCXX/Dialog/MessageBox.h +++ b/include/MwCXX/Dialog/MessageBox.h @@ -1,10 +1,12 @@ #ifndef __MWCXX_DIALOG_MESSAGEBOX_H__ #define __MWCXX_DIALOG_MESSAGEBOX_H__ +#include + namespace MwCXX { MwCXX::Window* MessageBox(MwCXX::Base* handle, MwCXX::String text, MwCXX::String title, int flag); MwCXX::Button* MessageBoxGetChild(MwCXX::Window* handle, int child); - void MessageBoxDestroy(MwCXX::Window* handle); + void MessageBoxDestroy(MwCXX::Window* handle); }; // namespace MwCXX #endif diff --git a/include/MwCXX/MachDep.h b/include/MwCXX/MachDep.h index 0d16c52..3e9ec4c 100644 --- a/include/MwCXX/MachDep.h +++ b/include/MwCXX/MachDep.h @@ -6,7 +6,7 @@ #include #include -// #define MWCXX_USE_C_STRING +#define MWCXX_USE_C_STRING namespace MwCXX { #ifdef MWCXX_USE_C_STRING diff --git a/include/MwCXX/Widget/All.h b/include/MwCXX/Widget/All.h new file mode 100644 index 0000000..b7cf78c --- /dev/null +++ b/include/MwCXX/Widget/All.h @@ -0,0 +1,23 @@ +#ifndef __MWCXX_WIDGET_ALL_H__ +#define __MWCXX_WIDGET_ALL_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/include/MwCXX/Widget/Base.h b/include/MwCXX/Widget/Base.h index ce0a544..ac9dd9d 100644 --- a/include/MwCXX/Widget/Base.h +++ b/include/MwCXX/Widget/Base.h @@ -10,7 +10,7 @@ namespace MwCXX { MwWidget widget; - MwCXX::Base* parent; + MwCXX::Base* parent; std::vector children; public: @@ -24,12 +24,14 @@ namespace MwCXX { void Move(int x, int y); void Resize(unsigned int width, unsigned int height); - int Step(); - int Pending(); + int Step(); + int Pending(); void Loop(); MwCXX::Base* GetParent(); + MwWidget GetWidget(); + #include }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/BaseAuto.h b/include/MwCXX/Widget/BaseAuto.h index 1afd16f..a0f729b 100644 --- a/include/MwCXX/Widget/BaseAuto.h +++ b/include/MwCXX/Widget/BaseAuto.h @@ -1,41 +1,41 @@ MwCXX::String GetBackground(); -void SetBackground(MwCXX::String value); -MwLLPixmap GetBackgroundPixmap(); -void SetBackgroundPixmap(MwLLPixmap value); -int GetBitmapFont(); -void SetBitmapFont(int value); -int GetBorderWidth(); -void SetBorderWidth(int value); -int GetDarkTheme(); -void SetDarkTheme(int value); -int GetFixedSize(); -void SetFixedSize(int value); -int GetForceInverted(); -void SetForceInverted(int value); +void SetBackground(MwCXX::String value); +MwLLPixmap GetBackgroundPixmap(); +void SetBackgroundPixmap(MwLLPixmap value); +int GetBitmapFont(); +void SetBitmapFont(int value); +int GetBorderWidth(); +void SetBorderWidth(int value); +int GetDarkTheme(); +void SetDarkTheme(int value); +int GetFixedSize(); +void SetFixedSize(int value); +int GetForceInverted(); +void SetForceInverted(int value); MwCXX::String GetForeground(); -void SetForeground(MwCXX::String value); -int GetHeight(); -void SetHeight(int value); -int GetIsRounded(); -void SetIsRounded(int value); -int GetModernLook(); -void SetModernLook(int value); -int GetRatio(); -void SetRatio(int value); +void SetForeground(MwCXX::String value); +int GetHeight(); +void SetHeight(int value); +int GetIsRounded(); +void SetIsRounded(int value); +int GetModernLook(); +void SetModernLook(int value); +int GetRatio(); +void SetRatio(int value); MwCXX::String GetSubBackground(); -void SetSubBackground(MwCXX::String value); +void SetSubBackground(MwCXX::String value); MwCXX::String GetSubForeground(); -void SetSubForeground(MwCXX::String value); -int GetUseMonospace(); -void SetUseMonospace(int value); -int GetWaitMS(); -void SetWaitMS(int value); -int GetWidth(); -void SetWidth(int value); -int GetX(); -void SetX(int value); -int GetY(); -void SetY(int value); +void SetSubForeground(MwCXX::String value); +int GetUseMonospace(); +void SetUseMonospace(int value); +int GetWaitMS(); +void SetWaitMS(int value); +int GetWidth(); +void SetWidth(int value); +int GetX(); +void SetX(int value); +int GetY(); +void SetY(int value); virtual void OnClipboard(MwCXX::String value) {}; virtual void OnDarkTheme(int value) {}; @@ -48,3 +48,15 @@ virtual void OnMouseMove(MwPoint value) {}; virtual void OnMouseUp(MwMouse value) {}; virtual void OnResize() {}; virtual void OnTick() {}; + +void (*ClipboardHandler)(MwCXX::Base* widget, MwCXX::String value); +void (*DarkThemeHandler)(MwCXX::Base* widget, int value); +void (*FocusInHandler)(MwCXX::Base* widget); +void (*FocusOutHandler)(MwCXX::Base* widget); +void (*KeyHandler)(MwCXX::Base* widget, int value); +void (*KeyReleaseHandler)(MwCXX::Base* widget, int value); +void (*MouseDownHandler)(MwCXX::Base* widget, MwMouse value); +void (*MouseMoveHandler)(MwCXX::Base* widget, MwPoint value); +void (*MouseUpHandler)(MwCXX::Base* widget, MwMouse value); +void (*ResizeHandler)(MwCXX::Base* widget); +void (*TickHandler)(MwCXX::Base* widget); diff --git a/include/MwCXX/Widget/Box.h b/include/MwCXX/Widget/Box.h index 332ef72..79e9c00 100644 --- a/include/MwCXX/Widget/Box.h +++ b/include/MwCXX/Widget/Box.h @@ -15,15 +15,15 @@ namespace MwCXX { Box(MwWidget widget, MwCXX::Base* parent = NULL); Box(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetOrientation(); + int GetOrientation(); void SetOrientation(int value); - int GetMargin(); + int GetMargin(); void SetMargin(int value); - int GetPadding(); + int GetPadding(); void SetPadding(int value); - int GetHasBorder(); + int GetHasBorder(); void SetHasBorder(int value); - int GetInverted(); + int GetInverted(); void SetInverted(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Button.h b/include/MwCXX/Widget/Button.h index 5f1a7fa..d2bfc28 100644 --- a/include/MwCXX/Widget/Button.h +++ b/include/MwCXX/Widget/Button.h @@ -15,19 +15,22 @@ namespace MwCXX { Button(MwWidget widget, MwCXX::Base* parent = NULL); Button(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - MwLLPixmap GetPixmap(); - void SetPixmap(MwLLPixmap value); + MwLLPixmap GetPixmap(); + void SetPixmap(MwLLPixmap value); MwCXX::String GetText(); - void SetText(MwCXX::String value); - int GetFlat(); - void SetFlat(int value); - int GetPadding(); - void SetPadding(int value); - int GetFillArea(); - void SetFillArea(int value); + void SetText(MwCXX::String value); + int GetFlat(); + void SetFlat(int value); + int GetPadding(); + void SetPadding(int value); + int GetFillArea(); + void SetFillArea(int value); virtual void OnActivate() {}; virtual void OnChanged() {}; + + void (*ActivateHandler)(MwCXX::Button* widget); + void (*ChangedHandler)(MwCXX::Button* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/CheckBox.h b/include/MwCXX/Widget/CheckBox.h index 36a8d79..090da8c 100644 --- a/include/MwCXX/Widget/CheckBox.h +++ b/include/MwCXX/Widget/CheckBox.h @@ -15,10 +15,12 @@ namespace MwCXX { CheckBox(MwWidget widget, MwCXX::Base* parent = NULL); CheckBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetChecked(); + int GetChecked(); void SetChecked(int value); virtual void OnChanged() {}; + + void (*ChangedHandler)(MwCXX::CheckBox* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ComboBox.h b/include/MwCXX/Widget/ComboBox.h index 01ec876..5f58ef2 100644 --- a/include/MwCXX/Widget/ComboBox.h +++ b/include/MwCXX/Widget/ComboBox.h @@ -15,12 +15,14 @@ namespace MwCXX { ComboBox(MwWidget widget, MwCXX::Base* parent = NULL); ComboBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetAreaShown(); + int GetAreaShown(); void SetAreaShown(int value); - int GetValue(); + int GetValue(); void SetValue(int value); virtual void OnComboBoxChanged(int value) {}; + + void (*ComboBoxChangedHandler)(MwCXX::ComboBox* widget, int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Entry.h b/include/MwCXX/Widget/Entry.h index 82d251d..4499d0b 100644 --- a/include/MwCXX/Widget/Entry.h +++ b/include/MwCXX/Widget/Entry.h @@ -16,12 +16,15 @@ namespace MwCXX { Entry(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); MwCXX::String GetText(); - void SetText(MwCXX::String value); - int GetHideInput(); - void SetHideInput(int value); + void SetText(MwCXX::String value); + int GetHideInput(); + void SetHideInput(int value); virtual void OnActivate() {}; virtual void OnChanged() {}; + + void (*ActivateHandler)(MwCXX::Entry* widget); + void (*ChangedHandler)(MwCXX::Entry* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Frame.h b/include/MwCXX/Widget/Frame.h index a430c0c..43c1db1 100644 --- a/include/MwCXX/Widget/Frame.h +++ b/include/MwCXX/Widget/Frame.h @@ -15,9 +15,9 @@ namespace MwCXX { Frame(MwWidget widget, MwCXX::Base* parent = NULL); Frame(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetHasBorder(); + int GetHasBorder(); void SetHasBorder(int value); - int GetInverted(); + int GetInverted(); void SetInverted(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Image.h b/include/MwCXX/Widget/Image.h index 063301f..3a23ba2 100644 --- a/include/MwCXX/Widget/Image.h +++ b/include/MwCXX/Widget/Image.h @@ -16,13 +16,13 @@ namespace MwCXX { Image(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); MwLLPixmap GetPixmap(); - void SetPixmap(MwLLPixmap value); - int GetHasBorder(); - void SetHasBorder(int value); - int GetInverted(); - void SetInverted(int value); - int GetFillArea(); - void SetFillArea(int value); + void SetPixmap(MwLLPixmap value); + int GetHasBorder(); + void SetHasBorder(int value); + int GetInverted(); + void SetInverted(int value); + int GetFillArea(); + void SetFillArea(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Label.h b/include/MwCXX/Widget/Label.h index f81524e..716b8f9 100644 --- a/include/MwCXX/Widget/Label.h +++ b/include/MwCXX/Widget/Label.h @@ -16,17 +16,17 @@ namespace MwCXX { Label(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); MwCXX::String GetText(); - void SetText(MwCXX::String value); - int GetAlignment(); - void SetAlignment(int value); - int GetBold(); - void SetBold(int value); - int GetSevenSegment(); - void SetSevenSegment(int value); - int GetLength(); - void SetLength(int value); - int GetLeftPadding(); - void SetLeftPadding(int value); + void SetText(MwCXX::String value); + int GetAlignment(); + void SetAlignment(int value); + int GetBold(); + void SetBold(int value); + int GetSevenSegment(); + void SetSevenSegment(int value); + int GetLength(); + void SetLength(int value); + int GetLeftPadding(); + void SetLeftPadding(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ListBox.h b/include/MwCXX/Widget/ListBox.h index f7aacda..1f02b7d 100644 --- a/include/MwCXX/Widget/ListBox.h +++ b/include/MwCXX/Widget/ListBox.h @@ -15,14 +15,16 @@ namespace MwCXX { ListBox(MwWidget widget, MwCXX::Base* parent = NULL); ListBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetLeftPadding(); + int GetLeftPadding(); void SetLeftPadding(int value); - int GetHasHeading(); + int GetHasHeading(); void SetHasHeading(int value); - int GetSingleClickSelectable(); + int GetSingleClickSelectable(); void SetSingleClickSelectable(int value); virtual void OnListBoxActivate(int value) {}; + + void (*ListBoxActivateHandler)(MwCXX::ListBox* widget, int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Menu.h b/include/MwCXX/Widget/Menu.h index 602fcff..ce3e08a 100644 --- a/include/MwCXX/Widget/Menu.h +++ b/include/MwCXX/Widget/Menu.h @@ -16,6 +16,8 @@ namespace MwCXX { Menu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); virtual void OnMenu(void* value) {}; + + void (*MenuHandler)(MwCXX::Menu* widget, void* value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/NumberEntry.h b/include/MwCXX/Widget/NumberEntry.h index 29ca4e5..a7fb295 100644 --- a/include/MwCXX/Widget/NumberEntry.h +++ b/include/MwCXX/Widget/NumberEntry.h @@ -16,10 +16,13 @@ namespace MwCXX { 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); + void SetText(MwCXX::String value); virtual void OnActivate() {}; virtual void OnChanged() {}; + + void (*ActivateHandler)(MwCXX::NumberEntry* widget); + void (*ChangedHandler)(MwCXX::NumberEntry* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ProgressBar.h b/include/MwCXX/Widget/ProgressBar.h index d776a64..d6d3b12 100644 --- a/include/MwCXX/Widget/ProgressBar.h +++ b/include/MwCXX/Widget/ProgressBar.h @@ -15,11 +15,11 @@ namespace MwCXX { ProgressBar(MwWidget widget, MwCXX::Base* parent = NULL); ProgressBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetMinValue(); + int GetMinValue(); void SetMinValue(int value); - int GetMaxValue(); + int GetMaxValue(); void SetMaxValue(int value); - int GetValue(); + int GetValue(); void SetValue(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/RadioBox.h b/include/MwCXX/Widget/RadioBox.h index e51fb1d..551d9eb 100644 --- a/include/MwCXX/Widget/RadioBox.h +++ b/include/MwCXX/Widget/RadioBox.h @@ -15,10 +15,12 @@ namespace MwCXX { RadioBox(MwWidget widget, MwCXX::Base* parent = NULL); RadioBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetChecked(); + int GetChecked(); void SetChecked(int value); virtual void OnChanged() {}; + + void (*ChangedHandler)(MwCXX::RadioBox* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/ScrollBar.h b/include/MwCXX/Widget/ScrollBar.h index d1c7f10..f01af73 100644 --- a/include/MwCXX/Widget/ScrollBar.h +++ b/include/MwCXX/Widget/ScrollBar.h @@ -15,20 +15,22 @@ namespace MwCXX { ScrollBar(MwWidget widget, MwCXX::Base* parent = NULL); ScrollBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetShowArrows(); + int GetShowArrows(); void SetShowArrows(int value); - int GetAreaShown(); + int GetAreaShown(); void SetAreaShown(int value); - int GetValue(); + int GetValue(); void SetValue(int value); - int GetMinValue(); + int GetMinValue(); void SetMinValue(int value); - int GetMaxValue(); + int GetMaxValue(); void SetMaxValue(int value); - int GetOrientation(); + int GetOrientation(); void SetOrientation(int value); virtual void OnChanged() {}; + + void (*ChangedHandler)(MwCXX::ScrollBar* widget); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/SubMenu.h b/include/MwCXX/Widget/SubMenu.h index 9886f2b..4c807b5 100644 --- a/include/MwCXX/Widget/SubMenu.h +++ b/include/MwCXX/Widget/SubMenu.h @@ -15,7 +15,7 @@ namespace MwCXX { SubMenu(MwWidget widget, MwCXX::Base* parent = NULL); SubMenu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetLeftPadding(); + int GetLeftPadding(); void SetLeftPadding(int value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/TreeView.h b/include/MwCXX/Widget/TreeView.h index f89e427..a2f4752 100644 --- a/include/MwCXX/Widget/TreeView.h +++ b/include/MwCXX/Widget/TreeView.h @@ -15,12 +15,14 @@ namespace MwCXX { TreeView(MwWidget widget, MwCXX::Base* parent = NULL); TreeView(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); - int GetLeftPadding(); + int GetLeftPadding(); void SetLeftPadding(int value); - int GetSingleClickSelectable(); + int GetSingleClickSelectable(); void SetSingleClickSelectable(int value); virtual void OnTreeViewActivate(void* value) {}; + + void (*TreeViewActivateHandler)(MwCXX::TreeView* widget, void* value); }; }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Window.h b/include/MwCXX/Widget/Window.h index 7476b1e..d82f30e 100644 --- a/include/MwCXX/Widget/Window.h +++ b/include/MwCXX/Widget/Window.h @@ -16,17 +16,17 @@ namespace MwCXX { Window(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); MwCXX::String GetTitle(); - void SetTitle(MwCXX::String value); - int GetMain(); - void SetMain(int value); - MwLLPixmap GetIconPixmap(); - void SetIconPixmap(MwLLPixmap value); - MwSizeHints* GetSizeHints(); - void SetSizeHints(MwSizeHints* value); - int GetHasBorder(); - void SetHasBorder(int value); - int GetInverted(); - void SetInverted(int value); + void SetTitle(MwCXX::String value); + int GetMain(); + void SetMain(int value); + MwLLPixmap GetIconPixmap(); + void SetIconPixmap(MwLLPixmap value); + MwSizeHints* GetSizeHints(); + void SetSizeHints(MwSizeHints* value); + int GetHasBorder(); + void SetHasBorder(int value); + int GetInverted(); + void SetInverted(int value); }; }; // namespace MwCXX diff --git a/objs.mk b/objs.mk index c466076..b6c5324 100644 --- a/objs.mk +++ b/objs.mk @@ -1 +1 @@ -OBJS += src/widget/baseauto.o src/widget/box.o src/widget/button.o src/widget/checkbox.o src/widget/entry.o src/widget/frame.o src/widget/image.o src/widget/label.o src/widget/listbox.o src/widget/menu.o src/widget/numberentry.o src/widget/scrollbar.o src/widget/submenu.o src/widget/viewport.o src/widget/window.o src/widget/progressbar.o src/widget/radiobox.o src/widget/combobox.o src/widget/treeview.o src/widget/opengl.o src/widget/vulkan.o +OBJS += src/dialog/colorpicker.o src/dialog/filechooser.o src/dialog/directorychooser.o src/dialog/messagebox.o src/widget/baseauto.o src/widget/box.o src/widget/button.o src/widget/checkbox.o src/widget/entry.o src/widget/frame.o src/widget/image.o src/widget/label.o src/widget/listbox.o src/widget/menu.o src/widget/numberentry.o src/widget/scrollbar.o src/widget/submenu.o src/widget/viewport.o src/widget/window.o src/widget/progressbar.o src/widget/radiobox.o src/widget/combobox.o src/widget/treeview.o src/widget/opengl.o src/widget/vulkan.o diff --git a/src/dialog/colorchooser.cc b/src/dialog/colorchooser.cc new file mode 100644 index 0000000..639017c --- /dev/null +++ b/src/dialog/colorchooser.cc @@ -0,0 +1,12 @@ +#include + +MwCXX::Window* MwCXX::ColorChooser(MwCXX::Base* handle, MwCXX::String title) { + return new MwCXX::Window(MwColorChooser((MwWidget)handle, +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + ), + handle); +} diff --git a/src/dialog/colorpicker.cc b/src/dialog/colorpicker.cc new file mode 100644 index 0000000..45d7d22 --- /dev/null +++ b/src/dialog/colorpicker.cc @@ -0,0 +1,12 @@ +#include + +MwCXX::Window* MwCXX::ColorPicker(MwCXX::Base* handle, MwCXX::String title) { + return new MwCXX::Window(MwColorPicker(handle->GetWidget(), +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + ), + handle); +} diff --git a/src/dialog/directorychooser.cc b/src/dialog/directorychooser.cc new file mode 100644 index 0000000..61b4fc4 --- /dev/null +++ b/src/dialog/directorychooser.cc @@ -0,0 +1,12 @@ +#include + +MwCXX::Window* MwCXX::DirectoryChooser(MwCXX::Base* handle, MwCXX::String title) { + return new MwCXX::Window(MwDirectoryChooser(handle->GetWidget(), +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + ), + handle); +} diff --git a/src/dialog/filechooser.cc b/src/dialog/filechooser.cc new file mode 100644 index 0000000..ecc4009 --- /dev/null +++ b/src/dialog/filechooser.cc @@ -0,0 +1,23 @@ +#include + +MwCXX::Window* MwCXX::FileChooser(MwCXX::Base* handle, MwCXX::String title) { + return new MwCXX::Window(MwFileChooser(handle->GetWidget(), +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + ), + handle); +} +MwCXX::Window* MwCXX::FileChooserEx(MwCXX::Base* handle, MwCXX::String title, int dir) { + return new MwCXX::Window(MwFileChooserEx(handle->GetWidget(), +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + , + (int)dir), + handle); +} diff --git a/src/dialog/messagebox.cc b/src/dialog/messagebox.cc new file mode 100644 index 0000000..ca5c5d7 --- /dev/null +++ b/src/dialog/messagebox.cc @@ -0,0 +1,25 @@ +#include + +MwCXX::Window* MwCXX::MessageBox(MwCXX::Base* handle, MwCXX::String text, MwCXX::String title, int flag) { + return new MwCXX::Window(MwMessageBox(handle->GetWidget(), +#ifdef MWCXX_USE_C_STRING + text +#else + text.c_str() +#endif + , +#ifdef MWCXX_USE_C_STRING + title +#else + title.c_str() +#endif + , + (int)flag), + handle); +} +MwCXX::Button* MwCXX::MessageBoxGetChild(MwCXX::Window* handle, int child) { + return new MwCXX::Button(MwMessageBoxGetChild(handle->GetWidget(), (int)child), handle); +} +void MwCXX::MessageBoxDestroy(MwCXX::Window* handle) { + MwMessageBoxDestroy(handle->GetWidget()); +} diff --git a/src/widget/base.cc b/src/widget/base.cc index 517c9ee..74f3f63 100644 --- a/src/widget/base.cc +++ b/src/widget/base.cc @@ -21,14 +21,14 @@ MwCXX::Base::Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, this->RegisterHandlers(); } -MwCXX::Base::~Base(){ - for(int i = 0; i < this->children.size(); i++){ +MwCXX::Base::~Base() { + for(int i = 0; i < this->children.size(); i++) { delete this->children[i]; } - if(this->parent != NULL){ - for(int i = 0; i < this->parent->children.size(); i++){ - if(this->parent->children[i] == this){ + if(this->parent != NULL) { + for(int i = 0; i < this->parent->children.size(); i++) { + if(this->parent->children[i] == this) { this->parent->children.erase(this->parent->children.begin() + i); break; } @@ -84,6 +84,10 @@ void MwCXX::Base::Loop() { MwLoop(this->widget); } -MwCXX::Base* MwCXX::Base::GetParent(){ +MwCXX::Base* MwCXX::Base::GetParent() { return this->parent; } + +MwWidget MwCXX::Base::GetWidget() { + return this->widget; +} diff --git a/src/widget/baseauto.cc b/src/widget/baseauto.cc index 80ea781..07a1306 100644 --- a/src/widget/baseauto.cc +++ b/src/widget/baseauto.cc @@ -169,46 +169,57 @@ void MwCXX::Base::SetY(int value) { static void __OnClipboard(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnClipboard((MwCXX::String)(char*)call); + if(((MwCXX::Base*)user)->ClipboardHandler != NULL) ((MwCXX::Base*)user)->ClipboardHandler((MwCXX::Base*)user, (MwCXX::String)(char*)call); } static void __OnDarkTheme(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnDarkTheme(*(int*)call); + if(((MwCXX::Base*)user)->DarkThemeHandler != NULL) ((MwCXX::Base*)user)->DarkThemeHandler((MwCXX::Base*)user, *(int*)call); } static void __OnFocusIn(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnFocusIn(); + if(((MwCXX::Base*)user)->FocusInHandler != NULL) ((MwCXX::Base*)user)->FocusInHandler((MwCXX::Base*)user); } static void __OnFocusOut(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnFocusOut(); + if(((MwCXX::Base*)user)->FocusOutHandler != NULL) ((MwCXX::Base*)user)->FocusOutHandler((MwCXX::Base*)user); } static void __OnKey(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnKey(*(int*)call); + if(((MwCXX::Base*)user)->KeyHandler != NULL) ((MwCXX::Base*)user)->KeyHandler((MwCXX::Base*)user, *(int*)call); } static void __OnKeyRelease(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnKeyRelease(*(int*)call); + if(((MwCXX::Base*)user)->KeyReleaseHandler != NULL) ((MwCXX::Base*)user)->KeyReleaseHandler((MwCXX::Base*)user, *(int*)call); } static void __OnMouseDown(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnMouseDown(*(MwMouse*)call); + if(((MwCXX::Base*)user)->MouseDownHandler != NULL) ((MwCXX::Base*)user)->MouseDownHandler((MwCXX::Base*)user, *(MwMouse*)call); } static void __OnMouseMove(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnMouseMove(*(MwPoint*)call); + if(((MwCXX::Base*)user)->MouseMoveHandler != NULL) ((MwCXX::Base*)user)->MouseMoveHandler((MwCXX::Base*)user, *(MwPoint*)call); } static void __OnMouseUp(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnMouseUp(*(MwMouse*)call); + if(((MwCXX::Base*)user)->MouseUpHandler != NULL) ((MwCXX::Base*)user)->MouseUpHandler((MwCXX::Base*)user, *(MwMouse*)call); } static void __OnResize(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnResize(); + if(((MwCXX::Base*)user)->ResizeHandler != NULL) ((MwCXX::Base*)user)->ResizeHandler((MwCXX::Base*)user); } static void __OnTick(MwWidget handle, void* user, void* call) { ((MwCXX::Base*)user)->OnTick(); + if(((MwCXX::Base*)user)->TickHandler != NULL) ((MwCXX::Base*)user)->TickHandler((MwCXX::Base*)user); } void MwCXX::Base::RegisterHandlers() { @@ -223,4 +234,16 @@ void MwCXX::Base::RegisterHandlers() { MwAddUserHandler(this->widget, MwNmouseUpHandler, __OnMouseUp, (void*)this); MwAddUserHandler(this->widget, MwNresizeHandler, __OnResize, (void*)this); MwAddUserHandler(this->widget, MwNtickHandler, __OnTick, (void*)this); + + this->ClipboardHandler = NULL; + this->DarkThemeHandler = NULL; + this->FocusInHandler = NULL; + this->FocusOutHandler = NULL; + this->KeyHandler = NULL; + this->KeyReleaseHandler = NULL; + this->MouseDownHandler = NULL; + this->MouseMoveHandler = NULL; + this->MouseUpHandler = NULL; + this->ResizeHandler = NULL; + this->TickHandler = NULL; } diff --git a/src/widget/box.cc b/src/widget/box.cc index 984558e..974b796 100644 --- a/src/widget/box.cc +++ b/src/widget/box.cc @@ -1,10 +1,12 @@ #include -MwCXX::Box::Box(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Box::Box(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/button.cc b/src/widget/button.cc index 4aac97f..6e93e8c 100644 --- a/src/widget/button.cc +++ b/src/widget/button.cc @@ -1,10 +1,12 @@ #include -MwCXX::Button::Button(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Button::Button(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -54,13 +56,18 @@ void MwCXX::Button::SetFillArea(int value) { static void __OnActivate(MwWidget handle, void* user, void* call) { ((MwCXX::Button*)user)->OnActivate(); + if(((MwCXX::Button*)user)->ActivateHandler != NULL) ((MwCXX::Button*)user)->ActivateHandler((MwCXX::Button*)user); } static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::Button*)user)->OnChanged(); + if(((MwCXX::Button*)user)->ChangedHandler != NULL) ((MwCXX::Button*)user)->ChangedHandler((MwCXX::Button*)user); } void MwCXX::Button::RegisterHandlers() { MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ActivateHandler = NULL; + this->ChangedHandler = NULL; } diff --git a/src/widget/checkbox.cc b/src/widget/checkbox.cc index f598ec7..fdc52ad 100644 --- a/src/widget/checkbox.cc +++ b/src/widget/checkbox.cc @@ -1,10 +1,12 @@ #include -MwCXX::CheckBox::CheckBox(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::CheckBox::CheckBox(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -18,8 +20,11 @@ void MwCXX::CheckBox::SetChecked(int value) { static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::CheckBox*)user)->OnChanged(); + if(((MwCXX::CheckBox*)user)->ChangedHandler != NULL) ((MwCXX::CheckBox*)user)->ChangedHandler((MwCXX::CheckBox*)user); } void MwCXX::CheckBox::RegisterHandlers() { MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ChangedHandler = NULL; } diff --git a/src/widget/combobox.cc b/src/widget/combobox.cc index 047b713..2d4986e 100644 --- a/src/widget/combobox.cc +++ b/src/widget/combobox.cc @@ -1,10 +1,12 @@ #include -MwCXX::ComboBox::ComboBox(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::ComboBox::ComboBox(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -26,8 +28,11 @@ void MwCXX::ComboBox::SetValue(int value) { static void __OnComboBoxChanged(MwWidget handle, void* user, void* call) { ((MwCXX::ComboBox*)user)->OnComboBoxChanged(*(int*)call); + if(((MwCXX::ComboBox*)user)->ComboBoxChangedHandler != NULL) ((MwCXX::ComboBox*)user)->ComboBoxChangedHandler((MwCXX::ComboBox*)user, *(int*)call); } void MwCXX::ComboBox::RegisterHandlers() { MwAddUserHandler(this->widget, MwNcomboBoxChangedHandler, __OnComboBoxChanged, (void*)this); + + this->ComboBoxChangedHandler = NULL; } diff --git a/src/widget/entry.cc b/src/widget/entry.cc index 6c53b1e..b360020 100644 --- a/src/widget/entry.cc +++ b/src/widget/entry.cc @@ -1,10 +1,12 @@ #include -MwCXX::Entry::Entry(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Entry::Entry(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -30,13 +32,18 @@ void MwCXX::Entry::SetHideInput(int value) { static void __OnActivate(MwWidget handle, void* user, void* call) { ((MwCXX::Entry*)user)->OnActivate(); + if(((MwCXX::Entry*)user)->ActivateHandler != NULL) ((MwCXX::Entry*)user)->ActivateHandler((MwCXX::Entry*)user); } static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::Entry*)user)->OnChanged(); + if(((MwCXX::Entry*)user)->ChangedHandler != NULL) ((MwCXX::Entry*)user)->ChangedHandler((MwCXX::Entry*)user); } void MwCXX::Entry::RegisterHandlers() { MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ActivateHandler = NULL; + this->ChangedHandler = NULL; } diff --git a/src/widget/frame.cc b/src/widget/frame.cc index d9df84a..a13f39c 100644 --- a/src/widget/frame.cc +++ b/src/widget/frame.cc @@ -1,10 +1,12 @@ #include -MwCXX::Frame::Frame(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Frame::Frame(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/image.cc b/src/widget/image.cc index ee1a131..075797f 100644 --- a/src/widget/image.cc +++ b/src/widget/image.cc @@ -1,10 +1,12 @@ #include -MwCXX::Image::Image(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Image::Image(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/label.cc b/src/widget/label.cc index a11a1a7..5128489 100644 --- a/src/widget/label.cc +++ b/src/widget/label.cc @@ -1,10 +1,12 @@ #include -MwCXX::Label::Label(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Label::Label(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/listbox.cc b/src/widget/listbox.cc index 66a509a..b7283f9 100644 --- a/src/widget/listbox.cc +++ b/src/widget/listbox.cc @@ -1,10 +1,12 @@ #include -MwCXX::ListBox::ListBox(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::ListBox::ListBox(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -34,8 +36,11 @@ void MwCXX::ListBox::SetSingleClickSelectable(int value) { static void __OnListBoxActivate(MwWidget handle, void* user, void* call) { ((MwCXX::ListBox*)user)->OnListBoxActivate(*(int*)call); + if(((MwCXX::ListBox*)user)->ListBoxActivateHandler != NULL) ((MwCXX::ListBox*)user)->ListBoxActivateHandler((MwCXX::ListBox*)user, *(int*)call); } void MwCXX::ListBox::RegisterHandlers() { MwAddUserHandler(this->widget, MwNlistBoxActivateHandler, __OnListBoxActivate, (void*)this); + + this->ListBoxActivateHandler = NULL; } diff --git a/src/widget/menu.cc b/src/widget/menu.cc index 9f03305..169be72 100644 --- a/src/widget/menu.cc +++ b/src/widget/menu.cc @@ -1,17 +1,22 @@ #include -MwCXX::Menu::Menu(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Menu::Menu(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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); + if(((MwCXX::Menu*)user)->MenuHandler != NULL) ((MwCXX::Menu*)user)->MenuHandler((MwCXX::Menu*)user, (void*)call); } void MwCXX::Menu::RegisterHandlers() { MwAddUserHandler(this->widget, MwNmenuHandler, __OnMenu, (void*)this); + + this->MenuHandler = NULL; } diff --git a/src/widget/numberentry.cc b/src/widget/numberentry.cc index d65f413..b8e1335 100644 --- a/src/widget/numberentry.cc +++ b/src/widget/numberentry.cc @@ -1,10 +1,12 @@ #include -MwCXX::NumberEntry::NumberEntry(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::NumberEntry::NumberEntry(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -22,13 +24,18 @@ void MwCXX::NumberEntry::SetText(MwCXX::String value) { static void __OnActivate(MwWidget handle, void* user, void* call) { ((MwCXX::NumberEntry*)user)->OnActivate(); + if(((MwCXX::NumberEntry*)user)->ActivateHandler != NULL) ((MwCXX::NumberEntry*)user)->ActivateHandler((MwCXX::NumberEntry*)user); } static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::NumberEntry*)user)->OnChanged(); + if(((MwCXX::NumberEntry*)user)->ChangedHandler != NULL) ((MwCXX::NumberEntry*)user)->ChangedHandler((MwCXX::NumberEntry*)user); } void MwCXX::NumberEntry::RegisterHandlers() { MwAddUserHandler(this->widget, MwNactivateHandler, __OnActivate, (void*)this); MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ActivateHandler = NULL; + this->ChangedHandler = NULL; } diff --git a/src/widget/opengl.cc b/src/widget/opengl.cc index d566ef7..b93feb1 100644 --- a/src/widget/opengl.cc +++ b/src/widget/opengl.cc @@ -1,11 +1,13 @@ #define MW_OPENGL_NO_INCLUDE #include -MwCXX::OpenGL::OpenGL(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::OpenGL::OpenGL(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/progressbar.cc b/src/widget/progressbar.cc index 492c0d6..86007f4 100644 --- a/src/widget/progressbar.cc +++ b/src/widget/progressbar.cc @@ -1,10 +1,12 @@ #include -MwCXX::ProgressBar::ProgressBar(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::ProgressBar::ProgressBar(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/radiobox.cc b/src/widget/radiobox.cc index fcb6517..36eb700 100644 --- a/src/widget/radiobox.cc +++ b/src/widget/radiobox.cc @@ -1,10 +1,12 @@ #include -MwCXX::RadioBox::RadioBox(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::RadioBox::RadioBox(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -18,8 +20,11 @@ void MwCXX::RadioBox::SetChecked(int value) { static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::RadioBox*)user)->OnChanged(); + if(((MwCXX::RadioBox*)user)->ChangedHandler != NULL) ((MwCXX::RadioBox*)user)->ChangedHandler((MwCXX::RadioBox*)user); } void MwCXX::RadioBox::RegisterHandlers() { MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ChangedHandler = NULL; } diff --git a/src/widget/scrollbar.cc b/src/widget/scrollbar.cc index 98d0ae3..34337cc 100644 --- a/src/widget/scrollbar.cc +++ b/src/widget/scrollbar.cc @@ -1,10 +1,12 @@ #include -MwCXX::ScrollBar::ScrollBar(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::ScrollBar::ScrollBar(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -58,8 +60,11 @@ void MwCXX::ScrollBar::SetOrientation(int value) { static void __OnChanged(MwWidget handle, void* user, void* call) { ((MwCXX::ScrollBar*)user)->OnChanged(); + if(((MwCXX::ScrollBar*)user)->ChangedHandler != NULL) ((MwCXX::ScrollBar*)user)->ChangedHandler((MwCXX::ScrollBar*)user); } void MwCXX::ScrollBar::RegisterHandlers() { MwAddUserHandler(this->widget, MwNchangedHandler, __OnChanged, (void*)this); + + this->ChangedHandler = NULL; } diff --git a/src/widget/submenu.cc b/src/widget/submenu.cc index 516ced8..2c14776 100644 --- a/src/widget/submenu.cc +++ b/src/widget/submenu.cc @@ -1,10 +1,12 @@ #include -MwCXX::SubMenu::SubMenu(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::SubMenu::SubMenu(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/treeview.cc b/src/widget/treeview.cc index f9dafbc..5d4d8ec 100644 --- a/src/widget/treeview.cc +++ b/src/widget/treeview.cc @@ -1,10 +1,12 @@ #include -MwCXX::TreeView::TreeView(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::TreeView::TreeView(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } @@ -26,8 +28,11 @@ void MwCXX::TreeView::SetSingleClickSelectable(int value) { static void __OnTreeViewActivate(MwWidget handle, void* user, void* call) { ((MwCXX::TreeView*)user)->OnTreeViewActivate((void*)call); + if(((MwCXX::TreeView*)user)->TreeViewActivateHandler != NULL) ((MwCXX::TreeView*)user)->TreeViewActivateHandler((MwCXX::TreeView*)user, (void*)call); } void MwCXX::TreeView::RegisterHandlers() { MwAddUserHandler(this->widget, MwNtreeViewActivateHandler, __OnTreeViewActivate, (void*)this); + + this->TreeViewActivateHandler = NULL; } diff --git a/src/widget/viewport.cc b/src/widget/viewport.cc index 918ce69..5842042 100644 --- a/src/widget/viewport.cc +++ b/src/widget/viewport.cc @@ -1,10 +1,12 @@ #include -MwCXX::Viewport::Viewport(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Viewport::Viewport(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/vulkan.cc b/src/widget/vulkan.cc index dcc81cb..abce262 100644 --- a/src/widget/vulkan.cc +++ b/src/widget/vulkan.cc @@ -1,11 +1,13 @@ #define MW_VULKAN_NO_INCLUDE #include -MwCXX::Vulkan::Vulkan(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Vulkan::Vulkan(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/src/widget/window.cc b/src/widget/window.cc index ec6063d..f0e85d0 100644 --- a/src/widget/window.cc +++ b/src/widget/window.cc @@ -1,10 +1,12 @@ #include -MwCXX::Window::Window(MwWidget widget, MwCXX::Base* parent) : MwCXX::Base(widget, parent) { +MwCXX::Window::Window(MwWidget widget, MwCXX::Base* parent) + : MwCXX::Base(widget, parent) { 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) { +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(); } diff --git a/test.cxx b/test.cxx index f7af5af..474f24d 100644 --- a/test.cxx +++ b/test.cxx @@ -5,12 +5,18 @@ #include +static void close_msg(MwCXX::Button* button){ + delete button->GetParent(); +} + class MyButton : public MwCXX::Button { protected: void OnActivate() { - std::cout << "Hello" << std::endl; + MwCXX::Window* msg; - MwCXX::MessageBox(this->GetParent(), "Hello", "Hello world", MwMB_BUTTONOK | MwMB_ICONNEWS); + msg = MwCXX::MessageBox(this->GetParent(), "Hello", "Hello world", MwMB_BUTTONOK | MwMB_ICONNEWS); + + MwCXX::MessageBoxGetChild(msg, MwMB_BUTTONOK)->ActivateHandler = close_msg; } public: