diff --git a/include/Mw/Widget/Button.h b/include/Mw/Widget/Button.h index 96ec9a3..a3f8459 100644 --- a/include/Mw/Widget/Button.h +++ b/include/Mw/Widget/Button.h @@ -2,6 +2,7 @@ /*! * %file Mw/Widget/Button.h * %brief Button widget + * %prop MwNpixmap */ #ifndef __MW_WIDGET_BUTTON_H__ #define __MW_WIDGET_BUTTON_H__ diff --git a/include/Mw/Widget/Image.h b/include/Mw/Widget/Image.h index 478660d..b994db5 100644 --- a/include/Mw/Widget/Image.h +++ b/include/Mw/Widget/Image.h @@ -2,6 +2,7 @@ /*! * %file Mw/Widget/Image.h * %brief Image widget + * %prop MwNpixmap */ #ifndef __MW_WIDGET_IMAGE_H__ #define __MW_WIDGET_IMAGE_H__ diff --git a/include/Mw/Widget/ScrollBar.h b/include/Mw/Widget/ScrollBar.h index 62bde8e..03ce649 100644 --- a/include/Mw/Widget/ScrollBar.h +++ b/include/Mw/Widget/ScrollBar.h @@ -2,6 +2,7 @@ /*! * %file Mw/Widget/ScrollBar.h * %brief ScrollBar widget + * %prop MwNareaShown MwNvalue MwNminValue MwNmaxValue MwNorientation */ #ifndef __MW_WIDGET_SCROLLBAR_H__ #define __MW_WIDGET_SCROLLBAR_H__ diff --git a/include/MwOO/Base.h b/include/MwOO/Base.h index 90f3a44..1a755cc 100644 --- a/include/MwOO/Base.h +++ b/include/MwOO/Base.h @@ -18,6 +18,14 @@ class Base { public: void Loop(void); + void SetX(int value); + void SetY(int value); + void SetWidth(int value); + void SetHeight(int value); + int GetX(void); + int GetY(void); + int GetWidth(void); + int GetHeight(void); /* BEGIN AUTOGENERATE */ virtual void OnActivate(void*) {}; virtual void OnResize(void*) {}; diff --git a/include/MwOO/Widget/Button.h b/include/MwOO/Widget/Button.h index b75653e..e4cad8e 100644 --- a/include/MwOO/Widget/Button.h +++ b/include/MwOO/Widget/Button.h @@ -8,6 +8,8 @@ namespace MwOO { class Button : public MwOO::Base { public: Button(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); + void SetPixmap(void* value); + void* GetPixmap(void); }; } // namespace MwOO diff --git a/include/MwOO/Widget/Image.h b/include/MwOO/Widget/Image.h index 8bf33f3..3864020 100644 --- a/include/MwOO/Widget/Image.h +++ b/include/MwOO/Widget/Image.h @@ -8,6 +8,8 @@ namespace MwOO { class Image : public MwOO::Base { public: Image(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); + void SetPixmap(void* value); + void* GetPixmap(void); }; } // namespace MwOO diff --git a/include/MwOO/Widget/ScrollBar.h b/include/MwOO/Widget/ScrollBar.h index 842f645..ebdbb31 100644 --- a/include/MwOO/Widget/ScrollBar.h +++ b/include/MwOO/Widget/ScrollBar.h @@ -8,6 +8,16 @@ namespace MwOO { class ScrollBar : public MwOO::Base { public: ScrollBar(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h); + void SetAreaShown(int value); + int GetAreaShown(void); + void SetValue(int value); + int GetValue(void); + void SetMinValue(int value); + int GetMinValue(void); + void SetMaxValue(int value); + int GetMaxValue(void); + void SetOrientation(int value); + int GetOrientation(void); }; } // namespace MwOO diff --git a/oosrc/base.cc b/oosrc/base.cc index e446883..f687262 100644 --- a/oosrc/base.cc +++ b/oosrc/base.cc @@ -16,6 +16,38 @@ void MwOO::Base::Loop(void){ MwLoop(this->widget); } +void MwOO::Base::SetX(int value){ + MwSetInteger(this->widget, MwNx, value); +} + +void MwOO::Base::SetY(int value){ + MwSetInteger(this->widget, MwNy, value); +} + +void MwOO::Base::SetWidth(int value){ + MwSetInteger(this->widget, MwNwidth, value); +} + +void MwOO::Base::SetHeight(int value){ + MwSetInteger(this->widget, MwNheight, value); +} + +int MwOO::Base::GetX(void){ + return MwGetInteger(this->widget, MwNx); +} + +int MwOO::Base::GetY(void){ + return MwGetInteger(this->widget, MwNy); +} + +int MwOO::Base::GetWidth(void){ + return MwGetInteger(this->widget, MwNwidth); +} + +int MwOO::Base::GetHeight(void){ + return MwGetInteger(this->widget, MwNheight); +} + /* BEGIN AUTOGENERATE */ static void __OnActivate(MwWidget widget, void* user, void* call){ MwOO::Base* c = (MwOO::Base*)user; diff --git a/oosrc/widget/button.cc b/oosrc/widget/button.cc index f408b05..d042fcb 100644 --- a/oosrc/widget/button.cc +++ b/oosrc/widget/button.cc @@ -4,3 +4,12 @@ MwOO::Button::Button(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwButtonClass, widget_name, parent, x, y, w, h){ } + +void MwOO::Button::SetPixmap(void* value){ + MwSetVoid(this->widget, MwNpixmap, value); +} + +void* MwOO::Button::GetPixmap(void){ + return MwGetVoid(this->widget, MwNpixmap); +} + diff --git a/oosrc/widget/frame.cc b/oosrc/widget/frame.cc index 7124f6d..4ac9a5e 100644 --- a/oosrc/widget/frame.cc +++ b/oosrc/widget/frame.cc @@ -4,3 +4,4 @@ MwOO::Frame::Frame(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwFrameClass, widget_name, parent, x, y, w, h){ } + diff --git a/oosrc/widget/image.cc b/oosrc/widget/image.cc index 54806b9..5e5de93 100644 --- a/oosrc/widget/image.cc +++ b/oosrc/widget/image.cc @@ -4,3 +4,12 @@ MwOO::Image::Image(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwImageClass, widget_name, parent, x, y, w, h){ } + +void MwOO::Image::SetPixmap(void* value){ + MwSetVoid(this->widget, MwNpixmap, value); +} + +void* MwOO::Image::GetPixmap(void){ + return MwGetVoid(this->widget, MwNpixmap); +} + diff --git a/oosrc/widget/menu.cc b/oosrc/widget/menu.cc index 61f8d1c..f071331 100644 --- a/oosrc/widget/menu.cc +++ b/oosrc/widget/menu.cc @@ -4,3 +4,4 @@ MwOO::Menu::Menu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwMenuClass, widget_name, parent, x, y, w, h){ } + diff --git a/oosrc/widget/opengl.cc b/oosrc/widget/opengl.cc index af7f100..6397a83 100644 --- a/oosrc/widget/opengl.cc +++ b/oosrc/widget/opengl.cc @@ -4,3 +4,4 @@ MwOO::OpenGL::OpenGL(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwOpenGLClass, widget_name, parent, x, y, w, h){ } + diff --git a/oosrc/widget/scrollbar.cc b/oosrc/widget/scrollbar.cc index 993d2b3..a54319b 100644 --- a/oosrc/widget/scrollbar.cc +++ b/oosrc/widget/scrollbar.cc @@ -4,3 +4,44 @@ MwOO::ScrollBar::ScrollBar(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwScrollBarClass, widget_name, parent, x, y, w, h){ } + +void MwOO::ScrollBar::SetAreaShown(int value){ + MwSetInteger(this->widget, MwNareaShown, value); +} + +int MwOO::ScrollBar::GetAreaShown(void){ + return MwGetInteger(this->widget, MwNareaShown); +} + +void MwOO::ScrollBar::SetValue(int value){ + MwSetInteger(this->widget, MwNvalue, value); +} + +int MwOO::ScrollBar::GetValue(void){ + return MwGetInteger(this->widget, MwNvalue); +} + +void MwOO::ScrollBar::SetMinValue(int value){ + MwSetInteger(this->widget, MwNminValue, value); +} + +int MwOO::ScrollBar::GetMinValue(void){ + return MwGetInteger(this->widget, MwNminValue); +} + +void MwOO::ScrollBar::SetMaxValue(int value){ + MwSetInteger(this->widget, MwNmaxValue, value); +} + +int MwOO::ScrollBar::GetMaxValue(void){ + return MwGetInteger(this->widget, MwNmaxValue); +} + +void MwOO::ScrollBar::SetOrientation(int value){ + MwSetInteger(this->widget, MwNorientation, value); +} + +int MwOO::ScrollBar::GetOrientation(void){ + return MwGetInteger(this->widget, MwNorientation); +} + diff --git a/oosrc/widget/submenu.cc b/oosrc/widget/submenu.cc index 38def23..33faf14 100644 --- a/oosrc/widget/submenu.cc +++ b/oosrc/widget/submenu.cc @@ -4,3 +4,4 @@ MwOO::SubMenu::SubMenu(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwSubMenuClass, widget_name, parent, x, y, w, h){ } + diff --git a/oosrc/widget/vulkan.cc b/oosrc/widget/vulkan.cc index a9d5055..a781717 100644 --- a/oosrc/widget/vulkan.cc +++ b/oosrc/widget/vulkan.cc @@ -4,3 +4,4 @@ MwOO::Vulkan::Vulkan(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwVulkanClass, widget_name, parent, x, y, w, h){ } + diff --git a/oosrc/widget/window.cc b/oosrc/widget/window.cc index b283d70..a0928a7 100644 --- a/oosrc/widget/window.cc +++ b/oosrc/widget/window.cc @@ -4,3 +4,4 @@ MwOO::Window::Window(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(MwWindowClass, widget_name, parent, x, y, w, h){ } + diff --git a/tools/genoo.pl b/tools/genoo.pl index 2bedbf7..f03cae0 100755 --- a/tools/genoo.pl +++ b/tools/genoo.pl @@ -9,6 +9,9 @@ my $objs = ""; my $decl = ""; my @calls = (); +my %ints = (); +my %texts = (); +my %voids = (); open(IN, "<", "include/Mw/StringDefs.h"); while (my $hl = ) { $hl =~ s/\r?\n$//; @@ -20,8 +23,17 @@ while (my $hl = ) { push(@calls, [@c]); } + elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"I(.+)"$/) { + $ints{$1} = uc(substr($2, 0, 1)) . substr($2, 1); + } + elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"S(.+)"$/) { + $texts{$1} = uc(substr($2, 0, 1)) . substr($2, 1); + } + elsif ($hl =~ /^#define[ \t]+([^ ]+)[ \t]+"V(.+)"$/) { + $voids{$1} = uc(substr($2, 0, 1)) . substr($2, 1); + } } -close(HIN); +close(IN); opendir(DIR, "include/Mw/Widget"); my @files = readdir(DIR); @@ -32,7 +44,18 @@ foreach my $f (@files) { $f =~ /^(.+)\.h$/; - my $name = $1; + my $name = $1; + my @props = (); + + open(IN, "include/Mw/Widget/$f"); + while (my $l = ) { + $l =~ s/\r?\n$//g; + + if ($l =~ /%prop[ \t]+(.+)$/) { + @props = split(/[ \t]+/, $1); + } + } + close(IN); open(OUT, ">", "include/MwOO/Widget/$f"); print(OUT "/* \$Id\$ */\n"); @@ -47,6 +70,27 @@ foreach my $f (@files) { print(OUT " ${name}(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h);\n" ); + + foreach my $prop (@props) { + my $type = ""; + my %hash = (); + if (defined($ints{$prop})) { + $type = "int"; + %hash = %ints; + } + elsif (defined($texts{$prop})) { + $type = "const char*"; + %hash = %texts; + } + elsif (defined($voids{$prop})) { + $type = "void*"; + %hash = %voids; + } + if (length($type) > 0) { + print(OUT " void Set" . $hash{$prop} . "($type value);\n"); + print(OUT " $type Get" . $hash{$prop} . "(void);\n"); + } + } print(OUT " };\n"); print(OUT "}\n"); print(OUT "\n"); @@ -62,6 +106,40 @@ foreach my $f (@files) { "MwOO::${name}::${name}(const char* widget_name, MwOO::Base* parent, int x, int y, int w, int h) : MwOO::Base(Mw${name}Class, widget_name, parent, x, y, w, h){\n" ); print(OUT "}\n"); + print(OUT "\n"); + + foreach my $prop (@props) { + my $type = ""; + my $typename = ""; + my %hash = (); + if (defined($ints{$prop})) { + $type = "int"; + $typename = "Integer"; + %hash = %ints; + } + elsif (defined($texts{$prop})) { + $type = "const char*"; + $typename = "Text"; + %hash = %texts; + } + elsif (defined($voids{$prop})) { + $type = "void*"; + $typename = "Void"; + %hash = %voids; + } + if (length($type) > 0) { + print( OUT "void MwOO::${name}::Set" + . $hash{$prop} + . "($type value){\n"); + print(OUT " MwSet$typename(this->widget, $prop, value);\n"); + print(OUT "}\n"); + print(OUT "\n"); + print(OUT "$type MwOO::${name}::Get" . $hash{$prop} . "(void){\n"); + print(OUT " return MwGet$typename(this->widget, $prop);\n"); + print(OUT "}\n"); + print(OUT "\n"); + } + } close(OUT); if (!($name eq 'Vulkan' || $name eq 'OpenGL')) {