diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..e168365 --- /dev/null +++ b/.clang-format @@ -0,0 +1,21 @@ +--- +UseTab: Always +TabWidth: 8 +AlignConsecutiveAssignments: + Enabled: true +AlignConsecutiveDeclarations: + Enabled: true +IndentAccessModifiers: true +NamespaceIndentation: All +IndentWidth: 8 +PointerAlignment: Left +ColumnLimit: 0 +AllowShortIfStatementsOnASingleLine: Always +AllowShortBlocksOnASingleLine: Never +AllowShortFunctionsOnASingleLine: Empty +AllowShortLoopsOnASingleLine: true +SpaceBeforeParens: Never +AlignEscapedNewlines: DontAlign +SortIncludes: false +AllowShortEnumsOnASingleLine: false +#IndentPPDirectives: AfterHash diff --git a/Makefile b/Makefile index 6498958..882e2cd 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,26 @@ MILSKO = ../milsko XEMIL = ../xemil -CXX = g++ -std=c++98 +CXX = g++ LIB = lib SO = .so EXEC = -.PHONY: all clean +.PHONY: all format clean .SUFFIXES: .cxx .o all: libMwCXX$(SO) +format: + clang-format --verbose -i `find . -name "*.cxx" -or -name "*.h"` + +OBJS = src/core.o src/widget/base.o include objs.mk +src/widget/base.o: src/widget/base.cxx src/widget/baseauto.cxx + bindgen$(EXEC): bindgen.o $(CXX) -L$(XEMIL)/lib -L$(XEMIL)/src -o $@ bindgen.o -lxemil @@ -22,7 +28,7 @@ libMwCXX$(SO): $(OBJS) $(CXX) -shared -L$(MILSKO)/lib -L$(MILSKO)/src -o $@ $(OBJS) -lMw .cxx.o: - $(CXX) -c -I$(MILSKO)/include -I$(XEMIL)/include -o $@ $< + $(CXX) -fPIC -c -Iinclude -I$(MILSKO)/include -I$(XEMIL)/include -o $@ $< clean: - rm -f *.so *.dll *.o *.exe bindgen.exe + rm -f *.so *.dll *.o */*.o */*/*.o *.exe bindgen.exe diff --git a/bindgen.cxx b/bindgen.cxx index 4421db4..b70282b 100644 --- a/bindgen.cxx +++ b/bindgen.cxx @@ -3,92 +3,387 @@ #include #include #include +#include +#include -struct property { - std::string type; - std::string struct_name; - int common; +struct typeinfo { + std::string type; + std::string name; + std::string struct_name; + int pointer; }; -std::ofstream objs; +struct property { + typeinfo type; + int common; + typeinfo arg_type; +}; + +std::map files; std::map props; -std::map types; -static std::string prop_type(std::string name){ - if(types.find(props[name].type) == types.end()) return "V" + name; +std::locale locale; - return types[props[name].type] + name; +static std::string get_ctype(typeinfo type, int name = 1) { + std::string ret = ""; + + if(type.type == "integer") { + ret += "int"; + } else if(type.type == "string") { + ret += "MwCXX::String"; + } else if(type.type == "pixmap") { + ret += "MwLLPixmap"; + } else if(type.type == "pointer") { + ret += "void*"; + } else if(type.type == "struct") { + ret += type.struct_name; + } + + if(type.pointer) ret += "*"; + + if(name && type.name != "") { + ret += " " + type.name; + } + + return ret; } -static void scan_property(xl_node_t* node){ - property prop; - char* s; +static std::string get_type(typeinfo type) { + if(type.type == "integer") { + return "Integer"; + } else if(type.type == "string") { + return "Text"; + } + + return "Void"; +} + +static std::string uppercase(std::string str) { + std::string r = str; + + for(int i = 0; i < r.size(); i++) { + r[i] = std::toupper(r[i], locale); + } + + return r; +} + +static std::string lowercase(std::string str) { + std::string r = str; + + for(int i = 0; i < r.size(); i++) { + r[i] = std::tolower(r[i], locale); + } + + return r; +} + +#define ATTR_TO_BOOL(node, x) ((s = xl_get_attribute(node, (x))) != NULL) && (strcmp(s, "no") != 0); + +static typeinfo xml_to_type(xl_node_t* node) { + char* s; + typeinfo ret; + + ret.type = node->name; + ret.name = ((s = xl_get_attribute(node, "name")) != NULL) ? s : ""; + ret.struct_name = ((s = xl_get_attribute(node, "defname")) != NULL) ? s : ""; + ret.pointer = ATTR_TO_BOOL(node, "pointer"); + + return ret; +} + +static std::string first_upper(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; if(node->type != XL_NODE_NODE) return; - prop.type = node->name; - prop.struct_name = ((s = xl_get_attribute(node, "defname")) != NULL) ? s : ""; - prop.common = ((s = xl_get_attribute(node, "common")) != NULL) && (strcmp(s, "yes") == 0); + 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; } -static void scan_properties(xl_node_t* node){ +static void scan_properties(xl_node_t* node) { xl_node_t* child = node->first_child; - while(child != NULL){ + while(child != NULL) { scan_property(child); child = child->next; } } -int main(int argc, char** argv){ - xemil_t* h; - int fail = 0; +static std::string widget_property_header(std::string name, std::string indent = "") { + std::stringstream strm; - if(argc < 2){ + 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; + + return strm.str(); +} + +static std::string scan_widget_property_header(xl_node_t* node, std::string indent) { + xl_node_t* child = node->first_child; + + if(node->type != XL_NODE_NODE) return ""; + + return widget_property_header(xl_get_attribute(node, "name"), indent); +} + +static std::string scan_widget_properties_header(xl_node_t* node, std::string indent) { + std::string r = ""; + xl_node_t* child = node->first_child; + + while(child != NULL) { + r += scan_widget_property_header(child, indent); + + child = child->next; + } + + return r; +} + +static std::string scan_widget_property_source(xl_node_t* node, std::string name) { + xl_node_t* child = node->first_child; + + if(node->type != XL_NODE_NODE) return ""; + + return widget_property_source(name, xl_get_attribute(node, "name")); +} + +static std::string scan_widget_properties_source(xl_node_t* node, std::string name) { + std::string r = ""; + xl_node_t* child = node->first_child; + + while(child != NULL) { + r += scan_widget_property_source(child, name); + + child = child->next; + } + + return r; +} + +static void scan_widget(xl_node_t* node) { + std::string name; + xl_node_t** nodes; + int i; + + if(node->type != XL_NODE_NODE) return; + + nodes = xl_get_path(node, "properties"); + + name = xl_get_attribute(node, "name"); + +#define OFS files["W" + name + ".h"] + + OFS = std::ofstream("include/MwCXX/Widget/" + name + ".h"); + + OFS << "#ifndef __MWCXX_WIDGET_" + uppercase(name) + "_H__" << std::endl; + OFS << "#define __MWCXX_WIDGET_" + uppercase(name) + "_H__" << std::endl; + OFS << std::endl; + OFS << "#include " << std::endl; + OFS << "#include " << std::endl; + OFS << std::endl; + OFS << "#include " << std::endl; + OFS << std::endl; + + OFS << "namespace MwCXX {" << std::endl; + OFS << " class " + name + " : public MwCXX::Base {" << 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) { + std::string r = ""; + + for(i = 0; nodes[i] != NULL; i++) { + r += scan_widget_properties_header(nodes[i], "\t\t\t"); + } + + if(r != "") OFS << std::endl + << r; + } + + OFS << " };" << std::endl; + OFS << "}; // namespace MwCXX" << std::endl; + + OFS << std::endl; + OFS << "#endif" << std::endl; + +#undef OFS + +#define OFS files["W" + name + ".cxx"] + + OFS = std::ofstream("src/widget/" + lowercase(name) + ".cxx"); + + if(name == "OpenGL" || name == "Vulkan") OFS << "#define MW_" + uppercase(name) + "_NO_INCLUDE" << std::endl; + + OFS << "#include " << std::endl; + OFS << std::endl; + + OFS << "MwCXX::" + name + "::" + name + "(MwWidget widget) : MwCXX::Base(widget) {" << 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 << "}" << std::endl; + OFS << std::endl; + + if(nodes != NULL) { + for(i = 0; nodes[i] != NULL; i++) { + OFS << scan_widget_properties_source(nodes[i], name); + } + } + +#undef OFS + + if(nodes != NULL) free(nodes); + + files["objs"] << " src/widget/" + lowercase(name) + ".o"; +} + +static void scan_widgets(xl_node_t* node) { + xl_node_t* child = node->first_child; + + while(child != NULL) { + scan_widget(child); + + child = child->next; + } +} + +static void base_widget() { + std::string r = ""; + +#define OFS files["WBaseAuto.h"] + + OFS = std::ofstream("include/MwCXX/Widget/BaseAuto.h"); + + for(auto p = props.begin(); p != props.end(); p++) { + if(!p->second.common) continue; + + OFS << widget_property_header(p->first); + } + +#undef OFS + +#define OFS files["WBaseAuto.cxx"] + + OFS = std::ofstream("src/widget/baseauto.cxx"); + + OFS << "#include " << std::endl; + + for(auto p = props.begin(); p != props.end(); p++) { + if(!p->second.common) continue; + + r += widget_property_source("Base", p->first); + } + + if(r != "") OFS << std::endl + << r; + +#undef OFS + + files["objs"] << " src/widget/baseauto.o"; +} + +int main(int argc, char** argv) { + xemil_t* h; + int fail = 0; + + if(argc < 2) { printf("Usage: %s XML\n", argv[0]); return 1; } + locale = std::locale::classic(); + h = xl_open_file(argv[1]); - if(h != NULL){ + if(h != NULL) { h->param.new_text = 1; if(xl_parse(h)) { xl_node_t** nodes; - int i; - objs = std::ofstream("objs.mk"); + files["objs"] = std::ofstream("objs.mk"); - objs << "OBJS = "; + files["objs"] << "OBJS +="; - types["integer"] = "I"; - types["string" ] = "S"; - types["handler"] = "C"; - - if((nodes = xl_get_path(h->root, "properties")) != NULL){ - for(i = 0; nodes[i] != NULL; i++){ + if((nodes = xl_get_path(h->root, "properties")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { scan_properties(nodes[i]); } + + free(nodes); } - objs << std::endl; + base_widget(); - objs.close(); - }else{ + if((nodes = xl_get_path(h->root, "widgets")) != NULL) { + for(int i = 0; nodes[i] != NULL; i++) { + scan_widgets(nodes[i]); + } + + free(nodes); + } + + files["objs"] << std::endl; + + for(auto f = files.begin(); f != files.end(); f++) { + f->second.close(); + } + } else { fail = 1; } xl_close(h); - }else{ + } else { fail = 1; } - if(fail){ + if(fail) { fprintf(stderr, "Failed to parse XML\n"); return 1; diff --git a/include/MwCXX/Core.h b/include/MwCXX/Core.h new file mode 100644 index 0000000..5d8dff0 --- /dev/null +++ b/include/MwCXX/Core.h @@ -0,0 +1,13 @@ +#ifndef __MWCXX_CORE_H__ +#define __MWCXX_CORE_H__ + +#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) + +namespace MwCXX { + void Init(); +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/MachDep.h b/include/MwCXX/MachDep.h new file mode 100644 index 0000000..3413d95 --- /dev/null +++ b/include/MwCXX/MachDep.h @@ -0,0 +1,18 @@ +#ifndef __MWCXX_MACHDEP_H__ +#define __MWCXX_MACHDEP_H__ + +#include + +#include + +// #define MWCXX_USE_C_STRING + +namespace MwCXX { +#ifdef MWCXX_USE_C_STRING + typedef char* String; +#else + typedef std::string String; +#endif +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Base.h b/include/MwCXX/Widget/Base.h new file mode 100644 index 0000000..0601b0e --- /dev/null +++ b/include/MwCXX/Widget/Base.h @@ -0,0 +1,21 @@ +#ifndef __MWCXX_WIDGET_BASE_H__ +#define __MWCXX_WIDGET_BASE_H__ + +#include + +namespace MwCXX { + class Base { + protected: + MwWidget widget; + + public: + Base(MwWidget widget); + Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + void Loop(); + +#include + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/BaseAuto.h b/include/MwCXX/Widget/BaseAuto.h new file mode 100644 index 0000000..a49af1d --- /dev/null +++ b/include/MwCXX/Widget/BaseAuto.h @@ -0,0 +1,58 @@ +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); + GetClipboard(); +void SetClipboard( value); + GetDarkTheme(); +void SetDarkTheme( value); +int GetFixedSize(); +void SetFixedSize(int value); + GetFocusIn(); +void SetFocusIn( value); + GetFocusOut(); +void SetFocusOut( 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); + GetKey(); +void SetKey( value); + GetKeyRelease(); +void SetKeyRelease( value); +int GetModernLook(); +void SetModernLook(int value); + GetMouseDown(); +void SetMouseDown( value); + GetMouseMove(); +void SetMouseMove( value); + GetMouseUp(); +void SetMouseUp( value); +int GetRatio(); +void SetRatio(int value); + GetResize(); +void SetResize( value); +MwCXX::String GetSubBackground(); +void SetSubBackground(MwCXX::String value); +MwCXX::String GetSubForeground(); +void SetSubForeground(MwCXX::String value); + GetTick(); +void SetTick( 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); diff --git a/include/MwCXX/Widget/Box.h b/include/MwCXX/Widget/Box.h new file mode 100644 index 0000000..50e2964 --- /dev/null +++ b/include/MwCXX/Widget/Box.h @@ -0,0 +1,28 @@ +#ifndef __MWCXX_WIDGET_BOX_H__ +#define __MWCXX_WIDGET_BOX_H__ + +#include +#include + +#include + +namespace MwCXX { + class Box : public MwCXX::Base { + public: + Box(MwWidget widget); + Box(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetOrientation(); + void SetOrientation(int value); + int GetMargin(); + void SetMargin(int value); + int GetPadding(); + void SetPadding(int value); + int GetHasBorder(); + void SetHasBorder(int value); + int GetInverted(); + void SetInverted(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Button.h b/include/MwCXX/Widget/Button.h new file mode 100644 index 0000000..0856ab8 --- /dev/null +++ b/include/MwCXX/Widget/Button.h @@ -0,0 +1,28 @@ +#ifndef __MWCXX_WIDGET_BUTTON_H__ +#define __MWCXX_WIDGET_BUTTON_H__ + +#include +#include + +#include + +namespace MwCXX { + class Button : public MwCXX::Base { + public: + Button(MwWidget widget); + Button(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/CheckBox.h b/include/MwCXX/Widget/CheckBox.h new file mode 100644 index 0000000..ad9a06a --- /dev/null +++ b/include/MwCXX/Widget/CheckBox.h @@ -0,0 +1,20 @@ +#ifndef __MWCXX_WIDGET_CHECKBOX_H__ +#define __MWCXX_WIDGET_CHECKBOX_H__ + +#include +#include + +#include + +namespace MwCXX { + class CheckBox : public MwCXX::Base { + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/ComboBox.h b/include/MwCXX/Widget/ComboBox.h new file mode 100644 index 0000000..f13e5bd --- /dev/null +++ b/include/MwCXX/Widget/ComboBox.h @@ -0,0 +1,22 @@ +#ifndef __MWCXX_WIDGET_COMBOBOX_H__ +#define __MWCXX_WIDGET_COMBOBOX_H__ + +#include +#include + +#include + +namespace MwCXX { + class ComboBox : public MwCXX::Base { + public: + ComboBox(MwWidget widget); + ComboBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetAreaShown(); + void SetAreaShown(int value); + int GetValue(); + void SetValue(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Entry.h b/include/MwCXX/Widget/Entry.h new file mode 100644 index 0000000..553186d --- /dev/null +++ b/include/MwCXX/Widget/Entry.h @@ -0,0 +1,22 @@ +#ifndef __MWCXX_WIDGET_ENTRY_H__ +#define __MWCXX_WIDGET_ENTRY_H__ + +#include +#include + +#include + +namespace MwCXX { + class Entry : public MwCXX::Base { + public: + Entry(MwWidget widget); + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Frame.h b/include/MwCXX/Widget/Frame.h new file mode 100644 index 0000000..7d1223b --- /dev/null +++ b/include/MwCXX/Widget/Frame.h @@ -0,0 +1,22 @@ +#ifndef __MWCXX_WIDGET_FRAME_H__ +#define __MWCXX_WIDGET_FRAME_H__ + +#include +#include + +#include + +namespace MwCXX { + class Frame : public MwCXX::Base { + public: + Frame(MwWidget widget); + Frame(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetHasBorder(); + void SetHasBorder(int value); + int GetInverted(); + void SetInverted(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Image.h b/include/MwCXX/Widget/Image.h new file mode 100644 index 0000000..ab4ac50 --- /dev/null +++ b/include/MwCXX/Widget/Image.h @@ -0,0 +1,26 @@ +#ifndef __MWCXX_WIDGET_IMAGE_H__ +#define __MWCXX_WIDGET_IMAGE_H__ + +#include +#include + +#include + +namespace MwCXX { + class Image : public MwCXX::Base { + public: + Image(MwWidget widget); + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Label.h b/include/MwCXX/Widget/Label.h new file mode 100644 index 0000000..fdb4ce7 --- /dev/null +++ b/include/MwCXX/Widget/Label.h @@ -0,0 +1,30 @@ +#ifndef __MWCXX_WIDGET_LABEL_H__ +#define __MWCXX_WIDGET_LABEL_H__ + +#include +#include + +#include + +namespace MwCXX { + class Label : public MwCXX::Base { + public: + Label(MwWidget widget); + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/ListBox.h b/include/MwCXX/Widget/ListBox.h new file mode 100644 index 0000000..b336a4d --- /dev/null +++ b/include/MwCXX/Widget/ListBox.h @@ -0,0 +1,24 @@ +#ifndef __MWCXX_WIDGET_LISTBOX_H__ +#define __MWCXX_WIDGET_LISTBOX_H__ + +#include +#include + +#include + +namespace MwCXX { + class ListBox : public MwCXX::Base { + public: + ListBox(MwWidget widget); + ListBox(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetLeftPadding(); + void SetLeftPadding(int value); + int GetHasHeading(); + void SetHasHeading(int value); + int GetSingleClickSelectable(); + void SetSingleClickSelectable(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Menu.h b/include/MwCXX/Widget/Menu.h new file mode 100644 index 0000000..2521fcd --- /dev/null +++ b/include/MwCXX/Widget/Menu.h @@ -0,0 +1,17 @@ +#ifndef __MWCXX_WIDGET_MENU_H__ +#define __MWCXX_WIDGET_MENU_H__ + +#include +#include + +#include + +namespace MwCXX { + class Menu : public MwCXX::Base { + public: + Menu(MwWidget widget); + Menu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/NumberEntry.h b/include/MwCXX/Widget/NumberEntry.h new file mode 100644 index 0000000..02ea016 --- /dev/null +++ b/include/MwCXX/Widget/NumberEntry.h @@ -0,0 +1,20 @@ +#ifndef __MWCXX_WIDGET_NUMBERENTRY_H__ +#define __MWCXX_WIDGET_NUMBERENTRY_H__ + +#include +#include + +#include + +namespace MwCXX { + class NumberEntry : public MwCXX::Base { + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/OpenGL.h b/include/MwCXX/Widget/OpenGL.h new file mode 100644 index 0000000..93f6cae --- /dev/null +++ b/include/MwCXX/Widget/OpenGL.h @@ -0,0 +1,17 @@ +#ifndef __MWCXX_WIDGET_OPENGL_H__ +#define __MWCXX_WIDGET_OPENGL_H__ + +#include +#include + +#include + +namespace MwCXX { + class OpenGL : public MwCXX::Base { + public: + OpenGL(MwWidget widget); + OpenGL(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/ProgressBar.h b/include/MwCXX/Widget/ProgressBar.h new file mode 100644 index 0000000..799fb8a --- /dev/null +++ b/include/MwCXX/Widget/ProgressBar.h @@ -0,0 +1,24 @@ +#ifndef __MWCXX_WIDGET_PROGRESSBAR_H__ +#define __MWCXX_WIDGET_PROGRESSBAR_H__ + +#include +#include + +#include + +namespace MwCXX { + class ProgressBar : public MwCXX::Base { + public: + ProgressBar(MwWidget widget); + ProgressBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetMinValue(); + void SetMinValue(int value); + int GetMaxValue(); + void SetMaxValue(int value); + int GetValue(); + void SetValue(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/RadioBox.h b/include/MwCXX/Widget/RadioBox.h new file mode 100644 index 0000000..e72fada --- /dev/null +++ b/include/MwCXX/Widget/RadioBox.h @@ -0,0 +1,20 @@ +#ifndef __MWCXX_WIDGET_RADIOBOX_H__ +#define __MWCXX_WIDGET_RADIOBOX_H__ + +#include +#include + +#include + +namespace MwCXX { + class RadioBox : public MwCXX::Base { + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/ScrollBar.h b/include/MwCXX/Widget/ScrollBar.h new file mode 100644 index 0000000..2ed8fee --- /dev/null +++ b/include/MwCXX/Widget/ScrollBar.h @@ -0,0 +1,30 @@ +#ifndef __MWCXX_WIDGET_SCROLLBAR_H__ +#define __MWCXX_WIDGET_SCROLLBAR_H__ + +#include +#include + +#include + +namespace MwCXX { + class ScrollBar : public MwCXX::Base { + public: + ScrollBar(MwWidget widget); + ScrollBar(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetShowArrows(); + void SetShowArrows(int value); + int GetAreaShown(); + void SetAreaShown(int value); + int GetValue(); + void SetValue(int value); + int GetMinValue(); + void SetMinValue(int value); + int GetMaxValue(); + void SetMaxValue(int value); + int GetOrientation(); + void SetOrientation(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/SubMenu.h b/include/MwCXX/Widget/SubMenu.h new file mode 100644 index 0000000..88e4a29 --- /dev/null +++ b/include/MwCXX/Widget/SubMenu.h @@ -0,0 +1,20 @@ +#ifndef __MWCXX_WIDGET_SUBMENU_H__ +#define __MWCXX_WIDGET_SUBMENU_H__ + +#include +#include + +#include + +namespace MwCXX { + class SubMenu : public MwCXX::Base { + public: + SubMenu(MwWidget widget); + SubMenu(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetLeftPadding(); + void SetLeftPadding(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/TreeView.h b/include/MwCXX/Widget/TreeView.h new file mode 100644 index 0000000..b63b2e3 --- /dev/null +++ b/include/MwCXX/Widget/TreeView.h @@ -0,0 +1,22 @@ +#ifndef __MWCXX_WIDGET_TREEVIEW_H__ +#define __MWCXX_WIDGET_TREEVIEW_H__ + +#include +#include + +#include + +namespace MwCXX { + class TreeView : public MwCXX::Base { + public: + TreeView(MwWidget widget); + TreeView(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + + int GetLeftPadding(); + void SetLeftPadding(int value); + int GetSingleClickSelectable(); + void SetSingleClickSelectable(int value); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Viewport.h b/include/MwCXX/Widget/Viewport.h new file mode 100644 index 0000000..64242dd --- /dev/null +++ b/include/MwCXX/Widget/Viewport.h @@ -0,0 +1,17 @@ +#ifndef __MWCXX_WIDGET_VIEWPORT_H__ +#define __MWCXX_WIDGET_VIEWPORT_H__ + +#include +#include + +#include + +namespace MwCXX { + class Viewport : public MwCXX::Base { + public: + Viewport(MwWidget widget); + Viewport(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Vulkan.h b/include/MwCXX/Widget/Vulkan.h new file mode 100644 index 0000000..00f761b --- /dev/null +++ b/include/MwCXX/Widget/Vulkan.h @@ -0,0 +1,17 @@ +#ifndef __MWCXX_WIDGET_VULKAN_H__ +#define __MWCXX_WIDGET_VULKAN_H__ + +#include +#include + +#include + +namespace MwCXX { + class Vulkan : public MwCXX::Base { + public: + Vulkan(MwWidget widget); + Vulkan(MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + }; +}; // namespace MwCXX + +#endif diff --git a/include/MwCXX/Widget/Window.h b/include/MwCXX/Widget/Window.h new file mode 100644 index 0000000..af48bc7 --- /dev/null +++ b/include/MwCXX/Widget/Window.h @@ -0,0 +1,30 @@ +#ifndef __MWCXX_WIDGET_WINDOW_H__ +#define __MWCXX_WIDGET_WINDOW_H__ + +#include +#include + +#include + +namespace MwCXX { + class Window : public MwCXX::Base { + public: + Window(MwWidget widget); + 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); + }; +}; // namespace MwCXX + +#endif diff --git a/objs.mk b/objs.mk index 36cdd1d..c466076 100644 --- a/objs.mk +++ b/objs.mk @@ -1 +1 @@ -OBJS = +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 diff --git a/src/core.cxx b/src/core.cxx new file mode 100644 index 0000000..4af022b --- /dev/null +++ b/src/core.cxx @@ -0,0 +1,5 @@ +#include + +void MwCXX::Init() { + MwLibraryInit(); +} diff --git a/src/widget/base.cxx b/src/widget/base.cxx new file mode 100644 index 0000000..d1e226e --- /dev/null +++ b/src/widget/base.cxx @@ -0,0 +1,17 @@ +#include + +MwCXX::Base::Base(MwWidget widget){ + this->widget = widget; +} + +MwCXX::Base::Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height){ +#ifdef MWCXX_USE_C_STRING + this->widget = MwCreateWidget(widget_class, name, parent == NULL ? NULL : parent->widget, x, y, width, height); +#else + this->widget = MwCreateWidget(widget_class, name.c_str(), parent == NULL ? NULL : parent->widget, x, y, width, height); +#endif +} + +void MwCXX::Base::Loop() { + MwLoop(this->widget); +} diff --git a/src/widget/baseauto.cxx b/src/widget/baseauto.cxx new file mode 100644 index 0000000..0ab0aa2 --- /dev/null +++ b/src/widget/baseauto.cxx @@ -0,0 +1,250 @@ +#include + +MwCXX::String MwCXX::Base::GetBackground() { + return (MwCXX::String)MwGetText(this->widget, MwNbackground); +} + +void MwCXX::Base::SetBackground(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNbackground, value.c_str()); +#else + MwSetText(this->widget, MwNbackground, (MwCXX::String)value); +#endif +} + +MwLLPixmap MwCXX::Base::GetBackgroundPixmap() { + return (MwLLPixmap)MwGetVoid(this->widget, MwNbackgroundPixmap); +} + +void MwCXX::Base::SetBackgroundPixmap(MwLLPixmap value) { + MwSetVoid(this->widget, MwNbackgroundPixmap, (MwLLPixmap)value); +} + +int MwCXX::Base::GetBitmapFont() { + return (int)MwGetInteger(this->widget, MwNbitmapFont); +} + +void MwCXX::Base::SetBitmapFont(int value) { + MwSetInteger(this->widget, MwNbitmapFont, (int)value); +} + +int MwCXX::Base::GetBorderWidth() { + return (int)MwGetInteger(this->widget, MwNborderWidth); +} + +void MwCXX::Base::SetBorderWidth(int value) { + MwSetInteger(this->widget, MwNborderWidth, (int)value); +} + + MwCXX::Base::GetClipboard() { + return ()MwGetVoid(this->widget, MwNclipboard); +} + +void MwCXX::Base::SetClipboard( value) { + MwSetVoid(this->widget, MwNclipboard, ()value); +} + + MwCXX::Base::GetDarkTheme() { + return ()MwGetVoid(this->widget, MwNdarkTheme); +} + +void MwCXX::Base::SetDarkTheme( value) { + MwSetVoid(this->widget, MwNdarkTheme, ()value); +} + +int MwCXX::Base::GetFixedSize() { + return (int)MwGetInteger(this->widget, MwNfixedSize); +} + +void MwCXX::Base::SetFixedSize(int value) { + MwSetInteger(this->widget, MwNfixedSize, (int)value); +} + + MwCXX::Base::GetFocusIn() { + return ()MwGetVoid(this->widget, MwNfocusIn); +} + +void MwCXX::Base::SetFocusIn( value) { + MwSetVoid(this->widget, MwNfocusIn, ()value); +} + + MwCXX::Base::GetFocusOut() { + return ()MwGetVoid(this->widget, MwNfocusOut); +} + +void MwCXX::Base::SetFocusOut( value) { + MwSetVoid(this->widget, MwNfocusOut, ()value); +} + +int MwCXX::Base::GetForceInverted() { + return (int)MwGetInteger(this->widget, MwNforceInverted); +} + +void MwCXX::Base::SetForceInverted(int value) { + MwSetInteger(this->widget, MwNforceInverted, (int)value); +} + +MwCXX::String MwCXX::Base::GetForeground() { + return (MwCXX::String)MwGetText(this->widget, MwNforeground); +} + +void MwCXX::Base::SetForeground(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNforeground, value.c_str()); +#else + MwSetText(this->widget, MwNforeground, (MwCXX::String)value); +#endif +} + +int MwCXX::Base::GetHeight() { + return (int)MwGetInteger(this->widget, MwNheight); +} + +void MwCXX::Base::SetHeight(int value) { + MwSetInteger(this->widget, MwNheight, (int)value); +} + +int MwCXX::Base::GetIsRounded() { + return (int)MwGetInteger(this->widget, MwNisRounded); +} + +void MwCXX::Base::SetIsRounded(int value) { + MwSetInteger(this->widget, MwNisRounded, (int)value); +} + + MwCXX::Base::GetKey() { + return ()MwGetVoid(this->widget, MwNkey); +} + +void MwCXX::Base::SetKey( value) { + MwSetVoid(this->widget, MwNkey, ()value); +} + + MwCXX::Base::GetKeyRelease() { + return ()MwGetVoid(this->widget, MwNkeyRelease); +} + +void MwCXX::Base::SetKeyRelease( value) { + MwSetVoid(this->widget, MwNkeyRelease, ()value); +} + +int MwCXX::Base::GetModernLook() { + return (int)MwGetInteger(this->widget, MwNmodernLook); +} + +void MwCXX::Base::SetModernLook(int value) { + MwSetInteger(this->widget, MwNmodernLook, (int)value); +} + + MwCXX::Base::GetMouseDown() { + return ()MwGetVoid(this->widget, MwNmouseDown); +} + +void MwCXX::Base::SetMouseDown( value) { + MwSetVoid(this->widget, MwNmouseDown, ()value); +} + + MwCXX::Base::GetMouseMove() { + return ()MwGetVoid(this->widget, MwNmouseMove); +} + +void MwCXX::Base::SetMouseMove( value) { + MwSetVoid(this->widget, MwNmouseMove, ()value); +} + + MwCXX::Base::GetMouseUp() { + return ()MwGetVoid(this->widget, MwNmouseUp); +} + +void MwCXX::Base::SetMouseUp( value) { + MwSetVoid(this->widget, MwNmouseUp, ()value); +} + +int MwCXX::Base::GetRatio() { + return (int)MwGetInteger(this->widget, MwNratio); +} + +void MwCXX::Base::SetRatio(int value) { + MwSetInteger(this->widget, MwNratio, (int)value); +} + + MwCXX::Base::GetResize() { + return ()MwGetVoid(this->widget, MwNresize); +} + +void MwCXX::Base::SetResize( value) { + MwSetVoid(this->widget, MwNresize, ()value); +} + +MwCXX::String MwCXX::Base::GetSubBackground() { + return (MwCXX::String)MwGetText(this->widget, MwNsubBackground); +} + +void MwCXX::Base::SetSubBackground(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNsubBackground, value.c_str()); +#else + MwSetText(this->widget, MwNsubBackground, (MwCXX::String)value); +#endif +} + +MwCXX::String MwCXX::Base::GetSubForeground() { + return (MwCXX::String)MwGetText(this->widget, MwNsubForeground); +} + +void MwCXX::Base::SetSubForeground(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNsubForeground, value.c_str()); +#else + MwSetText(this->widget, MwNsubForeground, (MwCXX::String)value); +#endif +} + + MwCXX::Base::GetTick() { + return ()MwGetVoid(this->widget, MwNtick); +} + +void MwCXX::Base::SetTick( value) { + MwSetVoid(this->widget, MwNtick, ()value); +} + +int MwCXX::Base::GetUseMonospace() { + return (int)MwGetInteger(this->widget, MwNuseMonospace); +} + +void MwCXX::Base::SetUseMonospace(int value) { + MwSetInteger(this->widget, MwNuseMonospace, (int)value); +} + +int MwCXX::Base::GetWaitMS() { + return (int)MwGetInteger(this->widget, MwNwaitMS); +} + +void MwCXX::Base::SetWaitMS(int value) { + MwSetInteger(this->widget, MwNwaitMS, (int)value); +} + +int MwCXX::Base::GetWidth() { + return (int)MwGetInteger(this->widget, MwNwidth); +} + +void MwCXX::Base::SetWidth(int value) { + MwSetInteger(this->widget, MwNwidth, (int)value); +} + +int MwCXX::Base::GetX() { + return (int)MwGetInteger(this->widget, MwNx); +} + +void MwCXX::Base::SetX(int value) { + MwSetInteger(this->widget, MwNx, (int)value); +} + +int MwCXX::Base::GetY() { + return (int)MwGetInteger(this->widget, MwNy); +} + +void MwCXX::Base::SetY(int value) { + MwSetInteger(this->widget, MwNy, (int)value); +} + diff --git a/src/widget/box.cxx b/src/widget/box.cxx new file mode 100644 index 0000000..65a0005 --- /dev/null +++ b/src/widget/box.cxx @@ -0,0 +1,48 @@ +#include + +MwCXX::Box::Box(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::Box::GetOrientation() { + return (int)MwGetInteger(this->widget, MwNorientation); +} + +void MwCXX::Box::SetOrientation(int value) { + MwSetInteger(this->widget, MwNorientation, (int)value); +} + +int MwCXX::Box::GetMargin() { + return (int)MwGetInteger(this->widget, MwNmargin); +} + +void MwCXX::Box::SetMargin(int value) { + MwSetInteger(this->widget, MwNmargin, (int)value); +} + +int MwCXX::Box::GetPadding() { + return (int)MwGetInteger(this->widget, MwNpadding); +} + +void MwCXX::Box::SetPadding(int value) { + MwSetInteger(this->widget, MwNpadding, (int)value); +} + +int MwCXX::Box::GetHasBorder() { + return (int)MwGetInteger(this->widget, MwNhasBorder); +} + +void MwCXX::Box::SetHasBorder(int value) { + MwSetInteger(this->widget, MwNhasBorder, (int)value); +} + +int MwCXX::Box::GetInverted() { + return (int)MwGetInteger(this->widget, MwNinverted); +} + +void MwCXX::Box::SetInverted(int value) { + MwSetInteger(this->widget, MwNinverted, (int)value); +} + diff --git a/src/widget/button.cxx b/src/widget/button.cxx new file mode 100644 index 0000000..fd4e07c --- /dev/null +++ b/src/widget/button.cxx @@ -0,0 +1,52 @@ +#include + +MwCXX::Button::Button(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +MwLLPixmap MwCXX::Button::GetPixmap() { + return (MwLLPixmap)MwGetVoid(this->widget, MwNpixmap); +} + +void MwCXX::Button::SetPixmap(MwLLPixmap value) { + MwSetVoid(this->widget, MwNpixmap, (MwLLPixmap)value); +} + +MwCXX::String MwCXX::Button::GetText() { + return (MwCXX::String)MwGetText(this->widget, MwNtext); +} + +void MwCXX::Button::SetText(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNtext, value.c_str()); +#else + MwSetText(this->widget, MwNtext, (MwCXX::String)value); +#endif +} + +int MwCXX::Button::GetFlat() { + return (int)MwGetInteger(this->widget, MwNflat); +} + +void MwCXX::Button::SetFlat(int value) { + MwSetInteger(this->widget, MwNflat, (int)value); +} + +int MwCXX::Button::GetPadding() { + return (int)MwGetInteger(this->widget, MwNpadding); +} + +void MwCXX::Button::SetPadding(int value) { + MwSetInteger(this->widget, MwNpadding, (int)value); +} + +int MwCXX::Button::GetFillArea() { + return (int)MwGetInteger(this->widget, MwNfillArea); +} + +void MwCXX::Button::SetFillArea(int value) { + MwSetInteger(this->widget, MwNfillArea, (int)value); +} + diff --git a/src/widget/checkbox.cxx b/src/widget/checkbox.cxx new file mode 100644 index 0000000..60a777f --- /dev/null +++ b/src/widget/checkbox.cxx @@ -0,0 +1,16 @@ +#include + +MwCXX::CheckBox::CheckBox(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::CheckBox::GetChecked() { + return (int)MwGetInteger(this->widget, MwNchecked); +} + +void MwCXX::CheckBox::SetChecked(int value) { + MwSetInteger(this->widget, MwNchecked, (int)value); +} + diff --git a/src/widget/combobox.cxx b/src/widget/combobox.cxx new file mode 100644 index 0000000..a4efb78 --- /dev/null +++ b/src/widget/combobox.cxx @@ -0,0 +1,24 @@ +#include + +MwCXX::ComboBox::ComboBox(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::ComboBox::GetAreaShown() { + return (int)MwGetInteger(this->widget, MwNareaShown); +} + +void MwCXX::ComboBox::SetAreaShown(int value) { + MwSetInteger(this->widget, MwNareaShown, (int)value); +} + +int MwCXX::ComboBox::GetValue() { + return (int)MwGetInteger(this->widget, MwNvalue); +} + +void MwCXX::ComboBox::SetValue(int value) { + MwSetInteger(this->widget, MwNvalue, (int)value); +} + diff --git a/src/widget/entry.cxx b/src/widget/entry.cxx new file mode 100644 index 0000000..18fe8a3 --- /dev/null +++ b/src/widget/entry.cxx @@ -0,0 +1,28 @@ +#include + +MwCXX::Entry::Entry(MwWidget widget) : MwCXX::Base(widget) { +} + +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::String MwCXX::Entry::GetText() { + return (MwCXX::String)MwGetText(this->widget, MwNtext); +} + +void MwCXX::Entry::SetText(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNtext, value.c_str()); +#else + MwSetText(this->widget, MwNtext, (MwCXX::String)value); +#endif +} + +int MwCXX::Entry::GetHideInput() { + return (int)MwGetInteger(this->widget, MwNhideInput); +} + +void MwCXX::Entry::SetHideInput(int value) { + MwSetInteger(this->widget, MwNhideInput, (int)value); +} + diff --git a/src/widget/frame.cxx b/src/widget/frame.cxx new file mode 100644 index 0000000..8470ae0 --- /dev/null +++ b/src/widget/frame.cxx @@ -0,0 +1,24 @@ +#include + +MwCXX::Frame::Frame(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::Frame::GetHasBorder() { + return (int)MwGetInteger(this->widget, MwNhasBorder); +} + +void MwCXX::Frame::SetHasBorder(int value) { + MwSetInteger(this->widget, MwNhasBorder, (int)value); +} + +int MwCXX::Frame::GetInverted() { + return (int)MwGetInteger(this->widget, MwNinverted); +} + +void MwCXX::Frame::SetInverted(int value) { + MwSetInteger(this->widget, MwNinverted, (int)value); +} + diff --git a/src/widget/image.cxx b/src/widget/image.cxx new file mode 100644 index 0000000..ed0cebd --- /dev/null +++ b/src/widget/image.cxx @@ -0,0 +1,40 @@ +#include + +MwCXX::Image::Image(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +MwLLPixmap MwCXX::Image::GetPixmap() { + return (MwLLPixmap)MwGetVoid(this->widget, MwNpixmap); +} + +void MwCXX::Image::SetPixmap(MwLLPixmap value) { + MwSetVoid(this->widget, MwNpixmap, (MwLLPixmap)value); +} + +int MwCXX::Image::GetHasBorder() { + return (int)MwGetInteger(this->widget, MwNhasBorder); +} + +void MwCXX::Image::SetHasBorder(int value) { + MwSetInteger(this->widget, MwNhasBorder, (int)value); +} + +int MwCXX::Image::GetInverted() { + return (int)MwGetInteger(this->widget, MwNinverted); +} + +void MwCXX::Image::SetInverted(int value) { + MwSetInteger(this->widget, MwNinverted, (int)value); +} + +int MwCXX::Image::GetFillArea() { + return (int)MwGetInteger(this->widget, MwNfillArea); +} + +void MwCXX::Image::SetFillArea(int value) { + MwSetInteger(this->widget, MwNfillArea, (int)value); +} + diff --git a/src/widget/label.cxx b/src/widget/label.cxx new file mode 100644 index 0000000..c9ad9c7 --- /dev/null +++ b/src/widget/label.cxx @@ -0,0 +1,60 @@ +#include + +MwCXX::Label::Label(MwWidget widget) : MwCXX::Base(widget) { +} + +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::String MwCXX::Label::GetText() { + return (MwCXX::String)MwGetText(this->widget, MwNtext); +} + +void MwCXX::Label::SetText(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNtext, value.c_str()); +#else + MwSetText(this->widget, MwNtext, (MwCXX::String)value); +#endif +} + +int MwCXX::Label::GetAlignment() { + return (int)MwGetInteger(this->widget, MwNalignment); +} + +void MwCXX::Label::SetAlignment(int value) { + MwSetInteger(this->widget, MwNalignment, (int)value); +} + +int MwCXX::Label::GetBold() { + return (int)MwGetInteger(this->widget, MwNbold); +} + +void MwCXX::Label::SetBold(int value) { + MwSetInteger(this->widget, MwNbold, (int)value); +} + +int MwCXX::Label::GetSevenSegment() { + return (int)MwGetInteger(this->widget, MwNsevenSegment); +} + +void MwCXX::Label::SetSevenSegment(int value) { + MwSetInteger(this->widget, MwNsevenSegment, (int)value); +} + +int MwCXX::Label::GetLength() { + return (int)MwGetInteger(this->widget, MwNlength); +} + +void MwCXX::Label::SetLength(int value) { + MwSetInteger(this->widget, MwNlength, (int)value); +} + +int MwCXX::Label::GetLeftPadding() { + return (int)MwGetInteger(this->widget, MwNleftPadding); +} + +void MwCXX::Label::SetLeftPadding(int value) { + MwSetInteger(this->widget, MwNleftPadding, (int)value); +} + diff --git a/src/widget/listbox.cxx b/src/widget/listbox.cxx new file mode 100644 index 0000000..a539f12 --- /dev/null +++ b/src/widget/listbox.cxx @@ -0,0 +1,32 @@ +#include + +MwCXX::ListBox::ListBox(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::ListBox::GetLeftPadding() { + return (int)MwGetInteger(this->widget, MwNleftPadding); +} + +void MwCXX::ListBox::SetLeftPadding(int value) { + MwSetInteger(this->widget, MwNleftPadding, (int)value); +} + +int MwCXX::ListBox::GetHasHeading() { + return (int)MwGetInteger(this->widget, MwNhasHeading); +} + +void MwCXX::ListBox::SetHasHeading(int value) { + MwSetInteger(this->widget, MwNhasHeading, (int)value); +} + +int MwCXX::ListBox::GetSingleClickSelectable() { + return (int)MwGetInteger(this->widget, MwNsingleClickSelectable); +} + +void MwCXX::ListBox::SetSingleClickSelectable(int value) { + MwSetInteger(this->widget, MwNsingleClickSelectable, (int)value); +} + diff --git a/src/widget/menu.cxx b/src/widget/menu.cxx new file mode 100644 index 0000000..753d70f --- /dev/null +++ b/src/widget/menu.cxx @@ -0,0 +1,8 @@ +#include + +MwCXX::Menu::Menu(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + diff --git a/src/widget/numberentry.cxx b/src/widget/numberentry.cxx new file mode 100644 index 0000000..fc50c4d --- /dev/null +++ b/src/widget/numberentry.cxx @@ -0,0 +1,20 @@ +#include + +MwCXX::NumberEntry::NumberEntry(MwWidget widget) : MwCXX::Base(widget) { +} + +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::String MwCXX::NumberEntry::GetText() { + return (MwCXX::String)MwGetText(this->widget, MwNtext); +} + +void MwCXX::NumberEntry::SetText(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNtext, value.c_str()); +#else + MwSetText(this->widget, MwNtext, (MwCXX::String)value); +#endif +} + diff --git a/src/widget/opengl.cxx b/src/widget/opengl.cxx new file mode 100644 index 0000000..3f5bf6e --- /dev/null +++ b/src/widget/opengl.cxx @@ -0,0 +1,9 @@ +#define MW_OPENGL_NO_INCLUDE +#include + +MwCXX::OpenGL::OpenGL(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + diff --git a/src/widget/progressbar.cxx b/src/widget/progressbar.cxx new file mode 100644 index 0000000..42f9cd8 --- /dev/null +++ b/src/widget/progressbar.cxx @@ -0,0 +1,32 @@ +#include + +MwCXX::ProgressBar::ProgressBar(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::ProgressBar::GetMinValue() { + return (int)MwGetInteger(this->widget, MwNminValue); +} + +void MwCXX::ProgressBar::SetMinValue(int value) { + MwSetInteger(this->widget, MwNminValue, (int)value); +} + +int MwCXX::ProgressBar::GetMaxValue() { + return (int)MwGetInteger(this->widget, MwNmaxValue); +} + +void MwCXX::ProgressBar::SetMaxValue(int value) { + MwSetInteger(this->widget, MwNmaxValue, (int)value); +} + +int MwCXX::ProgressBar::GetValue() { + return (int)MwGetInteger(this->widget, MwNvalue); +} + +void MwCXX::ProgressBar::SetValue(int value) { + MwSetInteger(this->widget, MwNvalue, (int)value); +} + diff --git a/src/widget/radiobox.cxx b/src/widget/radiobox.cxx new file mode 100644 index 0000000..e43b15b --- /dev/null +++ b/src/widget/radiobox.cxx @@ -0,0 +1,16 @@ +#include + +MwCXX::RadioBox::RadioBox(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::RadioBox::GetChecked() { + return (int)MwGetInteger(this->widget, MwNchecked); +} + +void MwCXX::RadioBox::SetChecked(int value) { + MwSetInteger(this->widget, MwNchecked, (int)value); +} + diff --git a/src/widget/scrollbar.cxx b/src/widget/scrollbar.cxx new file mode 100644 index 0000000..969f471 --- /dev/null +++ b/src/widget/scrollbar.cxx @@ -0,0 +1,56 @@ +#include + +MwCXX::ScrollBar::ScrollBar(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::ScrollBar::GetShowArrows() { + return (int)MwGetInteger(this->widget, MwNshowArrows); +} + +void MwCXX::ScrollBar::SetShowArrows(int value) { + MwSetInteger(this->widget, MwNshowArrows, (int)value); +} + +int MwCXX::ScrollBar::GetAreaShown() { + return (int)MwGetInteger(this->widget, MwNareaShown); +} + +void MwCXX::ScrollBar::SetAreaShown(int value) { + MwSetInteger(this->widget, MwNareaShown, (int)value); +} + +int MwCXX::ScrollBar::GetValue() { + return (int)MwGetInteger(this->widget, MwNvalue); +} + +void MwCXX::ScrollBar::SetValue(int value) { + MwSetInteger(this->widget, MwNvalue, (int)value); +} + +int MwCXX::ScrollBar::GetMinValue() { + return (int)MwGetInteger(this->widget, MwNminValue); +} + +void MwCXX::ScrollBar::SetMinValue(int value) { + MwSetInteger(this->widget, MwNminValue, (int)value); +} + +int MwCXX::ScrollBar::GetMaxValue() { + return (int)MwGetInteger(this->widget, MwNmaxValue); +} + +void MwCXX::ScrollBar::SetMaxValue(int value) { + MwSetInteger(this->widget, MwNmaxValue, (int)value); +} + +int MwCXX::ScrollBar::GetOrientation() { + return (int)MwGetInteger(this->widget, MwNorientation); +} + +void MwCXX::ScrollBar::SetOrientation(int value) { + MwSetInteger(this->widget, MwNorientation, (int)value); +} + diff --git a/src/widget/submenu.cxx b/src/widget/submenu.cxx new file mode 100644 index 0000000..8421485 --- /dev/null +++ b/src/widget/submenu.cxx @@ -0,0 +1,16 @@ +#include + +MwCXX::SubMenu::SubMenu(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::SubMenu::GetLeftPadding() { + return (int)MwGetInteger(this->widget, MwNleftPadding); +} + +void MwCXX::SubMenu::SetLeftPadding(int value) { + MwSetInteger(this->widget, MwNleftPadding, (int)value); +} + diff --git a/src/widget/treeview.cxx b/src/widget/treeview.cxx new file mode 100644 index 0000000..9c0544c --- /dev/null +++ b/src/widget/treeview.cxx @@ -0,0 +1,24 @@ +#include + +MwCXX::TreeView::TreeView(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + +int MwCXX::TreeView::GetLeftPadding() { + return (int)MwGetInteger(this->widget, MwNleftPadding); +} + +void MwCXX::TreeView::SetLeftPadding(int value) { + MwSetInteger(this->widget, MwNleftPadding, (int)value); +} + +int MwCXX::TreeView::GetSingleClickSelectable() { + return (int)MwGetInteger(this->widget, MwNsingleClickSelectable); +} + +void MwCXX::TreeView::SetSingleClickSelectable(int value) { + MwSetInteger(this->widget, MwNsingleClickSelectable, (int)value); +} + diff --git a/src/widget/viewport.cxx b/src/widget/viewport.cxx new file mode 100644 index 0000000..1de408f --- /dev/null +++ b/src/widget/viewport.cxx @@ -0,0 +1,8 @@ +#include + +MwCXX::Viewport::Viewport(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + diff --git a/src/widget/vulkan.cxx b/src/widget/vulkan.cxx new file mode 100644 index 0000000..25bfbc2 --- /dev/null +++ b/src/widget/vulkan.cxx @@ -0,0 +1,9 @@ +#define MW_VULKAN_NO_INCLUDE +#include + +MwCXX::Vulkan::Vulkan(MwWidget widget) : MwCXX::Base(widget) { +} + +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) { +} + diff --git a/src/widget/window.cxx b/src/widget/window.cxx new file mode 100644 index 0000000..9134094 --- /dev/null +++ b/src/widget/window.cxx @@ -0,0 +1,60 @@ +#include + +MwCXX::Window::Window(MwWidget widget) : MwCXX::Base(widget) { +} + +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::String MwCXX::Window::GetTitle() { + return (MwCXX::String)MwGetText(this->widget, MwNtitle); +} + +void MwCXX::Window::SetTitle(MwCXX::String value) { +#ifndef MWCXX_USE_C_STRING + MwSetText(this->widget, MwNtitle, value.c_str()); +#else + MwSetText(this->widget, MwNtitle, (MwCXX::String)value); +#endif +} + +int MwCXX::Window::GetMain() { + return (int)MwGetInteger(this->widget, MwNmain); +} + +void MwCXX::Window::SetMain(int value) { + MwSetInteger(this->widget, MwNmain, (int)value); +} + +MwLLPixmap MwCXX::Window::GetIconPixmap() { + return (MwLLPixmap)MwGetVoid(this->widget, MwNiconPixmap); +} + +void MwCXX::Window::SetIconPixmap(MwLLPixmap value) { + MwSetVoid(this->widget, MwNiconPixmap, (MwLLPixmap)value); +} + +MwSizeHints* MwCXX::Window::GetSizeHints() { + return (MwSizeHints*)MwGetVoid(this->widget, MwNsizeHints); +} + +void MwCXX::Window::SetSizeHints(MwSizeHints* value) { + MwSetVoid(this->widget, MwNsizeHints, (MwSizeHints*)value); +} + +int MwCXX::Window::GetHasBorder() { + return (int)MwGetInteger(this->widget, MwNhasBorder); +} + +void MwCXX::Window::SetHasBorder(int value) { + MwSetInteger(this->widget, MwNhasBorder, (int)value); +} + +int MwCXX::Window::GetInverted() { + return (int)MwGetInteger(this->widget, MwNinverted); +} + +void MwCXX::Window::SetInverted(int value) { + MwSetInteger(this->widget, MwNinverted, (int)value); +} + diff --git a/test.cxx b/test.cxx new file mode 100644 index 0000000..255ca0a --- /dev/null +++ b/test.cxx @@ -0,0 +1,37 @@ +#include +#include +#include + +#include + +class MyButton : public MwCXX::Button { + protected: + void OnActivate() { + std::cout << "Hello" << std::endl; + } + + public: + MWCXX_CONSTRUCTOR(MyButton, MwCXX::Button) { + this->SetText("Hello, world!"); + } +}; + +class MyWindow : public MwCXX::Window { + private: + MyButton* epic; + + public: + MWCXX_CONSTRUCTOR(MyWindow, MwCXX::Window) { + this->epic = new MyButton("epic app", this, 10, 10, 640 - 10 * 2, 480 - 10 * 2); + } +}; + +int main() { + MyWindow* wnd; + + MwCXX::Init(); + + wnd = new MyWindow("epic app", NULL, MwDEFAULT, MwDEFAULT, 640, 480); + + wnd->Loop(); +}