Gtk_Widget(3)

NAME - Gtk_Widget
Abstract Widget (Base class for all widgets)

HEADER REQUIRED
#include <gtk--/widget.h&gt;>

BASE CLASSES
Gtk_Object(3)

DERIVED BY
Gtk_Calendar(3) Gtk_Container(3) Gtk_DrawingArea(3) Gtk_Editable(3) Gtk_Misc(3) Gtk_Preview(3) Gtk_Progress(3) Gtk_Range(3) Gtk_Ruler(3) Gtk_Separator(3)

DESCRIPTION
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 set_events().

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.

PROPERTIES

allocation
    Type: GtkAllocation
    Set: size_allocate()

     The widgets actual size.

flags
    Type: GTK_OBJECT_FLAGS
    Get: See below.
    Set: set_flags(), unset_flags()

     A large set of flags controlling the behaviors of the widget.

flags.can_focus
    Type: bool
    Get: can_focus()
    Set: NA

     This flag determines whether a widget is able to handle focus grabs. There are no directly corresponding functions for setting/unsetting this flag, but it can be affected by the has_focus() argument via set_arg().

flags.can_default
    Type: bool
    Get: can_focus()
    Set: NA

     Same as can_focus for the default widget.

flags.has_focus
    Type: bool
    Get: has_focus()
    Set: grab_focus()

     .IP This flag will be set by grab_focus() for widgets that also have {num GTK_CAN_FOCUS} set. The flag will be unset once another widget grabs the focus.

flags.has_default
    Type: bool
    Get: has_default()
    Set: NA

     Same as has_focus for the default widget.

flags.has_grab
    Type: bool
    Get: has_grab()
    Set: NA

     This flag indicated the widget is in the grab_widgets stack, and will be the preferred one for receiving events other than ones of cosmetic value.

flags.mapped
    Type: bool
    Get: mapped()
    Set: NA

     Indicates that show() has been called on the widgets window(s). Mapping follows realization.

flags.no_window
    Type: bool
    Get: no_window()
    Set: NA

     This flag is indicative for a widget that does not provide its own GdkWindow. Visible action (e.g. drawing) is performed on the parent's GdkWindow.

    See {page Gtk_EventBox} and {page Gtk_Misc} for more details.

flags.realized
    Type: bool
    Get: realized()
    Set: NA

     Indicates if a widget has been realized on the server. A widget may be constructed, but not yet mapped into the X server yet. The process of constructing a server side object is called realization. After realization the widget has a GdkWindow (or its parent does in the case of flags.no_window )

flags.sensitive
    Type: bool
    Get: sensitive()
    Set: NA

     .IP The sensitivity of a widget determines whether it will receive certain events (e.g. button or key presses). One premise for the widgets sensitivity is to have flags.sensitive set.

flags.parent_sensitive
    Type: bool
    Get: parent_sensitive()
    Set: NA

     .IP This is the second premise for the widgets sensitivity. Once it has flags.sensitive and flags.parent_sensitive set, its state is effectively sensitive.

flags.visible
    Type: bool
    Get: visible()
    Set: show(), hide()

     .IP Implies that a widget will be flagged flags.mapped as soon as its parent is mapped. If not set, implies that a widget is not onscreen, therefore !flags.mapped.

name
    Type: string
    Get: get_name()
    Set: set_name()

     The widgets name. If the widget does not have a name then its name is its classes name. Among other things, the widget name is used to determine the style to use for a widget.

parent
    Type: Gtk_Widget *
    Set: set_parent(), reparent()

     Parent of this widget.

    This is normally set by the container to which the widget is added.

requisition
    Type: GtkRequisition
    Set: size_request()

     The widgets desired size.

state
    Type: GtkStateType
    Set: set_state()

     The saved state of the widget. When a widgets state is changed to {num GTK_STATE_INSENSITIVE} via set_state or set_sensitive the old state is kept around in this field. The state will be restored once the widget gets sensitive again.

    Available states: {num GTK_STATE_NORMAL, GTK_STATE_ACTIVE, GTK_STATE_PRELIGHT, GTK_STATE_SELECTED, GTK_STATE_INSENSITIVE }

style
    Type: Gtk_Style *
    Get: get_style()
    Set: set_style()

     The style for the widget. The style contains the colors the widget should be drawn in for each state along with graphics contexts used to draw with and the font to use for text.

    Set {page Gtk_Style} for more info.

window
    Type: Gdk_Window
    Get: get_window()

     The widgets window or its parent window if it does not have a window, which will be indicated no_window().

PUBLIC MEMBER INDEX
    Gtk_Widget(GtkWidget *castitem);
    virtual void  delete_self();
      Destroy and hides widget.
    void  unparent();
    void  reparent(const Gtk_Widget & newparent);
      Change a widgets parent.
    void  activate();
    void  popup(gint x, gint y);
    bool  intersect(const Gdk_Rectangle &area, const Gdk_Rectangle &intersection) const;
    void  grab_focus();
    void  grab_default();
    void  set_uposition(gint x, gint y);
    void  set_usize(gint width, gint height);
      Set minumum widget size.
    void  set_events(gint events);
      Set the events the widget wishs to capture.
    void  set_extension_events(GdkExtensionMode mode);
    GdkExtensionMode  get_extension_events() const;
    Gtk_Widget*  get_toplevel();
    Gtk_Widget*  get_ancestor(gint type) const;
    Gdk_Colormap  get_colormap() const;
      Return current widget colormap.
    Gdk_Visual  get_visual() const;
      Return current widget visual.
    gint  get_events() const;
    void  get_pointer(gint *x, gint *y) const;
    bool  is_ancestor(const Gtk_Widget &widget) const;
    void  set_style(const Gtk_Style &style);
    void  set_rc_style();
    void  ensure_style();
    const Gtk_Style*  get_style() const;
    Gtk_Style*  get_style();
    void  restore_default_style();
    static void  push_style(const Gtk_Style &style);
    static void  push_colormap(const Gdk_Colormap &cmap);
    static void  push_visual(const Gdk_Visual &visual);
    static void  pop_style();
    static void  pop_colormap();
    static void  pop_visual();
    static void  set_default_style(const Gtk_Style &style);
    static void  set_default_colormap(const Gdk_Colormap &colormap);
    static void  set_default_visual(const Gdk_Visual &visual);
    static Gtk_Style*  get_default_style();
    static Gdk_Colormap  get_default_colormap();
    static Gdk_Visual  get_default_visual();
    void  set_colormap(const Gdk_Colormap &colormap);
      Set colormap prior to realization.
    void  set_visual(const Gdk_Visual &visual);
      Set visual prior to realization.
    void  set_name(const _gtk_string &name);
      Set the {name} of the widget.
    _gtk_string  get_name() const;
      Return the {name} of the widget.
    void  set_state(GtkStateType state);
    void  set_sensitive(bool sensitive);
    const Gtk_Widget*  get_parent() const;
      Return the {parent} of this widget.
    Gtk_Widget*  get_parent();
    void  set_parent(const Gtk_Widget &parent);
      Set the widgets parent.
    void  set_parent_window(const Gdk_Window &parent_window);
    Gdk_Window  get_parent_window() const;
      Return the parent's Gdk_Window.
    Gdk_Window  get_window() const;
      Return the Gdk_Window on which the widget is drawn.
    void  queue_draw();
    void  queue_resize();
    void  shape_combine_mask(const Gdk_Bitmap &shape_mask, gint offset_x, gint offset_y);
    bool  hide_on_delete();
      (Gtk 1.1)
    guint  accelerator_signal(const Gtk_AccelGroup &accel_group, guint accel_key, guint accel_mods);
    void  lock_accelerators();
      (Gtk 1.1)
    void  unlock_accelerators();
      (Gtk 1.1)
    bool  accelerators_locked();
      (Gtk 1.1)
    void  set_app_paintable(bool app_paintable);
      (Gtk 1.1)
    void  add_accelerator(const _gtk_string &accel_signal, const Gtk_AccelGroup &accel_group, guint accel_key, guint accel_mods, GtkAccelFlags accel_flags);
      (Gtk 1.1)
    void  remove_accelerator(const Gtk_AccelGroup &accel_group, guint accel_key, guint accel_mods);
      (Gtk 1.1)
    void  remove_accelerators(const _gtk_string &accel_signal, bool	visible_only);
      (Gtk 1.1)
    void  add_events(gint	events);
      (Gtk 1.1)
    void  path(string *path, string *path_reversed);
      (Gtk 1.1)
    void  class_path(string *path, string *path_reversed);
      (Gtk 1.1)
    static void  pop_composite_child();
      (Gtk 1.1)
    static void  push_composite_child();
      (Gtk 1.1)
    void  queue_clear();
      (Gtk 1.1)
    void  queue_clear_area(gint x, gint y, gint width, gint height);
      (Gtk 1.1)
    void  queue_draw_area(gint x, gint y, gint width, gint height);
      (Gtk 1.1)
    void  set_composite_name(const _gtk_string &name);
      (Gtk 1.1)
    _gtk_string  get_composite_name();
      (Gtk 1.1)
    void  reset_rc_styles();
      (Gtk 1.1)
    void  get_child_requisition(GtkRequisition *req) const;
      (Gtk 1.1)
    void  drag_get_data(Gdk_Drag_Context &context, Gdk_Atom target, guint32 time);
      (Gtk 1.1)
    static void  drag_finish(Gdk_Drag_Context &context, bool success, bool del, guint32 time);
      (Gtk 1.1)
    void  drag_highlight();
      (Gtk 1.1)
    void  drag_unhighlight();
      (Gtk 1.1)
    void  drag_dest_set(int flags, GtkTargetEntry *targets, gint n_targets, int actions);
      (Gtk 1.1)
    void  drag_dest_set_proxy(Gdk_Window &proxy_window, GdkDragProtocol protocol, bool use_coordinates);
      (Gtk 1.1)
    void  drag_dest_unset();
      (Gtk 1.1)
    void  drag_source_set(int start_button_mask, GtkTargetEntry *targets, gint n_targets, int actions);
      (Gtk 1.1)
    void  drag_source_unset();
      (Gtk 1.1)
    void  drag_source_set_icon(Gdk_Colormap &colormap, Gdk_Pixmap &pixmap, Gdk_Bitmap &mask);
      (Gtk 1.1)
    static void  drag_set_icon_widget(Gdk_Drag_Context &context, Gtk_Widget &widget, gint hot_x, gint hot_y);
      (Gtk 1.1)
    static void  drag_set_icon_pixmap(Gdk_Drag_Context &context, Gdk_Colormap &colormap, Gdk_Pixmap &pixmap, Gdk_Bitmap &mask, gint hot_x, gint hot_y);
      (Gtk 1.1)
    static void  drag_set_icon_default(Gdk_Drag_Context &context);
      (Gtk 1.1)
    static void  drag_set_default_icon(Gdk_Colormap &colormap, Gdk_Pixmap &pixmap, Gdk_Bitmap &mask, gint hot_x, gint hot_y);
      (Gtk 1.1)
    bool  is_toplevel() const;
      Returns property {flags.toplevel}.
    bool  has_no_window() const;
      Returns property {flags.nowindow}.
    bool  is_realized() const;
      Returns property {flags.realized}.
    bool  is_mapped() const;
      Returns property {flags.mapped}.
    bool  is_visible() const;
      Returns property {flags.visible}.
    bool  is_drawable() const;
      Returns if the widget is ready to be drawn to.
    bool  sensitive() const;
      Returns property {flags.sensitive}. You might want to check
    bool  parent_sensitive() const;
    bool  is_sensitive() const;
    bool  can_focus() const;
    bool  has_focus() const;
    bool  can_default() const;
    bool  has_default() const;
    bool  rc_style() const;
    bool  has_grab() const;
    bool  is_composite_child() const;
    bool  app_paintable() const;
    bool  recieves_default() const;
    void  set_flags(gint flag) const;
      Set a member of the {flags} field.
    void  unset_flags(gint flag) const;
      Clear a member of the {flags} field.
    signal void  show(BaseObjectType);
      Show a widget.
    signal void  show_all(GtkWidget);
      Show a widget and all items inserted to it.
    signal void  hide(BaseObjectType);
      Hide a widget
    signal void  hide_all(GtkWidget);
      Hide a widget and all items inserted to it
    signal void  map(BaseObjectType);
      Emitted on mapping of a widget to the screen.
    signal void  unmap(BaseObjectType);
    signal void  realize(BaseObjectType);
      Emitted on realization of a widget.
    signal void  unrealize(BaseObjectType);
    signal void  draw(GtkWidget,GdkRectangle*);
      Emitted to draw the widget.
    signal void  draw_focus(BaseObjectType);
      Emitted to draw the widget in a focused state.
    signal void  draw_default(BaseObjectType);
      Emitted to draw the widget in a normal state.
    signal void  size_request(GtkRequisition*);
    signal void  size_allocate(GtkAllocation*);
    signal void  state_changed(GtkStateType);
      Emitted on a change of widget state.
    signal void  parent_set_c(GtkWidget*);
    signal void  parent_set(Gtk_Widget*);
    void  parent_set_callback(Gtk_Widget *p1);
    signal void  style_set_c(GtkStyle*);
    signal void  style_set(Gtk_Style*);
    void  style_set_callback(Gtk_Style *p1);
    signal gint  event(GdkEvent*);
    signal gint  button_press_event(GdkEventButton*);
      Event triggered by user pressing button.
    signal gint  button_release_event(GdkEventButton*);
      Event triggered by user releasing button.
    signal gint  motion_notify_event(GdkEventMotion*);
      Event triggered by user moving pointer.
    signal gint  delete_event(GdkEventAny*);
      Event triggered by window begin closed.
    signal gint  expose_event(GdkEventExpose*);
      Event triggered by window requiring a refresh.
    signal gint  key_press_event(GdkEventKey*);
      Event triggered by a key press will widget has focus.
    signal gint  key_release_event(GdkEventKey*);
      Event triggered by a key release will widget has focus.
    signal gint  enter_notify_event(GdkEventCrossing*);
      Event triggered by pointer entering widget area.
    signal gint  leave_notify_event(GdkEventCrossing*);
      Event triggered by pointer leaving widget area.
    signal gint  configure_event(GdkEventConfigure*);
      Event triggered by a window resizing.
    signal gint  focus_in_event(GdkEventFocus*);
    signal gint  focus_out_event(GdkEventFocus*);
    signal gint  map_event(GdkEventAny*);
    signal gint  unmap_event(GdkEventAny*);
    signal gint  property_notify_event(GdkEventProperty*);
    signal gint  selection_clear_event(GdkEventSelection*);
    signal gint  selection_request_event(GdkEventSelection*);
    signal gint  selection_notify_event(GdkEventSelection*);
    signal gint  proximity_in_event(GdkEventProximity*);
    signal gint  proximity_out_event(GdkEventProximity*);
    signal gint  client_event(GdkEventClient*);
    signal gint  no_expose_event(GdkEventAny*);
    signal gint  visibility_notify_event(GdkEventVisibility*);
    signal void  debug_msg(const gchar*);
    signal void  selection_get(GtkSelectionData*, guint, guint);
    signal void  selection_received(GtkSelectionData*, guint);
    signal void  drag_begin(GdkDragContext*);
    signal void  drag_end(GdkDragContext*);
    signal void  drag_data_get(GdkDragContext*, GtkSelectionData*, guint, guint32);
    signal void  drag_data_delete(GdkDragContext*);
    signal void  drag_leave(GdkDragContext*, guint);
    signal gboolean  drag_motion(GdkDragContext*, gint, gint, guint);
    signal gboolean  drag_drop(GdkDragContext*, gint, gint, guint);
    signal void  drag_data_received(GdkDragContext*, gint, gint, GtkSelectionData*, guint, guint32);
    GtkWidget*  gtkobj();
    const GtkWidget*  gtkobj() const;
    static bool  isGtkWidget(Gtk_Object *checkcast);
    gint  width() const;
      Returns width of widget.
    gint  height() const;
      Returns height of widget.
    virtual  ~Gtk_Widget();

PROTECTED MEMBER INDEX
    friend  CppClassType;
    typedef GtkWidget  BaseObjectType;
    typedef GtkWidgetClass  BaseClassType;
    virtual void * get_parent_class();
    virtual void  show_impl();
    virtual void  show_all_impl();
    virtual void  hide_impl();
    virtual void  hide_all_impl();
    virtual void  map_impl();
    virtual void  unmap_impl();
    virtual void  realize_impl();
    virtual void  unrealize_impl();
    virtual void  draw_impl(GdkRectangle* p1);
    virtual void  draw_focus_impl();
    virtual void  draw_default_impl();
    virtual void  size_request_impl(GtkRequisition* p1);
    virtual void  size_allocate_impl(GtkAllocation* p1);
    virtual void  state_changed_impl(GtkStateType p1);
    virtual void  parent_set_c_impl(GtkWidget* p1);
    virtual void  style_set_c_impl(GtkStyle* p1);
    virtual gint  event_impl(GdkEvent* p1);
    virtual gint  button_press_event_impl(GdkEventButton* p1);
    virtual gint  button_release_event_impl(GdkEventButton* p1);
    virtual gint  motion_notify_event_impl(GdkEventMotion* p1);
    virtual gint  delete_event_impl(GdkEventAny* p1);
    virtual gint  expose_event_impl(GdkEventExpose* p1);
    virtual gint  key_press_event_impl(GdkEventKey* p1);
    virtual gint  key_release_event_impl(GdkEventKey* p1);
    virtual gint  enter_notify_event_impl(GdkEventCrossing* p1);
    virtual gint  leave_notify_event_impl(GdkEventCrossing* p1);
    virtual gint  configure_event_impl(GdkEventConfigure* p1);
    virtual gint  focus_in_event_impl(GdkEventFocus* p1);
    virtual gint  focus_out_event_impl(GdkEventFocus* p1);
    virtual gint  map_event_impl(GdkEventAny* p1);
    virtual gint  unmap_event_impl(GdkEventAny* p1);
    virtual gint  property_notify_event_impl(GdkEventProperty* p1);
    virtual gint  selection_clear_event_impl(GdkEventSelection* p1);
    virtual gint  selection_request_event_impl(GdkEventSelection* p1);
    virtual gint  selection_notify_event_impl(GdkEventSelection* p1);
    virtual gint  proximity_in_event_impl(GdkEventProximity* p1);
    virtual gint  proximity_out_event_impl(GdkEventProximity* p1);
    virtual gint  client_event_impl(GdkEventClient* p1);
    virtual gint  no_expose_event_impl(GdkEventAny* p1);
    virtual gint  visibility_notify_event_impl(GdkEventVisibility* p1);
    virtual void  debug_msg_impl(const gchar* p1);
    virtual void  selection_get_impl(GtkSelectionData* p1, guint p2, guint p3);
    virtual void  selection_received_impl(GtkSelectionData* p1, guint p2);
    virtual void  drag_begin_impl(GdkDragContext* p1);
    virtual void  drag_end_impl(GdkDragContext* p1);
    virtual void  drag_data_get_impl(GdkDragContext* p1, GtkSelectionData* p2, guint p3, guint32 p4);
    virtual void  drag_data_delete_impl(GdkDragContext* p1);
    virtual void  drag_leave_impl(GdkDragContext* p1, guint p2);
    virtual gboolean  drag_motion_impl(GdkDragContext* p1, gint p2, gint p3, guint p4);
    virtual gboolean  drag_drop_impl(GdkDragContext* p1, gint p2, gint p3, guint p4);
    virtual void  drag_data_received_impl(GdkDragContext* p1, gint p2, gint p3, GtkSelectionData* p4, guint p5, guint32 p6);
    static Gtk_Style * default_style_;
    Gtk_Style*  _get_style() const;
    Gtk_Widget*  _get_parent() const;
    void  realize_if_needed();
    Gtk_Widget();
    mutable Gtk_ObjectHandle  toplevel_;
    mutable Gtk_ObjectHandle  ancestor_;
    mutable Gtk_ObjectHandle  parent_;
    mutable Gtk_ObjectHandle  style_;

PRIVATE MEMBER INDEX
    static CppClassType  widget_class;
    GtkType  get_type();

PUBLIC MEMBER DESCRIPTIONS

virtual void  Gtk_Widget::delete_self ();
    Destroy and hides widget..
    Destroys widget by adding to the trashcan. Calls hide() prior to deleting widget.

See Gtk_Trashcan

void  Gtk_Widget::reparent (const Gtk_Widget & newparent);
    Change a widgets parent..
    Equivalent to removing widget from old parent and adding it to the new parent, except that the widget will not be temporarily unrealized if both the old parent and the new parent are realized.

Use this in place of set_parent() in an application.

void  Gtk_Widget::set_events (gint events);
    Set the events the widget wishs to capture..
    The available event masks that the user can select are: GDK_EXPOSURE_MASK, GDK_POINTER_MOTION_MASK, GDK_POINTER_MOTION_HINT_MASK, GDK_BUTTON_MOTION_MASK, GDK_BUTTON1_MOTION_MASK, GDK_BUTTON2_MOTION_MASK, GDK_BUTTON3_MOTION_MASK, GDK_BUTTON_PRESS_MASK, GDK_BUTTON_RELEASE_MASK, GDK_KEY_PRESS_MASK, GDK_KEY_RELEASE_MASK, GDK_ENTER_NOTIFY_MASK, GDK_LEAVE_NOTIFY_MASK, GDK_FOCUS_CHANGE_MASK, GDK_STRUCTURE_MASK, GDK_PROPERTY_CHANGE_MASK, GDK_VISIBILITY_NOTIFY_MASK, GDK_PROXIMITY_IN_MASK, GDK_PROXIMITY_OUT_MASK, GDK_SUBSTRUCTURE_MASK

Gtk_Widget*  Gtk_Widget::get_toplevel ();

Gtk_Widget*  Gtk_Widget::get_ancestor (gint type) const;

void  Gtk_Widget::set_parent (const Gtk_Widget &parent);
    Set the widgets parent. .
    This is better left to the container to which the widget gets added. (Not for application use)

signal void  Gtk_Widget::show (BaseObjectType);
    Show a widget..
    If the widget is not already destroyed, this will make the widget visible by setting flags.visible.

signal void  Gtk_Widget::map (BaseObjectType);
    Emitted on mapping of a widget to the screen..
    See flags.mapped. This should not be called by the user.

signal void  Gtk_Widget::unmap (BaseObjectType);
    See flags.mapped. This should not be called by the user.

signal void  Gtk_Widget::realize (BaseObjectType);
    Emitted on realization of a widget..
    See flags.realized. This is also responsible for setting flags.realized when it is done. Therefore, when overriding the impl method, you should call the deafault realize method.

signal void  Gtk_Widget::unrealize (BaseObjectType);
    See flags.realized. This should not be called by the user.

signal void  Gtk_Widget::draw (GtkWidget,GdkRectangle*);
    Emitted to draw the widget..
    This is a gtk virtual function. It can only be overriden with the impl method.

signal gint  Gtk_Widget::expose_event (GdkEventExpose*);
    Event triggered by window requiring a refresh..
    Expose events cover a rectangular area that was covered or obscured by another window. That area is now exposed and thus is needs to be redrawn.

If the application is not capable of redrawing sections it should watch the count field and only draw on the last even indicated. This is important for things such as Gtk_DrawingArea.

PROTECTED MEMBER DESCRIPTIONS

PRIVATE MEMBER DESCRIPTIONS