/* Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see . */ #include #ifndef GTKMM_DISABLE_DEPRECATED #include #endif #include #include _DEFS(gtkmm,gtk) _PINCLUDE(gtkmm/private/misc_p.h) namespace Gtk { _CC_INCLUDE(gtk/gtk.h) _WRAP_ENUM(ImageType, GtkImageType, decl_prefix GTKMM_API) /** A widget displaying an image. * * The Gtk::Image widget displays an image. Various kinds of object can be * displayed as an image; most typically, you would load a Gdk::Pixbuf ("pixel * buffer") from a file, and then display that. * * Gtk::Image is a subclass of Gtk::Misc, which implies that you can align it * (center, left, right) and add padding to it, using Gtk::Misc methods. * * Gtk::Image is a "no window" widget (has no Gdk::Window of its own), so by * default does not receive events. If you want to receive events on the * image, such as button clicks, place the image inside a Gtk::EventBox, then * connect to the event signals on the event box. * * The Image widget looks like this: * @image html image1.png * * @ingroup Widgets */ class GTKMM_API Image : public Misc { _CLASS_GTKOBJECT(Image,GtkImage,GTK_IMAGE,Gtk::Misc,GtkMisc,,,GTKMM_API) _IGNORE(gtk_image_get_stock, gtk_image_get_icon_set) public: _CTOR_DEFAULT /** Creates an Image widget displaying the file @a filename. * If the file isn't found or can't be loaded, the resulting Gtk::Image will display a "broken image" icon. * * If the file contains an animation, the image will contain an animation. * * If you need to detect failures to load the file, use Gdk::Pixbuf::create_from_file() to load the file yourself, * then create the GtkImage from the pixbuf. (Or for animations, use Gdk::PixbufAnimation::create_from_file()). * * The storage type (get_storage_type()) of the returned image is not defined. It will be whatever is appropriate for displaying the file. */ _WRAP_CTOR(Image(const std::string& file), gtk_image_new_from_file) /** Creates a new Image widget displaying @a pixbuf. * Note that this just creates an GtkImage from the pixbuf. The Gtk::Image created will not react to state changes. * Should you want that, you should use the default constructor and set_from_icon_name(). */ _WRAP_CTOR(Image(const Glib::RefPtr& pixbuf), gtk_image_new_from_pixbuf) _IGNORE(gtk_image_new_from_icon_set) // deprecated since 3.10 //We don't wrap gtk_image_new_from_resource() to avoid a clash with the from-filename constructor. //But we do wrap gtk_image_set_from_resource() _IGNORE(gtk_image_new_from_resource) #ifndef GTKMM_DISABLE_DEPRECATED /** Creates an Image displaying a stock icon. * Sample stock icon identifiers are Gtk::Stock::OPEN, Gtk::Stock::EXIT. Sample stock sizes are Gtk::ICON_SIZE_MENU, Gtk::ICON_SIZE_SMALL_TOOLBAR. * If the stock icon name isn't known, a "broken image" icon will be displayed instead. * You can register your own stock icon names - see Gtk::IconFactory::add(). * @param stock_id A stock icon. * @param size A stock icon size. * @deprecated Use the default constructor and set_from_icon_name() instead. */ Image(const Gtk::StockID& stock_id, IconSize size); #endif //GTKMM_DISABLE_DEPRECATED #ifndef GTKMM_DISABLE_DEPRECATED /** @deprecated Use the default constructor and set_from_icon_name() instead. */ Image(const Glib::RefPtr& icon_set, IconSize size); #endif //GTKMM_DISABLE_DEPRECATED _WRAP_METHOD_DOCS_ONLY(gtk_image_set_from_animation) explicit Image(const Glib::RefPtr& animation); _WRAP_METHOD_DOCS_ONLY(gtk_image_new_from_icon_name, newin "3,24") _WRAP_CTOR(Image(const Glib::ustring& icon_name, IconSize icon_size), gtk_image_new_from_icon_name) _WRAP_METHOD_DOCS_ONLY(gtk_image_new_from_gicon, newin "3,24") _WRAP_CTOR(Image(const Glib::RefPtr& gicon, IconSize icon_size), gtk_image_new_from_gicon) #m4 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Surface>&',`cairo_surface_t*',`($3) ? const_cast(($3)->cobj()) : nullptr') /** Creates a new Gtk::Image displaying @a surface. * * @newin{3,24} * * @param surface A Cairo::Surface or an empty Cairo::RefPtr. * @return A new Gtk::Image. */ _WRAP_CTOR(Image(const ::Cairo::RefPtr< ::Cairo::Surface>& surface), gtk_image_new_from_surface) _WRAP_METHOD(void set(const std::string& filename), gtk_image_set_from_file) _WRAP_METHOD(void set_from_resource(const std::string& resource_path), gtk_image_set_from_resource) _WRAP_METHOD(void set(const Glib::RefPtr& pixbuf), gtk_image_set_from_pixbuf) _WRAP_METHOD(void set(const Gtk::StockID& stock_id, IconSize size), gtk_image_set_from_stock, deprecated "Use set_from_icon_name() instead.") _WRAP_METHOD(void set(const Glib::RefPtr& icon_set, IconSize size), gtk_image_set_from_icon_set, deprecated "Use set_from_icon_name() instead.") _WRAP_METHOD(void set(const Glib::RefPtr& animation), gtk_image_set_from_animation) _WRAP_METHOD(void set(const Glib::RefPtr& icon, IconSize size), gtk_image_set_from_gicon) _WRAP_METHOD(void set(const ::Cairo::RefPtr< ::Cairo::Surface>& surface), gtk_image_set_from_surface) _WRAP_METHOD(void set_from_icon_name(const Glib::ustring& icon_name, IconSize size), gtk_image_set_from_icon_name) _WRAP_METHOD(void clear(), gtk_image_clear) _WRAP_METHOD(ImageType get_storage_type() const, gtk_image_get_storage_type) _WRAP_METHOD(Glib::RefPtr get_pixbuf(), gtk_image_get_pixbuf, refreturn) _WRAP_METHOD(Glib::RefPtr get_pixbuf() const, gtk_image_get_pixbuf, refreturn, constversion) #ifndef GTKMM_DISABLE_DEPRECATED /** @deprecated Use get_icon_name() instead. */ void get_stock(Gtk::StockID& stock_id, IconSize& size) const; #endif //GTKMM_DISABLE_DEPRECATED #ifndef GTKMM_DISABLE_DEPRECATED /** @deprecated Use get_icon_name() instead. */ void get_icon_set(Glib::RefPtr& icon_set, IconSize& size) const; #endif //GTKMM_DISABLE_DEPRECATED _WRAP_METHOD(Glib::RefPtr get_animation(), gtk_image_get_animation, refreturn) _WRAP_METHOD(Glib::RefPtr get_animation() const, gtk_image_get_animation, refreturn, constversion) /** Gets the Gio::Icon and size being displayed by the Gtk::Image. * The storage type of the image must be IMAGE_EMPTY or * IMAGE_GICON (see get_storage_type()). * * @param icon_size A place to store an icon size. * * @newin{2,14} */ Glib::RefPtr get_gicon(Gtk::IconSize& icon_size); /** Gets the Gio::Icon and size being displayed by the Gtk::Image. * The storage type of the image must be IMAGE_EMPTY or * IMAGE_GICON (see get_storage_type()). * * @param icon_size A place to store an icon size. * * @newin{2,14} */ Glib::RefPtr get_gicon(Gtk::IconSize& icon_size) const; _IGNORE(gtk_image_get_gicon) Glib::ustring get_icon_name() const; Glib::ustring get_icon_name(IconSize& size); _IGNORE(gtk_image_get_icon_name) _WRAP_METHOD(int get_pixel_size() const, gtk_image_get_pixel_size) _WRAP_METHOD(void set_pixel_size(int pixel_size), gtk_image_set_pixel_size) _WRAP_PROPERTY("pixbuf", Glib::RefPtr) _WRAP_PROPERTY("file", Glib::ustring) _WRAP_PROPERTY("stock", Glib::ustring, deprecated "Use property_icon_name() instead.") _WRAP_PROPERTY("icon-set", Glib::RefPtr, deprecated "Use property_icon_name() instead.") _WRAP_PROPERTY("icon-size", int) _WRAP_PROPERTY("pixel-size", int) _WRAP_PROPERTY("pixbuf-animation", Glib::RefPtr) _WRAP_PROPERTY("icon-name", Glib::ustring) _WRAP_PROPERTY("storage-type", ImageType) _WRAP_PROPERTY("gicon", Glib::RefPtr) _WRAP_PROPERTY("use-fallback", bool) _WRAP_PROPERTY("resource", std::string) _WRAP_PROPERTY("surface", ::Cairo::RefPtr< ::Cairo::Surface>) }; } //namespace Gtk