{-# LINE 2 "./Graphics/UI/Gtk/General/Style.chs" #-}
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Styles
--
-- Author : Axel Simon
--
-- Created: 13 February 2003
--
-- 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.
--
-- TODO
--
-- It seems sensible to treat Styles as read only. The only way to modify
-- a style should be for the programmer to apply the RcStyle patches directly
-- to the widget.
--
-- Bind the draw... functions, they might be useful.
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- Customization of widgets.
--
module Graphics.UI.Gtk.General.Style (
-- * Description
--
-- | Styles are attached to widgets and determine how particular parts are
-- drawn and with what color. Thus they are should be seen as mandatory when
-- one implements a new custom widgets via 'DrawingArea'. Although the
-- parameterized drawing function don't have to be used, it is strongly
-- advisable (and more robust) to make use of the predefined graphics contexts
-- for the different states of a widget (retrieved by
-- 'Graphics.UI.Gtk.Abstract.Widget.widgetGetState').
--

-- * Types
  Style,
  StyleClass,
  castToStyle, gTypeStyle,
  toStyle,

-- * Methods
  styleGetForeground,
  styleGetBackground,
  styleGetLight,
  styleGetMiddle,
  styleGetDark,
  styleGetText,
  styleGetBase,
  styleGetAntiAliasing,


  stylePaintFlatBox,
  stylePaintLayout,


  ) where


{-# LINE 72 "./Graphics/UI/Gtk/General/Style.chs" #-}


import System.Glib.FFI
import Graphics.Rendering.Pango.Types
{-# LINE 76 "./Graphics/UI/Gtk/General/Style.chs" #-}
import Graphics.Rendering.Pango.BasicTypes
import Graphics.UI.Gtk.General.Structs (Rectangle)
import Graphics.UI.Gtk.General.Enums (StateType, ShadowType)


import Graphics.UI.Gtk.Types
{-# LINE 82 "./Graphics/UI/Gtk/General/Style.chs" #-}
import Graphics.UI.Gtk.General.Structs (styleGetForeground,
                         styleGetBackground,
                         styleGetLight,
                         styleGetMiddle,
                         styleGetDark,
                         styleGetText,
                         styleGetBase,
                         styleGetAntiAliasing)


stylePaintFlatBox :: WidgetClass widget
                  => Style
                  -> DrawWindow
                  -> StateType
                  -> ShadowType
                  -> Rectangle
                  -> widget
                  -> String
                  -> Int -> Int -> Int -> Int
                  -> IO ()
stylePaintFlatBox :: forall widget.
WidgetClass widget =>
Style
-> DrawWindow
-> StateType
-> ShadowType
-> Rectangle
-> widget
-> String
-> Int
-> Int
-> Int
-> Int
-> IO ()
stylePaintFlatBox Style
style DrawWindow
window StateType
stateType ShadowType
shadowType
                  Rectangle
clipRect widget
widget String
detail Int
x Int
y Int
width Int
height =
  Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Rectangle
clipRect ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Rectangle
rectPtr ->
  String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
detail ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
detailPtr ->
  (\(Style ForeignPtr Style
arg1) (DrawWindow ForeignPtr DrawWindow
arg2) CInt
arg3 CInt
arg4 Ptr ()
arg5 (Widget ForeignPtr Widget
arg6) CString
arg7 CInt
arg8 CInt
arg9 CInt
arg10 CInt
arg11 -> ForeignPtr Style -> (Ptr Style -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Style
arg1 ((Ptr Style -> IO ()) -> IO ()) -> (Ptr Style -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Style
argPtr1 ->ForeignPtr DrawWindow -> (Ptr DrawWindow -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr DrawWindow
arg2 ((Ptr DrawWindow -> IO ()) -> IO ())
-> (Ptr DrawWindow -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr DrawWindow
argPtr2 ->ForeignPtr Widget -> (Ptr Widget -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg6 ((Ptr Widget -> IO ()) -> IO ()) -> (Ptr Widget -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr6 ->Ptr Style
-> Ptr DrawWindow
-> CInt
-> CInt
-> Ptr ()
-> Ptr Widget
-> CString
-> CInt
-> CInt
-> CInt
-> CInt
-> IO ()
gtk_paint_flat_box Ptr Style
argPtr1 Ptr DrawWindow
argPtr2 CInt
arg3 CInt
arg4 Ptr ()
arg5 Ptr Widget
argPtr6 CString
arg7 CInt
arg8 CInt
arg9 CInt
arg10 CInt
arg11)
{-# LINE 107 "./Graphics/UI/Gtk/General/Style.chs" #-}
    style
    DrawWindow
window
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt) -> (StateType -> Int) -> StateType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.StateType -> Int
forall a. Enum a => a -> Int
fromEnum) StateType
stateType)
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt) -> (ShadowType -> Int) -> ShadowType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.ShadowType -> Int
forall a. Enum a => a -> Int
fromEnum) ShadowType
shadowType)
    (Ptr Rectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr Rectangle
rectPtr)
    (widget -> Widget
forall o. WidgetClass o => o -> Widget
toWidget widget
widget)
    CString
detailPtr
    (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
y)
    (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
width) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
height)

stylePaintLayout :: WidgetClass widget
                 => Style
                 -> DrawWindow
                 -> StateType
                 -> Bool
                 -> Rectangle
                 -> widget
                 -> String
                 -> Int -> Int
                 -> PangoLayout
                 -> IO ()
stylePaintLayout :: forall widget.
WidgetClass widget =>
Style
-> DrawWindow
-> StateType
-> Bool
-> Rectangle
-> widget
-> String
-> Int
-> Int
-> PangoLayout
-> IO ()
stylePaintLayout Style
style DrawWindow
window StateType
stateType Bool
useText
                  Rectangle
clipRect widget
widget String
detail Int
x Int
y (PangoLayout IORef PangoString
_ PangoLayoutRaw
layout) =
  Rectangle -> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
with Rectangle
clipRect ((Ptr Rectangle -> IO ()) -> IO ())
-> (Ptr Rectangle -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Rectangle
rectPtr ->
  String -> (CString -> IO ()) -> IO ()
forall a. String -> (CString -> IO a) -> IO a
withCString String
detail ((CString -> IO ()) -> IO ()) -> (CString -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CString
detailPtr ->
  (\(Style ForeignPtr Style
arg1) (DrawWindow ForeignPtr DrawWindow
arg2) CInt
arg3 CInt
arg4 Ptr ()
arg5 (Widget ForeignPtr Widget
arg6) CString
arg7 CInt
arg8 CInt
arg9 (PangoLayoutRaw ForeignPtr PangoLayoutRaw
arg10) -> ForeignPtr Style -> (Ptr Style -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Style
arg1 ((Ptr Style -> IO ()) -> IO ()) -> (Ptr Style -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Style
argPtr1 ->ForeignPtr DrawWindow -> (Ptr DrawWindow -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr DrawWindow
arg2 ((Ptr DrawWindow -> IO ()) -> IO ())
-> (Ptr DrawWindow -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr DrawWindow
argPtr2 ->ForeignPtr Widget -> (Ptr Widget -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Widget
arg6 ((Ptr Widget -> IO ()) -> IO ()) -> (Ptr Widget -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr Widget
argPtr6 ->ForeignPtr PangoLayoutRaw -> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr PangoLayoutRaw
arg10 ((Ptr PangoLayoutRaw -> IO ()) -> IO ())
-> (Ptr PangoLayoutRaw -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr PangoLayoutRaw
argPtr10 ->Ptr Style
-> Ptr DrawWindow
-> CInt
-> CInt
-> Ptr ()
-> Ptr Widget
-> CString
-> CInt
-> CInt
-> Ptr PangoLayoutRaw
-> IO ()
gtk_paint_layout Ptr Style
argPtr1 Ptr DrawWindow
argPtr2 CInt
arg3 CInt
arg4 Ptr ()
arg5 Ptr Widget
argPtr6 CString
arg7 CInt
arg8 CInt
arg9 Ptr PangoLayoutRaw
argPtr10)
{-# LINE 133 "./Graphics/UI/Gtk/General/Style.chs" #-}
    style
    DrawWindow
window
    ((Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral(Int -> CInt) -> (StateType -> Int) -> StateType -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
.StateType -> Int
forall a. Enum a => a -> Int
fromEnum) StateType
stateType)
    (Bool -> CInt
forall a. Num a => Bool -> a
fromBool Bool
useText)
    (Ptr Rectangle -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr Rectangle
rectPtr)
    (widget -> Widget
forall o. WidgetClass o => o -> Widget
toWidget widget
widget)
    CString
detailPtr
    (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x) (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
y)
    PangoLayoutRaw
layout

foreign import ccall safe "gtk_paint_flat_box"
  gtk_paint_flat_box :: ((Ptr Style) -> ((Ptr DrawWindow) -> (CInt -> (CInt -> ((Ptr ()) -> ((Ptr Widget) -> ((Ptr CChar) -> (CInt -> (CInt -> (CInt -> (CInt -> (IO ()))))))))))))

foreign import ccall safe "gtk_paint_layout"
  gtk_paint_layout :: ((Ptr Style) -> ((Ptr DrawWindow) -> (CInt -> (CInt -> ((Ptr ()) -> ((Ptr Widget) -> ((Ptr CChar) -> (CInt -> (CInt -> ((Ptr PangoLayoutRaw) -> (IO ())))))))))))