diff --git a/bindgen.cxx b/bindgen.cxx index 242f421..1e3158d 100644 --- a/bindgen.cxx +++ b/bindgen.cxx @@ -5,6 +5,7 @@ #include #include #include +#include struct typeinfo { std::string type; @@ -499,7 +500,7 @@ int main(int argc, char** argv) { int fail = 0; if(argc < 2) { - printf("Usage: %s XML\n", argv[0]); + std::cerr << "Usage: " + std::string(argv[0]) + " XML" << std::endl; return 1; } @@ -558,7 +559,7 @@ int main(int argc, char** argv) { } if(fail) { - fprintf(stderr, "Failed to parse XML\n"); + std::cerr << "Failed to parse XML" << std::endl; return 1; } diff --git a/include/MwCXX/MachDep.h b/include/MwCXX/MachDep.h index 3413d95..0fd78f9 100644 --- a/include/MwCXX/MachDep.h +++ b/include/MwCXX/MachDep.h @@ -9,9 +9,9 @@ namespace MwCXX { #ifdef MWCXX_USE_C_STRING - typedef char* String; + typedef const char* String; #else - typedef std::string String; + typedef const std::string String; #endif }; // namespace MwCXX diff --git a/include/MwCXX/Widget/Base.h b/include/MwCXX/Widget/Base.h index 66cc568..a1d5e5f 100644 --- a/include/MwCXX/Widget/Base.h +++ b/include/MwCXX/Widget/Base.h @@ -14,6 +14,12 @@ namespace MwCXX { Base(MwWidget widget); Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); + MwRect GetArea(); + void SetArea(MwRect r); + + void Move(int x, int y); + void Resize(unsigned int width, unsigned int height); + void Loop(); #include diff --git a/src/widget/base.cxx b/src/widget/base.cxx index 0bc9d3c..2258ab9 100644 --- a/src/widget/base.cxx +++ b/src/widget/base.cxx @@ -12,6 +12,42 @@ MwCXX::Base::Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, #else this->widget = MwCreateWidget(widget_class, name.c_str(), parent == NULL ? NULL : parent->widget, x, y, width, height); #endif + + this->RegisterHandlers(); +} + +MwRect MwCXX::Base::GetArea() { + MwRect rc; + + rc.x = MwGetInteger(this->widget, MwNx); + rc.y = MwGetInteger(this->widget, MwNy); + rc.width = MwGetInteger(this->widget, MwNwidth); + rc.height = MwGetInteger(this->widget, MwNheight); + + return rc; +} + +void MwCXX::Base::SetArea(MwRect rc) { + MwVaApply(this->widget, + MwNx, rc.x, + MwNy, rc.y, + MwNwidth, rc.width, + MwNheight, rc.height, + NULL); +} + +void MwCXX::Base::Move(int x, int y) { + MwVaApply(this->widget, + MwNx, x, + MwNy, y, + NULL); +} + +void MwCXX::Base::Resize(unsigned int width, unsigned int height) { + MwVaApply(this->widget, + MwNwidth, width, + MwNheight, height, + NULL); } void MwCXX::Base::Loop() { diff --git a/test.cxx b/test.cxx index fa91f1d..c667964 100644 --- a/test.cxx +++ b/test.cxx @@ -20,6 +20,13 @@ class MyWindow : public MwCXX::Window { private: MyButton* epic; + protected: + void OnResize() { + MwRect rc = this->GetArea(); + + this->epic->Resize(rc.width - 20, rc.height - 20); + } + public: MWCXX_CONSTRUCTOR(MyWindow, MwCXX::Window) { this->epic = new MyButton("epic app", this, 10, 10, 640 - 10 * 2, 480 - 10 * 2);