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 <sstream>
|
||||
#include <locale>
|
||||
#include <iostream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <MwCXX/Widget/BaseAuto.h>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
7
test.cxx
7
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue