Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 2003/09/02 10:35:04 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 //Check whether there is already a C++ wrapper instance associated with this C instance: 00238 Glib::ObjectBase* pObjectBase = ObjectBase::_get_current_wrapper((GObject*)pCWidget); 00239 00240 //If there is already a C++ instance, then return it again: 00241 if(pObjectBase) 00242 { 00243 widget = dynamic_cast<T_Widget*>( Glib::wrap(pCWidget) ); 00244 00245 //The dynamic cast checks that it is of the correct type. 00246 //Somebody might be trying to call get_widget_derived() after already calling get_widget(), 00247 //or after already calling get_widget_derived() with a different derived C++ type. 00248 if(!widget) 00249 g_critical("Gnome::Glade::Xml::get_widget_derived(): dynamic_cast<> failed. An existing C++ instance, of a different type, seems to exist."); 00250 } 00251 else 00252 { 00253 //Create a new C++ instance to wrap the existing C instance: 00254 00255 //Set the output variable. We needed to do this because we can not template the return type. 00256 Glib::RefPtr<Gnome::Glade::Xml> refThis(this); 00257 refThis->reference(); //take a copy. 00258 widget = new T_Widget(pCWidget, refThis); 00259 } 00260 00261 //We return it as well (we need the parameter as well, because C++ can not just template the return type.) 00262 return widget; 00263 } 00264 00265 00266 Glib::ListHandle<Gtk::Widget*> get_widget_prefix(const Glib::ustring& name); 00267 00269 void reparent_widget(const Glib::ustring& name, Gtk::Container& container); 00270 00271 00272 std::string relative_file(const std::string& filename) const; 00273 00274 00275 static Glib::ustring get_widget_name(Gtk::Widget& widget); 00276 00277 static Glib::RefPtr<Xml> get_widget_tree(Gtk::Widget& widget); 00278 00280 //typedef GtkWidget *(* GladeXMLCustomWidgetHandler) (GladeXML *xml, 00281 // gchar *func_name, 00282 // gchar *name, 00283 // gchar *string1, 00284 // gchar *string2, 00285 // gint int1, 00286 // gint int2, 00287 // gpointer user_data); 00288 00289 //void glade_set_custom_handler(GladeXMLCustomWidgetHandler handler, 00290 // gpointer user_data); 00291 00292 00293 protected: 00294 00295 00296 virtual GType lookup_type_vfunc(const Glib::ustring& classname); 00297 00298 00299 public: 00300 00301 public: 00302 //C++ methods used to invoke GTK+ virtual functions: 00303 00304 protected: 00305 //GTK+ Virtual Functions (override these to change behaviour): 00306 00307 //Default Signal Handlers:: 00308 00309 00310 }; 00311 00312 } // namespace Glade 00313 } // namespace Gnome 00314 00315 00316 namespace Glib 00317 { 00319 Glib::RefPtr<Gnome::Glade::Xml> wrap(GladeXML* object, bool take_copy = false); 00320 } 00321 00322 00323 #endif /* _LIBGLADEMM_XML_H */ 00324

Generated on Fri Aug 13 01:55:56 2004 for libglademm by doxygen 1.3.7