|
Graphics.UI.Gtk.Abstract.Widget | Portability | portable (depends on GHC) | Stability | provisional | Maintainer | gtk2hs-users@lists.sourceforge.net |
|
|
|
|
|
Description |
The base class for all widgets. While a widget cannot be created directly,
this module contains many useful methods common to all widgets. In
particular, these functions are needed to add functionality to
blank widgets such as DrawingArea or Layout.
|
|
Synopsis |
|
data Widget | | class ObjectClass o => WidgetClass o | | castToWidget :: GObjectClass obj => obj -> Widget | | toWidget :: WidgetClass o => o -> Widget | | type Allocation = Rectangle | | data Requisition = Requisition Int Int | | data Rectangle = Rectangle Int Int Int Int | | | | widgetGetState :: WidgetClass w => w -> IO StateType | | widgetGetSavedState :: WidgetClass w => w -> IO StateType | | widgetShow :: WidgetClass self => self -> IO () | | widgetShowNow :: WidgetClass self => self -> IO () | | widgetHide :: WidgetClass self => self -> IO () | | widgetShowAll :: WidgetClass self => self -> IO () | | widgetHideAll :: WidgetClass self => self -> IO () | | widgetDestroy :: WidgetClass self => self -> IO () | | widgetQueueDraw :: WidgetClass self => self -> IO () | | widgetGetDrawWindow :: WidgetClass widget => widget -> IO DrawWindow | | widgetGetSize :: WidgetClass widget => widget -> IO (Int, Int) | | widgetHasIntersection :: WidgetClass self => self -> Rectangle -> IO Bool | | widgetIntersect :: WidgetClass self => self -> Rectangle -> IO (Maybe Rectangle) | | widgetRegionIntersect :: WidgetClass self => self -> Region -> IO Region | | widgetActivate :: WidgetClass self => self -> IO Bool | | widgetSetSensitivity :: WidgetClass self => self -> Bool -> IO () | | widgetSetSizeRequest :: WidgetClass self => self -> Int -> Int -> IO () | | widgetGetSizeRequest :: WidgetClass self => self -> IO (Int, Int) | | widgetIsFocus :: WidgetClass self => self -> IO Bool | | widgetGrabFocus :: WidgetClass self => self -> IO () | | widgetSetAppPaintable :: WidgetClass self => self -> Bool -> IO () | | widgetSetName :: WidgetClass self => self -> String -> IO () | | widgetGetName :: WidgetClass self => self -> IO String | | | | widgetDelEvents :: WidgetClass self => self -> [EventMask] -> IO () | | widgetAddEvents :: WidgetClass self => self -> [EventMask] -> IO () | | widgetGetEvents :: WidgetClass self => self -> IO [EventMask] | | | | widgetSetExtensionEvents :: WidgetClass self => self -> [ExtensionMode] -> IO () | | widgetGetExtensionEvents :: WidgetClass self => self -> IO [ExtensionMode] | | widgetGetToplevel :: WidgetClass self => self -> IO Widget | | widgetIsAncestor :: (WidgetClass self, WidgetClass ancestor) => self -> ancestor -> IO Bool | | widgetReparent :: (WidgetClass self, WidgetClass newParent) => self -> newParent -> IO () | | | | widgetSetDirection :: WidgetClass self => self -> TextDirection -> IO () | | widgetGetDirection :: WidgetClass self => self -> IO TextDirection | | widgetQueueDrawArea :: WidgetClass self => self -> Int -> Int -> Int -> Int -> IO () | | widgetSetDoubleBuffered :: WidgetClass self => self -> Bool -> IO () | | widgetSetRedrawOnAllocate :: WidgetClass self => self -> Bool -> IO () | | widgetGetParentWindow :: WidgetClass self => self -> IO DrawWindow | | widgetGetPointer :: WidgetClass self => self -> IO (Int, Int) | | widgetTranslateCoordinates :: (WidgetClass self, WidgetClass destWidget) => self -> destWidget -> Int -> Int -> IO (Maybe (Int, Int)) | | widgetPath :: WidgetClass self => self -> IO (Int, String, String) | | widgetClassPath :: WidgetClass self => self -> IO (Int, String, String) | | widgetGetCompositeName :: WidgetClass self => self -> IO (Maybe String) | | widgetSetCompositeName :: WidgetClass self => self -> String -> IO () | | widgetGetParent :: WidgetClass self => self -> IO (Maybe Widget) | | widgetSetDefaultDirection :: TextDirection -> IO () | | widgetGetDefaultDirection :: IO TextDirection | | widgetGetStyle :: WidgetClass widget => widget -> IO Style | | widgetModifyStyle :: (WidgetClass self, RcStyleClass style) => self -> style -> IO () | | widgetGetModifierStyle :: WidgetClass self => self -> IO RcStyle | | widgetModifyFg :: WidgetClass self => self -> StateType -> Color -> IO () | | widgetModifyBg :: WidgetClass self => self -> StateType -> Color -> IO () | | widgetModifyText :: WidgetClass self => self -> StateType -> Color -> IO () | | widgetModifyBase :: WidgetClass self => self -> StateType -> Color -> IO () | | widgetModifyFont :: WidgetClass self => self -> Maybe FontDescription -> IO () | | widgetCreateLayout :: WidgetClass self => self -> String -> IO PangoLayout | | widgetCreatePangoContext :: WidgetClass self => self -> IO PangoContext | | widgetGetPangoContext :: WidgetClass self => self -> IO PangoContext | | widgetRenderIcon :: WidgetClass self => self -> StockId -> IconSize -> String -> IO (Maybe Pixbuf) | | widgetGetCanFocus :: WidgetClass self => self -> IO Bool | | widgetSetCanFocus :: WidgetClass self => self -> Bool -> IO () | | widgetExtensionEvents :: WidgetClass self => Attr self [ExtensionMode] | | widgetDirection :: WidgetClass self => Attr self TextDirection | | widgetCanFocus :: WidgetClass self => Attr self Bool | | onButtonPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterButtonPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onButtonRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterButtonRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onClient :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterClient :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onConfigure :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterConfigure :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onDelete :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterDelete :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onDestroyEvent :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterDestroyEvent :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onDirectionChanged :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterDirectionChanged :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onEnterNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterEnterNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onLeaveNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterLeaveNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onExpose :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterExpose :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onExposeRect :: WidgetClass w => w -> (Rectangle -> IO ()) -> IO (ConnectId w) | | afterExposeRect :: WidgetClass w => w -> (Rectangle -> IO ()) -> IO (ConnectId w) | | onFocusIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterFocusIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onFocusOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterFocusOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onGrabFocus :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterGrabFocus :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onDestroy :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterDestroy :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onHide :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterHide :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onHierarchyChanged :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterHierarchyChanged :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onKeyPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterKeyPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onKeyRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterKeyRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onMnemonicActivate :: WidgetClass w => w -> (Bool -> IO Bool) -> IO (ConnectId w) | | afterMnemonicActivate :: WidgetClass w => w -> (Bool -> IO Bool) -> IO (ConnectId w) | | onMotionNotify :: WidgetClass w => w -> Bool -> (Event -> IO Bool) -> IO (ConnectId w) | | afterMotionNotify :: WidgetClass w => w -> Bool -> (Event -> IO Bool) -> IO (ConnectId w) | | onParentSet :: (WidgetClass w, WidgetClass old) => w -> (old -> IO ()) -> IO (ConnectId w) | | afterParentSet :: (WidgetClass w, WidgetClass old) => w -> (old -> IO ()) -> IO (ConnectId w) | | onPopupMenu :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterPopupMenu :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onProximityIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterProximityIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onProximityOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterProximityOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onRealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterRealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onScroll :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterScroll :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onShow :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterShow :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onSizeAllocate :: WidgetClass w => w -> (Allocation -> IO ()) -> IO (ConnectId w) | | afterSizeAllocate :: WidgetClass w => w -> (Allocation -> IO ()) -> IO (ConnectId w) | | onSizeRequest :: WidgetClass w => w -> IO Requisition -> IO (ConnectId w) | | afterSizeRequest :: WidgetClass w => w -> IO Requisition -> IO (ConnectId w) | | | | onStateChanged :: WidgetClass w => w -> (StateType -> IO ()) -> IO (ConnectId w) | | afterStateChanged :: WidgetClass w => w -> (StateType -> IO ()) -> IO (ConnectId w) | | onUnmap :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterUnmap :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onUnrealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | afterUnrealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) | | onVisibilityNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterVisibilityNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | onWindowState :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) | | afterWindowState :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
|
|
Detail
|
|
Widget introduces style properties - these are basically object
properties that are stored not on the object, but in the style object
associated to the widget. Style properties are set in resource files. This
mechanism is used for configuring such things as the location of the
scrollbar arrows through the theme, giving theme authors more control over
the look of applications without the need to write a theme engine in C.
|
|
Class Hierarchy
|
|
| GObject
| +----Object
| +----Widget
| +----too many to list
|
|
Types
|
|
data Widget |
Instances | |
|
|
class ObjectClass o => WidgetClass o |
| Instances | |
|
|
castToWidget :: GObjectClass obj => obj -> Widget |
|
toWidget :: WidgetClass o => o -> Widget |
|
type Allocation = Rectangle |
Allocation
- for Widget's size_allocate signal
|
|
data Requisition |
Requisition
- for Widget's size_request
| Constructors | | Instances | |
|
|
data Rectangle |
Rectangle
- for Events
- Specifies x, y, width and height
| Constructors | | Instances | |
|
|
data AccelFlags |
State of an accelerator
| Constructors | AccelVisible | | AccelLocked | | AccelMask | |
| Instances | |
|
|
Methods
|
|
widgetGetState :: WidgetClass w => w -> IO StateType |
Retrieve the current state of the widget.
- The state refers to different modes of user interaction, see
StateType for more information.
|
|
widgetGetSavedState :: WidgetClass w => w -> IO StateType |
Retrieve the current state of the widget.
- If a widget is turned insensitive, the previous state is stored in
a specific location. This function retrieves this previous state.
|
|
widgetShow :: WidgetClass self => self -> IO () |
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 widgetShowAll 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.
|
|
widgetShowNow :: WidgetClass self => self -> IO () |
Shows a widget. If the widget is an unmapped toplevel widget (i.e. a
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.
|
|
widgetHide :: WidgetClass self => self -> IO () |
Reverses the effects of widgetShow, causing the widget to be hidden
(invisible to the user).
|
|
widgetShowAll :: WidgetClass self => self -> IO () |
Recursively shows a widget, and any child widgets (if the widget is a
container).
|
|
widgetHideAll :: WidgetClass self => self -> IO () |
Recursively hides a widget and any child widgets.
|
|
widgetDestroy :: WidgetClass self => self -> IO () |
Destroys a widget. Equivalent to
objectDestroy.
When a widget is destroyed it will be removed from the screen and
unrealized. When a widget is destroyed, it will break any references it
holds to other objects.If the widget is inside a container, the widget will
be removed from the container. The widget will be garbage collected
(finalized) time after your last reference to the widget dissapears.
In most cases, only toplevel widgets (windows) require explicit
destruction, because when you destroy a toplevel its children will be
destroyed as well.
|
|
widgetQueueDraw :: WidgetClass self => self -> IO () |
Send a redraw request to a widget. Equivalent to calling
widgetQueueDrawArea for the entire area of a widget.
|
|
widgetGetDrawWindow :: WidgetClass widget => widget -> IO DrawWindow |
Retrieves the DrawWindow that the widget draws onto.
This may be Nothing if the widget has not yet been realized, since a
widget does not allocate its window resources until just before it is
displayed on the screen. You can use the
onRealize signal to give you the
opportunity to use a widget's DrawWindow as soon as it has been created
but before the widget is displayed.
|
|
widgetGetSize :: WidgetClass widget => widget -> IO (Int, Int) |
Returns the current size.
- This information may be out of date if the user is resizing the window.
|
|
widgetHasIntersection |
:: WidgetClass self | | => self | | -> Rectangle | area - a rectangle
| -> IO Bool | returns True if there was an intersection
| Check if the widget intersects with a given area.
|
|
|
widgetIntersect |
:: WidgetClass self | | => self | | -> Rectangle | area - a rectangle
| -> IO (Maybe Rectangle) | returns the intersection or Nothing
| Computes the intersection of a widget's area and area, returning the
intersection, and returns Nothing if there was no intersection.
|
|
|
widgetRegionIntersect |
:: WidgetClass self | | => self | | -> Region | region - a Region in the same coordinate system as the
widget's allocation. That is, relative to the widget's
DrawWindow for NoWindow widgets; relative to the parent
DrawWindow of the widget's DrawWindow for widgets with
their own DrawWindow.
| -> IO Region | returns A region holding the intersection of the widget and
region. The coordinates of the return value are relative to
the widget's DrawWindow, if it has one, otherwise
it is relative to the parent's DrawWindow.
| Computes the intersection of a widget's area and region, returning
the intersection. The result may be empty, use
regionEmpty to check.
|
|
|
widgetActivate |
:: WidgetClass self | | => self | | -> IO Bool | returns True if the widget was activatable
| 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 widget isn't activatable, the function
returns False.
|
|
|
widgetSetSensitivity |
:: WidgetClass self | | => self | | -> Bool | sensitive - True to make the widget sensitive
| -> IO () | | 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.
|
|
|
widgetSetSizeRequest |
:: WidgetClass self | | => self | | -> Int | width - width widget should request, or -1 to unset
| -> Int | height - height widget should request, or -1 to unset
| -> IO () | | 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, windowSetDefaultSize
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, windowSetGeometryHints 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."
|
|
|
widgetGetSizeRequest |
:: WidgetClass self | | => self | | -> IO (Int, Int) | (width, height) | Gets the size request that was explicitly set for the widget using
widgetSetSizeRequest. A value of -1 for width or height
indicates that that dimension has not been set explicitly and the natural
requisition of the widget will be used intead. See widgetSetSizeRequest.
To get the size a widget will actually use, call connect to the
signal onSizeRequest instead of calling this function.
|
|
|
widgetIsFocus |
:: WidgetClass self | | => self | | -> IO Bool | returns True if the widget is the focus widget.
| Determines if the widget is the focus widget within its toplevel.
|
|
|
widgetGrabFocus :: WidgetClass self => self -> IO () |
Causes the widget to have the keyboard focus for the Window it's inside.
The widget must be a focusable widget, such as a Entry; something like
Frame won't work. (More precisely, it must have the CanFocus flag set.)
|
|
widgetSetAppPaintable |
:: WidgetClass self | | => self | | -> Bool | appPaintable - True if the application will paint on the
widget
| -> IO () | | Sets whether the application intends to draw on the widget in response
to an onExpose signal.
- 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 EventBox and 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.
|
|
|
widgetSetName |
:: WidgetClass self | | => self | | -> String | name - name for the widget
| -> IO () | | 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.
Note that widget names are separated by periods in paths (see
widgetPath), so names with embedded periods may cause confusion.
|
|
|
widgetGetName :: WidgetClass self => self -> IO String |
Retrieves the name of a widget. See widgetSetName for the significance
of widget names.
|
|
data EventMask |
specify which events a widget will emit signals on
| Constructors | ExposureMask | | PointerMotionMask | | PointerMotionHintMask | | ButtonMotionMask | | Button1MotionMask | | Button2MotionMask | | Button3MotionMask | | ButtonPressMask | | ButtonReleaseMask | | KeyPressMask | | KeyReleaseMask | | EnterNotifyMask | | LeaveNotifyMask | | FocusChangeMask | | StructureMask | | PropertyChangeMask | | VisibilityNotifyMask | | ProximityInMask | | ProximityOutMask | | SubstructureMask | | ScrollMask | | AllEventsMask | |
| Instances | |
|
|
widgetDelEvents :: WidgetClass self => self -> [EventMask] -> IO () |
Disable event signals.
- Remove events from the EventMask of this widget. The event mask
determines which events a widget will receive. Events are signals
that return an Event data type. On connecting to a such a signal,
the event mask is automatically adjusted so that he signal is emitted.
This function is useful to disable the reception of the signal. It
should be called whenever a signal receiving an Event is disconected.
|
|
widgetAddEvents :: WidgetClass self => self -> [EventMask] -> IO () |
Enable event signals.
|
|
widgetGetEvents :: WidgetClass self => self -> IO [EventMask] |
Get enabled event signals.
|
|
data ExtensionMode |
specify which input extension a widget desires
| Constructors | ExtensionEventsNone | | ExtensionEventsAll | | ExtensionEventsCursor | |
| Instances | |
|
|
widgetSetExtensionEvents :: WidgetClass self => self -> [ExtensionMode] -> IO () |
Sets the extension events.
|
|
widgetGetExtensionEvents :: WidgetClass self => self -> IO [ExtensionMode] |
Retrieves the extension events the widget will receive; see
widgetSetExtensionEvents.
|
|
widgetGetToplevel |
:: WidgetClass self | | => self | widget - the widget in question
| -> IO Widget | returns the topmost ancestor of widget, or widget
itself if there's no ancestor.
| 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.
|
|
|
widgetIsAncestor |
:: (WidgetClass self, WidgetClass ancestor) | | => self | widget - the widget in question
| -> ancestor | ancestor - another Widget
| -> IO Bool | returns True if ancestor contains widget as a child,
grandchild, great grandchild, etc.
| Determines whether widget is somewhere inside ancestor, possibly with
intermediate containers.
|
|
|
widgetReparent |
|
|
data TextDirection |
Is the text written from left to right or the exotic way?
| Constructors | TextDirNone | | TextDirLtr | | TextDirRtl | |
| Instances | |
|
|
widgetSetDirection :: WidgetClass self => self -> TextDirection -> IO () |
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).
If the direction is set to TextDirNone, then the value set by
widgetSetDefaultDirection will be used.
|
|
widgetGetDirection :: WidgetClass self => self -> IO TextDirection |
Gets the reading direction for a particular widget. See
widgetSetDirection.
|
|
widgetQueueDrawArea |
:: WidgetClass self | | => self | | -> Int | x - x coordinate of upper-left corner of rectangle to redraw
| -> Int | y - y coordinate of upper-left corner of rectangle to redraw
| -> Int | width - width of region to draw
| -> Int | height - height of region to draw
| -> IO () | | Invalidates the rectangular area of widget defined by x, y, width
and height by calling
drawWindowInvalidateRect on the widget's
DrawWindow 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 drawWindowInvalidateRect
directly, to schedule a redraw
of a DrawingArea or some portion thereof.
Frequently you can just call
windowInvalidateRect or
windowInvalidateRegion 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.
|
|
|
widgetSetDoubleBuffered |
:: WidgetClass self | | => self | | -> Bool | doubleBuffered - True to double-buffer a widget
| -> IO () | | Widgets are double buffered by default; you can use this function to turn
off the buffering. "Double buffered" simply means that
drawWindowBeginPaintRegion and
drawWindowEndPaint are called automatically
around expose events sent to the widget.
drawWindowBeginPaintRegion diverts all
drawing to a widget's window to an offscreen buffer, and
drawWindowEndPaint
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
drawWindowBeginPaint).
|
|
|
widgetSetRedrawOnAllocate |
:: WidgetClass self | | => self | | -> Bool | redrawOnAllocate - 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.
| -> IO () | | 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 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 its 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.
|
|
|
widgetGetParentWindow :: WidgetClass self => self -> IO DrawWindow |
Gets the widget's parent window.
|
|
widgetGetPointer |
:: WidgetClass self | | => self | | -> IO (Int, Int) | (x, y) - X Y coordinate
| Obtains the location of the mouse pointer in widget coordinates. Widget
coordinates are a bit odd; for historical reasons, they are defined as
widgetGetParentWindow coordinates for widgets that are not NoWindow widgets,
and are relative to the widget's allocation's (x,y) for
widgets that are NoWindow widgets.
|
|
|
widgetTranslateCoordinates |
:: (WidgetClass self, WidgetClass destWidget) | | => self | srcWidget - a Widget
| -> destWidget | destWidget - a Widget
| -> Int | srcX - X position relative to srcWidget
| -> Int | srcY - Y position relative to srcWidget
| -> IO (Maybe (Int, Int)) | Just (destX, destY) - X and Y position
relative to destWidget. Returns Nothing if
either widget was not realized, or there was no
common ancestor.
| Translate coordinates relative to srcWidget's allocation to coordinates
relative to destWidget's allocations. In order to perform this operation,
both widgets must be realized, and must share a common toplevel.
|
|
|
widgetPath |
:: WidgetClass self | | => self | | -> IO (Int, String, String) | (pathLength, path, pathReversed) - length
of the path, path string and reverse path
string
| Obtains the full path to the widget. The path is simply the name of a
widget and all its parents in the container hierarchy, separated by periods.
The name of a widget comes from widgetGetName. Paths are used to apply
styles to a widget in gtkrc configuration files. Widget names are the type
of the widget by default (e.g. "GtkButton") or can be set to an
application-specific value with widgetSetName. By setting the name of a
widget, you allow users or theme authors to apply styles to that specific
widget in their gtkrc file. Also returns the path in reverse
order, i.e. starting with the widget's name instead of starting with the
name of the widget's outermost ancestor.
|
|
|
widgetClassPath |
:: WidgetClass self | | => self | | -> IO (Int, String, String) | (pathLength, path, pathReversed) - length
of the path, path string and reverse path
string
| Same as widgetPath, but always uses the name of a widget's type, never
uses a custom name set with widgetSetName.
|
|
|
widgetGetCompositeName |
:: WidgetClass self | | => self | | -> IO (Maybe String) | returns the composite name of widget, or
Nothing if widget is not a composite child.
| Obtains the composite name of a widget.
|
|
|
widgetSetCompositeName |
:: WidgetClass self | | => self | | -> String | name - the name to set.
| -> IO () | | Sets a widgets composite name. A child widget of a container is
composite if it serves as an internal widget and, thus, is not
added by the user.
|
|
|
widgetGetParent :: WidgetClass self => self -> IO (Maybe Widget) |
Returns the parent container of widget.
- Returns the parent container of widget if it has one.
|
|
widgetSetDefaultDirection |
|
|
widgetGetDefaultDirection :: IO TextDirection |
Obtains the current default reading direction. See
widgetSetDefaultDirection.
|
|
widgetGetStyle :: WidgetClass widget => widget -> IO Style |
Retrieve the Style associated with the widget.
|
|
widgetModifyStyle |
:: (WidgetClass self, RcStyleClass style) | | => self | | -> style | style - the RcStyle holding the style modifications
| -> IO () | | Modifies style values on the widget. 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
widgetSetStyle. The 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 widgetModifyStyle or with such functions as
widgetModifyFg. If you wish to retain previous values, you must first call
widgetGetModifierStyle, make your modifications to the returned style,
then call widgetModifyStyle with that style. On the other hand, if you
first call widgetModifyStyle, subsequent calls to such functions
widgetModifyFg will have a cumulative effect with the initial
modifications.
|
|
|
widgetGetModifierStyle :: WidgetClass self => self -> IO RcStyle |
Returns the current modifier style for the widget. (As set by
widgetModifyStyle.) If no style has previously set, a new 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
widgetModifyStyle, passing in the returned rc style, to make sure that
your changes take effect.
Caution: passing the style back to widgetModifyStyle will normally end
up destroying it, because widgetModifyStyle 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.
|
|
widgetModifyFg |
:: WidgetClass self | | => self | | -> StateType | state - the state for which to set the foreground color.
| -> Color | color - the color to assign (does not need to be
allocated), or Nothing to undo the effect of previous calls
to of widgetModifyFg.
| -> IO () | | Sets the foreground color for a widget in a particular state. All other
style values are left untouched. See also widgetModifyStyle.
|
|
|
widgetModifyBg |
:: WidgetClass self | | => self | | -> StateType | state - the state for which to set the background color.
| -> Color | color - the color to assign (does not need to be
allocated), or Nothing to undo the effect of previous calls
to of widgetModifyBg.
| -> IO () | | Sets the background color for a widget in a particular state. All other
style values are left untouched. See also widgetModifyStyle.
Note that "no window" widgets (which have the NoWindow flag set) draw
on their parent container's window and thus may not draw any background
themselves. This is the case for e.g. Label. To modify the background of
such widgets, you have to set the background color on their parent; if you
want to set the background of a rectangular area around a label, try placing
the label in a EventBox widget and setting the background color on that.
|
|
|
widgetModifyText |
:: WidgetClass self | | => self | | -> StateType | state - the state for which to set the text color.
| -> Color | color - the color to assign (does not need to be
allocated), or Nothing to undo the effect of previous calls
to of widgetModifyText.
| -> IO () | | 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 widgetModifyBase) for widgets such as Entry and
TextView. See also widgetModifyStyle.
|
|
|
widgetModifyBase |
:: WidgetClass self | | => self | | -> StateType | state - the state for which to set the base color.
| -> Color | color - the color to assign (does not need to be
allocated), or Nothing to undo the effect of previous calls
to of widgetModifyBase.
| -> IO () | | 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 widgetModifyText) for widgets such as Entry and
TextView. See also widgetModifyStyle.
Note that "no window" widgets (which have the NoWindow flag set) draw
on their parent container's window and thus may not draw any background
themselves. This is the case for e.g. Label. To modify the background of
such widgets, you have to set the base color on their parent; if you want to
set the background of a rectangular area around a label, try placing the
label in a EventBox widget and setting the base color on that.
|
|
|
widgetModifyFont |
|
|
widgetCreateLayout |
:: WidgetClass self | | => self | | -> String | text - text to set on the layout
| -> IO PangoLayout | | Prepare text for display.
The PangoLayout represents the rendered text. It can be shown on screen
by calling drawLayout.
The returned PangoLayout shares the same font information (PangoContext) as this
widget. If this information changes, the PangoLayout should change. The
following code ensures that the displayed text always reflects the widget's
settings:
l <- widgetCreateLayout w "My Text."
let update = do
layoutContextChanged l
-- update the Drawables which show this layout
w `onDirectionChanged` update
w `onStyleChanged` update
|
|
|
widgetCreatePangoContext |
|
|
widgetGetPangoContext |
:: WidgetClass self | | => self | | -> IO PangoContext | returns the PangoContext for the widget.
| Gets a PangoContext with the appropriate font description and base
direction for this widget. Unlike the context returned by
widgetCreatePangoContext, 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 PangoLayout using this context, you must deal
with changes to the context by calling
layoutContextChanged on the layout
in response to the onStyleChanged and onDirectionChanged signals for the
widget.
|
|
|
widgetRenderIcon |
:: WidgetClass self | | => self | | -> StockId | the stock ID of the icon
| -> IconSize | size - a stock size. The size
iconSizeInvalid means
render at the size of the source and don't scale (if there are
multiple source sizes, Gtk+ picks one of the available sizes).
| -> String | detail - render detail to pass to theme engine
| -> IO (Maybe Pixbuf) | the new Pixbuf
if the stock icon was found
| A convenience function that uses the theme engine and RC file settings
for widget to look up the stock icon and render it to a
Pixbuf.
The icon should be one of the stock id constants such as
stockOpen. size should be a
size such as iconSizeMenu.
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 Pixbuf are
shared with the rest of the
application and should not be modified.
|
|
|
widgetGetCanFocus :: WidgetClass self => self -> IO Bool |
Check if this widget can receive keyboard input.
|
|
widgetSetCanFocus :: WidgetClass self => self -> Bool -> IO () |
Set if this widget can receive keyboard input.
- To use the onKeyPress event, the widget must be allowed
to get the input focus. Once it has the input focus all keyboard
input is directed to this widget.
|
|
Attributes
|
|
widgetExtensionEvents :: WidgetClass self => Attr self [ExtensionMode] |
The mask that decides what kind of extension events this widget gets.
Default value: ExtensionEventsNone
|
|
widgetDirection :: WidgetClass self => Attr self TextDirection |
'direction' property. See widgetGetDirection and widgetSetDirection
|
|
widgetCanFocus :: WidgetClass self => Attr self Bool |
Whether the widget can have the input focus.
|
|
Signals
|
|
onButtonPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
A Button was pressed.
- This widget is part of a button which was just pressed. The event passed
to the user function is a Button event.
|
|
afterButtonPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onButtonRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
A Button was released.
|
|
afterButtonRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onClient :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
afterClient :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onConfigure :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The widget's status has changed.
|
|
afterConfigure :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onDelete :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
This signal is emitted when the close icon on the
surrounding window is pressed. The default action is to emit the
"destroy" signal.
|
|
afterDelete :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onDestroyEvent :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The widget will be destroyed.
- The widget received a destroy event from the window manager.
|
|
afterDestroyEvent :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onDirectionChanged :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The default text direction was changed.
|
|
afterDirectionChanged :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onEnterNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
Mouse cursor entered widget.
|
|
afterEnterNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onLeaveNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
Mouse cursor leaves widget.
|
|
afterLeaveNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onExpose :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
Instructs the widget to redraw.
- This event is useful for the DrawingArea. On receiving this signal
the content of the passed Rectangle or Region needs to be redrawn.
The return value should be True if the region was completely redrawn
and False if other handlers in the chain should be invoked.
If a client will redraw the whole area and is not interested in the
extra information in Expose, it is more efficient
to use onExposeRect.
- Widgets that are very expensive to re-render, such as an image editor,
may prefer to use the onExpose call back which delivers a
Region in addition to a Rectangle. A Region consists of several
rectangles that need redrawing. The simpler onExposeRect event encodes
the area to be redrawn as a bounding rectangle which might be easier
to deal with in a particular application.
|
|
afterExpose :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onExposeRect :: WidgetClass w => w -> (Rectangle -> IO ()) -> IO (ConnectId w) |
Expose event delivering a Rectangle.
|
|
afterExposeRect :: WidgetClass w => w -> (Rectangle -> IO ()) -> IO (ConnectId w) |
|
onFocusIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
Widget gains input focus.
|
|
afterFocusIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onFocusOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
Widget looses input focus.
|
|
afterFocusOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onGrabFocus :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The widget is about to receive all events.
- It is possible to redirect all input events to one widget to force the
user to use only this widget. Such a situation is initiated by
addGrab.
|
|
afterGrabFocus :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onDestroy :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The widget will be destroyed.
- This is the last signal this widget will receive.
|
|
afterDestroy :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onHide :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The widget was asked to hide itself.
- This signal is emitted each time widgetHide is called. Use
onUnmap when your application needs to be informed
when the widget is actually removed from screen.
|
|
afterHide :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onHierarchyChanged :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The toplevel window changed.
- When a subtree of widgets is removed or added from a tree with a toplevel
window this signal is emitted. It is emitted on each widget in the
detached or attached subtree.
|
|
afterHierarchyChanged :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onKeyPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
A key was pressed.
|
|
afterKeyPress :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onKeyRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
A key was released.
|
|
afterKeyRelease :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onMnemonicActivate :: WidgetClass w => w -> (Bool -> IO Bool) -> IO (ConnectId w) |
|
afterMnemonicActivate :: WidgetClass w => w -> (Bool -> IO Bool) -> IO (ConnectId w) |
|
onMotionNotify :: WidgetClass w => w -> Bool -> (Event -> IO Bool) -> IO (ConnectId w) |
Track mouse movements.
- If hint is False, a callback for every movement of the mouse is
generated. To avoid a backlog of mouse messages, it is usually sufficient
to sent hint to True, generating only one event. The
application now has to state that it is ready for the next message by
calling drawWindowGetPointer.
|
|
afterMotionNotify :: WidgetClass w => w -> Bool -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onParentSet :: (WidgetClass w, WidgetClass old) => w -> (old -> IO ()) -> IO (ConnectId w) |
|
afterParentSet :: (WidgetClass w, WidgetClass old) => w -> (old -> IO ()) -> IO (ConnectId w) |
|
onPopupMenu :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
afterPopupMenu :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onProximityIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The input device became active.
- This event indicates that a pen of a graphics tablet or similar device is
now touching the tablet.
|
|
afterProximityIn :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onProximityOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The input device became inactive.
- The pen was removed from the graphics tablet's surface.
|
|
afterProximityOut :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onRealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
This widget's drawing area is about to be
destroyed.
|
|
afterRealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onScroll :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
The mouse wheel has turned.
|
|
afterScroll :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onShow :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The widget was asked to show itself.
- This signal is emitted each time widgetShow is called. Use
onMap when your application needs to be informed when
the widget is actually shown.
|
|
afterShow :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onSizeAllocate :: WidgetClass w => w -> (Allocation -> IO ()) -> IO (ConnectId w) |
Inform widget about the size it has.
- After querying a widget for the size it wants to have (through emitting
the "sizeRequest" signal) a container will emit this signal to
inform the widget about the real size it should occupy.
|
|
afterSizeAllocate :: WidgetClass w => w -> (Allocation -> IO ()) -> IO (ConnectId w) |
|
onSizeRequest :: WidgetClass w => w -> IO Requisition -> IO (ConnectId w) |
Query the widget for the size it likes to
have.
- A parent container emits this signal to its child to query the needed
height and width of the child. There is not guarantee that the widget
will actually get this area.
|
|
afterSizeRequest :: WidgetClass w => w -> IO Requisition -> IO (ConnectId w) |
|
data StateType |
Widget states
| Constructors | StateNormal | | StateActive | | StatePrelight | | StateSelected | | StateInsensitive | |
| Instances | |
|
|
onStateChanged :: WidgetClass w => w -> (StateType -> IO ()) -> IO (ConnectId w) |
|
afterStateChanged :: WidgetClass w => w -> (StateType -> IO ()) -> IO (ConnectId w) |
|
onUnmap :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
The widget was removed from screen.
|
|
afterUnmap :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onUnrealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
This widget's drawing area is about to be
destroyed.
|
|
afterUnrealize :: WidgetClass w => w -> IO () -> IO (ConnectId w) |
|
onVisibilityNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
afterVisibilityNotify :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
onWindowState :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
afterWindowState :: WidgetClass w => w -> (Event -> IO Bool) -> IO (ConnectId w) |
|
Produced by Haddock version 0.8 |