From: Duncan C. <dun...@us...> - 2004-07-30 16:39:02
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/buttons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10993/gtk/buttons Modified Files: Button.chs Log Message: added missing functions, or functions that were new in gtk-2.4 removed a function that is no longer needed from general/Structs.hsc Index: Button.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/buttons/Button.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Button.chs 23 May 2004 15:48:35 -0000 1.5 +++ Button.chs 30 Jul 2004 16:38:52 -0000 1.6 @@ -1,3 +1,4 @@ +{-# OPTIONS -cpp #-} -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Button -- @@ -21,6 +22,7 @@ -- -- | -- +#include <gtk/gtkversion.h> module Button( Button, @@ -44,6 +46,12 @@ buttonGetUseStock, buttonSetUseUnderline, buttonGetUseUnderline, +#if GTK_CHECK_VERSION(2,4,0) + buttonSetFocusOnClick, + buttonGetFocusOnClick, + buttonSetAlignment, + buttonGetAlignment, +#endif onButtonActivate, afterButtonActivate, onClicked, @@ -191,6 +199,38 @@ buttonGetUseUnderline b = liftM toBool $ {#call unsafe button_get_use_underline#} (toButton b) +#if GTK_CHECK_VERSION(2,4,0) +-- | Sets whether the button will grab focus when it is clicked with the mouse. +-- +buttonSetFocusOnClick :: ButtonClass b => b -> Bool -> IO () +buttonSetFocusOnClick b focus = + {#call unsafe button_set_focus_on_click#} (toButton b) (fromBool focus) + +-- | Gets whether the button grabs focus when it is clicked with the mouse. +-- +buttonGetFocusOnClick :: ButtonClass b => b -> IO Bool +buttonGetFocusOnClick b = liftM toBool $ + {#call unsafe button_get_focus_on_click#} (toButton b) + +-- | Sets the alignment of the child. This has no effect unless the child +-- derives from "Misc" "Aligment". +-- +buttonSetAlignment :: ButtonClass b => b -> (Float, Float) -> IO () +buttonSetAlignment b (xalign, yalign) = + {#call unsafe button_set_alignment#} (toButton b) + (realToFrac xalign) (realToFrac yalign) + +-- | Gets the alignment of the child in the button. +-- +buttonGetAlignment :: ButtonClass b => b -> IO (Float, Float) +buttonGetAlignment b = + alloca $ \xalignPtr -> alloca $ \yalignPtr -> do + {#call unsafe button_get_alignment#} (toButton b) xalignPtr yalignPtr + xalign <- peek xalignPtr + yalign <- peek yalignPtr + return (realToFrac xalign, realToFrac yalign) +#endif + -- signals |