Invalidates the rectangular area of widget defined by x , y , width and height by calling gdk_window_invalidate_rect() on the widget's window and all its child windows.
Given an accelerator group, accel_group , and an accelerator path, accel_path , sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, widget will be activated.
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.
Checks to see if a mouse drag starting at ( start_x , start_y ) and ending at ( current_x , current_y ) has passed the GTK+ drag threshhold, and thus should trigger the beginning of a drag-and-drop operation.
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.
Constructor & Destructor Documentation
virtual Gtk::Widget::~Widget
(
)
[virtual]
Gtk::Widget::Widget
(
)
[protected]
Member Function Documentation
bool Gtk::Widget::activate
(
)
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; clicking a button, selecting a menu item, etc. If widget isn't activatable, the function returns false.
Installs an accelerator for this widget in accel_group that causes accel_signal to be emitted if the accelerator is activated.
The 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.
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. direction indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward). child_focus() invokes the "focus" signal on Gtk::Widget; widgets override the default handler for this signal in order to implement appropriate focus behavior.
The "focus" default handler for a widget should return true if moving in direction left the focus on a focusable location inside that widget, and false if moving in 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.
Creates a new Pango::Layout with the appropriate colormap, font description, and base direction for drawing text for this widget.
If you keep a Pango::Layout created in this way around, in order notify the layout of changes to the base direction or font of this widget, you must call pango_layout_context_changed() in response to the ::style_set and ::direction_set signals for the widget.
Checks to see if a mouse drag starting at ( start_x , start_y ) and ending at ( current_x , current_y ) has passed the GTK+ drag threshhold, and thus should trigger the beginning of a drag-and-drop operation.
Looks for a match between context ->targets and the dest_target_list , returning the first matching target, otherwise returning Gdk::NONE.
dest_target_list should usually be the return value from gtk_drag_dest_get_target_list(), but some widgets may have different valid targets for different parts of the widget; in that case, they will have to implement a drag_motion handler that passes the correct target list to this function.
Parameters:
widget
Drag destination widget.
context
Drag context.
target_list
List of droppable targets, or 0 to use gtk_drag_dest_get_target_list ( widget ).
Returns:
First target that the source offers and the dest can accept, or Gdk::NONE.
Sets the icon that will be used for drags from a particular widget from a pixmap/mask.
GTK+ retains references for the arguments, and will release them when they are no longer needed. Use gtk_drag_source_set_icon_pixbuf() instead.
Parameters:
widget
A Gtk::Widget.
colormap
The colormap of the icon.
pixmap
The image data for the icon.
mask
The transparency mask for an image.
void Gtk::Widget::drag_source_unset
(
)
void Gtk::Widget::drag_unhighlight
(
)
void Gtk::Widget::ensure_style
(
)
Ensures that widget has a style ( widget ->style).
Not a very useful function; most of the time, if you want the style, the widget is realized, and realized widgets are guaranteed to have a style already.
bool Gtk::Widget::event
(
GdkEvent*
event
)
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.
Gets the first ancestor of widget with type widget_type .
For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets the first Gtk::Box that's an ancestor of 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().
Gets the first ancestor of widget with type widget_type .
For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets the first Gtk::Box that's an ancestor of 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().
This function is only for use in widget implementations.
Obtains widget ->requisition, unless someone has forced a particular geometry on the widget (e.g. with set_usize()), in which case it returns that geometry instead of the widget's requisition.
This function differs from size_request() in that it retrieves the last size request value from widget ->requisition, while size_request() actually calls the "size_request" method on widget to compute the size request and fill in widget ->requisition, and only then returns widget ->requisition.
Because this function does not call the "size_request" method, it can only be used when you know that widget ->requisition is up-to-date, that is, size_request() has been called since the last time a resize was queued. In general, only container implementations have this information; applications should use size_request().
Returns the clipboard object for the given selection to be used with widget .
widget must have a Gdk::Display associated with it, so must be attached to a toplevel window.
Parameters:
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.
Returns:
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.
Returns the clipboard object for the given selection to be used with widget .
widget must have a Gdk::Display associated with it, so must be attached to a toplevel window.
Parameters:
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.
Returns:
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.
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.
Returns:
The Gdk::Display for the toplevel for this widget.
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.
Returns:
The Gdk::Display for the toplevel for this widget.
Returns the current modifier style for the widget.
(As set by modify_style().) If no style has previously set, a new Gtk::RcStyle will be created with all values unset, and set as the modifier style for the widget. If you make changes to this rc style, you must call modify_style(), passing in the returned rc style, to make sure that your changes take effect.
Caution: passing the style back to modify_style() will normally end up destroying it, because modify_style() copies the passed-in style and sets the copy as the new modifier style, thus dropping any reference to the old modifier style. Add a reference to the modifier style if you want to keep it alive.
Returns:
The modifier style for the widget. This rc style is owned by the widget. If you want to keep a pointer to value this around, you must add a refcount using Gtk::RcStyle::ref().
Returns the current modifier style for the widget.
(As set by modify_style().) If no style has previously set, a new Gtk::RcStyle will be created with all values unset, and set as the modifier style for the widget. If you make changes to this rc style, you must call modify_style(), passing in the returned rc style, to make sure that your changes take effect.
Caution: passing the style back to modify_style() will normally end up destroying it, because modify_style() copies the passed-in style and sets the copy as the new modifier style, thus dropping any reference to the old modifier style. Add a reference to the modifier style if you want to keep it alive.
Returns:
The modifier style for the widget. This rc style is owned by the widget. If you want to keep a pointer to value this around, you must add a refcount using Gtk::RcStyle::ref().
Gets a Pango::Context with the appropriate colormap, font description and base direction for this widget.
Unlike the context returned by create_pango_context(), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget's attributes.
If you create and keep a Pango::Layout using this context, you must deal with changes to the context by calling pango_layout_context_changed() on the layout in response to the ::style_set and ::direction_set signals for the widget.
Obtains the location of the mouse pointer in widget coordinates.
Widget coordinates are a bit odd; for historical reasons, they are defined as widget ->window coordinates for widgets that are not Gtk::NO_WINDOW widgets, and are relative to widget ->allocation.x, widget ->allocation.y for widgets that are Gtk::NO_WINDOW widgets.
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.
Returns:
The Gdk::Window root window for the toplevel for this widget.
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.
Returns:
The Gdk::Window root window for the toplevel for this widget.
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.
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.
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.
Gets the size request that was explicitly set for the widget using set_size_request().
A value of -1 stored in width or 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.
This function returns the topmost widget in the container hierarchy widget is a part of.
If 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 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.
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel))
{
[ Perform action on toplevel. ]
}
Returns:
The topmost ancestor of widget , or widget itself if there's no ancestor.
Widget* Gtk::Widget::get_toplevel
(
)
This function returns the topmost widget in the container hierarchy widget is a part of.
If 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 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.
GtkWidget *toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel))
{
[ Perform action on toplevel. ]
}
Returns:
The topmost ancestor of widget , or widget itself if there's no ancestor.
widget must have the Gtk::CAN_DEFAULT flag set; typically you have to set this flag yourself by calling GTK_WIDGET_SET_FLAGS ( 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 Gtk::Widget::grab_focus
(
)
Causes widget to have the keyboard focus for the Gtk::Window it's inside.
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.)
bool Gtk::Widget::has_default
(
)
const
bool Gtk::Widget::has_focus
(
)
const
bool Gtk::Widget::has_grab
(
)
const
bool Gtk::Widget::has_no_window
(
)
const
bool Gtk::Widget::has_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.
Returns:
true if there is a Gdk::Screen associcated with the widget.
Since: 2.2.
void Gtk::Widget::hide
(
)
Reverses the effects of show(), causing the widget to be hidden (invisible to the user).
Determines whether widget is somewhere inside ancestor , possibly with intermediate containers.
Parameters:
ancestor
Another Gtk::Widget.
Returns:
true if ancestor contains widget as a child, grandchild, great grandchild, etc.
bool Gtk::Widget::is_composite_child
(
)
const
bool Gtk::Widget::is_drawable
(
)
const
bool Gtk::Widget::is_focus
(
)
const
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.)
Sets the base color for a widget in a particular state.
All other style values are left untouched. The base color is the background color used along with the text color (see modify_text()) for widgets such as Gtk::Entry and Gtk::TextView. See also modify_style().
Parameters:
state
The state for which to set the base color.
color
The color to assign (does not need to be allocated), or 0 to undo the effect of previous calls to of modify_base().
Modifications made using this technique take precedence over style values set via an RC file, however, they will be overriden if a style is explicitely set on the widget using set_style(). The Gtk::RcStyle structure is designed so each field can either be set or unset, so it is possible, using this function, to modify some style values and leave the others unchanged.
Note that modifications made with this function are not cumulative with previous calls to modify_style() or with such functions as modify_fg(). If you wish to retain previous values, you must first call get_modifier_style(), make your modifications to the returned style, then call modify_style() with that style. On the other hand, if you first call modify_style(), subsequent calls to such functions modify_fg() will have a cumulative effect with the initial modifications.
Sets the text color for a widget in a particular state.
All other style values are left untouched. The text color is the foreground color used along with the base color (see modify_base()) for widgets such as Gtk::Entry and Gtk::TextView. See also modify_style().
Parameters:
state
The state for which to set the text color.
color
The color to assign (does not need to be allocated), or 0 to undo the effect of previous calls to of modify_text().
Makes all newly-created widgets as composite children until the corresponding pop_composite_child() call.
A composite child is a child that's an implementation detail of the container it's inside and should not be visible to people using the container. Composite children aren't treated differently by GTK (but see Gtk::Container::foreach() vs. Gtk::Container::forall()), but e.g. GUI builders might want to treat them in a different way.
Equivalent to calling queue_draw_area() for the entire area of a widget.
void Gtk::Widget::queue_draw_area
(
int
x,
int
y,
int
width,
int
height
)
Invalidates the rectangular area of widget defined by x , y , width and 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.
Parameters:
x
X coordinate of upper-left corner of rectangle to redraw.
y
Y coordinate of upper-left corner of rectangle to redraw.
width
Width of region to draw.
height
Height of region to draw.
void Gtk::Widget::queue_resize
(
)
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.
bool Gtk::Widget::rc_style
(
)
const
void Gtk::Widget::realize
(
)
[protected]
Creates the GDK (windowing system) resources associated with a widget.
For example, widget ->window will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget's parent widgets to be realized; calling realize() realizes the widget's parents in addition to widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.
This function is primarily used in widget implementations, and isn't very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as "expose_event". Or simply Glib::signal_connect_after() to the "realize" signal.
Computes the intersection of a widget 's area and region , returning the intersection.
The result may be empty, use gdk_region_empty() to check.
Parameters:
region
A Gdk::Region, in the same coordinate system as widget ->allocation. That is, relative to widget ->window for NO_WINDOW widgets; relative to the parent window of widget ->window for widgets with their own window.
Returns:
A newly allocated region holding the intersection of widget and region . The coordinates of the return value are relative to widget ->window for NO_WINDOW widgets, and relative to the parent window of widget ->window for widgets with their own window.
A convenience function that uses the theme engine and RC file settings for widget to look up stock_id and render it to a pixbuf.
stock_id should be a stock icon ID such as Gtk::STOCK_OPEN or Gtk::STOCK_OK. size should be a size such as Gtk::ICON_SIZE_MENU. detail should be a string that identifies the widget or code doing the rendering, so that theme engines can special-case rendering for that widget or code.
The pixels in the returned Gdk::Pixbuf are shared with the rest of the application and should not be modified. The pixbuf should be freed after use with Glib::object_unref().
Parameters:
stock_id
A stock ID.
size
A stock size.
detail
Render detail to pass to theme engine.
Returns:
A new pixbuf, or 0 if the stock ID wasn't known.
void Gtk::Widget::reparent
(
Widget&
newparent
)
Moves a widget from one Gtk::Container to another, handling reference count issues to avoid destroying the widget.
Recursively resets the shape on this widget and its descendants.
int Gtk::Widget::send_expose
(
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().
Given an accelerator group, accel_group , and an accelerator path, accel_path , sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, 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::ItemFactory. If you use Gtk::ItemFactory, setting up accelerator paths will be done automatically.
Even when you you aren't using Gtk::ItemFactory, if you only want to set up accelerators on menu items Gtk::MenuItem::set_accel_path() provides a somewhat more convenient interface.
Sets whether widget should be mapped along with its when its parent is mapped and 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.
Parameters:
is_visible
If true, widget should be mapped along with its parent.
Sets the reading direction on a particular widget.
This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitely visual rather than logical (such as buttons for text justification).
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.
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.
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).
Parameters:
name
Name for the widget.
void Gtk::Widget::set_parent
(
Widget&
parent
)
[protected]
This function is useful only when implementing subclasses of Gtk::Container.
Sets the container as the parent of widget , and takes care of some details such as updating the state and style of the child to reflect its new location. The opposite function is unparent().
Sets whether a when a widgets size allocation changes, the entire widget is queued for drawing.
By default, this setting is true and the entire widget is redrawn on every size change. If your widget leaves the upper left are unchanged when made bigger, turning this setting on 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 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.
Parameters:
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.
For widgets that support scrolling, sets the scroll adjustments and returns true.
For widgets that don't support scrolling, does nothing and returns false. Widgets that don't support scrolling can be scrolled by placing them in a Gtk::Viewport, which does support scrolling.
Parameters:
hadjustment
An adjustment for horizontal scrolling, or 0.
vadjustment
An adjustment for vertical scrolling, or 0.
Returns:
true if the widget supports scrolling.
void Gtk::Widget::set_sensitive
(
bool
sensitive = true
)
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.
Parameters:
sensitive
true to make the widget sensitive.
void Gtk::Widget::set_size_request
(
int
width = -1,
int
height = -1
)
Sets the minimum size of a widget; that is, the widget's size request will be width by 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."
Sets the Gtk::Style for a widget ( 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().
Parameters:
style
A Gtk::Style, or 0 to remove the effect of a previous set_style() and go back to the default style.
This allows for transparent windows etc., see gdk_window_shape_combine_mask() for more information.
Parameters:
shape_mask
Shape to be added, or 0 to remove an existing shape.
offset_x
X position of shape mask with respect to window .
offset_y
Y position of shape mask with respect to window .
void Gtk::Widget::show
(
)
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 Gtk::Widget::show_all
(
)
Recursively shows a widget, and any child widgets (if the widget is a container).
virtual void Gtk::Widget::show_all_vfunc
(
)
[protected, virtual]
void Gtk::Widget::show_now
(
)
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.
This function is only used by Gtk::Container subclasses, to assign a size and position to their child widgets.
Parameters:
allocation
Position and size to be allocated to widget .
void Gtk::Widget::size_request
(
GtkRequisition*
requisition
)
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.