{-# LINE 2 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} -- -*-haskell-*- -- GIMP Toolkit (GTK) CellRenderer TreeView -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Copyright (C) 1999-2006 Axel Simon -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- -- | -- Maintainer : gtk2hs-users@lists.sourceforge.net -- Stability : provisional -- Portability : portable (depends on GHC) -- -- An object for rendering a cell in a list, icon or combo box widget. -- module Graphics.UI.Gtk.ModelView.CellRenderer ( -- * Detail -- -- | The 'CellRenderer' is a base class of a set of objects used for rendering -- a cell to a 'Drawable'. These objects are used primarily by the 'TreeView' -- widget, though they aren't tied to them in any specific way. It is worth -- noting that 'CellRenderer' is not a 'Widget' and cannot be treated as such. -- -- The primary use of a 'CellRenderer' is for drawing a certain graphical -- elements on a 'Drawable'. Typically, one cell renderer is used to draw many -- cells on the screen. To this extent, it isn't expected that a -- 'CellRenderer' keep any permanent state around. Instead, any state is set -- just prior to use by changing the attributes of the cell. Then, the cell is -- measured and rendered in the correct location. -- -- Beyond merely rendering a cell, cell renderers can optionally provide -- active user interface elements. A cell renderer can be activatable like -- 'Graphics.UI.Gtk.ModelView.CellRendererToggle', which toggles when it gets -- activated by a mouse click, or it can be editable like -- 'Graphics.UI.Gtk.ModelView.CellRendererText', which allows the user to edit -- the text using a 'Graphics.UI.Gtk.Entry.Entry'. -- * Class Hierarchy -- | -- @ -- | 'GObject' -- | +----'Object' -- | +----CellRenderer -- | +----'CellRendererText' -- | +----'CellRendererPixbuf' -- | +----'CellRendererProgress' -- | +----'CellRendererCombo' -- | +----'CellRendererToggle' -- @ -- * Types CellRenderer, CellRendererClass, castToCellRenderer, gTypeCellRenderer, toCellRenderer, CellRendererMode(..), -- * Methods cellRendererStopEditing, cellRendererGetFixedSize, cellRendererSetFixedSize, -- * Attributes cellMode, cellVisible, cellSensitive, cellXAlign, cellYAlign, cellXPad, cellYPad, cellWidth, cellHeight, cellIsExpander, cellIsExpanded, cellBackground, cellBackgroundSet, -- * Signals editingStarted, editingCanceled, -- * Deprecated {-# LINE 114 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} ) where import System.Glib.FFI import System.Glib.UTFString import System.Glib.Attributes ( Attr, WriteAttr ) import System.Glib.Properties import Graphics.UI.Gtk.Types {-# LINE 121 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} import Graphics.UI.Gtk.Signals {-# LINE 125 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} import Graphics.UI.Gtk.ModelView.Types {-# LINE 126 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} {-# LINE 128 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} data CellRendererMode = CellRendererModeInert | CellRendererModeActivatable | CellRendererModeEditable deriving (Enum,Eq) {-# LINE 130 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} -- %hash c:75b3 d:45ca -- | Informs the cell renderer that the editing is stopped. If @canceled@ is -- @True@, the cell renderer will emit the 'editingCanceled' signal. -- -- * Available since Gtk+ version 2.6 -- cellRendererStopEditing :: CellRendererClass self => self -> Bool -- ^ @canceled@ - @True@ if the editing has been canceled -> IO () cellRendererStopEditing self canceled = (\(CellRenderer arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gtk_cell_renderer_stop_editing argPtr1 arg2) {-# LINE 144 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} (toCellRenderer self) (fromBool canceled) -- %hash c:6d51 d:dc3e -- | Returns @(width, height)@ denoting the size of the fixed size of -- @cell@. If no fixed size is set, returns @-1@ for that value. -- cellRendererGetFixedSize :: CellRendererClass self => self -> IO (Int, Int) -- ^ @(width, height)@ cellRendererGetFixedSize self = alloca $ \widthPtr -> alloca $ \heightPtr -> (\(CellRenderer arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_cell_renderer_get_fixed_size argPtr1 arg2 arg3) {-# LINE 158 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} (toCellRenderer self) widthPtr heightPtr >> peek widthPtr >>= \width -> peek heightPtr >>= \height -> return (fromIntegral width, fromIntegral height) -- %hash c:85dc d:5fd4 -- | Sets the renderer size to be explicit, independent of the properties set. -- cellRendererSetFixedSize :: CellRendererClass self => self -> Int -- ^ @width@ - the width of the cell renderer, or -1 -> Int -- ^ @height@ - the height of the cell renderer, or -1 -> IO () cellRendererSetFixedSize self width height = (\(CellRenderer arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gtk_cell_renderer_set_fixed_size argPtr1 arg2 arg3) {-# LINE 174 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} (toCellRenderer self) (fromIntegral width) (fromIntegral height) -------------------- -- Attributes -- | Editable mode of the CellRenderer. -- -- Default value: 'CellRendererModeInert' -- cellMode :: CellRendererClass self => Attr self CellRendererMode cellMode = newAttrFromEnumProperty "mode" gtk_cell_renderer_mode_get_type {-# LINE 188 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} -- | Display the cell. -- -- Default value: @True@ -- cellVisible :: CellRendererClass self => Attr self Bool cellVisible = newAttrFromBoolProperty "visible" -- | Display the cell sensitive. -- -- Default value: @True@ -- cellSensitive :: CellRendererClass self => Attr self Bool cellSensitive = newAttrFromBoolProperty "sensitive" -- | The x-align. -- -- Allowed values: @[0,1]@ -- -- Default value: @0.5@ -- cellXAlign :: CellRendererClass self => Attr self Float cellXAlign = newAttrFromFloatProperty "xalign" -- | The y-align. -- -- Allowed values: @[0,1]@ -- -- Default value: @0.5@ -- cellYAlign :: CellRendererClass self => Attr self Float cellYAlign = newAttrFromFloatProperty "yalign" -- | The xpad. -- -- Default value: @0@ -- cellXPad :: CellRendererClass self => Attr self Int cellXPad = newAttrFromUIntProperty "xpad" -- | The ypad. -- -- Default value: @0@ -- cellYPad :: CellRendererClass self => Attr self Int cellYPad = newAttrFromUIntProperty "ypad" -- | The fixed width. -- -- Allowed values: @>= -1@ -- -- Default value: @-1@ -- cellWidth :: CellRendererClass self => Attr self Int cellWidth = newAttrFromIntProperty "width" -- | The fixed height. -- -- Allowed values: @>= -1@ -- -- Default value: @-1@ -- cellHeight :: CellRendererClass self => Attr self Int cellHeight = newAttrFromIntProperty "height" -- | Row has children. -- -- Default value: @False@ -- cellIsExpander :: CellRendererClass self => Attr self Bool cellIsExpander = newAttrFromBoolProperty "is-expander" -- | Row is an expander row, and is expanded. -- -- Default value: @False@ -- cellIsExpanded :: CellRendererClass self => Attr self Bool cellIsExpanded = newAttrFromBoolProperty "is-expanded" -- | Cell background color as a string. -- -- Default value: @\"\"@ -- cellBackground :: (CellRendererClass self, GlibString string) => WriteAttr self string cellBackground = writeAttrFromStringProperty "cell-background" {-# LINE 283 "./Graphics/UI/Gtk/ModelView/CellRenderer.chs" #-} -- | Whether the 'cellBackground' \/ 'cellBackgroundColor' attribute is set. -- -- You can use this to reset the attribute to its default. -- -- Default value: @False@ -- cellBackgroundSet :: CellRendererClass self => Attr self Bool cellBackgroundSet = newAttrFromBoolProperty "cell-background-set" -------------------- -- Signals -- %hash c:eff4 d:fc12 -- | This signal gets emitted when the user cancels the process of editing a -- cell. For example, an editable cell renderer could be written to cancel -- editing when the user presses Escape. -- -- * Available since Gtk+ version 2.4 -- editingCanceled :: CellRendererClass self => Signal self (IO ()) editingCanceled = Signal (connect_NONE__NONE "editing-canceled") -- %hash c:41f0 d:49f -- | This signal gets emitted when a cell starts to be edited. The indended -- use of this signal is to do special setup on @editable@, e.g. adding a -- 'EntryCompletion' or setting up additional columns in a 'ComboBox'. -- -- * The widget that is passed to the handler contains the widget that is used -- by the 'CellRenderer' to interact with the user. The widget must be -- casted to the appropriate widget. For instance, a -- 'Graphics.UI.Gtk.ModelView.CellRendererText' uses an -- 'Graphics.UI.Gtk.Entry.Entry' widget, while a -- 'Graphics.UI.Gtk.ModelView.CellRendererCombo' uses a -- 'Graphics.UI.Gtk.ModelView.ComboBox.ComboBox' (if -- 'Graphics.UI.Gtk.ModelView.CellRendererCombo.cellComboHasEntry' is -- @False@) or a 'Graphics.UI.Gtk.ModelView.ComboBoxEntry.ComboBoxEntry' (if -- 'Graphics.UI.Gtk.ModelView.CellRendererCombo.cellComboHasEntry' is -- @True@). -- -- * Available since Gtk+ version 2.6 -- editingStarted :: CellRendererClass self => Signal self (Widget -> TreePath -> IO ()) editingStarted = Signal editingStartedInternal editingStartedInternal after cr act = connect_OBJECT_GLIBSTRING__NONE "editing-started" after cr $ \ce path -> act ce (stringToTreePath path) -------------------- -- Deprecated Signals foreign import ccall safe "gtk_cell_renderer_stop_editing" gtk_cell_renderer_stop_editing :: ((Ptr CellRenderer) -> (CInt -> (IO ()))) foreign import ccall safe "gtk_cell_renderer_get_fixed_size" gtk_cell_renderer_get_fixed_size :: ((Ptr CellRenderer) -> ((Ptr CInt) -> ((Ptr CInt) -> (IO ())))) foreign import ccall safe "gtk_cell_renderer_set_fixed_size" gtk_cell_renderer_set_fixed_size :: ((Ptr CellRenderer) -> (CInt -> (CInt -> (IO ())))) foreign import ccall unsafe "gtk_cell_renderer_mode_get_type" gtk_cell_renderer_mode_get_type :: CULong