{-# LINE 2 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget ButtonBox
--
-- Author : Matthew Walton
--
-- Created: 28 April 2004
--
-- Copyright (C) 2004-2005 Matthew Walton
--
-- 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)
--
-- Base class for 'HButtonBox' and 'VButtonBox'
--
module Graphics.UI.Gtk.Abstract.ButtonBox (
-- * Detail
--
-- | The primary purpose of this class is to keep track of the various
-- properties of 'HButtonBox' and 'VButtonBox' widgets.
--
-- 'buttonBoxGetChildSize' retrieves the minimum width and height for
-- widgets in a given button box. 'buttonBoxSetChildSize' allows those
-- properties to be changed.
--
-- The internal padding of buttons can be retrieved and changed per button
-- box using 'buttonBoxGetChildIpadding' and 'buttonBoxSetChildIpadding'
-- respectively.
--
-- 'buttonBoxGetSpacing' and 'buttonBoxSetSpacing' retrieve and change
-- default number of pixels between buttons, respectively.
--
-- 'buttonBoxGetLayout' and 'buttonBoxSetLayout' retrieve and alter the
-- method used to spread the buttons in a button box across the container,
-- respectively.
--
-- The main purpose of 'ButtonBox' is to make sure the children have all the
-- same size. Therefore it ignores the homogeneous property which it inherited
-- from 'Box', and always behaves as if homogeneous was @True@.

-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Container'
-- | +----'Box'
-- | +----ButtonBox
-- | +----'HButtonBox'
-- | +----'VButtonBox'
-- @

-- * Types
  ButtonBox,
  ButtonBoxClass,
  castToButtonBox, gTypeButtonBox,
  toButtonBox,
  ButtonBoxStyle(..),

-- * Methods
  buttonBoxGetLayout,
  buttonBoxSetLayout,
  buttonBoxSetChildSecondary,

  buttonBoxGetChildSecondary,






-- * Attributes
  buttonBoxLayoutStyle,

-- * Child Attributes
  buttonBoxChildSecondary,



  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import Graphics.UI.Gtk.Types
{-# LINE 100 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
import Graphics.UI.Gtk.General.Enums (ButtonBoxStyle(..))
import Graphics.UI.Gtk.Abstract.ContainerChildProperties


{-# LINE 104 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}

--------------------
-- Methods

-- | Retrieves the method being used to arrange the buttons in the button box.
--
buttonBoxGetLayout :: ButtonBoxClass self => self -> IO ButtonBoxStyle
buttonBoxGetLayout :: forall self. ButtonBoxClass self => self -> IO ButtonBoxStyle
buttonBoxGetLayout self
self =
  (CInt -> ButtonBoxStyle) -> IO CInt -> IO ButtonBoxStyle
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> ButtonBoxStyle
forall a. Enum a => Int -> a
toEnum (Int -> ButtonBoxStyle) -> (CInt -> Int) -> CInt -> ButtonBoxStyle
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) (IO CInt -> IO ButtonBoxStyle) -> IO CInt -> IO ButtonBoxStyle
forall a b. (a -> b) -> a -> b
$
  (\(ButtonBox ForeignPtr ButtonBox
arg1) -> ForeignPtr ButtonBox -> (Ptr ButtonBox -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr ButtonBox
arg1 ((Ptr ButtonBox -> IO CInt) -> IO CInt)
-> (Ptr ButtonBox -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr ButtonBox
argPtr1 ->Ptr ButtonBox -> IO CInt
gtk_button_box_get_layout Ptr ButtonBox
argPtr1)
{-# LINE 114 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
    (toButtonBox self)


-- | Returns whether @child@ should appear in a secondary group of children.
--
-- * Available since Gtk+ version 2.4
--
buttonBoxGetChildSecondary :: (ButtonBoxClass self, WidgetClass child) => self
 -> child -- ^ @child@ - a child of the button box widget
 -> IO Bool -- ^ returns whether @child@ should appear in a secondary group of
            -- children.
buttonBoxGetChildSecondary :: forall self child.
(ButtonBoxClass self, WidgetClass child) =>
self -> child -> IO Bool
buttonBoxGetChildSecondary self
self child
child =
  (CInt -> Bool) -> IO CInt -> IO Bool
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM CInt -> Bool
forall a. (Eq a, Num a) => a -> Bool
toBool (IO CInt -> IO Bool) -> IO CInt -> IO Bool
forall a b. (a -> b) -> a -> b
$
  (\(ButtonBox ForeignPtr ButtonBox
arg1) (Widget ForeignPtr Widget
arg2) -> ForeignPtr ButtonBox -> (Ptr ButtonBox -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr ButtonBox
arg1 ((Ptr ButtonBox -> IO CInt) -> IO CInt)
-> (Ptr ButtonBox -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr ButtonBox
argPtr1 ->ForeignPtr Widget -> (Ptr Widget -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg2 ((Ptr Widget -> IO CInt) -> IO CInt)
-> (Ptr Widget -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr2 ->Ptr ButtonBox -> Ptr Widget -> IO CInt
gtk_button_box_get_child_secondary Ptr ButtonBox
argPtr1 Ptr Widget
argPtr2)
{-# LINE 128 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
    (toButtonBox self)
    (child -> Widget
forall o. WidgetClass o => o -> Widget
toWidget child
child)
{-# LINE 157 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
-- | Changes the way buttons are arranged in their container.
--
buttonBoxSetLayout :: ButtonBoxClass self => self
 -> ButtonBoxStyle -- ^ @layoutStyle@ - the new layout style.
 -> IO ()
buttonBoxSetLayout :: forall self. ButtonBoxClass self => self -> ButtonBoxStyle -> IO ()
buttonBoxSetLayout self
self ButtonBoxStyle
layoutStyle =
  (\(ButtonBox ForeignPtr ButtonBox
arg1) CInt
arg2 -> ForeignPtr ButtonBox -> (Ptr ButtonBox -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr ButtonBox
arg1 ((Ptr ButtonBox -> IO ()) -> IO ())
-> (Ptr ButtonBox -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ButtonBox
argPtr1 ->Ptr ButtonBox -> CInt -> IO ()
gtk_button_box_set_layout Ptr ButtonBox
argPtr1 CInt
arg2)
{-# LINE 164 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
    (toButtonBox self)
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (ButtonBoxStyle -> Int) -> ButtonBoxStyle -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ButtonBoxStyle -> Int
forall a. Enum a => a -> Int
fromEnum) ButtonBoxStyle
layoutStyle)

-- | Sets whether @child@ should appear in a secondary group of children. A
-- typical use of a secondary child is the help button in a dialog.
--
-- This group appears after the other children if the style is
-- 'ButtonboxStart', 'ButtonboxSpread' or 'ButtonboxEdge', and before the other
-- children if the style is 'ButtonboxEnd'. For horizontal button boxes, the
-- definition of before\/after depends on direction of the widget (see
-- 'widgetSetDirection'). If the style is 'ButtonboxStart' or 'ButtonboxEnd',
-- then the secondary children are aligned at the other end of the button box
-- from the main children. For the other styles, they appear immediately next
-- to the main children.
--
buttonBoxSetChildSecondary :: (ButtonBoxClass self, WidgetClass child) => self
 -> child -- ^ @child@ - a child of the button box widget
 -> Bool -- ^ @isSecondary@ - if @True@, the @child@ appears in a secondary
          -- group of the button box.
 -> IO ()
buttonBoxSetChildSecondary :: forall self child.
(ButtonBoxClass self, WidgetClass child) =>
self -> child -> Bool -> IO ()
buttonBoxSetChildSecondary self
self child
child Bool
isSecondary =
  (\(ButtonBox ForeignPtr ButtonBox
arg1) (Widget ForeignPtr Widget
arg2) CInt
arg3 -> ForeignPtr ButtonBox -> (Ptr ButtonBox -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr ButtonBox
arg1 ((Ptr ButtonBox -> IO ()) -> IO ())
-> (Ptr ButtonBox -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ButtonBox
argPtr1 ->ForeignPtr Widget -> (Ptr Widget -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg2 ((Ptr Widget -> IO ()) -> IO ()) -> (Ptr Widget -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr2 ->Ptr ButtonBox -> Ptr Widget -> CInt -> IO ()
gtk_button_box_set_child_secondary Ptr ButtonBox
argPtr1 Ptr Widget
argPtr2 CInt
arg3)
{-# LINE 186 "./Graphics/UI/Gtk/Abstract/ButtonBox.chs" #-}
    (toButtonBox self)
    (child -> Widget
forall o. WidgetClass o => o -> Widget
toWidget child
child)
    (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
isSecondary)

--------------------
-- Attributes

-- | How to layout the buttons in the box. Possible values are default,
-- spread, edge, start and end.
--
-- Default value: 'ButtonboxDefaultStyle'
--
buttonBoxLayoutStyle :: ButtonBoxClass self => Attr self ButtonBoxStyle
buttonBoxLayoutStyle :: forall self. ButtonBoxClass self => Attr self ButtonBoxStyle
buttonBoxLayoutStyle = (self -> IO ButtonBoxStyle)
-> (self -> ButtonBoxStyle -> IO ())
-> ReadWriteAttr self ButtonBoxStyle ButtonBoxStyle
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO ButtonBoxStyle
forall self. ButtonBoxClass self => self -> IO ButtonBoxStyle
buttonBoxGetLayout
  self -> ButtonBoxStyle -> IO ()
forall self. ButtonBoxClass self => self -> ButtonBoxStyle -> IO ()
buttonBoxSetLayout

--------------------
-- Child Attributes

-- | If @True@, the child appears in a secondary group of children, suitable
-- for, e.g., help buttons.
--
-- Default value: @False@
--
buttonBoxChildSecondary :: (ButtonBoxClass self, WidgetClass child) => child -> Attr self Bool
buttonBoxChildSecondary :: forall self child.
(ButtonBoxClass self, WidgetClass child) =>
child -> Attr self Bool
buttonBoxChildSecondary = String -> child -> Attr self Bool
forall container child.
(ContainerClass container, WidgetClass child) =>
String -> child -> Attr container Bool
newAttrFromContainerChildBoolProperty String
"secondary"

foreign import ccall safe "gtk_button_box_get_layout"
  gtk_button_box_get_layout :: ((Ptr ButtonBox) -> (IO CInt))

foreign import ccall safe "gtk_button_box_get_child_secondary"
  gtk_button_box_get_child_secondary :: ((Ptr ButtonBox) -> ((Ptr Widget) -> (IO CInt)))

foreign import ccall safe "gtk_button_box_set_layout"
  gtk_button_box_set_layout :: ((Ptr ButtonBox) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_button_box_set_child_secondary"
  gtk_button_box_set_child_secondary :: ((Ptr ButtonBox) -> ((Ptr Widget) -> (CInt -> (IO ()))))