From: Duncan C. <dun...@us...> - 2004-08-01 16:08:26
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18039/gtk/entry Modified Files: SpinButton.chs 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: SpinButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/entry/SpinButton.chs,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- SpinButton.chs 30 Jul 2004 16:32:01 -0000 1.6 +++ SpinButton.chs 1 Aug 2004 16:08:13 -0000 1.7 @@ -21,12 +21,9 @@ -- -- | -- --- * A spin button provides the possiblity to enter a numeric value without --- using the keyboard. --- --- +-- A spin button provides the possiblity to enter a numeric value without using +-- the keyboard. -- --- * TODO module SpinButton( SpinButton, @@ -38,18 +35,25 @@ spinButtonSetAdjustment, spinButtonGetAdjustment, spinButtonSetDigits, + spinButtonGetDigits, spinButtonSetIncrements, + spinButtonGetIncrements, spinButtonSetRange, + spinButtonGetRange, spinButtonGetValue, spinButtonGetValueAsInt, spinButtonSetValue, SpinButtonUpdatePolicy(..), spinButtonSetUpdatePolicy, + spinButtonGetUpdatePolicy, spinButtonSetNumeric, + spinButtonGetNumeric, SpinType(..), spinButtonSpin, spinButtonSetWrap, + spinButtonGetWrap, spinButtonSetSnapToTicks, + spinButtonGetSnapToTicks, spinButtonUpdate, onInput, afterInput, @@ -126,6 +130,12 @@ spinButtonSetDigits sb digits = {#call spin_button_set_digits#} (toSpinButton sb) (fromIntegral digits) +-- | Gets the number of digits shown. +-- +spinButtonGetDigits :: SpinButtonClass sb => sb -> IO Int +spinButtonGetDigits sb = liftM fromIntegral $ + {#call spin_button_get_digits#} (toSpinButton sb) + -- | Sets the increment for up\/down buttons. -- spinButtonSetIncrements :: SpinButtonClass sb => sb -> Double -> Double -> @@ -133,13 +143,32 @@ spinButtonSetIncrements sb step page = {#call spin_button_set_increments#} (toSpinButton sb) (realToFrac step) (realToFrac page) --- | Set the maximal allowable range for the --- spinbutton. +-- | Sets the increment for up\/down buttons. +-- +spinButtonGetIncrements :: SpinButtonClass sb => sb -> IO (Double, Double) +spinButtonGetIncrements sb = + alloca $ \stepPtr -> alloca $ \pagePtr -> do + {#call unsafe spin_button_get_increments#} (toSpinButton sb) stepPtr pagePtr + step <- peek stepPtr + page <- peek pagePtr + return (realToFrac step, realToFrac page) + +-- | Set the maximal allowable range for the spinbutton. -- spinButtonSetRange :: SpinButtonClass sb => sb -> Double -> Double -> IO () spinButtonSetRange sb min max = {#call spin_button_set_range#} (toSpinButton sb) (realToFrac min) (realToFrac max) +-- | Get the maximal allowable range for the spinbutton. +-- +spinButtonGetRange :: SpinButtonClass sb => sb -> IO (Double, Double) +spinButtonGetRange sb = + alloca $ \minPtr -> alloca $ \maxPtr -> do + {#call unsafe spin_button_get_range#} (toSpinButton sb) minPtr maxPtr + min <- peek minPtr + max <- peek maxPtr + return (realToFrac min, realToFrac max) + -- | Retrieve the current value as a floating point -- value. -- @@ -160,45 +189,68 @@ spinButtonSetValue sb value = {#call spin_button_set_value#} (toSpinButton sb) (realToFrac value) --- | Whether the an out-of-range value set by --- 'spinButtonSetValue' is clamped to the limits or simply ignored. +-- | Whether the an out-of-range value set by 'spinButtonSetValue' is clamped to +-- the limits or simply ignored. -- spinButtonSetUpdatePolicy :: SpinButtonClass sb => sb -> SpinButtonUpdatePolicy -> IO () spinButtonSetUpdatePolicy sb up = {#call spin_button_set_update_policy#} (toSpinButton sb) ((fromIntegral.fromEnum) up) --- | Sets the flag that determines if non-numeric --- text can be typed into the spin button. +-- | Gets the update behavior of a spin button. See 'spinButtonSetUpdatePolicy'. +-- +spinButtonGetUpdatePolicy :: SpinButtonClass sb => sb + -> IO SpinButtonUpdatePolicy +spinButtonGetUpdatePolicy sb = liftM (toEnum.fromIntegral) $ + {#call unsafe spin_button_get_update_policy#} (toSpinButton sb) + +-- | Sets the flag that determines if non-numeric text can be typed into the +-- spin button. -- spinButtonSetNumeric :: SpinButtonClass sb => sb -> Bool -> IO () spinButtonSetNumeric sb numeric = {#call spin_button_set_numeric#} (toSpinButton sb) (fromBool numeric) --- | Increment or decrement the current value of the --- SpinButton. +-- | Returns whether non-numeric text can be typed into the spin button. +-- +spinButtonGetNumeric :: SpinButtonClass sb => sb -> IO Bool +spinButtonGetNumeric sb = + liftM toBool $ {#call unsafe spin_button_get_numeric#} (toSpinButton sb) + +-- | Increment or decrement the current value of the SpinButton. -- spinButtonSpin :: SpinButtonClass sb => sb -> SpinType -> Double -> IO () spinButtonSpin sb st offset = {#call spin_button_spin#} (toSpinButton sb) ((fromIntegral.fromEnum) st) (realToFrac offset) --- | Sets the flag that determines if a spin button --- value wraps around to the opposite limit when the upper or lower limit of --- the range is exceeded. +-- | Sets the flag that determines if a spin button value wraps around to the +-- opposite limit when the upper or lower limit of the range is exceeded. -- spinButtonSetWrap :: SpinButtonClass sb => sb -> Bool -> IO () spinButtonSetWrap sb wrap = {#call spin_button_set_wrap#} (toSpinButton sb) (fromBool wrap) --- | Sets the policy as to whether values are --- corrected to the nearest step increment when a spin button is activated --- after providing an invalid value. +-- | Returns whether the spin button's value wraps around to the opposite limit +-- when the upper or lower limit of the range is exceeded. +-- +spinButtonGetWrap :: SpinButtonClass sb => sb -> IO Bool +spinButtonGetWrap sb = + liftM toBool $ {#call spin_button_get_wrap#} (toSpinButton sb) + +-- | Sets the policy as to whether values are corrected to the nearest step +-- increment when a spin button is activated after providing an invalid value. -- spinButtonSetSnapToTicks :: SpinButtonClass sb => sb -> Bool -> IO () spinButtonSetSnapToTicks sb snapToTicks = {#call spin_button_set_snap_to_ticks#} (toSpinButton sb) (fromBool snapToTicks) +-- | Returns whether the values are corrected to the nearest step. +-- +spinButtonGetSnapToTicks :: SpinButtonClass sb => sb -> IO Bool +spinButtonGetSnapToTicks sb = liftM toBool $ + {#call unsafe spin_button_get_snap_to_ticks#} (toSpinButton sb) + -- | Force an update of the SpinButton. -- spinButtonUpdate :: SpinButtonClass sb => sb -> IO () |