index
gtk-- homepage



Description:
Gtk_Widget

#include <gtk--/widget.h>
Base classes: Gtk_Object
Derived by: Gtk_Calendar Gtk_Container Gtk_DrawingArea Gtk_Editable Gtk_Misc Gtk_Preview Gtk_Progress Gtk_Range Gtk_Ruler Gtk_Separator

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 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:


Public member index:


static GtkType get_type();
GtkWidget *gtkobj();
const GtkWidget *gtkobj()const;
static bool isA(Gtk_Object *checkcast);
virtual ~Gtk_Widget();
void unparent();
Destroy and hides widget.

void show_now();
void queue_draw();
void queue_draw_area(gint x,gint y,gint width,gint height);
void queue_clear();
void queue_clear_area(gint x,gint y,gint width,gint height);
void queue_resize();
guint accelerator_signal(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 add_accelerator(const gtkmm_string &accel_signal,Gtk_AccelGroup &accel_group,guint accel_key,guint accel_mods,GtkAccelFlags accel_flags);
(Gtk 1.1)

void remove_accelerator(Gtk_AccelGroup &accel_group,guint accel_key,guint accel_mods);
(Gtk 1.1)

void remove_accelerators(const gtkmm_string &accel_signal,bool visible_only);
(Gtk 1.1)

bool activate();
void reparent(Gtk_Widget &newparent);
Change a widgets parent.

void popup(gint x,gint y);
gint intersect(const Gdk_Rectangle &area,const Gdk_Rectangle &intersection)const;
void grab_default();
void set_name(const gtkmm_string &name);
gtkmm_string get_name()const;
Return the name of the widget.

void set_state(GtkStateType state);
void set_sensitive(bool sensitive);
void set_app_paintable(bool app_paintable);
Gtk_Widget *get_parent()const;
Return the parent of this widget.

void set_parent_window(const Gdk_Window &parent_window);
Set the widgets parent.

Gdk_Window get_parent_window()const;
Return the parent's Gdk_Window.

void set_uposition(gint x,gint y);
void set_usize(gint x,gint y);
Set minumum widget size.

void set_events(gint events);
Set the events the widget wishs to capture.

void add_events(gint events);
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.

void set_colormap(const Gdk_Colormap &colormap);
Set colormap prior to realization.

void set_visual(const Gdk_Visual &visual);
Set visual prior to realization.

gint get_events()const;
Set the name of the widget.

void get_pointer(gint &x,gint &y)const;
bool is_ancestor(Gtk_Widget &widget)const;
bool hide_on_delete();
void set_style(Gtk_Style &style);
void set_rc_style();
void ensure_style();
const Gtk_Style *get_style()const;
void restore_default_style();
void set_composite_name(const gtkmm_string &name);
gtkmm_string get_composite_name();
void reset_rc_styles();
static void push_style(Gtk_Style &style);
static void push_colormap(const Gdk_Colormap &cmap);
static void push_visual(const Gdk_Visual &visual);
static void push_composite_child();
static void pop_style();
static void pop_colormap();
static void pop_visual();
static void pop_composite_child();
static void set_default_style(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 shape_combine_mask(const Gdk_Bitmap &shape_mask,gint offset_x,gint offset_y);
void path(string *path,string *path_reversed);
(Gtk 1.1)

void class_path(string *path,string *path_reversed);
(Gtk 1.1)

Gdk_Window get_window()const;
Return the Gdk_Window on which the widget is drawn.

GdkDragContext *gtkmm_drag_begin(GtkTargetList *p0,GdkDragAction p1,gint p2,GdkEvent *p3);
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(GtkDestDefaults flags,const GtkTargetEntry *targets,gint n_targets,GdkDragAction 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(GdkModifierType start_button_mask,const GtkTargetEntry *targets,gint n_targets,GdkDragAction 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.

emitable signal void show();
Show a widget.

void show_all();
Show a widget and all items inserted to it.

emitable signal void hide();
Hide a widget

void hide_all();
Hide a widget and all items inserted to it

emitable signal void map_();
Emitted on mapping of a widget to the screen.

emitable signal void unmap_();
emitable signal void realize();
Emitted on realization of a widget.

emitable signal void unrealize_();
emitable signal void grab_focus();
void draw(GdkRectangle *p0);
Emitted to draw the widget.

emitable signal void draw_focus();
Emitted to draw the widget in a focused state.

emitable signal void draw_default();
Emitted to draw the widget in a normal state.

emitable signal void size_request(GtkRequisition *);
emitable signal void size_allocate(GtkAllocation *);
signal void state_changed(GtkStateType);
Informs objects that their state has changed.

signal void Gtk_Widget *(parent_changed);
(internal) Informs objects that their parent changed.

emitable signal gint event(GdkEvent *);
(internal) Informs objects that their style has been changed.

emitable signal gint button_press_event(GdkEventButton *);
Event triggered by user pressing button.

emitable signal gint button_release_event(GdkEventButton *);
Event triggered by user releasing button.

emitable signal gint motion_notify_event(GdkEventMotion *);
Event triggered by user moving pointer.

emitable signal gint delete_event(GdkEventAny *);
Event triggered by window begin closed.

emitable signal gint expose_event(GdkEventExpose *);
Event triggered by window requiring a refresh.

emitable signal gint key_press_event(GdkEventKey *);
Event triggered by a key press will widget has focus.

emitable signal gint key_release_event(GdkEventKey *);
Event triggered by a key release will widget has focus.

emitable signal gint enter_notify_event(GdkEventCrossing *);
Event triggered by pointer entering widget area.

emitable signal gint leave_notify_event(GdkEventCrossing *);
Event triggered by pointer leaving widget area.

emitable signal gint configure_event(GdkEventConfigure *);
Event triggered by a window resizing.

emitable signal gint focus_in_event(GdkEventFocus *);
emitable signal gint focus_out_event(GdkEventFocus *);
emitable signal gint map_event(GdkEventAny *);
emitable signal gint unmap_event(GdkEventAny *);
emitable signal gint property_notify_event(GdkEventProperty *);
emitable signal gint selection_clear_event(GdkEventSelection *);
emitable signal gint selection_request_event(GdkEventSelection *);
emitable signal gint selection_notify_event(GdkEventSelection *);
emitable signal gint proximity_in_event(GdkEventProximity *);
emitable signal gint proximity_out_event(GdkEventProximity *);
emitable signal gint client_event(GdkEventClient *);
emitable signal gint no_expose_event(GdkEventAny *);
emitable 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,guint);
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);
gint width()const;
Returns width of widget.

gint height()const;
Returns height of widget.

Protected member index:


void initialize_class();
void *get_parent_class();
static void init_parent_class();
explicit Gtk_Widget(GtkWidget *castitem);
void realize_if_needed();
Gtk_Widget();
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 grab_focus_impl();
virtual void draw_impl(GdkRectangle *p0);
virtual void draw_focus_impl();
virtual void draw_default_impl();
virtual void size_request_impl(GtkRequisition *p0);
virtual void size_allocate_impl(GtkAllocation *p0);
virtual void state_changed_impl(GtkStateType p0);
virtual void parent_changed_impl(Gtk_Widget *p0);
virtual gint event_impl(GdkEvent *p0);
virtual gint button_press_event_impl(GdkEventButton *p0);
virtual gint button_release_event_impl(GdkEventButton *p0);
virtual gint motion_notify_event_impl(GdkEventMotion *p0);
virtual gint delete_event_impl(GdkEventAny *p0);
virtual gint expose_event_impl(GdkEventExpose *p0);
virtual gint key_press_event_impl(GdkEventKey *p0);
virtual gint key_release_event_impl(GdkEventKey *p0);
virtual gint enter_notify_event_impl(GdkEventCrossing *p0);
virtual gint leave_notify_event_impl(GdkEventCrossing *p0);
virtual gint configure_event_impl(GdkEventConfigure *p0);
virtual gint focus_in_event_impl(GdkEventFocus *p0);
virtual gint focus_out_event_impl(GdkEventFocus *p0);
virtual gint map_event_impl(GdkEventAny *p0);
virtual gint unmap_event_impl(GdkEventAny *p0);
virtual gint property_notify_event_impl(GdkEventProperty *p0);
virtual gint selection_clear_event_impl(GdkEventSelection *p0);
virtual gint selection_request_event_impl(GdkEventSelection *p0);
virtual gint selection_notify_event_impl(GdkEventSelection *p0);
virtual gint proximity_in_event_impl(GdkEventProximity *p0);
virtual gint proximity_out_event_impl(GdkEventProximity *p0);
virtual gint client_event_impl(GdkEventClient *p0);
virtual gint no_expose_event_impl(GdkEventAny *p0);
virtual gint visibility_notify_event_impl(GdkEventVisibility *p0);
virtual void debug_msg_impl(const gchar *p0);
virtual void selection_get_impl(GtkSelectionData *p0,guint p1,guint p2);
virtual void selection_received_impl(GtkSelectionData *p0,guint p1);
virtual void drag_begin_impl(GdkDragContext *p0);
virtual void drag_end_impl(GdkDragContext *p0);
virtual void drag_data_get_impl(GdkDragContext *p0,GtkSelectionData *p1,guint p2,guint p3);
virtual void drag_data_delete_impl(GdkDragContext *p0);
virtual void drag_leave_impl(GdkDragContext *p0,guint p1);
virtual gboolean drag_motion_impl(GdkDragContext *p0,gint p1,gint p2,guint p3);
virtual gboolean drag_drop_impl(GdkDragContext *p0,gint p1,gint p2,guint p3);
virtual void drag_data_received_impl(GdkDragContext *p0,gint p1,gint p2,GtkSelectionData *p3,guint p4,guint32 p5);
Private member index:


Gtk_Widget(const Gtk_Widget &);
Gtk_Widget &operator =(const Gtk_Widget &);
void reset_shapes();

Public member details:


unparent
void Gtk_Widget::unparent();

Destroy and hides widget.
Destroys widget by adding to the trashcan. Calls hide() prior to deleting widget.

See Gtk_Trashcan


reparent
void Gtk_Widget::reparent(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.


set_parent_window
void Gtk_Widget::set_parent_window(const Gdk_Window &parent_window);

Set the widgets parent.
This is better left to the container to which the widget gets added. (Not for application use)


set_events
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


get_toplevel
Gtk_Widget *Gtk_Widget::get_toplevel();


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


show
emitable signal void Gtk_Widget::show();

Show a widget.
If the widget is not already destroyed, this will make the widget visible by setting flags.visible.


map_
emitable signal void Gtk_Widget::map_();

Emitted on mapping of a widget to the screen.
See flags.mapped. This should not be called by the user.


unmap_
emitable signal void Gtk_Widget::unmap_();

See flags.mapped. This should not be called by the user.


realize
emitable signal void Gtk_Widget::realize();

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.


unrealize_
emitable signal void Gtk_Widget::unrealize_();

See flags.realized. This should not be called by the user.


draw
void Gtk_Widget::draw(GdkRectangle *p0);

Emitted to draw the widget.
This is a gtk virtual function. It can only be overriden with the impl method.


state_changed
signal void Gtk_Widget::state_changed(GtkStateType);

Informs objects that their state has changed.
The old state is passed as the argument.


Gtk_Widget*
signal void Gtk_Widget::Gtk_Widget *(parent_changed);

(internal) Informs objects that their parent changed.
The widget passed is the former parent, which may be 0 if there was no parent.


event
emitable signal gint Gtk_Widget::event(GdkEvent *);

(internal) Informs objects that their style has been changed.
The former style is passed as the argument.


expose_event
emitable 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 details:



Private member details:



Examples:





(pages generated by PERCEPS -script.)