From: Duncan C. <dun...@us...> - 2005-03-15 19:59:32
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5160/gtk/Graphics/UI/Gtk/Entry Modified Files: Entry.chs.pp EntryCompletion.chs.pp HScale.chs SpinButton.chs VScale.chs Log Message: Documentation changes and code formatting changes. Index: VScale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry/VScale.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- VScale.chs 25 Feb 2005 01:11:33 -0000 1.3 +++ VScale.chs 15 Mar 2005 19:59:12 -0000 1.4 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A vertical slider widget for selecting a value from a range. +-- A vertical slider widget for selecting a value from a range -- module Graphics.UI.Gtk.Entry.VScale ( --- * Description +-- * Detail -- -- | The 'VScale' widget is used to allow the user to select a value using a -- vertical slider. To create one, use 'hScaleNewWithRange'. @@ -68,21 +68,31 @@ -------------------- -- Constructors --- | Create a new VScale widget. +-- | Creates a new 'VScale'. -- -vScaleNew :: Adjustment -> IO VScale -vScaleNew adj = makeNewObject mkVScale $ liftM castPtr $ - {#call unsafe vscale_new#} adj +vScaleNew :: + Adjustment -- ^ @adjustment@ - the 'Adjustment' which sets the range of + -- the scale. + -> IO VScale +vScaleNew adjustment = + makeNewObject mkVScale $ liftM castPtr $ + {# call unsafe vscale_new #} + adjustment --- | Create a new VScale widget with @min@, @max@ and @step@ values rather than --- an "Adjustment" object. +-- | Creates a new vertical scale widget that lets the user input a number +-- between @min@ and @max@ (including @min@ and @max@) with the increment +-- @step@. @step@ must be nonzero; it's the distance the slider moves when +-- using the arrow keys to adjust the scale value. -- -vScaleNewWithRange :: Double -- ^ Minimum value - -> Double -- ^ Maximum value - -> Double -- ^ Step increment (tick size) used with keyboard - -- shortcuts. Must be nonzero. - -> IO VScale +vScaleNewWithRange :: + Double -- ^ @min@ - minimum value + -> Double -- ^ @max@ - maximum value + -> Double -- ^ @step@ - step increment (tick size) used with keyboard + -- shortcuts. Must be nonzero. + -> IO VScale vScaleNewWithRange min max step = makeNewObject mkVScale $ liftM castPtr $ - {#call unsafe vscale_new_with_range#} (realToFrac min) (realToFrac max) + {# call unsafe vscale_new_with_range #} + (realToFrac min) + (realToFrac max) (realToFrac step) Index: SpinButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry/SpinButton.chs,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- SpinButton.chs 13 Mar 2005 19:34:33 -0000 1.5 +++ SpinButton.chs 15 Mar 2005 19:59:12 -0000 1.6 @@ -122,185 +122,287 @@ -------------------- -- Constructors --- | Create a new SpinButton. --- --- * @climbRate@ is the amount by which the value is changed each time --- the up\/down buttons are pressed. --- --- * @digits@ is the number of shown digits. Set to 0 to work with --- integer values. +-- | Creates a new 'SpinButton'. -- -spinButtonNew :: Adjustment -> Double -> Int -> IO SpinButton -spinButtonNew adj climbRate digits = makeNewObject mkSpinButton $ - liftM castPtr $ {#call unsafe spin_button_new#} adj (realToFrac climbRate) - (fromIntegral digits) +spinButtonNew :: + Adjustment -- ^ @adjustment@ - the 'Adjustment' object that this spin + -- button should use. + -> Double -- ^ @climbRate@ - specifies how much the spin button + -- changes when an arrow is clicked on. + -> Int -- ^ @digits@ - the number of decimal places to display. + -> IO SpinButton +spinButtonNew adjustment climbRate digits = + makeNewObject mkSpinButton $ liftM castPtr $ + {# call unsafe spin_button_new #} + adjustment + (realToFrac climbRate) + (fromIntegral digits) --- | Create a new SpinButton with a restricted --- range. --- --- * This is a convenience function because the user does not have to create --- an Adjustment first. Page increments are set to 10 * @step@. +-- | This is a convenience constructor that allows creation of a numeric +-- 'SpinButton' without manually creating an adjustment. The value is initially +-- set to the minimum value and a page increment of 10 * @step@ is the default. +-- The precision of the spin button is equivalent to the precision of @step@. -- -spinButtonNewWithRange :: Double -> Double -> Double -> IO SpinButton -spinButtonNewWithRange min max step = makeNewObject mkSpinButton $ - liftM castPtr $ {#call unsafe spin_button_new_with_range#} - (realToFrac min) (realToFrac max) (realToFrac step) +spinButtonNewWithRange :: + Double -- ^ @min@ - Minimum allowable value + -> Double -- ^ @max@ - Maximum allowable value + -> Double -- ^ @step@ - Increment added or subtracted by spinning the + -- widget + -> IO SpinButton +spinButtonNewWithRange min max step = + makeNewObject mkSpinButton $ liftM castPtr $ + {# call unsafe spin_button_new_with_range #} + (realToFrac min) + (realToFrac max) + (realToFrac step) -------------------- -- Methods --- | Change the settings of a SpinButton. +-- | Changes the properties of an existing spin button. The adjustment, climb +-- rate, and number of decimal places are all changed accordingly, after this +-- function call. -- -spinButtonConfigure :: SpinButtonClass sb => sb -> Adjustment -> Double -> - Int -> IO () -spinButtonConfigure sb adj climbRate digits = {#call spin_button_configure#} - (toSpinButton sb) adj (realToFrac climbRate) (fromIntegral digits) +spinButtonConfigure :: SpinButtonClass self => self + -> Adjustment -- ^ @adjustment@ - a 'Adjustment'. + -> Double -- ^ @climbRate@ - the new climb rate. + -> Int -- ^ @digits@ - the number of decimal places to display in the + -- spin button. + -> IO () +spinButtonConfigure self adjustment climbRate digits = + {# call spin_button_configure #} + (toSpinButton self) + adjustment + (realToFrac climbRate) + (fromIntegral digits) --- | Attach a new Adjustment object to the --- SpinButton. +-- | Replaces the 'Adjustment' associated with the spin button. -- -spinButtonSetAdjustment :: SpinButtonClass sb => sb -> Adjustment -> IO () -spinButtonSetAdjustment sb adj = {#call spin_button_set_adjustment#} - (toSpinButton sb) adj +spinButtonSetAdjustment :: SpinButtonClass self => self + -> Adjustment -- ^ @adjustment@ - a 'Adjustment' to replace the existing + -- adjustment + -> IO () +spinButtonSetAdjustment self adjustment = + {# call spin_button_set_adjustment #} + (toSpinButton self) + adjustment --- | Retrieve the Adjustment object that is --- currently controlling the SpinButton. +-- | Get the adjustment associated with a 'SpinButton' -- -spinButtonGetAdjustment :: SpinButtonClass sb => sb -> IO Adjustment -spinButtonGetAdjustment sb = makeNewObject mkAdjustment $ - {#call unsafe spin_button_get_adjustment#} (toSpinButton sb) +spinButtonGetAdjustment :: SpinButtonClass self => self + -> IO Adjustment -- ^ returns the 'Adjustment' of @spinButton@ +spinButtonGetAdjustment self = + makeNewObject mkAdjustment $ + {# call unsafe spin_button_get_adjustment #} + (toSpinButton self) --- | Sets the number of shown digits. +-- | Set the precision to be displayed by @spinButton@. Up to 20 digit +-- precision is allowed. -- -spinButtonSetDigits :: SpinButtonClass sb => sb -> Int -> IO () -spinButtonSetDigits sb digits = {#call spin_button_set_digits#} - (toSpinButton sb) (fromIntegral digits) +spinButtonSetDigits :: SpinButtonClass self => self + -> Int -- ^ @digits@ - the number of digits after the decimal point to be + -- displayed for the spin button's value + -> IO () +spinButtonSetDigits self digits = + {# call spin_button_set_digits #} + (toSpinButton self) + (fromIntegral digits) --- | Gets the number of digits shown. +-- | Fetches the precision of @spinButton@. See 'spinButtonSetDigits'. -- -spinButtonGetDigits :: SpinButtonClass sb => sb -> IO Int -spinButtonGetDigits sb = liftM fromIntegral $ - {#call spin_button_get_digits#} (toSpinButton sb) +spinButtonGetDigits :: SpinButtonClass self => self + -> IO Int -- ^ returns the current precision +spinButtonGetDigits self = + liftM fromIntegral $ + {# call spin_button_get_digits #} + (toSpinButton self) --- | Sets the increment for up\/down buttons. +-- | Sets the step and page increments for the spin button. This affects how +-- quickly the value changes when the spin button's arrows are activated. -- -spinButtonSetIncrements :: SpinButtonClass sb => sb -> Double -> Double -> - IO () -spinButtonSetIncrements sb step page = {#call spin_button_set_increments#} - (toSpinButton sb) (realToFrac step) (realToFrac page) +spinButtonSetIncrements :: SpinButtonClass self => self + -> Double -- ^ @step@ - increment applied for a button 1 press. + -> Double -- ^ @page@ - increment applied for a button 2 press. + -> IO () +spinButtonSetIncrements self step page = + {# call spin_button_set_increments #} + (toSpinButton self) + (realToFrac step) + (realToFrac page) --- | Sets the increment for up\/down buttons. +-- | Gets the current step and page the increments used by the spin button. See +-- 'spinButtonSetIncrements'. -- -spinButtonGetIncrements :: SpinButtonClass sb => sb -> IO (Double, Double) -spinButtonGetIncrements sb = - alloca $ \stepPtr -> alloca $ \pagePtr -> do - {#call unsafe spin_button_get_increments#} (toSpinButton sb) stepPtr pagePtr +spinButtonGetIncrements :: SpinButtonClass self => self + -> IO (Double, Double) -- ^ @(step, page)@ +spinButtonGetIncrements self = + alloca $ \stepPtr -> + alloca $ \pagePtr -> do + {# call unsafe spin_button_get_increments #} + (toSpinButton self) + stepPtr + pagePtr step <- peek stepPtr page <- peek pagePtr return (realToFrac step, realToFrac page) --- | Set the maximal allowable range for the spinbutton. +-- | Sets the minimum and maximum allowable values for the spin button -- -spinButtonSetRange :: SpinButtonClass sb => sb -> Double -> Double -> IO () -spinButtonSetRange sb min max = {#call spin_button_set_range#} - (toSpinButton sb) (realToFrac min) (realToFrac max) +spinButtonSetRange :: SpinButtonClass self => self + -> Double -- ^ @min@ - minimum allowable value + -> Double -- ^ @max@ - maximum allowable value + -> IO () +spinButtonSetRange self min max = + {# call spin_button_set_range #} + (toSpinButton self) + (realToFrac min) + (realToFrac max) --- | Get the maximal allowable range for the spinbutton. +-- | Gets the range allowed for the spin button. See 'spinButtonSetRange'. -- -spinButtonGetRange :: SpinButtonClass sb => sb -> IO (Double, Double) -spinButtonGetRange sb = - alloca $ \minPtr -> alloca $ \maxPtr -> do - {#call unsafe spin_button_get_range#} (toSpinButton sb) minPtr maxPtr +spinButtonGetRange :: SpinButtonClass self => self + -> IO (Double, Double) -- ^ @(min, max)@ +spinButtonGetRange self = + alloca $ \minPtr -> + alloca $ \maxPtr -> do + {# call unsafe spin_button_get_range #} + (toSpinButton self) + minPtr + maxPtr min <- peek minPtr max <- peek maxPtr return (realToFrac min, realToFrac max) --- | Retrieve the current value as a floating point --- value. +-- | Retrieve the current value of the spin button as a floating point value. -- -spinButtonGetValue :: SpinButtonClass sb => sb -> IO Double -spinButtonGetValue sb = liftM realToFrac $ - {#call unsafe spin_button_get_value#} (toSpinButton sb) +spinButtonGetValue :: SpinButtonClass self => self -> IO Double +spinButtonGetValue self = + liftM realToFrac $ + {# call unsafe spin_button_get_value #} + (toSpinButton self) --- | Retrieve the current value as integral --- value. +-- | Retrieve the current value of the spin button as an integral value. -- -spinButtonGetValueAsInt :: SpinButtonClass sb => sb -> IO Int -spinButtonGetValueAsInt sb = liftM fromIntegral $ - {#call unsafe spin_button_get_value_as_int#} (toSpinButton sb) +spinButtonGetValueAsInt :: SpinButtonClass self => self -> IO Int +spinButtonGetValueAsInt self = + liftM fromIntegral $ + {# call unsafe spin_button_get_value_as_int #} + (toSpinButton self) -- | Set the value of the SpinButton. -- -spinButtonSetValue :: SpinButtonClass sb => sb -> Double -> IO () -spinButtonSetValue sb value = {#call spin_button_set_value#} - (toSpinButton sb) (realToFrac value) +spinButtonSetValue :: SpinButtonClass self => self -> Double -> IO () +spinButtonSetValue self value = + {# call spin_button_set_value #} + (toSpinButton self) + (realToFrac value) --- | Whether the an out-of-range value set by 'spinButtonSetValue' is clamped to --- the limits or simply ignored. +-- | Sets the update behavior of a spin button. This determines whether the +-- spin button is always updated or only when a valid value is set. -- -spinButtonSetUpdatePolicy :: SpinButtonClass sb => sb -> - SpinButtonUpdatePolicy -> IO () -spinButtonSetUpdatePolicy sb up = {#call spin_button_set_update_policy#} - (toSpinButton sb) ((fromIntegral.fromEnum) up) +spinButtonSetUpdatePolicy :: SpinButtonClass self => self + -> SpinButtonUpdatePolicy -- ^ @policy@ - a 'SpinButtonUpdatePolicy' value + -> IO () +spinButtonSetUpdatePolicy self policy = + {# call spin_button_set_update_policy #} + (toSpinButton self) + ((fromIntegral . fromEnum) policy) --- | Gets the update behavior of a spin button. See 'spinButtonSetUpdatePolicy'. +-- | 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) +spinButtonGetUpdatePolicy :: SpinButtonClass self => self + -> IO SpinButtonUpdatePolicy -- ^ returns the current update policy +spinButtonGetUpdatePolicy self = + liftM (toEnum . fromIntegral) $ + {# call unsafe spin_button_get_update_policy #} + (toSpinButton self) -- | 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) +spinButtonSetNumeric :: SpinButtonClass self => self + -> Bool -- ^ @numeric@ - flag indicating if only numeric entry is allowed. + -> IO () +spinButtonSetNumeric self numeric = + {# call spin_button_set_numeric #} + (toSpinButton self) + (fromBool numeric) --- | Returns whether non-numeric text can be typed into the spin button. +-- | Returns whether non-numeric text can be typed into the spin button. See +-- 'spinButtonSetNumeric'. -- -spinButtonGetNumeric :: SpinButtonClass sb => sb -> IO Bool -spinButtonGetNumeric sb = - liftM toBool $ {#call unsafe spin_button_get_numeric#} (toSpinButton sb) +spinButtonGetNumeric :: SpinButtonClass self => self + -> IO Bool -- ^ returns @True@ if only numeric text can be entered +spinButtonGetNumeric self = + liftM toBool $ + {# call unsafe spin_button_get_numeric #} + (toSpinButton self) --- | Increment or decrement the current value of the SpinButton. +-- | Increment or decrement a spin button's value in a specified direction by +-- a specified amount. -- -spinButtonSpin :: SpinButtonClass sb => sb -> SpinType -> Double -> IO () -spinButtonSpin sb st offset = {#call spin_button_spin#} (toSpinButton sb) - ((fromIntegral.fromEnum) st) (realToFrac offset) +spinButtonSpin :: SpinButtonClass self => self + -> SpinType -- ^ @direction@ - a 'SpinType' indicating the direction to spin. + -> Double -- ^ @increment@ - step increment to apply in the specified + -- direction. + -> IO () +spinButtonSpin self direction increment = + {# call spin_button_spin #} + (toSpinButton self) + ((fromIntegral . fromEnum) direction) + (realToFrac increment) -- | 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) +spinButtonSetWrap :: SpinButtonClass self => self + -> Bool -- ^ @wrap@ - a flag indicating if wrapping behavior is performed. + -> IO () +spinButtonSetWrap self wrap = + {# call spin_button_set_wrap #} + (toSpinButton self) + (fromBool wrap) --- | Returns whether the spin button's value wraps around to the opposite limit --- when the upper or lower limit of the range is exceeded. +-- | Returns whether the spin button's value wraps around to the opposite +-- limit when the upper or lower limit of the range is exceeded. See +-- 'spinButtonSetWrap'. -- -spinButtonGetWrap :: SpinButtonClass sb => sb -> IO Bool -spinButtonGetWrap sb = - liftM toBool $ {#call spin_button_get_wrap#} (toSpinButton sb) +spinButtonGetWrap :: SpinButtonClass self => self + -> IO Bool -- ^ returns @True@ if the spin button wraps around +spinButtonGetWrap self = + liftM toBool $ + {# call spin_button_get_wrap #} + (toSpinButton self) -- | 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) +spinButtonSetSnapToTicks :: SpinButtonClass self => self + -> Bool -- ^ @snapToTicks@ - a flag indicating if invalid values should be + -- corrected. + -> IO () +spinButtonSetSnapToTicks self snapToTicks = + {# call spin_button_set_snap_to_ticks #} + (toSpinButton self) + (fromBool snapToTicks) --- | Returns whether the values are corrected to the nearest step. +-- | Returns whether the values are corrected to the nearest step. See +-- 'spinButtonSetSnapToTicks'. -- -spinButtonGetSnapToTicks :: SpinButtonClass sb => sb -> IO Bool -spinButtonGetSnapToTicks sb = liftM toBool $ - {#call unsafe spin_button_get_snap_to_ticks#} (toSpinButton sb) +spinButtonGetSnapToTicks :: SpinButtonClass self => self + -> IO Bool -- ^ returns @True@ if values are snapped to the nearest step. +spinButtonGetSnapToTicks self = + liftM toBool $ + {# call unsafe spin_button_get_snap_to_ticks #} + (toSpinButton self) --- | Force an update of the SpinButton. +-- | Manually force an update of the spin button. -- -spinButtonUpdate :: SpinButtonClass sb => sb -> IO () -spinButtonUpdate sb = {#call spin_button_update#} (toSpinButton sb) +spinButtonUpdate :: SpinButtonClass self => self -> IO () +spinButtonUpdate self = + {# call spin_button_update #} + (toSpinButton self) -------------------- -- Properties Index: EntryCompletion.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry/EntryCompletion.chs.pp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- EntryCompletion.chs.pp 13 Mar 2005 19:34:33 -0000 1.6 +++ EntryCompletion.chs.pp 15 Mar 2005 19:59:12 -0000 1.7 @@ -26,10 +26,10 @@ -- -- Completion functionality for the 'Entry' widget. -- --- * Available since Gtk version 2.4 +-- * Module available since Gtk+ version 2.4 -- module Graphics.UI.Gtk.Entry.EntryCompletion ( --- * Description +-- * Detail -- -- | 'EntryCompletion' is an auxiliary object to be used in conjunction with -- 'Entry' to provide the completion functionality. It implements the @@ -90,9 +90,7 @@ -- * Properties entryCompletionMinimumKeyLength -) where - -#if GTK_CHECK_VERSION(2,4,0) + ) where import Monad (liftM) import Data.IORef (newIORef, readIORef, writeIORef) @@ -108,9 +106,12 @@ {# context lib="gtk" prefix="gtk" #} +#if GTK_CHECK_VERSION(2,4,0) -------------------- -- Constructors +-- | Creates a new 'EntryCompletion' object. +-- entryCompletionNew :: IO EntryCompletion entryCompletionNew = makeNewGObject mkEntryCompletion $ liftM castPtr $ @@ -119,60 +120,52 @@ -------------------- -- Methods -entryCompletionGetEntry :: EntryCompletion -> IO (Maybe Entry) -entryCompletionGetEntry ec = do - entryPtr <- {# call gtk_entry_completion_get_entry #} ec - if entryPtr == nullPtr - then return Nothing - else liftM Just $ makeNewObject mkEntry $ return (castPtr entryPtr) +-- | Gets the entry @completion@ has been attached to. +-- +entryCompletionGetEntry :: EntryCompletion + -> IO (Maybe Widget) -- ^ returns the entry @completion@ has been attached + -- to. +entryCompletionGetEntry self = + maybeNull (makeNewObject mkWidget) $ + {# call gtk_entry_completion_get_entry #} + self -entryCompletionSetModel :: EntryCompletion -> TreeModel -> IO () -entryCompletionSetModel ec tm = - {# call gtk_entry_completion_set_model #} ec tm +-- | Sets the model for a 'EntryCompletion'. If @completion@ already has a +-- model set, it will remove it before setting the new model. If model is +-- @Nothing@, then it will unset the model. +-- +entryCompletionSetModel :: TreeModelClass model => EntryCompletion + -> Maybe model -- ^ @model@ - The 'TreeModel'. + -> IO () +entryCompletionSetModel self model = + {# call gtk_entry_completion_set_model #} + self + (maybe (TreeModel nullForeignPtr) toTreeModel model) -entryCompletionGetModel :: EntryCompletion -> IO TreeModel -entryCompletionGetModel ec = - makeNewGObject mkTreeModel $ - {# call gtk_entry_completion_get_model #} ec +-- | Returns the model the 'EntryCompletion' is using as data source. Returns +-- @Nothing@ if the model is unset. +-- +entryCompletionGetModel :: EntryCompletion + -> IO (Maybe TreeModel) -- ^ returns A 'TreeModel', or @Nothing@ if none is + -- currently being used. +entryCompletionGetModel self = + maybeNull (makeNewGObject mkTreeModel) $ + {# call gtk_entry_completion_get_model #} + self +-- | Sets the match function for @completion@ to be @func@. The match function +-- is used to determine if a row should or should not be in the completion +-- list. +-- entryCompletionSetMatchFunc :: EntryCompletion -> (String -> TreeIter -> IO ()) -> IO () -entryCompletionSetMatchFunc ec handler = - connect_GtkEntryCompletionMatchFunc ec handler - -entryCompletionSetMinimumKeyLength :: EntryCompletion -> Int -> IO () -entryCompletionSetMinimumKeyLength ec minLength = - {# call gtk_entry_completion_set_minimum_key_length #} ec - (fromIntegral minLength) - -entryCompletionGetMinimumKeyLength :: EntryCompletion -> IO Int -entryCompletionGetMinimumKeyLength ec = - liftM fromIntegral $ - {# call gtk_entry_completion_get_minimum_key_length #} ec - -entryCompletionComplete :: EntryCompletion -> IO () -entryCompletionComplete ec = - {# call gtk_entry_completion_complete #} ec - -entryCompletionInsertActionText :: EntryCompletion -> Int -> String -> IO () -entryCompletionInsertActionText ec index text = - withUTFString text $ \strPtr -> - {# call gtk_entry_completion_insert_action_text #} ec - (fromIntegral index) strPtr - -entryCompletionInsertActionMarkup :: EntryCompletion -> Int -> String -> IO () -entryCompletionInsertActionMarkup ec index markup = - withUTFString markup $ \strPtr -> - {# call gtk_entry_completion_insert_action_markup #} ec - (fromIntegral index) strPtr - -entryCompletionDeleteAction :: EntryCompletion -> Int -> IO () -entryCompletionDeleteAction ec index = - {# call gtk_entry_completion_delete_action #} ec (fromIntegral index) - -entryCompletionSetTextColumn :: EntryCompletion -> Int -> IO () -entryCompletionSetTextColumn ec column = - {# call gtk_entry_completion_set_text_column #} ec (fromIntegral column) - +entryCompletionSetMatchFunc ec handler = do + hPtr <- mkHandler_GtkEntryCompletionMatchFunc + (\_ keyPtr iterPtr _ -> do key <- peekUTFString keyPtr + iter <- createTreeIter iterPtr + handler key iter) + dPtr <- mkFunPtrDestructor hPtr + {# call gtk_entry_completion_set_match_func #} ec + (castFunPtr hPtr) nullPtr dPtr ------------------------------------------------- -- Callback stuff for entryCompletionSetMatchFunc @@ -189,17 +182,93 @@ GtkEntryCompletionMatchFunc -> IO (FunPtr GtkEntryCompletionMatchFunc) -connect_GtkEntryCompletionMatchFunc :: EntryCompletion -> - (String -> TreeIter -> IO ()) -> - IO () -connect_GtkEntryCompletionMatchFunc ec user = do - hPtr <- mkHandler_GtkEntryCompletionMatchFunc - (\_ keyPtr iterPtr _ -> do key <- peekUTFString keyPtr - iter <- createTreeIter iterPtr - user key iter) - dPtr <- mkFunPtrDestructor hPtr - {# call gtk_entry_completion_set_match_func #} ec - (castFunPtr hPtr) nullPtr dPtr +-- | Requires the length of the search key for @completion@ to be at least +-- @length@. This is useful for long lists, where completing using a small key +-- takes a lot of time and will come up with meaningless results anyway (ie, a +-- too large dataset). +-- +entryCompletionSetMinimumKeyLength :: EntryCompletion + -> Int -- ^ @length@ - The minimum length of the key in order to + -- start completing. + -> IO () +entryCompletionSetMinimumKeyLength self length = + {# call gtk_entry_completion_set_minimum_key_length #} + self + (fromIntegral length) + +-- | Returns the minimum key length as set for @completion@. +-- +entryCompletionGetMinimumKeyLength :: EntryCompletion + -> IO Int -- ^ returns The currently used minimum key length. +entryCompletionGetMinimumKeyLength self = + liftM fromIntegral $ + {# call gtk_entry_completion_get_minimum_key_length #} + self + +-- | Requests a completion operation, or in other words a refiltering of the +-- current list with completions, using the current key. The completion list +-- view will be updated accordingly. +-- +entryCompletionComplete :: EntryCompletion -> IO () +entryCompletionComplete self = + {# call gtk_entry_completion_complete #} + self + +-- | Inserts an action in @completion@'s action item list at position @index@ +-- with text @text@. If you want the action item to have markup, use +-- 'entryCompletionInsertActionMarkup'. +-- +entryCompletionInsertActionText :: EntryCompletion + -> Int -- ^ @index@ - The index of the item to insert. + -> String -- ^ @text@ - Text of the item to insert. + -> IO () +entryCompletionInsertActionText self index text = + withUTFString text $ \textPtr -> + {# call gtk_entry_completion_insert_action_text #} + self + (fromIntegral index) + textPtr + +-- | Inserts an action in @completion@'s action item list at position @index@ +-- with markup @markup@. +-- +entryCompletionInsertActionMarkup :: EntryCompletion + -> Int -- ^ @index@ - The index of the item to insert. + -> String -- ^ @markup@ - Markup of the item to insert. + -> IO () +entryCompletionInsertActionMarkup self index markup = + withUTFString markup $ \markupPtr -> + {# call gtk_entry_completion_insert_action_markup #} + self + (fromIntegral index) + markupPtr + +-- | Deletes the action at @index@ from @completion@'s action list. +-- +entryCompletionDeleteAction :: EntryCompletion + -> Int -- ^ @index@ - The index of the item to Delete. + -> IO () +entryCompletionDeleteAction self index = + {# call gtk_entry_completion_delete_action #} + self + (fromIntegral index) + +-- | Convenience function for setting up the most used case of this code: a +-- completion list with just strings. This function will set up @completion@ to +-- have a list displaying all (and just) strings in the completion list, and to +-- get those strings from @column@ in the model of @completion@. +-- +-- This functions creates and adds a 'CellRendererText' for the selected +-- column. +-- +entryCompletionSetTextColumn :: EntryCompletion + -> Int -- ^ @column@ - The column in the model of @completion@ to + -- get strings from. + -> IO () +entryCompletionSetTextColumn self column = + {# call gtk_entry_completion_set_text_column #} + self + (fromIntegral column) -------------------- -- Properties Index: HScale.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry/HScale.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- HScale.chs 25 Feb 2005 01:11:33 -0000 1.3 +++ HScale.chs 15 Mar 2005 19:59:12 -0000 1.4 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A horizontal slider widget for selecting a value from a range. +-- A horizontal slider widget for selecting a value from a range -- module Graphics.UI.Gtk.Entry.HScale ( --- * Description +-- * Detail -- -- | The 'HScale' widget is used to allow the user to select a value using a -- horizontal slider. To create one, use 'hScaleNewWithRange'. @@ -68,21 +68,31 @@ -------------------- -- Constructors --- | Create a new HScale widget. +-- | Creates a new 'HScale'. -- -hScaleNew :: Adjustment -> IO HScale -hScaleNew adj = makeNewObject mkHScale $ liftM castPtr $ - {#call unsafe hscale_new#} adj +hScaleNew :: + Adjustment -- ^ @adjustment@ - the 'Adjustment' which sets the range of + -- the scale. + -> IO HScale +hScaleNew adjustment = + makeNewObject mkHScale $ liftM castPtr $ + {# call unsafe hscale_new #} + adjustment --- | Create a new HScale widget with @min@, @max@ and @step@ values rather than --- an "Adjustment" object. +-- | Creates a new horizontal scale widget that lets the user input a number +-- between @min@ and @max@ (including @min@ and @max@) with the increment +-- @step@. @step@ must be nonzero; it's the distance the slider moves when +-- using the arrow keys to adjust the scale value. -- -hScaleNewWithRange :: Double -- ^ Minimum value - -> Double -- ^ Maximum value - -> Double -- ^ Step increment (tick size) used with keyboard - -- shortcuts. Must be nonzero. - -> IO HScale +hScaleNewWithRange :: + Double -- ^ @min@ - minimum value + -> Double -- ^ @max@ - maximum value + -> Double -- ^ @step@ - step increment (tick size) used with keyboard + -- shortcuts + -> IO HScale hScaleNewWithRange min max step = makeNewObject mkHScale $ liftM castPtr $ - {#call unsafe hscale_new_with_range#} (realToFrac min) (realToFrac max) + {# call unsafe hscale_new_with_range #} + (realToFrac min) + (realToFrac max) (realToFrac step) Index: Entry.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Entry/Entry.chs.pp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Entry.chs.pp 13 Mar 2005 19:34:33 -0000 1.5 +++ Entry.chs.pp 15 Mar 2005 19:59:12 -0000 1.6 @@ -29,10 +29,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A single line text entry field. +-- A single line text entry field -- module Graphics.UI.Gtk.Entry.Entry ( --- * Description +-- * Detail -- -- | The 'Entry' widget is a single line text entry widget. A fairly large set -- of key bindings are supported by default. If the entered text is longer than @@ -129,160 +129,260 @@ -------------------- -- Constructors --- | Create a new 'Entry' widget. +-- | Creates a new 'Entry' widget. -- entryNew :: IO Entry -entryNew = makeNewObject mkEntry $ liftM castPtr $ {#call unsafe entry_new#} +entryNew = + makeNewObject mkEntry $ liftM castPtr $ + {# call unsafe entry_new #} -------------------- -- Methods --- | Set the text of the 'Entry' widget. +-- | Sets the text in the widget to the given value, replacing the current +-- contents. -- -entrySetText :: EntryClass ec => ec -> String -> IO () -entrySetText ec str = withUTFString str $ {#call entry_set_text#} (toEntry ec) +entrySetText :: EntryClass self => self -> String -> IO () +entrySetText self text = + withUTFString text $ \textPtr -> + {# call entry_set_text #} + (toEntry self) + textPtr --- | Get the text of the 'Entry' widget. +-- | Retrieves the contents of the entry widget. See also 'editableGetChars'. -- -entryGetText :: EntryClass ec => ec -> IO String -entryGetText ec = {#call entry_get_text#} (toEntry ec) >>= peekUTFString +entryGetText :: EntryClass self => self -> IO String +entryGetText self = + {# call entry_get_text #} + (toEntry self) + >>= peekUTFString #ifndef DISABLE_DEPRECATED --- | Append to the text of the 'Entry' widget. +-- | Appends the given text to the contents of the widget. -- -entryAppendText :: EntryClass ec => ec -> String -> IO () -entryAppendText ec str = - withUTFString str $ {#call entry_append_text#} (toEntry ec) +-- * Warning: this function is deprecated and should not be used in +-- newly-written code. +-- +entryAppendText :: EntryClass self => self -> String -> IO () +entryAppendText self text = + withUTFString text $ \textPtr -> + {# call entry_append_text #} + (toEntry self) + textPtr --- | Prepend the text of the 'Entry' widget. +-- | Prepends the given text to the contents of the widget. -- -entryPrependText :: EntryClass ec => ec -> String -> IO () -entryPrependText ec str = - withUTFString str $ {#call entry_prepend_text#} (toEntry ec) +-- * Warning: this function is deprecated and should not be used in +-- newly-written code. +-- +entryPrependText :: EntryClass self => self -> String -> IO () +entryPrependText self text = + withUTFString text $ \textPtr -> + {# call entry_prepend_text #} + (toEntry self) + textPtr #endif --- | Set whether to use password mode (display stars instead of the text). +-- | Sets whether the contents of the entry are visible or not. When +-- visibility is set to @False@, characters are displayed as the invisible +-- char, and will also appear that way when the text in the entry widget is +-- copied elsewhere. -- --- * The replacement character can be changed with 'entrySetInvisibleChar'. +-- The default invisible char is the asterisk \'*\', but it can be changed +-- with 'entrySetInvisibleChar'. -- -entrySetVisibility :: EntryClass ec => ec -> Bool -> IO () -entrySetVisibility ec visible = - {#call entry_set_visibility#} (toEntry ec) (fromBool visible) +entrySetVisibility :: EntryClass self => self + -> Bool -- ^ @visible@ - @True@ if the contents of the entry are displayed + -- as plaintext. + -> IO () +entrySetVisibility self visible = + {# call entry_set_visibility #} + (toEntry self) + (fromBool visible) --- | Get whether widget is in password mode. +-- | Retrieves whether the text in @entry@ is visible. See +-- 'entrySetVisibility'. -- -entryGetVisibility :: EntryClass ec => ec -> IO Bool -entryGetVisibility ec = - liftM toBool $ {#call entry_get_visibility#} (toEntry ec) +entryGetVisibility :: EntryClass self => self + -> IO Bool -- ^ returns @True@ if the text is currently visible +entryGetVisibility self = + liftM toBool $ + {# call entry_get_visibility #} + (toEntry self) --- | Set the replacement character for invisible text. +-- | Sets the character to use in place of the actual text when +-- 'entrySetVisibility' has been called to set text visibility to @False@. i.e. +-- this is the character used in \"password mode\" to show the user how many +-- characters have been typed. The default invisible char is an asterisk +-- (\'*\'). If you set the invisible char to @\'\\0\'@, then the user will get +-- no feedback at all; there will be no text on the screen as they type. -- -entrySetInvisibleChar :: EntryClass ec => ec -> Char -> IO () -entrySetInvisibleChar ec ch = - {#call unsafe entry_set_invisible_char#} (toEntry ec) ((fromIntegral.ord) ch) +entrySetInvisibleChar :: EntryClass self => self -> Char -> IO () +entrySetInvisibleChar self ch = + {# call unsafe entry_set_invisible_char #} + (toEntry self) + ((fromIntegral . ord) ch) --- | Get the current replacement character for invisible text, --- or 0 if not in password mode. +-- | Retrieves the character displayed in place of the real characters for +-- entries with visisbility set to false. See 'entrySetInvisibleChar'. -- -entryGetInvisibleChar :: EntryClass ec => ec -> IO Char -entryGetInvisibleChar ec = liftM (chr.fromIntegral) $ - {#call unsafe entry_get_invisible_char#} (toEntry ec) +entryGetInvisibleChar :: EntryClass self => self + -> IO Char -- ^ returns the current invisible char, or @\'\\0\'@, if the + -- entry does not show invisible text at all. +entryGetInvisibleChar self = + liftM (chr . fromIntegral) $ + {# call unsafe entry_get_invisible_char #} + (toEntry self) --- | Sets a maximum length the text may grow to. --- --- * A negative number resets the restriction. +-- | Sets the maximum allowed length of the contents of the widget. If the +-- current contents are longer than the given length, then they will be +-- truncated to fit. -- -entrySetMaxLength :: EntryClass ec => ec -> Int -> IO () -entrySetMaxLength ec max = - {#call entry_set_max_length#} (toEntry ec) (fromIntegral max) +entrySetMaxLength :: EntryClass self => self + -> Int -- ^ @max@ - the maximum length of the entry, or 0 for no maximum. + -- (other than the maximum length of entries.) The value passed in + -- will be clamped to the range 0-65536. + -> IO () +entrySetMaxLength self max = + {# call entry_set_max_length #} + (toEntry self) + (fromIntegral max) --- | Gets a maximum length the text is allowed to grow to. +-- | Retrieves the maximum allowed length of the text in @entry@. See +-- 'entrySetMaxLength'. -- -entryGetMaxLength :: EntryClass ec => ec -> IO Int -entryGetMaxLength ec = - liftM fromIntegral $ {#call unsafe entry_get_max_length#} (toEntry ec) +entryGetMaxLength :: EntryClass self => self + -> IO Int -- ^ returns the maximum allowed number of characters in 'Entry', + -- or 0 if there is no maximum. +entryGetMaxLength self = + liftM fromIntegral $ + {# call unsafe entry_get_max_length #} + (toEntry self) -- | Query whether pressing return will activate the default widget. -- -entryGetActivatesDefault :: EntryClass ec => ec -> IO Bool -entryGetActivatesDefault ec = liftM toBool $ - {#call unsafe entry_get_activates_default#} (toEntry ec) +entryGetActivatesDefault :: EntryClass self => self + -> IO Bool -- ^ returns @True@ if the entry will activate the default widget +entryGetActivatesDefault self = + liftM toBool $ + {# call unsafe entry_get_activates_default #} + (toEntry self) --- | Specify if pressing return will activate --- the default widget. +-- | If @setting@ is @True@, pressing Enter in the @entry@ will activate the +-- default widget for the window containing the entry. This usually means that +-- the dialog box containing the entry will be closed, since the default widget +-- is usually one of the dialog buttons. -- --- * This setting is useful in 'Dialog' boxes where enter should press --- the default button. +-- (For experts: if @setting@ is @True@, the entry calls +-- 'windowActivateDefault' on the window containing the entry, in the default +-- handler for the \"activate\" signal.) -- -entrySetActivatesDefault :: EntryClass ec => ec -> Bool -> IO () -entrySetActivatesDefault ec setting = {#call entry_set_activates_default#} - (toEntry ec) (fromBool setting) +-- This setting is useful in 'Dialog' boxes where enter should press the +-- default button. +-- +entrySetActivatesDefault :: EntryClass self => self + -> Bool -- ^ @setting@ - @True@ to activate window's default widget on Enter + -- keypress + -> IO () +entrySetActivatesDefault self setting = + {# call entry_set_activates_default #} + (toEntry self) + (fromBool setting) -- | Query if the text 'Entry' is displayed with a frame around it. -- -entryGetHasFrame :: EntryClass ec => ec -> IO Bool -entryGetHasFrame ec = liftM toBool $ - {#call unsafe entry_get_has_frame#} (toEntry ec) +entryGetHasFrame :: EntryClass self => self + -> IO Bool -- ^ returns whether the entry has a beveled frame +entryGetHasFrame self = + liftM toBool $ + {# call unsafe entry_get_has_frame #} + (toEntry self) --- | Specifies whehter the 'Entry' should be in an etched-in frame. +-- | Sets whether the entry has a beveled frame around it. -- -entrySetHasFrame :: EntryClass ec => ec -> Bool -> IO () -entrySetHasFrame ec setting = {#call entry_set_has_frame#} - (toEntry ec) (fromBool setting) +entrySetHasFrame :: EntryClass self => self -> Bool -> IO () +entrySetHasFrame self setting = + {# call entry_set_has_frame #} + (toEntry self) + (fromBool setting) -- | Retrieve the number of characters the widget should ask for. -- -entryGetWidthChars :: EntryClass ec => ec -> IO Int -entryGetWidthChars ec = liftM fromIntegral $ - {#call unsafe entry_get_width_chars#} (toEntry ec) +entryGetWidthChars :: EntryClass self => self + -> IO Int -- ^ returns number of chars to request space for, or negative if + -- unset +entryGetWidthChars self = + liftM fromIntegral $ + {# call unsafe entry_get_width_chars #} + (toEntry self) --- | Specifies how large the 'Entry' should be in characters. +-- | Changes the size request of the entry to be about the right size for +-- @nChars@ characters. Note that it changes the size /request/, the size can +-- still be affected by how you pack the widget into containers. If @nChars@ is +-- -1, the size reverts to the default entry size. -- --- * This setting is only considered when the widget formulates its size --- request. Make sure that it is not mapped (shown) before you change this --- value. +-- This setting is only considered when the widget formulates its size +-- request. Make sure that it is not mapped (shown) before you change this +-- value. -- -entrySetWidthChars :: EntryClass ec => ec -> Int -> IO () -entrySetWidthChars ec setting = {#call entry_set_width_chars#} - (toEntry ec) (fromIntegral setting) +entrySetWidthChars :: EntryClass self => self + -> Int -- ^ @nChars@ - width in chars + -> IO () +entrySetWidthChars self nChars = + {# call entry_set_width_chars #} + (toEntry self) + (fromIntegral nChars) #if GTK_CHECK_VERSION(2,4,0) -- | Sets the alignment for the contents of the entry. This controls the -- horizontal positioning of the contents when the displayed text is shorter -- than the width of the entry. -- --- * Since gtk 2.4 +-- * Available since Gtk version 2.4 -- -entrySetAlignment :: EntryClass ec => ec -> Float -> IO () -entrySetAlignment ec xalign = - {#call entry_set_alignment#} (toEntry ec) (realToFrac xalign) +entrySetAlignment :: EntryClass self => self + -> Float -- ^ @xalign@ - The horizontal alignment, from 0 (left) to 1 + -- (right). Reversed for RTL layouts + -> IO () +entrySetAlignment self xalign = + {# call entry_set_alignment #} + (toEntry self) + (realToFrac xalign) -- | Gets the value set by 'entrySetAlignment'. -- --- * Since gtk 2.4 +-- * Available since Gtk version 2.4 -- -entryGetAlignment :: EntryClass ec => ec -> IO Float -entryGetAlignment ec = - liftM realToFrac $ {#call unsafe entry_get_alignment#} (toEntry ec) +entryGetAlignment :: EntryClass self => self + -> IO Float -- ^ returns the alignment +entryGetAlignment self = + liftM realToFrac $ + {# call unsafe entry_get_alignment #} + (toEntry self) -- | Sets the auxiliary completion object to use with the entry. All further -- configuration of the completion mechanism is done on completion using the --- "EntryCompletion" API. +-- 'EntryCompletion' API. -- --- * Since gtk 2.4 +-- * Available since Gtk version 2.4 -- -entrySetCompletion :: EntryClass ec => ec -> EntryCompletion -> IO () -entrySetCompletion ec completion = {#call gtk_entry_set_completion#} - (toEntry ec) completion +entrySetCompletion :: EntryClass self => self -> EntryCompletion -> IO () +entrySetCompletion self completion = + {# call gtk_entry_set_completion #} + (toEntry self) + completion -- | Returns the auxiliary completion object currently in use by the entry. -- --- * Since gtk 2.4 +-- * Available since Gtk version 2.4 -- -entryGetCompletion :: EntryClass ec => ec -> IO EntryCompletion -entryGetCompletion ec = +entryGetCompletion :: EntryClass self => self + -> IO EntryCompletion -- ^ returns The auxiliary completion object currently + -- in use by @entry@. +entryGetCompletion self = makeNewGObject mkEntryCompletion $ - {#call gtk_entry_get_completion#} (toEntry ec) + {# call gtk_entry_get_completion #} + (toEntry self) #endif -------------------- |