This commit is contained in:
Nishi 2026-04-17 22:44:19 +09:00
commit bbc8b871bb
Signed by: nishi
GPG key ID: 27EF69B208EB9343
5 changed files with 54 additions and 4 deletions

View file

@ -5,6 +5,7 @@
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <locale> #include <locale>
#include <iostream>
struct typeinfo { struct typeinfo {
std::string type; std::string type;
@ -499,7 +500,7 @@ int main(int argc, char** argv) {
int fail = 0; int fail = 0;
if(argc < 2) { if(argc < 2) {
printf("Usage: %s XML\n", argv[0]); std::cerr << "Usage: " + std::string(argv[0]) + " XML" << std::endl;
return 1; return 1;
} }
@ -558,7 +559,7 @@ int main(int argc, char** argv) {
} }
if(fail) { if(fail) {
fprintf(stderr, "Failed to parse XML\n"); std::cerr << "Failed to parse XML" << std::endl;
return 1; return 1;
} }

View file

@ -9,9 +9,9 @@
namespace MwCXX { namespace MwCXX {
#ifdef MWCXX_USE_C_STRING #ifdef MWCXX_USE_C_STRING
typedef char* String; typedef const char* String;
#else #else
typedef std::string String; typedef const std::string String;
#endif #endif
}; // namespace MwCXX }; // namespace MwCXX

View file

@ -14,6 +14,12 @@ namespace MwCXX {
Base(MwWidget widget); Base(MwWidget widget);
Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent, int x, int y, unsigned int width, unsigned int height); 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(); void Loop();
#include <MwCXX/Widget/BaseAuto.h> #include <MwCXX/Widget/BaseAuto.h>

View file

@ -12,6 +12,42 @@ MwCXX::Base::Base(MwClass widget_class, MwCXX::String name, MwCXX::Base* parent,
#else #else
this->widget = MwCreateWidget(widget_class, name.c_str(), parent == NULL ? NULL : parent->widget, x, y, width, height); this->widget = MwCreateWidget(widget_class, name.c_str(), parent == NULL ? NULL : parent->widget, x, y, width, height);
#endif #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() { void MwCXX::Base::Loop() {

View file

@ -20,6 +20,13 @@ class MyWindow : public MwCXX::Window {
private: private:
MyButton* epic; MyButton* epic;
protected:
void OnResize() {
MwRect rc = this->GetArea();
this->epic->Resize(rc.width - 20, rc.height - 20);
}
public: public:
MWCXX_CONSTRUCTOR(MyWindow, MwCXX::Window) { MWCXX_CONSTRUCTOR(MyWindow, MwCXX::Window) {
this->epic = new MyButton("epic app", this, 10, 10, 640 - 10 * 2, 480 - 10 * 2); this->epic = new MyButton("epic app", this, 10, 10, 640 - 10 * 2, 480 - 10 * 2);