Gtk2HsContentsIndex
Graphics.UI.Gtk.Abstract.Widget
Portabilityportable (depends on GHC)
Stabilityprovisional
Maintainergtk2hs-users@lists.sourceforge.net
Contents
Detail
Class Hierarchy
Types
Methods
Attributes
Signals
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
data AccelFlags
= AccelVisible
| AccelLocked
| AccelMask
data DirectionType
= DirTabForward
| DirTabBackward
| DirUp
| DirDown
| DirLeft
| DirRight
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
data EventMask
= ExposureMask
| PointerMotionMask
| PointerMotionHintMask
| ButtonMotionMask
| Button1MotionMask
| Button2MotionMask
| Button3MotionMask
| ButtonPressMask
| ButtonReleaseMask
| KeyPressMask
| KeyReleaseMask
| EnterNotifyMask
| LeaveNotifyMask
| FocusChangeMask
| StructureMask
| PropertyChangeMask
| VisibilityNotifyMask
| ProximityInMask
| ProximityOutMask
| SubstructureMask
| ScrollMask
| AllEventsMask
widgetDelEvents :: WidgetClass self => self -> [EventMask] -> IO ()
widgetAddEvents :: WidgetClass self => self -> [EventMask] -> IO ()
widgetGetEvents :: WidgetClass self => self -> IO [EventMask]
data ExtensionMode
= ExtensionEventsNone
| ExtensionEventsAll
| ExtensionEventsCursor
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 ()
data TextDirection
= TextDirNone
| TextDirLtr
| TextDirRtl
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)
onFocus :: WidgetClass w => w -> (DirectionType -> IO Bool) -> IO (ConnectId w)
afterFocus :: WidgetClass w => w -> (DirectionType -> IO Bool) -> 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)
data StateType
= StateNormal
| StateActive
| StatePrelight
| StateSelected
| StateInsensitive
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
show/hide Instances
class ObjectClass o => WidgetClass o
show/hide Instances
WidgetClass AboutDialog
WidgetClass AccelLabel
WidgetClass Alignment
WidgetClass Arrow
WidgetClass AspectFrame
WidgetClass Bin
WidgetClass Box
WidgetClass Button
WidgetClass ButtonBox
WidgetClass CList
WidgetClass CTree
WidgetClass Calendar
WidgetClass CellView
WidgetClass CheckButton
WidgetClass CheckMenuItem
WidgetClass ColorButton
WidgetClass ColorSelection
WidgetClass ColorSelectionDialog
WidgetClass Combo
WidgetClass ComboBox
WidgetClass ComboBoxEntry
WidgetClass Container
WidgetClass Dialog
WidgetClass DrawingArea
WidgetClass Entry
WidgetClass EventBox
WidgetClass Expander
WidgetClass FileChooserButton
WidgetClass FileChooserDialog
WidgetClass FileChooserWidget
WidgetClass FileSelection
WidgetClass Fixed
WidgetClass FontButton
WidgetClass FontSelection
WidgetClass FontSelectionDialog
WidgetClass Frame
WidgetClass GLDrawingArea
WidgetClass HBox
WidgetClass HButtonBox
WidgetClass HPaned
WidgetClass HRuler
WidgetClass HScale
WidgetClass HScrollbar
WidgetClass HSeparator
WidgetClass HandleBox
WidgetClass IconView
WidgetClass Image
WidgetClass ImageMenuItem
WidgetClass InputDialog
WidgetClass Invisible
WidgetClass Item
WidgetClass Label
WidgetClass Layout
WidgetClass List
WidgetClass ListItem
WidgetClass Menu
WidgetClass MenuBar
WidgetClass MenuItem
WidgetClass MenuShell
WidgetClass MenuToolButton
WidgetClass MessageDialog
WidgetClass Misc
WidgetClass MozEmbed
WidgetClass Notebook
WidgetClass OptionMenu
WidgetClass Paned
WidgetClass Plug
WidgetClass Preview
WidgetClass ProgressBar
WidgetClass RadioButton
WidgetClass RadioMenuItem
WidgetClass RadioToolButton
WidgetClass Range
WidgetClass Ruler
WidgetClass Scale
WidgetClass Scrollbar
WidgetClass ScrolledWindow
WidgetClass Separator
WidgetClass SeparatorMenuItem
WidgetClass SeparatorToolItem
WidgetClass Socket
WidgetClass SourceView
WidgetClass SpinButton
WidgetClass Statusbar
WidgetClass Table
WidgetClass TearoffMenuItem
WidgetClass TextView
WidgetClass TipsQuery
WidgetClass ToggleButton
WidgetClass ToggleToolButton
WidgetClass ToolButton
WidgetClass ToolItem
WidgetClass Toolbar
WidgetClass TreeView
WidgetClass VBox
WidgetClass VButtonBox
WidgetClass VPaned
WidgetClass VRuler
WidgetClass VScale
WidgetClass VScrollbar
WidgetClass VSeparator
WidgetClass Viewport
WidgetClass Widget
WidgetClass Window
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
Requisition Int Int
show/hide Instances
data Rectangle

Rectangle

  • for Events
  • Specifies x, y, width and height
Constructors
Rectangle Int Int Int Int
show/hide Instances
data AccelFlags
State of an accelerator
Constructors
AccelVisible
AccelLocked
AccelMask
show/hide Instances
data DirectionType
Editing direction
Constructors
DirTabForward
DirTabBackward
DirUp
DirDown
DirLeft
DirRight
show/hide 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
-> Rectanglearea - a rectangle
-> IO Boolreturns True if there was an intersection
Check if the widget intersects with a given area.
widgetIntersect
:: WidgetClass self
=> self
-> Rectanglearea - 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
-> Regionregion - 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 Regionreturns 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 Boolreturns 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
-> Boolsensitive - 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
-> Intwidth - width widget should request, or -1 to unset
-> Intheight - 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 Boolreturns 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