{-# LINE 2 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget MenuBar
--
-- Author : Axel Simon
--
-- Created: 21 May 2001
--
-- Copyright (C) 1999-2005 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)
--
-- A subclass widget for 'MenuShell' which holds 'MenuItem' widgets
--
module Graphics.UI.Gtk.MenuComboToolbar.MenuBar (
-- * Detail
--
-- | The 'MenuBar' is a subclass of 'MenuShell' which contains one to many
-- 'MenuItem'. The result is a standard menu bar which can hold many menu
-- items.

-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----'Container'
-- | +----'MenuShell'
-- | +----MenuBar
-- @

-- * Types
  MenuBar,
  MenuBarClass,
  castToMenuBar, gTypeMenuBar,
  toMenuBar,

  PackDirection(..),


-- * Constructors
  menuBarNew,

-- * Methods

  menuBarSetPackDirection,
  menuBarGetPackDirection,
  menuBarSetChildPackDirection,
  menuBarGetChildPackDirection,


-- * Attributes

  menuBarPackDirection,
  menuBarChildPackDirection,

  ) where

import Control.Monad (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import Graphics.UI.Gtk.Abstract.Object (makeNewObject)
import Graphics.UI.Gtk.Types
{-# LINE 79 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}


{-# LINE 81 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}


-- | Determines how to pack a menu bar: left-to-right, right-to-left,
-- top-to-bottom or bottom-to-top.
data PackDirection = PackDirectionLtr
                   | PackDirectionRtl
                   | PackDirectionTtb
                   | PackDirectionBtt
                   deriving (Int -> PackDirection
PackDirection -> Int
PackDirection -> [PackDirection]
PackDirection -> PackDirection
PackDirection -> PackDirection -> [PackDirection]
PackDirection -> PackDirection -> PackDirection -> [PackDirection]
(PackDirection -> PackDirection)
-> (PackDirection -> PackDirection)
-> (Int -> PackDirection)
-> (PackDirection -> Int)
-> (PackDirection -> [PackDirection])
-> (PackDirection -> PackDirection -> [PackDirection])
-> (PackDirection -> PackDirection -> [PackDirection])
-> (PackDirection
    -> PackDirection -> PackDirection -> [PackDirection])
-> Enum PackDirection
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PackDirection -> PackDirection
succ :: PackDirection -> PackDirection
$cpred :: PackDirection -> PackDirection
pred :: PackDirection -> PackDirection
$ctoEnum :: Int -> PackDirection
toEnum :: Int -> PackDirection
$cfromEnum :: PackDirection -> Int
fromEnum :: PackDirection -> Int
$cenumFrom :: PackDirection -> [PackDirection]
enumFrom :: PackDirection -> [PackDirection]
$cenumFromThen :: PackDirection -> PackDirection -> [PackDirection]
enumFromThen :: PackDirection -> PackDirection -> [PackDirection]
$cenumFromTo :: PackDirection -> PackDirection -> [PackDirection]
enumFromTo :: PackDirection -> PackDirection -> [PackDirection]
$cenumFromThenTo :: PackDirection -> PackDirection -> PackDirection -> [PackDirection]
enumFromThenTo :: PackDirection -> PackDirection -> PackDirection -> [PackDirection]
Enum)

{-# LINE 86 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}


--------------------
-- Constructors

-- | Creates the new 'MenuBar'
--
menuBarNew :: IO MenuBar
menuBarNew :: IO MenuBar
menuBarNew =
  (ForeignPtr MenuBar -> MenuBar, FinalizerPtr MenuBar)
-> IO (Ptr MenuBar) -> IO MenuBar
forall obj.
ObjectClass obj =>
(ForeignPtr obj -> obj, FinalizerPtr obj) -> IO (Ptr obj) -> IO obj
makeNewObject (ForeignPtr MenuBar -> MenuBar, FinalizerPtr MenuBar)
forall {a}. (ForeignPtr MenuBar -> MenuBar, FinalizerPtr a)
mkMenuBar (IO (Ptr MenuBar) -> IO MenuBar) -> IO (Ptr MenuBar) -> IO MenuBar
forall a b. (a -> b) -> a -> b
$
  (Ptr Widget -> Ptr MenuBar) -> IO (Ptr Widget) -> IO (Ptr MenuBar)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Ptr Widget -> Ptr MenuBar
forall a b. Ptr a -> Ptr b
castPtr :: Ptr Widget -> Ptr MenuBar) (IO (Ptr Widget) -> IO (Ptr MenuBar))
-> IO (Ptr Widget) -> IO (Ptr MenuBar)
forall a b. (a -> b) -> a -> b
$
  IO (Ptr Widget)
gtk_menu_bar_new
{-# LINE 98 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}

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


-- | Sets how items should be packed inside a menubar.
--
-- * Available since Gtk+ version 2.8
--
menuBarSetPackDirection :: MenuBarClass self => self
 -> PackDirection -- ^ @packDir@ - a new 'PackDirection'.
 -> IO ()
menuBarSetPackDirection :: forall self. MenuBarClass self => self -> PackDirection -> IO ()
menuBarSetPackDirection self
self PackDirection
packDir =
  (\(MenuBar ForeignPtr MenuBar
arg1) CInt
arg2 -> ForeignPtr MenuBar -> (Ptr MenuBar -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MenuBar
arg1 ((Ptr MenuBar -> IO ()) -> IO ())
-> (Ptr MenuBar -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MenuBar
argPtr1 ->Ptr MenuBar -> CInt -> IO ()
gtk_menu_bar_set_pack_direction Ptr MenuBar
argPtr1 CInt
arg2)
{-# LINE 112 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}
    (toMenuBar self)
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (PackDirection -> Int) -> PackDirection -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackDirection -> Int
forall a. Enum a => a -> Int
fromEnum) PackDirection
packDir)

-- | Retrieves the current pack direction of the menubar. See
-- 'menuBarSetPackDirection'.
--
-- * Available since Gtk+ version 2.8
--
menuBarGetPackDirection :: MenuBarClass self => self
 -> IO PackDirection -- ^ returns the pack direction
menuBarGetPackDirection :: forall self. MenuBarClass self => self -> IO PackDirection
menuBarGetPackDirection self
self =
  (CInt -> PackDirection) -> IO CInt -> IO PackDirection
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PackDirection
forall a. Enum a => Int -> a
toEnum (Int -> PackDirection) -> (CInt -> Int) -> CInt -> PackDirection
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 PackDirection) -> IO CInt -> IO PackDirection
forall a b. (a -> b) -> a -> b
$
  (\(MenuBar ForeignPtr MenuBar
arg1) -> ForeignPtr MenuBar -> (Ptr MenuBar -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MenuBar
arg1 ((Ptr MenuBar -> IO CInt) -> IO CInt)
-> (Ptr MenuBar -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr MenuBar
argPtr1 ->Ptr MenuBar -> IO CInt
gtk_menu_bar_get_pack_direction Ptr MenuBar
argPtr1)
{-# LINE 125 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}
    (toMenuBar self)

-- | Sets how widgets should be packed inside the children of a menubar.
--
-- * Available since Gtk+ version 2.8
--
menuBarSetChildPackDirection :: MenuBarClass self => self
 -> PackDirection -- ^ @childPackDir@ - a new 'PackDirection'.
 -> IO ()
menuBarSetChildPackDirection :: forall self. MenuBarClass self => self -> PackDirection -> IO ()
menuBarSetChildPackDirection self
self PackDirection
childPackDir =
  (\(MenuBar ForeignPtr MenuBar
arg1) CInt
arg2 -> ForeignPtr MenuBar -> (Ptr MenuBar -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MenuBar
arg1 ((Ptr MenuBar -> IO ()) -> IO ())
-> (Ptr MenuBar -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr MenuBar
argPtr1 ->Ptr MenuBar -> CInt -> IO ()
gtk_menu_bar_set_child_pack_direction Ptr MenuBar
argPtr1 CInt
arg2)
{-# LINE 136 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}
    (toMenuBar self)
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (PackDirection -> Int) -> PackDirection -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackDirection -> Int
forall a. Enum a => a -> Int
fromEnum) PackDirection
childPackDir)

-- | Retrieves the current child pack direction of the menubar. See
-- 'menuBarSetChildPackDirection'.
--
-- * Available since Gtk+ version 2.8
--
menuBarGetChildPackDirection :: MenuBarClass self => self
 -> IO PackDirection -- ^ returns the child pack direction
menuBarGetChildPackDirection :: forall self. MenuBarClass self => self -> IO PackDirection
menuBarGetChildPackDirection self
self =
  (CInt -> PackDirection) -> IO CInt -> IO PackDirection
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (Int -> PackDirection
forall a. Enum a => Int -> a
toEnum (Int -> PackDirection) -> (CInt -> Int) -> CInt -> PackDirection
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 PackDirection) -> IO CInt -> IO PackDirection
forall a b. (a -> b) -> a -> b
$
  (\(MenuBar ForeignPtr MenuBar
arg1) -> ForeignPtr MenuBar -> (Ptr MenuBar -> IO CInt) -> IO CInt
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr MenuBar
arg1 ((Ptr MenuBar -> IO CInt) -> IO CInt)
-> (Ptr MenuBar -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ \Ptr MenuBar
argPtr1 ->Ptr MenuBar -> IO CInt
gtk_menu_bar_get_child_pack_direction Ptr MenuBar
argPtr1)
{-# LINE 149 "./Graphics/UI/Gtk/MenuComboToolbar/MenuBar.chs" #-}
    (toMenuBar self)


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


-- | The pack direction of the menubar. It determines how menuitems are
-- arranged in the menubar.
--
-- Default value: 'PackDirectionLtr'
--
menuBarPackDirection :: MenuBarClass self => Attr self PackDirection
menuBarPackDirection :: forall self. MenuBarClass self => Attr self PackDirection
menuBarPackDirection = (self -> IO PackDirection)
-> (self -> PackDirection -> IO ())
-> ReadWriteAttr self PackDirection PackDirection
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO PackDirection
forall self. MenuBarClass self => self -> IO PackDirection
menuBarGetPackDirection
  self -> PackDirection -> IO ()
forall self. MenuBarClass self => self -> PackDirection -> IO ()
menuBarSetPackDirection

-- | The pack direction of the menubar. It determines how the widgets
-- contained in child menuitems are arranged.
--
-- Default value: 'PackDirectionLtr'
--
menuBarChildPackDirection :: MenuBarClass self => Attr self PackDirection
menuBarChildPackDirection :: forall self. MenuBarClass self => Attr self PackDirection
menuBarChildPackDirection = (self -> IO PackDirection)
-> (self -> PackDirection -> IO ())
-> ReadWriteAttr self PackDirection PackDirection
forall o a b.
(o -> IO a) -> (o -> b -> IO ()) -> ReadWriteAttr o a b
newAttr
  self -> IO PackDirection
forall self. MenuBarClass self => self -> IO PackDirection
menuBarGetChildPackDirection
  self -> PackDirection -> IO ()
forall self. MenuBarClass self => self -> PackDirection -> IO ()
menuBarSetChildPackDirection

foreign import ccall unsafe "gtk_menu_bar_new"
  gtk_menu_bar_new :: (IO (Ptr Widget))

foreign import ccall safe "gtk_menu_bar_set_pack_direction"
  gtk_menu_bar_set_pack_direction :: ((Ptr MenuBar) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_menu_bar_get_pack_direction"
  gtk_menu_bar_get_pack_direction :: ((Ptr MenuBar) -> (IO CInt))

foreign import ccall safe "gtk_menu_bar_set_child_pack_direction"
  gtk_menu_bar_set_child_pack_direction :: ((Ptr MenuBar) -> (CInt -> (IO ())))

foreign import ccall safe "gtk_menu_bar_get_child_pack_direction"
  gtk_menu_bar_get_child_pack_direction :: ((Ptr MenuBar) -> (IO CInt))