From: Duncan C. <dun...@us...> - 2004-08-01 16:08:37
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/abstract In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18039/gtk/abstract Modified Files: Misc.chs Paned.chs Range.chs Scale.chs api.ignore Log Message: Add missing functions. Update api.ignore files with more deprecated functions. Also fix a couple typo bugs and tidy up some documentation. Index: Range.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Range.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Range.chs 23 May 2004 15:46:02 -0000 1.5 +++ Range.chs 1 Aug 2004 16:08:14 -0000 1.6 @@ -31,10 +31,15 @@ rangeGetAdjustment, UpdateType(..), rangeSetUpdatePolicy, + rangeGetUpdatePolicy, rangeSetAdjustment, rangeGetInverted, rangeSetInverted, ScrollType(..), + rangeSetIncrements, + rangeSetRange, + rangeSetValue, + rangeGetValue, onMoveSlider, afterMoveSlider ) where @@ -57,20 +62,24 @@ rangeGetAdjustment r = makeNewObject mkAdjustment $ {#call unsafe range_get_adjustment#} (toRange r) --- | Set how the internal 'Adjustment' --- object is updated. +-- | Set how the internal 'Adjustment' object is updated. -- rangeSetUpdatePolicy :: RangeClass r => r -> UpdateType -> IO () rangeSetUpdatePolicy r up = {#call range_set_update_policy#} (toRange r) ((fromIntegral.fromEnum) up) +-- | Get the update policy for the range widget. +-- +rangeGetUpdatePolicy :: RangeClass r => r -> IO UpdateType +rangeGetUpdatePolicy r = liftM (toEnum.fromIntegral) $ + {#call unsafe range_get_update_policy#} (toRange r) + -- | Insert a new 'Adjustment' object. -- rangeSetAdjustment :: RangeClass r => r -> Adjustment -> IO () rangeSetAdjustment r adj = {#call range_set_adjustment#} (toRange r) adj --- | Get the inverted flag (determines if the range is --- reversed). +-- | Get the inverted flag (determines if the range is reversed). -- rangeGetInverted :: RangeClass r => r -> IO Bool rangeGetInverted r = @@ -81,6 +90,43 @@ rangeSetInverted :: RangeClass r => r -> Bool -> IO () rangeSetInverted r inv = {#call range_set_inverted#} (toRange r) (fromBool inv) +-- | Sets the step and page sizes for the range. The step size is used when the +-- user clicks the "Scrollbar" arrows or moves "Scale" via arrow keys. The +-- page size is used for example when moving via Page Up or Page Down keys. +-- +rangeSetIncrements :: RangeClass r => r + -> Double -- ^ step size + -> Double -- ^ page size + -> IO () +rangeSetIncrements r step page = + {#call range_set_increments#} (toRange r) (realToFrac step) (realToFrac page) + +-- | Sets the allowable values in the 'Range', and clamps the range value to be +-- between min and max. +-- +rangeSetRange :: RangeClass r => r + -> Double -- ^ min + -> Double -- ^ max + -> IO () +rangeSetRange r min max = + {#call range_set_range#} (toRange r) (realToFrac min) (realToFrac max) + +-- | Sets the current value of the range. The range emits the \"value_changed\" +-- signal if the value changes. +-- +-- * If the value is outside the minimum or maximum range values, it will be +-- clamped to fit inside them. +-- +rangeSetValue :: RangeClass r => r -> Double -> IO () +rangeSetValue r value = + {#call range_set_value#} (toRange r) (realToFrac value) + +-- | Gets the current value of the range. +-- +rangeGetValue :: RangeClass r => r -> IO Double +rangeGetValue r = liftM realToFrac $ + {#call unsafe range_get_value#} (toRange r) + -- signals -- | The slide has moved. The arguments give Index: Paned.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Paned.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Paned.chs 23 May 2004 15:46:02 -0000 1.5 +++ Paned.chs 1 Aug 2004 16:08:14 -0000 1.6 @@ -1,3 +1,4 @@ +{-# OPTIONS -cpp #-} -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Paned -- @@ -25,6 +26,7 @@ -- used by the user to divide the given space between two widgets. The two -- concrete implementations are HPaned and VPaned. -- +#include <gtk/gtkversion.h> module Paned( Paned, @@ -36,6 +38,10 @@ panedPack2, panedSetPosition, panedGetPosition +#if GTK_CHECK_VERSION(2,4,0) + ,panedGetChild1, + panedGetChild2 +#endif ) where import Monad (liftM) @@ -51,36 +57,31 @@ -- | Add a widget to the first (top or left) area. -- --- * The widget does not expand if 'Paned' expands. It does not --- shrink either. +-- * The widget does not expand if 'Paned' expands. It does not shrink either. -- panedAdd1 :: (PanedClass p, WidgetClass w) => p -> w -> IO () panedAdd1 p w = {#call paned_add1#} (toPaned p) (toWidget w) -- | Add a widget to the second (bottom or right) area. -- --- * The widget does not expand if 'Paned' expands. But it does --- shrink. +-- * The widget does not expand if 'Paned' expands. But it does shrink. -- panedAdd2 :: (PanedClass p, WidgetClass w) => p -> w -> IO () panedAdd2 p w = {#call paned_add2#} (toPaned p) (toWidget w) --- | Add a widget to the first area and specify its resizing --- behaviour. +-- | Add a widget to the first area and specify its resizing behaviour. -- panedPack1 :: (PanedClass p, WidgetClass w) => p -> w -> Bool -> Bool -> IO () panedPack1 p w expand shrink = {#call paned_pack1#} (toPaned p) (toWidget w) (fromBool expand) (fromBool shrink) --- | Add a widget to the second area and specify its --- resizing behaviour. +-- | Add a widget to the second area and specify its resizing behaviour. -- panedPack2 :: (PanedClass p, WidgetClass w) => p -> w -> Bool -> Bool -> IO () panedPack2 p w expand shrink = {#call paned_pack2#} (toPaned p) (toWidget w) (fromBool expand) (fromBool shrink) --- | Set the gutter to the specified --- @position@ (in pixels). +-- | Set the gutter to the specified @position@ (in pixels). -- panedSetPosition :: PanedClass p => p -> Int -> IO () panedSetPosition p position = @@ -91,3 +92,17 @@ panedGetPosition :: PanedClass p => p -> IO Int panedGetPosition p = liftM fromIntegral $ {#call unsafe paned_get_position#} (toPaned p) + +#if GTK_CHECK_VERSION(2,4,0) +-- | Obtains the first child of the paned widget. +-- +panedGetChild1 :: PanedClass p => p -> IO Widget +panedGetChild1 p = + makeNewObject mkWidget $ {#call unsafe paned_get_child1#} (toPaned p) + +-- | Obtains the second child of the paned widget. +-- +panedGetChild2 :: PanedClass p => p -> IO Widget +panedGetChild2 p = + makeNewObject mkWidget $ {#call unsafe paned_get_child2#} (toPaned p) +#endif Index: Misc.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Misc.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Misc.chs 23 May 2004 15:46:02 -0000 1.4 +++ Misc.chs 1 Aug 2004 16:08:14 -0000 1.5 @@ -28,7 +28,9 @@ MiscClass, castToMisc, miscSetAlignment, - miscSetPadding + miscGetAlignment, + miscSetPadding, + miscGetPadding ) where import Monad (liftM) @@ -49,10 +51,29 @@ miscSetAlignment misc xalign yalign = {#call misc_set_alignment#} (toMisc misc) (realToFrac xalign) (realToFrac yalign) +-- | Get the alignment of the widget. +-- +miscGetAlignment :: MiscClass m => m -> IO (Double, Double) +miscGetAlignment misc = + alloca $ \xalignPtr -> alloca $ \yalignPtr -> do + {#call unsafe misc_get_alignment#} (toMisc misc) xalignPtr yalignPtr + xalign <- peek xalignPtr + yalign <- peek yalignPtr + return (realToFrac xalign, realToFrac yalign) -- | Set the amount of space to add around the widget. -- miscSetPadding :: MiscClass m => m -> Int -> Int -> IO () miscSetPadding misc xpad ypad = {#call misc_set_padding#} (toMisc misc) (fromIntegral xpad) (fromIntegral ypad) - + +-- | Get the amount of space added around the widget. +-- +miscGetPadding :: MiscClass m => m -> IO (Int, Int) +miscGetPadding misc = + alloca $ \xpadPtr -> alloca $ \ypadPtr -> do + {#call unsafe misc_get_padding#} (toMisc misc) xpadPtr ypadPtr + xpad <- peek xpadPtr + ypad <- peek ypadPtr + return (fromIntegral xpad, fromIntegral ypad) + Index: Scale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/Scale.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Scale.chs 23 May 2004 15:46:02 -0000 1.4 +++ Scale.chs 1 Aug 2004 16:08:14 -0000 1.5 @@ -30,9 +30,12 @@ ScaleClass, castToScale, scaleSetDigits, + scaleGetDigits, scaleSetDrawValue, + scaleGetDrawValue, PositionType(..), - scaleSetValuePos + scaleSetValuePos, + scaleGetValuePos ) where import Monad (liftM) @@ -53,18 +56,33 @@ scaleSetDigits s prec = {#call scale_set_digits#} (toScale s) (fromIntegral prec) --- | Specify if the current value is to be drawn next --- to the slider. +-- | Get the number of displayed digits after the comma. +-- +scaleGetDigits :: ScaleClass s => s -> IO Int +scaleGetDigits s = + liftM fromIntegral $ {#call unsafe scale_get_digits#} (toScale s) + +-- | Specify if the current value is to be drawn next to the slider. -- scaleSetDrawValue :: ScaleClass s => s -> Bool -> IO () scaleSetDrawValue s draw = {#call scale_set_draw_value#} (toScale s) (fromBool draw) --- | Specify where the value is to be displayed --- (relative to the slider). +-- | Returns whether the current value is drawn next to the slider. +-- +scaleGetDrawValue :: ScaleClass s => s -> IO Bool +scaleGetDrawValue s = + liftM toBool $ {#call unsafe scale_get_draw_value#} (toScale s) + +-- | Specify where the value is to be displayed (relative to the slider). -- scaleSetValuePos :: ScaleClass s => s -> PositionType -> IO () scaleSetValuePos s pos = {#call scale_set_value_pos#} (toScale s) ((fromIntegral.fromEnum) pos) +-- | Gets the position in which the current value is displayed. +-- +scaleGetValuePos :: ScaleClass s => s -> IO PositionType +scaleGetValuePos s = + liftM (toEnum.fromIntegral) $ {#call unsafe scale_get_value_pos#} (toScale s) Index: api.ignore =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/abstract/api.ignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- api.ignore 30 Jul 2004 16:46:55 -0000 1.1 +++ api.ignore 1 Aug 2004 16:08:14 -0000 1.2 @@ -18,3 +18,29 @@ #somewhat internal api exclude gtk_container_child do not exclude gtk_container_child_[sg]et_property + +#internal function +exclude gtk_paned_compute_position + +#deprecated widget functions +exclude gtk_widget_set$ +exclude gtk_widget_draw$ +exclude gtk_widget_set_uposition +exclude gtk_widget_set_usize +exclude gtk_widget_queue_clear +exclude gtk_widget_queue_clear_area + +#only for widget implementations +exclude gtk_widget_unparent +exclude gtk_widget_map +exclude gtk_widget_unmap +exclude gtk_widget_realize +exclude gtk_widget_unrealize +exclude gtk_widget_queue_resize +exclude gtk_widget_get_child_requisition +exclude gtk_widget_set_state +exclude gtk_widget_queue_draw_area #TODO: might we want this one? +exclude gtk_widget_child_focus +exclude gtk_widget_get_child_visible +exclude gtk_widget_set_child_visible + |