From: Michael Olbrich Date: Tue, 1 Nov 2011 15:08:54 +0100 Subject: [PATCH] Add support for gwt Produce code for all gwt widgets. Signed-off-by: Michael Olbrich --- src/writers/Makefile.am | 1 + src/writers/WriterBase.cc | 9 +++-- src/writers/WriterBase.hh | 3 +- src/writers/gwt.cc | 80 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 src/writers/gwt.cc diff --git a/src/writers/Makefile.am b/src/writers/Makefile.am index 94a1b23..9a0bace 100644 --- a/src/writers/Makefile.am +++ b/src/writers/Makefile.am @@ -25,6 +25,7 @@ noinst_HEADERS = WriterBase.hh adjustment.hh bin.hh box.hh button.hh \ togglebutton.hh toolitem.hh widget.hh window.hh safemap.hh libwriters_a_SOURCES = WriterBase.cc WriterBase_matches.cc Class.cc \ + gwt.cc \ accellabel.cc \ accelgroup.cc adjustment.cc alignment.cc arrow.cc \ aspectframe.cc bbox.cc bonobo_dock.cc bonobo_dockitem.cc \ diff --git a/src/writers/WriterBase.cc b/src/writers/WriterBase.cc index f893d32..a91d4b4 100644 --- a/src/writers/WriterBase.cc +++ b/src/writers/WriterBase.cc @@ -322,15 +322,17 @@ void WriterBase::WriteTranslatableProperty(const Widget &w, CxxFile &f, const st } } -void WriterBase::WriteEnumPropertyNS(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, bool only_new) -{ if (w.hasProperty(property)) +void WriterBase::WriteEnumPropertyNS(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, + bool only_new, std::string functname) +{ if (functname.empty()) functname=property; + if (w.hasProperty(property)) { f.Statement() << instance; std::string val=Gtkmm2Namespace(w.getProperty(property)); if (only_new && GTKMM2) f << "property_" << property << "().set_value(" << val << ')'; else - f << "set_" << property << '(' + f << "set_" << functname << '(' << val << ')'; } } @@ -436,6 +438,7 @@ std::string WriterBase::Gtkmm2Namespace(const std::string &s) std::string res=s; replace_all(res,"GTK_","Gtk::"); replace_all(res,"GDK_","Gdk::"); + replace_all(res,"GWT_","Gwt::"); return res; } diff --git a/src/writers/WriterBase.hh b/src/writers/WriterBase.hh index 8a8c972..5c6f97d 100644 --- a/src/writers/WriterBase.hh +++ b/src/writers/WriterBase.hh @@ -186,7 +186,8 @@ public: // for new property based code static void WriteTranslatableProperty(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, bool only_new=false); static void WriteBoolProperty(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, bool only_new=false, std::string functname=""); - static void WriteEnumPropertyNS(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, bool only_new=false); + static void WriteEnumPropertyNS(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, + bool only_new=false, std::string functname=""); static void WriteIntProperty(const Widget &w, CxxFile &f, const std::string &instance, const std::string &property, bool only_new=false, std::string functname=""); static void WriteIntIntProperty(const Widget &w, CxxFile &f, const std::string &instance, diff --git a/src/writers/gwt.cc b/src/writers/gwt.cc new file mode 100644 index 0000000..b622c0c --- /dev/null +++ b/src/writers/gwt.cc @@ -0,0 +1,80 @@ +// $Id: gwt.cc,v 1.14 2002/05/14 08:25:44 christof Exp $ +/* glade--: C++ frontend for glade (Gtk+ User Interface Builder) + * Copyright (C) 1998 Christof Petig + * Copyright (C) 1999-2000 Adolf Petig GmbH & Co. KG, written by Christof Petig + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "drawingarea.hh" + +class Gwt_PlotCanvas : public Gtk_DrawingArea +{public: + typedef Gtk_DrawingArea Parent; + virtual const std::string TypeName(const Widget &w) const; + virtual const std::string IncludeName(const Widget &w) const; + Gwt_PlotCanvas(); + virtual bool NeedExplicitCtor(const Widget &w) const + { return false; } + virtual void ConstructionArgs(Widget const &w, CxxFile &f) const + { f.FunctionArg(); } +}; + +static Gwt_PlotCanvas Gwt_PlotCanvas; + +const std::string Gwt_PlotCanvas::TypeName(const Widget &w) const +{ return "Gwt::PlotCanvas"; +} + +const std::string Gwt_PlotCanvas::IncludeName(const Widget &w) const +{ return "gwtmm/gwtmm.h"; +} + +Gwt_PlotCanvas::Gwt_PlotCanvas() +{ Writer["GwtPlotCanvas"]=this; +} + +class Gwt_PlotScale : public Gtk_DrawingArea +{public: + typedef Gtk_DrawingArea Parent; + virtual const std::string TypeName(const Widget &w) const; + virtual const std::string IncludeName(const Widget &w) const; + Gwt_PlotScale(); + virtual void Configure(const Widget &w, CxxFile &f,const std::string &instance) const; + virtual bool NeedExplicitCtor(const Widget &w) const + { return false; } + virtual void ConstructionArgs(Widget const &w, CxxFile &f) const + { f.FunctionArg(); } +}; + +static Gwt_PlotScale Gwt_PlotScale; + +const std::string Gwt_PlotScale::TypeName(const Widget &w) const +{ return "Gwt::PlotScale"; +} + +const std::string Gwt_PlotScale::IncludeName(const Widget &w) const +{ return "gwtmm/gwtmm.h"; +} + +Gwt_PlotScale::Gwt_PlotScale() +{ Writer["GwtPlotScale"]=this; +} + +void Gwt_PlotScale::Configure(const Widget &w, CxxFile &f,const std::string &instance) const +{ Parent::Configure(w,f,instance); + WriteEnumPropertyNS(w,f,instance, "scale_type", false, "type"); +} +