1 // $Id: gnome_druidpagestd.cc,v 1.6 2002/11/04 11:31:03 christof Exp $
2 /* glade--: C++ frontend for glade (Gtk+ User Interface Builder)
3 * Copyright (C) 1998 Christof Petig
4 * Copyright (C) 1999-2000 Adolf Petig GmbH & Co. KG, written by Christof Petig
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #include "gnome_druidpage.hh"
22
23 class Gnome_DruidPageStandard : public Gnome_DruidPage
24 {public:
25 typedef Gnome_DruidPage Parent;
26 virtual const std::string TypeName(const Widget &w) const;
27 virtual const std::string IncludeName(const Widget &w) const;
28 Gnome_DruidPageStandard();
29 virtual bool NeedExplicitCtor(const Widget &w) const;
30 virtual void ConstructionArgs(const Widget &w, CxxFile &f) const;
31 virtual void AddChildren(const Widget &w,CxxFile &f,const std::string &instance,const WriterBase &writer_for_subw, const Widget &widget_for_subw) const;
32 virtual Subwidget IsSubwidget(const Widget &parent,const Widget &w2) const;
33 virtual void Configure(const Widget &w, CxxFile &f,const std::string &instance) const;
34 };
name_reserved_for_implementation_p(const char * str)35
36 static Gnome_DruidPageStandard Gnome_DruidPageStandard;
37
38 const std::string Gnome_DruidPageStandard::TypeName(const Widget &w) const
39 { return GnomeUIPrefix()+"DruidPageStandard";
40 }
41
42 const std::string Gnome_DruidPageStandard::IncludeName(const Widget &w) const
43 { return Configuration.GnomeUImmIncludePath()+"druid-page-standard.h";
44 }
45
should_suggest_as_macro_p(cpp_hashnode * hashnode)46 Gnome_DruidPageStandard::Gnome_DruidPageStandard()
47 { Writer["GnomeDruidPageStandard"]=this;
48 }
49
50 void Gnome_DruidPageStandard::ConstructionArgs(const Widget &w, CxxFile &f) const
51 { f.FunctionArg();
52 }
53
54 bool Gnome_DruidPageStandard::NeedExplicitCtor(const Widget &w) const
55 { return false; }
56
57 void Gnome_DruidPageStandard::AddChildren(const Widget &w,CxxFile &f,const std::string &instance,const WriterBase &writer_for_subw, const Widget &widget_for_subw) const
58 { const WriterBase &vwr(LookupWriter("GtkVBox"));
59 if (w.begin()==w.end()) return;
60 const Widget w2(*(w.begin()));
61 assert(w2.ChildName()=="GnomeDruidPageStandard:vbox");
62
63 for (Widget::const_iterator i=w2.begin();i!=w2.end();++i)
64 { ((Gtk_Container&)vwr).AddChild(*i,f,Configuration.InstanceName(w2.Name())+"->");
find_closest_macro_cpp_cb(cpp_reader *,cpp_hashnode * hashnode,void * user_data)65 }
66 }
67
68 Subwidget Gnome_DruidPageStandard::IsSubwidget(const Widget &w,const Widget &ch) const
69 { if (ch.ChildName()=="GnomeDruidPageStandard:vbox") return is_Subwidget_only;
70 if (!ch.ChildName().empty()) { std::cerr << "Child name '" << ch.ChildName() << "'\n"; }
71 return not_Subwidget;
72 }
73
74 void Gnome_DruidPageStandard::Configure(const Widget &w, CxxFile &f,const std::string &instance) const
75 { Parent::Configure(w,f,instance);
76
77 assert (w.begin()!=w.end());
78 const Widget w2(*(w.begin()));
79 assert (w2.ChildName()=="GnomeDruidPageStandard:vbox");
80
81 const std::string name(Configuration.InstanceName(w2.Name()));
best_macro_match(tree goal,edit_distance_t best_distance_so_far,cpp_reader * reader)82 f.Declaration() << GtkPrefix() << "VBox *" << name;
83 f.Assignment() << gtk_wrapper() << "((GtkVBox*)GNOME_DRUID_PAGE_STANDARD("
84 << instance << gtk_object_pointer() << ")->vbox)";
85 LookupWriter("GtkVBox").Configure(w2,f,name+"->");
86 }
87
88