things
This commit is contained in:
parent
d7d6ae1479
commit
bbc8b871bb
5 changed files with 54 additions and 4 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
||||||
|
|
|
||||||
7
test.cxx
7
test.cxx
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue