Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

xml.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 // Generated by gtkmmproc -- DO NOT MODIFY!
00003 #ifndef _LIBGLADEMM_XML_H
00004 #define _LIBGLADEMM_XML_H
00005 
00006 #include <glibmm.h>
00007 
00008 /* $Id: xml.hg,v 1.17.2.2 2004/03/28 12:55:42 murrayc Exp $ */
00009 
00010 /* Copyright (C) 2002 The libglademm Development Team
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Library General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Library General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Library General Public
00023  * License along with this library; if not, write to the Free
00024  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  */
00026 
00027 #include <gtkmm/container.h>
00028 
00029 
00030 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00031 typedef struct _GladeXML GladeXML;
00032 typedef struct _GladeXMLClass GladeXMLClass;
00033 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00034 
00035 
00036 namespace Gnome
00037 {
00038 
00039 namespace Glade
00040 { class Xml_Class; } // namespace Glade
00041 
00042 } // namespace Gnome
00043 namespace Gnome
00044 {
00045 
00046 namespace Glade
00047 {
00048 
00049 class XmlError : public Glib::Exception
00050 {
00051 public:
00052   explicit XmlError(const Glib::ustring& message);
00053   virtual ~XmlError() throw();
00054 
00055   XmlError(const XmlError& other);
00056   XmlError& operator=(const XmlError& other);
00057 
00058   virtual Glib::ustring what() const;
00059 
00060 private:
00061   Glib::ustring message_;
00062 };
00063 
00064 
00065 class Xml : public Glib::Object
00066 {
00067   
00068 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00069 
00070 public:
00071   typedef Xml CppObjectType;
00072   typedef Xml_Class CppClassType;
00073   typedef GladeXML BaseObjectType;
00074   typedef GladeXMLClass BaseClassType;
00075 
00076 private:  friend class Xml_Class;
00077   static CppClassType xml_class_;
00078 
00079 private:
00080   // noncopyable
00081   Xml(const Xml&);
00082   Xml& operator=(const Xml&);
00083 
00084 protected:
00085   explicit Xml(const Glib::ConstructParams& construct_params);
00086   explicit Xml(GladeXML* castitem);
00087 
00088 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00089 
00090 public:
00091   virtual ~Xml();
00092 
00093 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00094   static GType get_type()      G_GNUC_CONST;
00095   static GType get_base_type() G_GNUC_CONST;
00096 #endif
00097 
00099   GladeXML*       gobj()       { return reinterpret_cast<GladeXML*>(gobject_); }
00100 
00102   const GladeXML* gobj() const { return reinterpret_cast<GladeXML*>(gobject_); }
00103 
00104   GladeXML* gobj_copy();
00105 
00106 private:
00107 
00108   
00109    //Ignore private glade_xml functions.
00110 
00111 protected:
00115   Xml(const std::string& filename, const Glib::ustring& root, const Glib::ustring& domain);
00116 
00120   Xml(const char* buffer, int size, const Glib::ustring& root, const Glib::ustring& domain);
00121 
00122   Gtk::Widget* get_widget_checked(const Glib::ustring& name, GType type);
00123   GtkWidget* get_cwidget(const Glib::ustring& name);
00124 
00125 public:
00126   typedef Gnome::Glade::XmlError Error;
00127 
00131   static Glib::RefPtr<Xml> create(const std::string& filename,
00132                                   const Glib::ustring& root   = Glib::ustring(),
00133                                   const Glib::ustring& domain = Glib::ustring());
00134 
00138   static Glib::RefPtr<Xml> create_from_buffer(const char* buffer, int size,
00139                                               const Glib::ustring& root   = Glib::ustring(),
00140                                               const Glib::ustring& domain = Glib::ustring());
00141 
00142   std::string get_filename() const;
00143 
00144 //void       glade_xml_signal_connect      (GladeXML *self,
00145 //                                        const char *handlername,
00146 //                                        GCallback func);
00147 //void       glade_xml_signal_connect_data (GladeXML *self,
00148 //                                        const char *handlername,
00149 //                                        GCallback func,
00150 //                                        gpointer user_data);
00151 //
00152 //void       glade_xml_signal_autoconnect  (GladeXML *self);
00153 //
00154 //
00155 //typedef void (*GladeXMLConnectFunc) (const gchar *handler_name,
00156 //                                   GObject *object,
00157 //                                   const gchar *signal_name,
00158 //                                   const gchar *signal_data,
00159 //                                   GObject *connect_object,
00160 //                                   gboolean after,
00161 //                                   gpointer user_data);
00162 //
00163 //
00164 //void       glade_xml_signal_connect_full     (GladeXML *self,
00165 //                                            const gchar *handler_name,
00166 //                                            GladeXMLConnectFunc func,
00167 //                                            gpointer user_data);
00168 //
00169 //void       glade_xml_signal_autoconnect_full (GladeXML *self,
00170 //                                            GladeXMLConnectFunc func,
00171 //                                            gpointer user_data);
00172 //
00173 //
00183   Gtk::Widget* get_widget(const Glib::ustring& name);
00184 
00198   template <class T_Widget> inline
00199   T_Widget* get_widget(const Glib::ustring& name, T_Widget*& widget)
00200   {
00201     // The dynamic_cast<> should never fail if get_widget_checked() succeeded.
00202     widget = dynamic_cast<T_Widget*>(this->get_widget_checked(name, T_Widget::get_base_type()));
00203 
00204     if(!widget)
00205       g_critical("Gnome::Glade::Xml::get_widget(): dynamic_cast<> failed.");
00206       
00207     return widget;
00208   }
00209 
00227   template <class T_Widget> inline
00228   T_Widget* get_widget_derived(const Glib::ustring& name, T_Widget*& widget)
00229   {
00230      // initialize input parameter
00231      widget = 0;
00232 
00233      // Get the widget from the glade file.
00234      typedef  typename T_Widget::BaseObjectType cwidget_type;
00235      cwidget_type* pCWidget = (cwidget_type*)get_cwidget(name);
00236 
00237      //The error was already reported by get_cwidget().
00238      if(!pCWidget)
00239        return 0;
00240 
00241      //Check whether there is already a C++ wrapper instance associated with this C instance:
00242      Glib::ObjectBase* pObjectBase = ObjectBase::_get_current_wrapper((GObject*)pCWidget);
00243 
00244      //If there is already a C++ instance, then return it again:
00245      if(pObjectBase)
00246      {
00247        widget = dynamic_cast<T_Widget*>( Glib::wrap(pCWidget) );
00248 
00249        //The dynamic cast checks that it is of the correct type.
00250        //Somebody might be trying to call get_widget_derived() after already calling get_widget(),
00251        //or after already calling get_widget_derived() with a different derived C++ type.
00252        if(!widget)
00253         g_critical("Gnome::Glade::Xml::get_widget_derived(): dynamic_cast<> failed. An existing C++ instance, of a different type, seems to exist.");      
00254      }
00255      else
00256      {
00257        //Create a new C++ instance to wrap the existing C instance:
00258        
00259        //Set the output variable. We needed to do this because we can not template the return type.
00260        Glib::RefPtr<Gnome::Glade::Xml> refThis(this);
00261        refThis->reference(); //take a copy.
00262        widget = new T_Widget(pCWidget, refThis);
00263      }
00264 
00265      //We return it as well (we need the parameter as well, because C++ can not just template the return type.)
00266      return widget;
00267   }
00268 
00269   
00270   Glib::ListHandle<Gtk::Widget*> get_widget_prefix(const Glib::ustring& name);
00271 
00273   void reparent_widget(const Glib::ustring& name, Gtk::Container& container);
00274 
00275   
00276   std::string relative_file(const std::string& filename) const;
00277 
00278   
00279   static Glib::ustring get_widget_name(Gtk::Widget& widget);
00280   
00281   static Glib::RefPtr<Xml> get_widget_tree(Gtk::Widget& widget);
00282 
00284 //typedef GtkWidget *(* GladeXMLCustomWidgetHandler) (GladeXML *xml,
00285 //                                                  gchar *func_name,
00286 //                                                  gchar *name,
00287 //                                                  gchar *string1,
00288 //                                                  gchar *string2,
00289 //                                                  gint int1,
00290 //                                                  gint int2,
00291 //                                                  gpointer user_data);
00292 
00293 //void glade_set_custom_handler(GladeXMLCustomWidgetHandler handler,
00294 //                            gpointer user_data);
00295 
00296 
00297 protected:
00298 
00299   
00300   virtual GType lookup_type_vfunc(const Glib::ustring& classname);
00301 
00302 
00303 public:
00304 
00305 public:
00306   //C++ methods used to invoke GTK+ virtual functions:
00307 
00308 protected:
00309   //GTK+ Virtual Functions (override these to change behaviour):
00310 
00311   //Default Signal Handlers::
00312 
00313 
00314 };
00315 
00316 } // namespace Glade
00317 } // namespace Gnome
00318 
00319 
00320 namespace Glib
00321 {
00323   Glib::RefPtr<Gnome::Glade::Xml> wrap(GladeXML* object, bool take_copy = false);
00324 }
00325 
00326 
00327 #endif /* _LIBGLADEMM_XML_H */
00328 

Generated on Thu May 5 14:28:51 2005 for libglademm by  doxygen 1.4.2