// -*- c++ -*- // Generated by gtkmmproc -- DO NOT MODIFY! #ifndef _GTKMM_WIDGET_H #define _GTKMM_WIDGET_H #include /* $Id$ */ /* Copyright (C) 2002, 2003 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include //For GTKMM_ATKMM_ENABLED #ifdef GTKMM_ATKMM_ENABLED #include #include #endif //GTKMM_ATKMM_ENABLED #include #include #include #include #include #include #include #include //#include #include #include #include #include //#include #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { typedef struct _GtkTargetEntry GtkTargetEntry; } #endif /* DOXYGEN_SHOULD_SKIP_THIS */ #ifndef DOXYGEN_SHOULD_SKIP_THIS typedef struct _GtkWidget GtkWidget; typedef struct _GtkWidgetClass GtkWidgetClass; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ namespace Gtk { class Widget_Class; } // namespace Gtk namespace Gtk { /** @addtogroup gtkmmEnums Enums and Flags */ /** * @ingroup gtkmmEnums * @par Bitwise operators: * %DestDefaults operator|(DestDefaults, DestDefaults)
* %DestDefaults operator&(DestDefaults, DestDefaults)
* %DestDefaults operator^(DestDefaults, DestDefaults)
* %DestDefaults operator~(DestDefaults)
* %DestDefaults& operator|=(DestDefaults&, DestDefaults)
* %DestDefaults& operator&=(DestDefaults&, DestDefaults)
* %DestDefaults& operator^=(DestDefaults&, DestDefaults)
*/ enum DestDefaults { DEST_DEFAULT_MOTION = 1 << 0, DEST_DEFAULT_HIGHLIGHT = 1 << 1, DEST_DEFAULT_DROP = 1 << 2, DEST_DEFAULT_ALL = 0x07 }; /** @ingroup gtkmmEnums */ inline DestDefaults operator|(DestDefaults lhs, DestDefaults rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline DestDefaults operator&(DestDefaults lhs, DestDefaults rhs) { return static_cast(static_cast(lhs) & static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline DestDefaults operator^(DestDefaults lhs, DestDefaults rhs) { return static_cast(static_cast(lhs) ^ static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline DestDefaults operator~(DestDefaults flags) { return static_cast(~static_cast(flags)); } /** @ingroup gtkmmEnums */ inline DestDefaults& operator|=(DestDefaults& lhs, DestDefaults rhs) { return (lhs = static_cast(static_cast(lhs) | static_cast(rhs))); } /** @ingroup gtkmmEnums */ inline DestDefaults& operator&=(DestDefaults& lhs, DestDefaults rhs) { return (lhs = static_cast(static_cast(lhs) & static_cast(rhs))); } /** @ingroup gtkmmEnums */ inline DestDefaults& operator^=(DestDefaults& lhs, DestDefaults rhs) { return (lhs = static_cast(static_cast(lhs) ^ static_cast(rhs))); } } // namespace Gtk #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace Glib { template <> class Value : public Glib::Value_Flags { public: static GType value_type() G_GNUC_CONST; }; } // namespace Glib #endif /* DOXYGEN_SHOULD_SKIP_THIS */ namespace Gtk { /** * @ingroup gtkmmEnums * @par Bitwise operators: * %WidgetFlags operator|(WidgetFlags, WidgetFlags)
* %WidgetFlags operator&(WidgetFlags, WidgetFlags)
* %WidgetFlags operator^(WidgetFlags, WidgetFlags)
* %WidgetFlags operator~(WidgetFlags)
* %WidgetFlags& operator|=(WidgetFlags&, WidgetFlags)
* %WidgetFlags& operator&=(WidgetFlags&, WidgetFlags)
* %WidgetFlags& operator^=(WidgetFlags&, WidgetFlags)
*/ enum WidgetFlags { TOPLEVEL = 1 << 4, NO_WINDOW = 1 << 5, REALIZED = 1 << 6, MAPPED = 1 << 7, VISIBLE = 1 << 8, SENSITIVE = 1 << 9, PARENT_SENSITIVE = 1 << 10, CAN_FOCUS = 1 << 11, HAS_FOCUS = 1 << 12, CAN_DEFAULT = 1 << 13, HAS_DEFAULT = 1 << 14, HAS_GRAB = 1 << 15, RC_STYLE = 1 << 16, COMPOSITE_CHILD = 1 << 17, NO_REPARENT = 1 << 18, APP_PAINTABLE = 1 << 19, RECEIVES_DEFAULT = 1 << 20, DOUBLE_BUFFERED = 1 << 21, NO_SHOW_ALL = 1 << 22 }; /** @ingroup gtkmmEnums */ inline WidgetFlags operator|(WidgetFlags lhs, WidgetFlags rhs) { return static_cast(static_cast(lhs) | static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline WidgetFlags operator&(WidgetFlags lhs, WidgetFlags rhs) { return static_cast(static_cast(lhs) & static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline WidgetFlags operator^(WidgetFlags lhs, WidgetFlags rhs) { return static_cast(static_cast(lhs) ^ static_cast(rhs)); } /** @ingroup gtkmmEnums */ inline WidgetFlags operator~(WidgetFlags flags) { return static_cast(~static_cast(flags)); } /** @ingroup gtkmmEnums */ inline WidgetFlags& operator|=(WidgetFlags& lhs, WidgetFlags rhs) { return (lhs = static_cast(static_cast(lhs) | static_cast(rhs))); } /** @ingroup gtkmmEnums */ inline WidgetFlags& operator&=(WidgetFlags& lhs, WidgetFlags rhs) { return (lhs = static_cast(static_cast(lhs) & static_cast(rhs))); } /** @ingroup gtkmmEnums */ inline WidgetFlags& operator^=(WidgetFlags& lhs, WidgetFlags rhs) { return (lhs = static_cast(static_cast(lhs) ^ static_cast(rhs))); } } // namespace Gtk #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace Glib { template <> class Value : public Glib::Value_Flags { public: static GType value_type() G_GNUC_CONST; }; } // namespace Glib #endif /* DOXYGEN_SHOULD_SKIP_THIS */ namespace Gtk { /** * @ingroup gtkmmEnums */ enum WidgetHelpType { WIDGET_HELP_TOOLTIP, WIDGET_HELP_WHATS_THIS }; } // namespace Gtk #ifndef DOXYGEN_SHOULD_SKIP_THIS namespace Glib { template <> class Value : public Glib::Value_Enum { public: static GType value_type() G_GNUC_CONST; }; } // namespace Glib #endif /* DOXYGEN_SHOULD_SKIP_THIS */ namespace Gtk { class Action; class Style; class AccelGroup; class Adjustment; class Window; class Container; class Settings; class Tooltip; typedef GtkRequisition Requisition; // Gtk::Allocation is a typedef of Gdk::Rectangle because GtkAllocation is // a typedef of GdkRectangle. typedef Gdk::Rectangle Allocation; /** @defgroup Widgets Widgets */ /** Abstract Widget (Base class for all widgets) * * As the base class of all widgets this contains all of the properties * and methods common to all widgets. It is an abstract class that * can not be instantiated. * * Important part of widgets are the *_event signals and virtual methods * that every widget have. Those are events coming directly from gdk and * thus also from XLib. By overriding those virtual methods you can * trap everything a widget can ever do. * In order to capture events from a widget, the event mask must * first be set with (). * * Only widgets with a Gdk::Window on the server side are allowed to * capture events. Widgets in the Gtk::Misc group for example lack * a Gdk::Window. */ class Widget : public Object #ifdef GTKMM_ATKMM_ENABLED ,public Atk::Implementor #endif //GTKMM_ATKMM_ENABLED { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS typedef Widget CppObjectType; typedef Widget_Class CppClassType; typedef GtkWidget BaseObjectType; typedef GtkWidgetClass BaseClassType; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ virtual ~Widget(); #ifndef DOXYGEN_SHOULD_SKIP_THIS private: friend class Widget_Class; static CppClassType widget_class_; // noncopyable Widget(const Widget&); Widget& operator=(const Widget&); protected: explicit Widget(const Glib::ConstructParams& construct_params); explicit Widget(GtkWidget* castitem); #endif /* DOXYGEN_SHOULD_SKIP_THIS */ public: #ifndef DOXYGEN_SHOULD_SKIP_THIS static GType get_type() G_GNUC_CONST; static GType get_base_type() G_GNUC_CONST; #endif ///Provides access to the underlying C GtkObject. GtkWidget* gobj() { return reinterpret_cast(gobject_); } ///Provides access to the underlying C GtkObject. const GtkWidget* gobj() const { return reinterpret_cast(gobject_); } public: //C++ methods used to invoke GTK+ virtual functions: #ifdef GLIBMM_VFUNCS_ENABLED #endif //GLIBMM_VFUNCS_ENABLED protected: //GTK+ Virtual Functions (override these to change behaviour): #ifdef GLIBMM_VFUNCS_ENABLED #endif //GLIBMM_VFUNCS_ENABLED //Default Signal Handlers:: #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED virtual void on_show(); virtual void on_hide(); virtual void on_map(); virtual void on_unmap(); virtual void on_realize(); virtual void on_unrealize(); virtual void on_size_request(Requisition* requisition); virtual void on_size_allocate(Allocation& allocation); virtual void on_state_changed(Gtk::StateType previous_state); virtual void on_parent_changed(Widget* previous_parent); virtual void on_hierarchy_changed(Widget* previous_toplevel); virtual void on_style_changed(const Glib::RefPtr& previous_style); virtual void on_direction_changed(TextDirection direction); virtual void on_grab_notify(bool was_grabbed); virtual void on_child_notify(GParamSpec* pspec); virtual bool on_mnemonic_activate(bool group_cycling); virtual void on_grab_focus(); virtual bool on_focus(DirectionType direction); virtual bool on_event(GdkEvent* event); virtual bool on_button_press_event(GdkEventButton* event); virtual bool on_button_release_event(GdkEventButton* event); virtual bool on_scroll_event(GdkEventScroll* event); virtual bool on_motion_notify_event(GdkEventMotion* event); virtual bool on_delete_event(GdkEventAny* event); virtual bool on_expose_event(GdkEventExpose* event); virtual bool on_key_press_event(GdkEventKey* event); virtual bool on_key_release_event(GdkEventKey* event); virtual bool on_enter_notify_event(GdkEventCrossing* event); virtual bool on_leave_notify_event(GdkEventCrossing* event); virtual bool on_configure_event(GdkEventConfigure* event); virtual bool on_focus_in_event(GdkEventFocus* event); virtual bool on_focus_out_event(GdkEventFocus* event); virtual bool on_map_event(GdkEventAny* event); virtual bool on_unmap_event(GdkEventAny* event); virtual bool on_property_notify_event(GdkEventProperty* event); virtual bool on_selection_clear_event(GdkEventSelection* event); virtual bool on_selection_request_event(GdkEventSelection* event); virtual bool on_selection_notify_event(GdkEventSelection* event); virtual bool on_proximity_in_event(GdkEventProximity* event); virtual bool on_proximity_out_event(GdkEventProximity* event); virtual bool on_visibility_notify_event(GdkEventVisibility* event); virtual bool on_client_event(GdkEventClient* event); virtual bool on_no_expose_event(GdkEventAny* event); virtual bool on_window_state_event(GdkEventWindowState* event); virtual void on_selection_get(SelectionData& selection_data, guint info, guint time); virtual void on_selection_received(const SelectionData& selection_data, guint time); virtual void on_drag_begin(const Glib::RefPtr& context); virtual void on_drag_end(const Glib::RefPtr& context); virtual void on_drag_data_get(const Glib::RefPtr& context, SelectionData& selection_data, guint info, guint time); virtual void on_drag_data_delete(const Glib::RefPtr& context); virtual void on_drag_leave(const Glib::RefPtr& context, guint time); virtual bool on_drag_motion(const Glib::RefPtr& context, int x, int y, guint time); virtual bool on_drag_drop(const Glib::RefPtr& context, int x, int y, guint time); virtual void on_drag_data_received(const Glib::RefPtr& context, int x, int y, const SelectionData& selection_data, guint info, guint time); #ifdef GTKMM_ATKMM_ENABLED virtual Glib::RefPtr on_get_accessible(); #endif // GTKMM_ATKMM_ENABLED virtual void on_screen_changed(const Glib::RefPtr& previous_screen); #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED private: public: friend class Main; /** For widgets that support scrolling, sets the scroll adjustments and * Return value: true if the widget supports scrolling * @param hadjustment An adjustment for horizontal scrolling, or 0. * @param vadjustment An adjustment for vertical scrolling, or 0. * @return true if the widget supports scrolling. */ bool set_scroll_adjustments(Adjustment& hadjustment, Adjustment& vadjustment); /** Flags a widget to be displayed. Any widget that isn't shown will * not appear on the screen. If you want to show all the widgets in a * container, it's easier to call show_all() on the * container, instead of individually showing the widgets. * * Remember that you have to show the containers containing a widget, * in addition to the widget itself, before it will appear onscreen. * * When a toplevel container is shown, it is immediately realized and * mapped; other shown widgets are realized and mapped when their * toplevel container is realized and mapped. */ void show(); /** Shows a widget. If the widget is an unmapped toplevel widget * (i.e. a Gtk::Window that has not yet been shown), enter the main * loop and wait for the window to actually be mapped. Be careful; * because the main loop is running, anything can happen during * this function. */ void show_now(); /** Reverses the effects of show(), causing the widget to be * hidden (invisible to the user). */ void hide(); /** Recursively shows a widget, and any child widgets (if the widget is * a container). */ void show_all(); /** Recursively hides a widget and any child widgets. */ void hide_all(); /* QUEUE DRAWS */ /** Equivalent to calling queue_draw_area() for the * entire area of a widget. */ void queue_draw(); /** Invalidates the rectangular area of @a widget defined by @a x , @a y , * @a width and @a height by calling gdk_window_invalidate_rect() on the * widget's window and all its child windows. Once the main loop * becomes idle (after the current batch of events has been processed, * roughly), the window will receive expose events for the union of * all regions that have been invalidated. * * Normally you would only use this function in widget * implementations. You might also use it, or * gdk_window_invalidate_rect() directly, to schedule a redraw of a * Gtk::DrawingArea or some portion thereof. * * Frequently you can just call gdk_window_invalidate_rect() or * gdk_window_invalidate_region() instead of this function. Those * functions will invalidate only a single window, instead of the * widget and all its children. * * The advantage of adding to the invalidated region compared to * simply drawing immediately is efficiency; using an invalid region * ensures that you only have to redraw one time. * @param x X coordinate of upper-left corner of rectangle to redraw. * @param y Y coordinate of upper-left corner of rectangle to redraw. * @param width Width of region to draw. * @param height Height of region to draw. */ void queue_draw_area(int x, int y, int width, int height); /** This function is only for use in widget implementations. * Flags a widget to have its size renegotiated; should * be called when a widget for some reason has a new size request. * For example, when you change the text in a Gtk::Label, Gtk::Label * queues a resize to ensure there's enough space for the new text. */ void queue_resize(); /** This function is typically used when implementing a Gtk::Container * subclass. Obtains the preferred size of a widget. The container * uses this information to arrange its child widgets and decide what * size allocations to give them with size_allocate(). * * You can also call this function from an application, with some * caveats. Most notably, getting a size request requires the widget * to be associated with a screen, because font information may be * needed. Multihead-aware applications should keep this in mind. * * Also remember that the size request is not necessarily the size * a widget will actually be allocated. * * See also get_child_requisition(). * @result A Gtk::Requisition. */ Requisition size_request() const; #ifndef GTKMM_DISABLE_DEPRECATED /** This function is typically used when implementing a Gtk::Container * subclass. Obtains the preferred size of a widget. The container * uses this information to arrange its child widgets and decide what * size allocations to give them with size_allocate(). * * You can also call this function from an application, with some * caveats. Most notably, getting a size request requires the widget * to be associated with a screen, because font information may be * needed. Multihead-aware applications should keep this in mind. * * Also remember that the size request is not necessarily the size * a widget will actually be allocated. * * See also get_child_requisition(). * @deprecated Use size_request() const. * @param requisition A Gtk::Requisition to be filled in. */ void size_request(const Requisition& requisition); #endif // GTKMM_DISABLE_DEPRECATED /** This function is only used by Gtk::Container subclasses, to assign a size * and position to their child widgets. * @param allocation Position and size to be allocated to @a widget . */ void size_allocate(const Allocation& allocation); /** Installs an accelerator for this @a widget in @a accel_group that causes * @a accel_signal to be emitted if the accelerator is activated. * The @a accel_group needs to be added to the widget's toplevel via * Gtk::Window::add_accel_group(), and the signal must be of type G::RUN_ACTION. * Accelerators added through this function are not user changeable during * runtime. If you want to support accelerators that can be changed by the * user, use gtk_accel_map_add_entry() and set_accel_path() or * Gtk::MenuItem::set_accel_path() instead. * @param accel_signal Widget signal to emit on accelerator activation. * @param accel_group Accel group for this widget, added to its toplevel. * @param accel_key GDK keyval of the accelerator. * @param accel_mods Modifier key combination of the accelerator. * @param accel_flags Flag accelerators, e.g. Gtk::ACCEL_VISIBLE. */ void add_accelerator(const Glib::ustring& accel_signal, const Glib::RefPtr& accel_group, guint accel_key, Gdk::ModifierType accel_mods, AccelFlags accel_flags); /** Removes an accelerator from @a widget , previously installed with * add_accelerator(). * @param accel_group Accel group for this widget. * @param accel_key GDK keyval of the accelerator. * @param accel_mods Modifier key combination of the accelerator. * @return Whether an accelerator was installed and could be removed. */ bool remove_accelerator(const Glib::RefPtr& accel_group, guint accel_key, Gdk::ModifierType accel_mods); /** Given an accelerator group, @a accel_group , and an accelerator path, * @a accel_path , sets up an accelerator in @a accel_group so whenever the * key binding that is defined for @a accel_path is pressed, @a widget * will be activated. This removes any accelerators (for any * accelerator group) installed by previous calls to * set_accel_path(). Associating accelerators with * paths allows them to be modified by the user and the modifications * to be saved for future use. (See gtk_accel_map_save().) * * This function is a low level function that would most likely * be used by a menu creation system like Gtk::UIManager. If you * use Gtk::UIManager, setting up accelerator paths will be done * automatically. * * Even when you you aren't using Gtk::UIManager, if you only want to * set up accelerators on menu items Gtk::MenuItem::set_accel_path() * provides a somewhat more convenient interface. * @param accel_path Path used to look up the accelerator. * @param accel_group A Gtk::AccelGroup. */ void set_accel_path(const Glib::ustring& accel_path, const Glib::RefPtr& accel_group); //GList* gtk_widget_list_accel_closures(); //TODO: Or maybe it is useless: gboolean gtk_widget_can_activate_accel(GtkWidget *widget, guint signal_id) bool mnemonic_activate(bool group_cycling); //TODO: Use C++ type /** Rarely-used function. This function is used to emit * the event signals on a widget (those signals should never * be emitted without using this function to do so). * If you want to synthesize an event though, don't use this function; * instead, use gtk_main_do_event() so the event will behave as if * it were in the event queue. Don't synthesize expose events; instead, * use gdk_window_invalidate_rect() to invalidate a region of the * window. * @param event A Gdk::Event. * @return Return from the event signal emission (true if * the event was handled). */ bool event(GdkEvent* event); /** Very rarely-used function. This function is used to emit * an expose event signals on a widget. This function is not * normally used directly. The only time it is used is when * propagating an expose event to a child NO_WINDOW widget, and * that is normally done using Gtk::Container::propagate_expose(). * * If you want to force an area of a window to be redrawn, * use gdk_window_invalidate_rect() or gdk_window_invalidate_region(). * To cause the redraw to be done immediately, follow that call * with a call to gdk_window_process_updates(). * @param event A expose Gdk::Event. * @return Return from the event signal emission (true if * the event was handled). */ int send_expose(GdkEvent* event); /** For widgets that can be "activated" (buttons, menu items, etc.) * this function activates them. Activation is what happens when you * press Enter on a widget during key navigation. If @a widget isn't * activatable, the function returns false. * @return true if the widget was activatable. */ bool activate(); /** Moves a widget from one Gtk::Container to another, handling reference * count issues to avoid destroying the widget. * @param new_parent A Gtk::Container to move the widget into. */ void reparent(Widget & new_parent); bool intersect(const Gdk::Rectangle& area) const; /** Computes the intersection of a @a widget 's area and @a area , storing * the intersection in @a intersection , and returns true if there was * an intersection. @a intersection may be 0 if you're only * interested in whether there was an intersection. * @param area A rectangle. * @param intersection Rectangle to store intersection of @a widget and @a area . * @return true if there was an intersection. */ bool intersect(const Gdk::Rectangle& area, Gdk::Rectangle& intersection) const; /** Computes the intersection of a @a widget 's area and @a region , returning * the intersection. The result may be empty, use gdk_region_empty() to * check. * @param region A Gdk::Region, in the same coordinate system as * @a widget ->allocation. That is, relative to @a widget ->window * for NO_WINDOW widgets; relative to the parent window * of @a widget ->window for widgets with their own window. * @return A newly allocated region holding the intersection of @a widget * and @a region . The coordinates of the return value are * relative to @a widget ->window for NO_WINDOW widgets, and * relative to the parent window of @a widget ->window for * widgets with their own window. */ Gdk::Region region_intersect(const Gdk::Region& region) const; /** Stops emission of Gtk::Widget::child-notify signals on @a widget . The * signals are queued until thaw_child_notify() is called * on @a widget . * * This is the analogue of Glib::object_freeze_notify() for child properties. */ void freeze_child_notify(); /** Emits a Gtk::Widget::child-notify signal for the * child property @a child_property * on @a widget . * * This is the analogue of Glib::object_notify() for child properties. * @param child_property The name of a child property installed on the * class of @a widget <!-- -->'s parent. */ void child_notify(const Glib::ustring& child_property); /** Reverts the effect of a previous call to freeze_child_notify(). * This causes all queued Gtk::Widget::child-notify signals on @a widget to be * emitted. */ void thaw_child_notify(); /** Determines if the widget is the focus widget within its * toplevel. (This does not mean that the HAS_FOCUS flag is * necessarily set; HAS_FOCUS will only be set if the * toplevel widget additionally has the global input focus.) * @return true if the widget is the focus widget. */ bool is_focus() const; /** Causes @a widget to have the keyboard focus for the Gtk::Window it's * inside. @a widget must be a focusable widget, such as a Gtk::Entry; * something like Gtk::Frame won't work. (More precisely, it must have the * Gtk::CAN_FOCUS flag set.) */ void grab_focus(); /** Causes @a widget to become the default widget. @a widget must have the * Gtk::CAN_DEFAULT flag set; typically you have to set this flag * yourself by calling GTK_WIDGET_SET_FLAGS ( @a widget , * GTK_CAN_DEFAULT). The default widget is activated when * the user presses Enter in a window. Default widgets must be * activatable, that is, activate() should affect them. */ void grab_default(); /** Block events to everything else than this widget and its children. This * way you can get modal behaviour (usually not recommended). One practical * example could be when implementing a key-binding widget that needs * exclusive access to the key combination that the user presses next. * * Calls to add_modal_grab should be paired with calls to remove_modal_grab. */ void add_modal_grab(); /** Remove the modal grab of the widget in case it was previously grabbed. */ void remove_modal_grab(); /** Retrieve the widget which is currently grabbing all events. */ static Widget* get_current_modal_grab(); /** Widgets can be named, which allows you to refer to them from a * gtkrc file. You can apply a style to widgets with a particular name * in the gtkrc file. See the documentation for gtkrc files (on the * same page as the docs for Gtk::RcStyle). * * Note that widget names are separated by periods in paths (see * path()), so names with embedded periods may cause confusion. * @param name Name for the widget. */ void set_name(const Glib::ustring& name); void unset_name(); /** Retrieves the name of a widget. See set_name() for the * significance of widget names. * @return Name of the widget. This string is owned by GTK+ and * should not be modified or freed. */ Glib::ustring get_name() const; /** This function is for use in widget implementations. Sets the state * of a widget (insensitive, prelighted, etc.) Usually you should set * the state using wrapper functions such as set_sensitive(). * @param state New state for @a widget . */ void set_state(Gtk::StateType state); /** Sets the sensitivity of a widget. A widget is sensitive if the user * can interact with it. Insensitive widgets are "grayed out" and the * user can't interact with them. Insensitive widgets are known as * "inactive", "disabled", or "ghosted" in some other toolkits. * @param sensitive true to make the widget sensitive. */ void set_sensitive(bool sensitive = true); /** Sets whether the application intends to draw on the widget in * an Gtk::Widget::expose-event handler. * * This is a hint to the widget and does not affect the behavior of * the GTK+ core; many widgets ignore this flag entirely. For widgets * that do pay attention to the flag, such as Gtk::EventBox and Gtk::Window, * the effect is to suppress default themed drawing of the widget's * background. (Children of the widget will still be drawn.) The application * is then entirely responsible for drawing the widget background. * * Note that the background is still drawn when the widget is mapped. * If this is not suitable (e.g. because you want to make a transparent * window using an RGBA visual), you can work around this by doing: * @code * gtk_widget_realize (window); * gdk_window_set_back_pixmap (window->window, 0, false); * gtk_widget_show (window); * @endcode * @param app_paintable true if the application will paint on the widget. */ void set_app_paintable(bool app_paintable = true); /** Widgets are double buffered by default; you can use this function * to turn off the buffering. "Double buffered" simply means that * gdk_window_begin_paint_region() and gdk_window_end_paint() are called * automatically around expose events sent to the * widget. gdk_window_begin_paint() diverts all drawing to a widget's * window to an offscreen buffer, and gdk_window_end_paint() draws the * buffer to the screen. The result is that users see the window * update in one smooth step, and don't see individual graphics * primitives being rendered. * * In very simple terms, double buffered widgets don't flicker, * so you would only use this function to turn off double buffering * if you had special needs and really knew what you were doing. * * @note if you turn off double-buffering, you have to handle * expose events, since even the clearing to the background color or * pixmap will not happen automatically (as it is done in * gdk_window_begin_paint()). * @param double_buffered true to double-buffer a widget. */ void set_double_buffered(bool double_buffered = true); /** Sets whether the entire widget is queued for drawing when its size * allocation changes. By default, this setting is true and * the entire widget is redrawn on every size change. If your widget * leaves the upper left unchanged when made bigger, turning this * setting off will improve performance. * * Note that for NO_WINDOW widgets setting this flag to false turns * off all allocation on resizing: the widget will not even redraw if * its position changes; this is to allow containers that don't draw * anything to avoid excess invalidations. If you set this flag on a * NO_WINDOW widget that does draw on @a widget ->window, * you are responsible for invalidating both the old and new allocation * of the widget when the widget is moved and responsible for invalidating * regions newly when the widget increases size. * @param redraw_on_allocate If true, the entire widget will be redrawn * when it is allocated to a new size. Otherwise, only the * new portion of the widget will be redrawn. */ void set_redraw_on_allocate(bool redraw_on_allocate = true); /** Sets whether @a widget should be mapped along with its when its parent * is mapped and @a widget has been shown with show(). * * The child visibility can be set for widget before it is added to * a container with set_parent(), to avoid mapping * children unnecessary before immediately unmapping them. However * it will be reset to its default state of true when the widget * is removed from a container. * * Note that changing the child visibility of a widget does not * queue a resize on the widget. Most of the time, the size of * a widget is computed from all visible children, whether or * not they are mapped. If this is not the case, the container * can queue a resize itself. * * This function is only useful for container implementations and * never should be called by an application. * @param is_visible If true, @a widget should be mapped along with its parent. */ void set_child_visible(bool is_visible = true); /** Gets the value set with set_child_visible(). * If you feel a need to use this function, your code probably * needs reorganization. * * This function is only useful for container implementations and * never should be called by an application. * @return true if the widget is mapped with the parent. */ bool get_child_visible() const; /** Return value: the parent container of @a widget , or 0 * @return The parent container of @a widget , or 0. */ Container* get_parent(); /** Return value: the parent container of @a widget , or 0 * @return The parent container of @a widget , or 0. */ const Container* get_parent() const; /** Gets @a widget 's parent window. * @return The parent window of @a widget . */ Glib::RefPtr get_parent_window(); /** Gets @a widget 's parent window. * @return The parent window of @a widget . */ Glib::RefPtr get_parent_window() const; /** Sets a non default parent window for @a widget . * @param parent_window The new parent window. */ void set_parent_window(const Glib::RefPtr& parent_window); /** This function is used by custom widget implementations; if you're * writing an app, you'd use grab_focus() to move the focus * to a particular widget, and Gtk::Container::set_focus_chain() to * change the focus tab order. So you may want to investigate those * functions instead. * * child_focus() is called by containers as the user moves * around the window using keyboard shortcuts. @a direction indicates * what kind of motion is taking place (up, down, left, right, tab * forward, tab backward). child_focus() emits the * Gtk::Widget::focus" signal; widgets override the default handler * for this signal in order to implement appropriate focus behavior. * * The default ::focus handler for a widget should return true if * moving in @a direction left the focus on a focusable location inside * that widget, and false if moving in @a direction moved the focus * outside the widget. If returning true, widgets normally * call grab_focus() to place the focus accordingly; * if returning false, they don't modify the current focus location. * * This function replaces gtk_container_focus() from GTK+ 1.2. * It was necessary to check that the child was visible, sensitive, * and focusable before calling gtk_container_focus(). * child_focus() returns false if the widget is not * currently in a focusable state, so there's no need for those checks. * @param direction Direction of focus movement. * @return true if focus ended up inside @a widget . */ bool child_focus(DirectionType direction); /** This function should be called whenever keyboard navigation within * a single widget hits a boundary. The function emits the * Gtk::Widget::keynav-changed signal on the widget and its return * value should be interpreted in a way similar to the return value of * child_focus(): * * When true is returned, stay in the widget, the failed keyboard * navigation is Ok and/or there is nowhere we can/should move the * focus to. * * When false is returned, the caller should continue with keyboard * navigation outside the widget, e.g. by calling * child_focus() on the widget's toplevel. * * The default ::keynav-failed handler returns true for * Gtk::DIR_TAB_FORWARD and Gtk::DIR_TAB_BACKWARD. For the other * values of Gtk::DirectionType, it looks at the * Gtk::Settings:gtk-keynav-cursor-only" setting and returns false * if the setting is true. This way the entire user interface * becomes cursor-navigatable on input devices such as mobile phones * which only have cursor keys but no tab key. * * Whenever the default handler returns true, it also calls * error_bell() to notify the user of the failed keyboard * navigation. * * A use case for providing an own implementation of ::keynav-failed * (either by connecting to it or by overriding it) would be a row of * Gtk::Entry widgets where the user should be able to navigate the * entire row with the cursor keys, as e.g. known from user interfaces * that require entering license keys. * @param direction Direction of focus movement. * @return true if stopping keyboard navigation is fine, false * if the emitting widget should try to handle the keyboard * navigation attempt in its parent container(s). * * @newin2p12. */ bool keynav_failed(DirectionType direction); /** Notifies the user about an input-related error on this widget. * If the Gtk::Settings gtk-error-bell proeprty is true, it calls * Gdk::Window::beep(), otherwise it does nothing. * * Note that the effect of Gdk::Window::beep() can be configured in many * ways, depending on the windowing backend and the desktop environment * or window manager that is used. * * @newin2p12 */ void error_bell(); /** Sets the minimum size of a widget; that is, the widget's size * request will be @a width by @a height . You can use this function to * force a widget to be either larger or smaller than it normally * would be. * * In most cases, Gtk::Window::set_default_size() is a better choice for * toplevel windows than this function; setting the default size will * still allow users to shrink the window. Setting the size request * will force them to leave the window at least as large as the size * request. When dealing with window sizes, * Gtk::Window::set_geometry_hints() can be a useful function as well. * * Note the inherent danger of setting any fixed size - themes, * translations into other languages, different fonts, and user action * can all change the appropriate size for a given widget. So, it's * basically impossible to hardcode a size that will always be * correct. * * The size request of a widget is the smallest size a widget can * accept while still functioning well and drawing itself correctly. * However in some strange cases a widget may be allocated less than * its requested size, and in many cases a widget may be allocated more * space than it requested. * * If the size request in a given direction is -1 (unset), then * the "natural" size request of the widget will be used instead. * * Widgets can't actually be allocated a size less than 1 by 1, but * you can pass 0,0 to this function to mean "as small as possible." * @param width Width @a widget should request, or -1 to unset. * @param height Height @a widget should request, or -1 to unset. */ void set_size_request(int width = -1, int height = -1); /** Gets the size request that was explicitly set for the widget using * set_size_request(). A value of -1 stored in @a width or * @a height indicates that that dimension has not been set explicitly * and the natural requisition of the widget will be used intead. See * set_size_request(). To get the size a widget will * actually use, call size_request() instead of * this function. * @param width Return location for width, or 0. * @param height Return location for height, or 0. */ void get_size_request(int& width, int& height) const; /** Sets the event mask (see Gdk::EventMask) for a widget. The event * mask determines which events a widget will receive. Keep in mind * that different widgets have different default event masks, and by * changing the event mask you may disrupt a widget's functionality, * so be careful. This function must be called while a widget is * unrealized. Consider add_events() for widgets that are * already realized, or if you want to preserve the existing event * mask. This function can't be used with Gtk::NO_WINDOW widgets; * to get events on those widgets, place them inside a Gtk::EventBox * and receive events on the event box. * @param events Event mask. */ void set_events(Gdk::EventMask events); /** Adds the events in the bitfield @a events to the event mask for * @a widget . See set_events() for details. * @param events An event mask, see Gdk::EventMask. */ void add_events(Gdk::EventMask events); /** Sets the extension events mask to @a mode . See Gdk::ExtensionMode * and gdk_input_set_extension_events(). * @param mode Bitfield of extension events to receive. */ void set_extension_events(Gdk::ExtensionMode mode); /** Retrieves the extension events the widget will receive; see * gdk_input_set_extension_events(). * @return Extension events for @a widget . */ Gdk::ExtensionMode get_extension_events() const; /** This function returns the topmost widget in the container hierarchy * @a widget is a part of. If @a widget has no parent widgets, it will be * returned as the topmost widget. No reference will be added to the * returned widget; it should not be unreferenced. * * Note the difference in behavior vs. get_ancestor(); * gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) * would return * 0 if @a widget wasn't inside a toplevel window, and if the * window was inside a Gtk::Window-derived widget which was in turn * inside the toplevel Gtk::Window. While the second case may * seem unlikely, it actually happens when a Gtk::Plug is embedded * inside a Gtk::Socket within the same application. * * To reliably find the toplevel Gtk::Window, use * get_toplevel() and check if the T::OPLEVEL flags * is set on the result. * @code * GtkWidget *toplevel = gtk_widget_get_toplevel (widget); * if (GTK_WIDGET_TOPLEVEL (toplevel)) * { * [ Perform action on toplevel. ] * } * @endcode * @return The topmost ancestor of @a widget , or @a widget itself * if there's no ancestor. */ Container* get_toplevel(); /** This function returns the topmost widget in the container hierarchy * @a widget is a part of. If @a widget has no parent widgets, it will be * returned as the topmost widget. No reference will be added to the * returned widget; it should not be unreferenced. * * Note the difference in behavior vs. get_ancestor(); * gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW) * would return * 0 if @a widget wasn't inside a toplevel window, and if the * window was inside a Gtk::Window-derived widget which was in turn * inside the toplevel Gtk::Window. While the second case may * seem unlikely, it actually happens when a Gtk::Plug is embedded * inside a Gtk::Socket within the same application. * * To reliably find the toplevel Gtk::Window, use * get_toplevel() and check if the T::OPLEVEL flags * is set on the result. * @code * GtkWidget *toplevel = gtk_widget_get_toplevel (widget); * if (GTK_WIDGET_TOPLEVEL (toplevel)) * { * [ Perform action on toplevel. ] * } * @endcode * @return The topmost ancestor of @a widget , or @a widget itself * if there's no ancestor. */ const Container* get_toplevel() const; /** Gets the first ancestor of @a widget with type @a widget_type . For example, * gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets * the first Gtk::Box that's an ancestor of @a widget . No reference will be * added to the returned widget; it should not be unreferenced. See note * about checking for a toplevel Gtk::Window in the docs for * get_toplevel(). * * Note that unlike is_ancestor(), get_ancestor() * considers @a widget to be an ancestor of itself. * @param widget_type Ancestor type. * @return The ancestor widget, or 0 if not found. */ Widget* get_ancestor(GType widget_type); /** Gets the first ancestor of @a widget with type @a widget_type . For example, * gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets * the first Gtk::Box that's an ancestor of @a widget . No reference will be * added to the returned widget; it should not be unreferenced. See note * about checking for a toplevel Gtk::Window in the docs for * get_toplevel(). * * Note that unlike is_ancestor(), get_ancestor() * considers @a widget to be an ancestor of itself. * @param widget_type Ancestor type. * @return The ancestor widget, or 0 if not found. */ const Widget* get_ancestor(GType widget_type) const; /** Gets the colormap that will be used to render @a widget . No reference will * be added to the returned colormap; it should not be unreferenced. * @return The colormap used by @a widget . */ Glib::RefPtr get_colormap(); /** Gets the visual that will be used to render @a widget . * @return The visual for @a widget . */ Glib::RefPtr get_visual(); /** Get the Gdk::Screen from the toplevel window associated with * this widget. This function can only be called after the widget * has been added to a widget hierarchy with a Gtk::Window * at the top. * * In general, you should only create screen specific * resources when a widget has been realized, and you should * free those resources when the widget is unrealized. * @return The Gdk::Screen for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_screen(); /** Get the Gdk::Screen from the toplevel window associated with * this widget. This function can only be called after the widget * has been added to a widget hierarchy with a Gtk::Window * at the top. * * In general, you should only create screen specific * resources when a widget has been realized, and you should * free those resources when the widget is unrealized. * @return The Gdk::Screen for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_screen() const; /** Checks whether there is a Gdk::Screen is associated with * this widget. All toplevel widgets have an associated * screen, and all widgets added into a heirarchy with a toplevel * window at the top. * @return true if there is a Gdk::Screen associcated * with the widget. * * @newin2p2. */ bool has_screen() const; /** Get the Gdk::Display for the toplevel window associated with * this widget. This function can only be called after the widget * has been added to a widget hierarchy with a Gtk::Window at the top. * * In general, you should only create display specific * resources when a widget has been realized, and you should * free those resources when the widget is unrealized. * @return The Gdk::Display for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_display(); /** Get the Gdk::Display for the toplevel window associated with * this widget. This function can only be called after the widget * has been added to a widget hierarchy with a Gtk::Window at the top. * * In general, you should only create display specific * resources when a widget has been realized, and you should * free those resources when the widget is unrealized. * @return The Gdk::Display for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_display() const; /** Get the root window where this widget is located. This function can * only be called after the widget has been added to a widget * heirarchy with Gtk::Window at the top. * * The root window is useful for such purposes as creating a popup * Gdk::Window associated with the window. In general, you should only * create display specific resources when a widget has been realized, * and you should free those resources when the widget is unrealized. * @return The Gdk::Window root window for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_root_window(); /** Get the root window where this widget is located. This function can * only be called after the widget has been added to a widget * heirarchy with Gtk::Window at the top. * * The root window is useful for such purposes as creating a popup * Gdk::Window associated with the window. In general, you should only * create display specific resources when a widget has been realized, * and you should free those resources when the widget is unrealized. * @return The Gdk::Window root window for the toplevel for this widget. * * @newin2p2. */ Glib::RefPtr get_root_window() const; /** Gets the settings object holding the settings (global property * settings, RC file information, etc) used for this widget. * * Note that this function can only be called when the Gtk::Widget * is attached to a toplevel, since the settings object is specific * to a particular Gdk::Screen. * @return The relevant Gtk::Settings object. */ Glib::RefPtr get_settings(); /** Return value: the appropriate clipboard object. If no * @param selection A Gdk::Atom which identifies the clipboard * to use. Gdk::SELECTION_CLIPBOARD gives the * default clipboard. Another common value * is Gdk::SELECTION_PRIMARY, which gives * the primary X selection. * @return The appropriate clipboard object. If no * clipboard already exists, a new one will * be created. Once a clipboard object has * been created, it is persistent for all time. * * @newin2p2. */ Glib::RefPtr get_clipboard(const Glib::ustring& selection); /** Return value: the appropriate clipboard object. If no * @param selection A Gdk::Atom which identifies the clipboard * to use. Gdk::SELECTION_CLIPBOARD gives the * default clipboard. Another common value * is Gdk::SELECTION_PRIMARY, which gives * the primary X selection. * @return The appropriate clipboard object. If no * clipboard already exists, a new one will * be created. Once a clipboard object has * been created, it is persistent for all time. * * @newin2p2. */ Glib::RefPtr get_clipboard(const Glib::ustring& selection) const; //TODO: This probably needs a special conversion to do an extra ref (take_copy=true) for the returned instance: /** Returns: the Atk::Object associated with @a widget * @return The Atk::Object associated with @a widget . */ #ifdef GTKMM_ATKMM_ENABLED Glib::RefPtr get_accessible(); #endif // GTKMM_ATKMM_ENABLED /** Sets the colormap for the widget to the given value. Widget must not * have been previously realized. This probably should only be used * from an init() function (i.e. from the constructor * for the widget). * @param colormap A colormap. */ void set_colormap(const Glib::RefPtr &colormap); /** Return value: event mask for @a widget * @return Event mask for @a widget . */ Gdk::EventMask get_events() const; /** Obtains the location of the mouse pointer in widget coordinates. * Widget coordinates are a bit odd; for historical reasons, they are * defined as @a widget ->window coordinates for widgets that are not * Gtk::NO_WINDOW widgets, and are relative to @a widget ->allocation.x, * @a widget ->allocation.y for widgets that are Gtk::NO_WINDOW widgets. * @param x Return location for the X coordinate, or 0. * @param y Return location for the Y coordinate, or 0. */ void get_pointer(int &x, int &y) const; /** Determines whether @a widget is somewhere inside @a ancestor , possibly with * intermediate containers. * @param ancestor Another Gtk::Widget. * @return true if @a ancestor contains @a widget as a child, * grandchild, great grandchild, etc. */ bool is_ancestor(Widget &ancestor) const; /** Translate coordinates relative to @a src_widget 's allocation to coordinates * relative to @a dest_widget 's allocations. In order to perform this * operation, both widgets must be realized, and must share a common * toplevel. * @param dest_widget A Gtk::Widget. * @param src_x X position relative to @a src_widget . * @param src_y Y position relative to @a src_widget . * @param dest_x Location to store X position relative to @a dest_widget . * @param dest_y Location to store Y position relative to @a dest_widget . * @return false if either widget was not realized, or there * was no common ancestor. In this case, nothing is stored in * * @a dest_x and * @a dest_y . Otherwise true. */ bool translate_coordinates(Widget& dest_widget, int src_x, int src_y, int& dest_x, int& dest_y); /* STYLE */ /** Sets the Gtk::Style for a widget ( @a widget ->style). You probably don't * want to use this function; it interacts badly with themes, because * themes work by replacing the Gtk::Style. Instead, use * modify_style(). * @param style A Gtk::Style. */ void set_style(const Glib::RefPtr