Copyright | (c) George Steel 2017 |
---|---|
License | BSD3 |
Maintainer | george.steel@gmail.org |
Safe Haskell | None |
Language | Haskell2010 |
EDSL for widget layouts ussing GTK container widgets.
Containers containing single children are created by actions taking the child widget as their last parameter, allowing for easy composition using =<<
.
Containers taking multiple children take their contents as a reader monad which runs over the newly-created widget, allowing packing commands to insert children of heterogeneous types, possibly with options.
As all container-creation actions run in MonadIO
, nesting containers can be done inline with standard monadic composition.
Given the wiegets foo, bar, baz, where foo supports scrolling (such as a TreeView) we can create a simple layout as follows
layout <- createVBox 0 $ do bstretch =<< createFrame ShadowIn =<< createScrolledWindow foo bpack <=< createHBox 0 $ do bpack bar bspacer bpack =<< set' [attr := val] baz
- clearChildren :: (MonadIO m, ContainerClass w) => w -> m ()
- set' :: MonadIO m => [AttrOp w] -> w -> m w
- createHBox :: MonadIO m => Int -> ReaderT HBox IO a -> m HBox
- createVBox :: MonadIO m => Int -> ReaderT VBox IO a -> m VBox
- bpack :: (WidgetClass w, BoxClass b) => w -> ReaderT b IO ()
- bstretch :: (WidgetClass w, BoxClass b) => w -> ReaderT b IO ()
- bspacer :: BoxClass b => ReaderT b IO ()
- createGrid :: MonadIO m => Int -> Int -> ReaderT Grid IO () -> m Grid
- gcell :: (WidgetClass w, GridClass g) => (Int, Int) -> w -> ReaderT g IO ()
- gcellspan :: (WidgetClass w, GridClass g) => (Int, Int) -> (Int, Int) -> w -> ReaderT g IO ()
- createStack :: MonadIO m => ReaderT Stack IO () -> m Stack
- stackElem :: WidgetClass w => Text -> w -> ReaderT Stack IO ()
- stackElemTitled :: WidgetClass w => Text -> Text -> w -> ReaderT Stack IO ()
- createStackSwitcher :: MonadIO m => Stack -> m StackSwitcher
- createNotebook :: MonadIO m => ReaderT Notebook IO a -> m Notebook
- nbpage :: WidgetClass w => Text -> w -> ReaderT Notebook IO ()
- createScrolledWindow :: (MonadIO m, WidgetClass w) => w -> m ScrolledWindow
- createScrolledViewport :: (MonadIO m, WidgetClass w) => w -> m ScrolledWindow
- createFrame :: (MonadIO m, WidgetClass w) => ShadowType -> w -> m Frame
- createExpander :: (MonadIO m, WidgetClass w) => Text -> Bool -> w -> m Expander
- createHPaned :: (MonadIO m, WidgetClass w1, WidgetClass w2) => w1 -> w2 -> m HPaned
- createVPaned :: (MonadIO m, WidgetClass w1, WidgetClass w2) => w1 -> w2 -> m VPaned
Documentation
clearChildren :: (MonadIO m, ContainerClass w) => w -> m () Source #
Destroys all children in a container, leaving it empty
set' :: MonadIO m => [AttrOp w] -> w -> m w Source #
Sets aattributes on a widget and returns the widget. Useful for setting attributes inline in a composition chain.
Box
createHBox :: MonadIO m => Int -> ReaderT HBox IO a -> m HBox Source #
Creates an HBox with a given spacing and fills it using the reader.
createVBox :: MonadIO m => Int -> ReaderT VBox IO a -> m VBox Source #
Creates a VBox with a given spacing and fills it using the reader.
bpack :: (WidgetClass w, BoxClass b) => w -> ReaderT b IO () Source #
Inserts a witget into the enclosing box as its natural size.
bstretch :: (WidgetClass w, BoxClass b) => w -> ReaderT b IO () Source #
Inserts a widget into the enclosing box with rubber length (takes all excess space).
Grid
createGrid :: MonadIO m => Int -> Int -> ReaderT Grid IO () -> m Grid Source #
Creates a Grid (with the given x and y spacing) and fills it using the reader.
gcell :: (WidgetClass w, GridClass g) => (Int, Int) -> w -> ReaderT g IO () Source #
Inserts a widget into the enclosing Grid at the given (x,y) position.
gcellspan :: (WidgetClass w, GridClass g) => (Int, Int) -> (Int, Int) -> w -> ReaderT g IO () Source #
Inserts a widget into the enclosign Grid spanning several cells, with position fiven by the first srgument and size given by the second.
Stack
createStack :: MonadIO m => ReaderT Stack IO () -> m Stack Source #
Creates a Stack and fills it using the reader.
stackElem :: WidgetClass w => Text -> w -> ReaderT Stack IO () Source #
Adds an element to the enclosing Stack with the given key.
stackElemTitled :: WidgetClass w => Text -> Text -> w -> ReaderT Stack IO () Source #
Adds an element to the enclosing Stack with the given key and title.
createStackSwitcher :: MonadIO m => Stack -> m StackSwitcher Source #
Creates a StackSwitcher for a given Stack
Notebook
createNotebook :: MonadIO m => ReaderT Notebook IO a -> m Notebook Source #
Createa a Notebook and fills it using the reader.
nbpage :: WidgetClass w => Text -> w -> ReaderT Notebook IO () Source #
Add a tab to the enclosing Notebook with the given title
Scrolling
createScrolledWindow :: (MonadIO m, WidgetClass w) => w -> m ScrolledWindow Source #
Creates a ScrolledWindow around a widget supporting scrolling natively.
createScrolledViewport :: (MonadIO m, WidgetClass w) => w -> m ScrolledWindow Source #
Creates a ScrolledWindow and Vieqwport around a widget not supporting scrollign such as a Box or Grid.
Misc
createFrame :: (MonadIO m, WidgetClass w) => ShadowType -> w -> m Frame Source #
Creates a frame around a widget with a given shadow type
createExpander :: (MonadIO m, WidgetClass w) => Text -> Bool -> w -> m Expander Source #
Creates an Expander around a given widget. The Text and Bool parameters control the label of the expander and whether it starts expanded.
createHPaned :: (MonadIO m, WidgetClass w1, WidgetClass w2) => w1 -> w2 -> m HPaned Source #
Creates an HPaned contsing two other widgets.
createVPaned :: (MonadIO m, WidgetClass w1, WidgetClass w2) => w1 -> w2 -> m VPaned Source #
Creates a VPaned containing two other widgets.