From: Duncan C. <dun...@us...> - 2005-03-15 19:47:58
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Buttons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2191/gtk/Graphics/UI/Gtk/Buttons Modified Files: Button.chs.pp CheckButton.chs ToggleButton.chs Log Message: Documentation changes and code formatting changes. Index: CheckButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Buttons/CheckButton.chs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CheckButton.chs 25 Feb 2005 01:11:32 -0000 1.3 +++ CheckButton.chs 15 Mar 2005 19:47:47 -0000 1.4 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- create widgets with a discrete toggle button. +-- Create widgets with a discrete toggle button -- module Graphics.UI.Gtk.Buttons.CheckButton ( --- * Description +-- * Detail -- -- | A 'CheckButton' places a discrete 'ToggleButton' next to a widget, -- (usually a 'Label'). See the section on 'ToggleButton' widgets for more @@ -73,27 +73,34 @@ -------------------- -- Constructors --- | Create a new button with a check field. +-- | Creates a new 'CheckButton'. -- checkButtonNew :: IO CheckButton -checkButtonNew = makeNewObject mkCheckButton $ - liftM castPtr {#call unsafe check_button_new#} +checkButtonNew = + makeNewObject mkCheckButton $ liftM castPtr $ + {# call unsafe check_button_new #} --- | Create a new CheckButton with a text to --- the right of it. +-- | Creates a new 'CheckButton' with a 'Label' to the right of it. -- -checkButtonNewWithLabel :: String -> IO CheckButton -checkButtonNewWithLabel lbl = withUTFString lbl (\strPtr -> +checkButtonNewWithLabel :: + String -- ^ @label@ - the text for the check button. + -> IO CheckButton +checkButtonNewWithLabel label = makeNewObject mkCheckButton $ liftM castPtr $ - {#call unsafe check_button_new_with_label#} strPtr) + withUTFString label $ \labelPtr -> + {# call unsafe check_button_new_with_label #} + labelPtr --- | Create a checkButton with an --- accelerator key. --- --- * Like 'checkButtonNewWithLabel' but turns every underscore in --- the label to a underlined character. +-- | Creates a new 'CheckButton' containing a label. The label will be created +-- using 'labelNewWithMnemonic', so underscores in @label@ indicate the +-- mnemonic for the check button. -- -checkButtonNewWithMnemonic :: String -> IO CheckButton -checkButtonNewWithMnemonic lbl = withUTFString lbl (\strPtr -> - makeNewObject mkCheckButton $ liftM castPtr $ - {#call unsafe check_button_new_with_mnemonic#} strPtr) +checkButtonNewWithMnemonic :: + String -- ^ @label@ - The text of the button, with an underscore + -- in front of the mnemonic character + -> IO CheckButton +checkButtonNewWithMnemonic label = + makeNewObject mkCheckButton $ liftM castPtr $ + withUTFString label $ \labelPtr -> + {# call unsafe check_button_new_with_mnemonic #} + labelPtr Index: ToggleButton.chs =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Buttons/ToggleButton.chs,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ToggleButton.chs 13 Mar 2005 19:34:32 -0000 1.4 +++ ToggleButton.chs 15 Mar 2005 19:47:47 -0000 1.5 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- Create buttons which retain their state. +-- Create buttons which retain their state -- module Graphics.UI.Gtk.Buttons.ToggleButton ( --- * Description +-- * Detail -- -- | A 'ToggleButton' is a 'Button' which will remain \'pressed-in\' when -- clicked. Clicking again will cause the toggle button to return to its normal @@ -99,77 +99,128 @@ -------------------- -- Constructors --- | Create a new ToggleButton widget. +-- | Creates a new toggle button. A widget should be packed into the button, +-- as in 'buttonNew'. -- toggleButtonNew :: IO ToggleButton -toggleButtonNew = makeNewObject mkToggleButton $ liftM castPtr - {#call unsafe toggle_button_new#} - +toggleButtonNew = + makeNewObject mkToggleButton $ liftM castPtr $ + {# call unsafe toggle_button_new #} --- | Create a ToggleButton with a label in it. +-- | Creates a new toggle button with a text label. -- -toggleButtonNewWithLabel :: String -> IO ToggleButton -toggleButtonNewWithLabel lbl = withUTFString lbl (\strPtr -> +toggleButtonNewWithLabel :: + String -- ^ @label@ - a string containing the message to be + -- placed in the toggle button. + -> IO ToggleButton +toggleButtonNewWithLabel label = makeNewObject mkToggleButton $ liftM castPtr $ - {#call unsafe toggle_button_new_with_label#} strPtr) + withUTFString label $ \labelPtr -> + {# call unsafe toggle_button_new_with_label #} + labelPtr --- | Create a ToggleButton with a label in it. Underscores in label indicate the +-- | Creates a new 'ToggleButton' containing a label. The label will be +-- created using 'labelNewWithMnemonic', so underscores in @label@ indicate the -- mnemonic for the button. -- -toggleButtonNewWithMnemonic :: String -> IO ToggleButton -toggleButtonNewWithMnemonic lbl = withUTFString lbl (\strPtr -> +toggleButtonNewWithMnemonic :: + String -- ^ @label@ - the text of the button, with an underscore + -- in front of the mnemonic character + -> IO ToggleButton +toggleButtonNewWithMnemonic label = makeNewObject mkToggleButton $ liftM castPtr $ - {#call unsafe toggle_button_new_with_mnemonic#} strPtr) + withUTFString label $ \labelPtr -> + {# call unsafe toggle_button_new_with_mnemonic #} + labelPtr -------------------- -- Methods -- | Sets whether the button is displayed as a separate indicator and label. --- You can call this function on a "CheckButton" or a "RadioButton" with @False@ +-- You can call this function on a 'CheckButton' or a 'RadioButton' with @False@ -- to make the button look like a normal button. -- -toggleButtonSetMode :: ToggleButtonClass tb => tb -> Bool -> IO () -toggleButtonSetMode tb mode = - {#call toggle_button_set_mode#} (toToggleButton tb) (fromBool mode) +-- This function only effects instances of classes like 'CheckButton' and +-- 'RadioButton' that derive from 'ToggleButton', not instances of +-- 'ToggleButton' itself. +-- +toggleButtonSetMode :: ToggleButtonClass self => self + -> Bool -- ^ @drawIndicator@ - if @True@, draw the button as a separate + -- indicator and label; if @False@, draw the button like a normal + -- button + -> IO () +toggleButtonSetMode self drawIndicator = + {# call toggle_button_set_mode #} + (toToggleButton self) + (fromBool drawIndicator) -- | Retrieves whether the button is displayed as a separate indicator and --- label. +-- label. See 'toggleButtonSetMode'. -- -toggleButtonGetMode :: ToggleButtonClass tb => tb -> IO Bool -toggleButtonGetMode tb = - liftM toBool $ {#call unsafe toggle_button_get_mode#} (toToggleButton tb) +toggleButtonGetMode :: ToggleButtonClass self => self + -> IO Bool -- ^ returns @True@ if the togglebutton is drawn as a separate + -- indicator and label. +toggleButtonGetMode self = + liftM toBool $ + {# call unsafe toggle_button_get_mode #} + (toToggleButton self) --- | Emit the 'toggled' signal on the button. +-- | Emits the toggled signal on the 'ToggleButton'. There is no good reason +-- for an application ever to call this function. -- -toggleButtonToggled :: ToggleButtonClass tb => tb -> IO () -toggleButtonToggled tb = {#call toggle_button_toggled#} (toToggleButton tb) +toggleButtonToggled :: ToggleButtonClass self => self -> IO () +toggleButtonToggled self = + {# call toggle_button_toggled #} + (toToggleButton self) --- | Retrieve the current state of the button. Returns True if the button is --- depressed. +-- | Queries a 'ToggleButton' and returns its current state. Returns @True@ if +-- the toggle button is pressed in and @False@ if it is raised. -- -toggleButtonGetActive :: ToggleButtonClass tb => tb -> IO Bool -toggleButtonGetActive tb = liftM toBool $ - {#call unsafe toggle_button_get_active#} (toToggleButton tb) +toggleButtonGetActive :: ToggleButtonClass self => self + -> IO Bool +toggleButtonGetActive self = + liftM toBool $ + {# call unsafe toggle_button_get_active #} + (toToggleButton self) --- | Sets the state of the ToggleButton. True means the button should be --- depressed. +-- | Sets the status of the toggle button. Set to @True@ if you want the +-- 'ToggleButton' to be \'pressed in\', and @False@ to raise it. This action +-- causes the toggled signal to be emitted. -- -toggleButtonSetActive :: ToggleButtonClass tb => tb -> Bool -> IO () -toggleButtonSetActive tb active = - {#call toggle_button_set_active#} (toToggleButton tb) (fromBool active) +toggleButtonSetActive :: ToggleButtonClass self => self + -> Bool -- ^ @isActive@ - @True@ or @False@. + -> IO () +toggleButtonSetActive self isActive = + {# call toggle_button_set_active #} + (toToggleButton self) + (fromBool isActive) --- | Retrieve the inconsistent flag of the button. An inconsistent state only --- visually affects the button. It will be displayed in an \"in-between\" state. +-- | Gets the value set by 'toggleButtonSetInconsistent'. -- -toggleButtonGetInconsistent :: ToggleButtonClass tb => tb -> IO Bool -toggleButtonGetInconsistent tb = liftM toBool $ - {#call unsafe toggle_button_get_inconsistent#} (toToggleButton tb) +toggleButtonGetInconsistent :: ToggleButtonClass self => self + -> IO Bool -- ^ returns @True@ if the button is displayed as inconsistent, + -- @False@ otherwise +toggleButtonGetInconsistent self = + liftM toBool $ + {# call unsafe toggle_button_get_inconsistent #} + (toToggleButton self) --- | Sets the inconsistent flag of the ToggleButton. +-- | If the user has selected a range of elements (such as some text or +-- spreadsheet cells) that are affected by a toggle button, and the current +-- values in that range are inconsistent, you may want to display the toggle in +-- an \"in between\" state. This function turns on \"in between\" display. +-- Normally you would turn off the inconsistent state again if the user toggles +-- the toggle button. This has to be done manually, +-- 'toggleButtonSetInconsistent' only affects visual appearance, it doesn't +-- affect the semantics of the button. -- -toggleButtonSetInconsistent :: ToggleButtonClass tb => tb -> Bool -> IO () -toggleButtonSetInconsistent tb incon = - {#call toggle_button_set_inconsistent#} (toToggleButton tb) (fromBool incon) +toggleButtonSetInconsistent :: ToggleButtonClass self => self + -> Bool -- ^ @setting@ - @True@ if state is inconsistent + -> IO () +toggleButtonSetInconsistent self setting = + {# call toggle_button_set_inconsistent #} + (toToggleButton self) + (fromBool setting) -------------------- -- Properties @@ -202,9 +253,11 @@ -------------------- -- Signals --- | Whenever the state of the button is changed, the toggled signal is emitted. +-- | Whenever the state of the button is changed, the toggled signal is +-- emitted. -- -onToggled, afterToggled :: ButtonClass b => b -> IO () -> IO (ConnectId b) +onToggled, afterToggled :: ToggleButtonClass self => self + -> IO () + -> IO (ConnectId self) onToggled = connect_NONE__NONE "toggled" False afterToggled = connect_NONE__NONE "toggled" True - Index: Button.chs.pp =================================================================== RCS file: /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Buttons/Button.chs.pp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Button.chs.pp 13 Mar 2005 19:34:32 -0000 1.4 +++ Button.chs.pp 15 Mar 2005 19:47:31 -0000 1.5 @@ -24,10 +24,10 @@ -- Stability : provisional -- Portability : portable (depends on GHC) -- --- A widget that creates a signal when clicked on. +-- A widget that creates a signal when clicked on -- module Graphics.UI.Gtk.Buttons.Button ( --- * Description +-- * Detail -- -- | The 'Button' widget is generally used to attach a function to that is -- called when the button is pressed. The various signals and how to use them @@ -121,156 +121,255 @@ -------------------- -- Constructors --- | Create a new Button widget. +-- | Creates a new 'Button' widget. To add a child widget to the button, use +-- 'containerAdd'. -- buttonNew :: IO Button -buttonNew = makeNewObject mkButton $ liftM castPtr {#call unsafe button_new#} +buttonNew = + makeNewObject mkButton $ liftM castPtr $ + {# call unsafe button_new #} --- | Create a button with a label in it. +-- | Creates a 'Button' widget with a 'Label' child containing the given text. -- -buttonNewWithLabel :: String -> IO Button -buttonNewWithLabel lbl = withUTFString lbl (\strPtr -> +buttonNewWithLabel :: + String -- ^ @label@ - The text you want the 'Label' to hold. + -> IO Button +buttonNewWithLabel label = makeNewObject mkButton $ liftM castPtr $ - {#call unsafe button_new_with_label#} strPtr) + withUTFString label $ \labelPtr -> + {# call unsafe button_new_with_label #} + labelPtr --- | Create a button with an accelerator key. --- --- * Like 'buttonNewWithLabel' but turns every underscore in the --- label to a underlined character which then acts as a mnemonic (keyboard --- shortcut). +-- | Creates a new 'Button' containing a label. If characters in @label@ are +-- preceded by an underscore, they are underlined. If you need a literal +-- underscore character in a label, use \'__\' (two underscores). The first +-- underlined character represents a keyboard accelerator called a mnemonic. +-- Pressing Alt and that key activates the button. -- -buttonNewWithMnemonic :: String -> IO Button -buttonNewWithMnemonic lbl = withUTFString lbl (\strPtr -> - makeNewObject mkButton $ liftM castPtr $ - {#call unsafe button_new_with_mnemonic#} strPtr) +buttonNewWithMnemonic :: + String -- ^ @label@ - The text of the button, with an underscore in + -- front of the mnemonic character + -> IO Button +buttonNewWithMnemonic label = + makeNewObject mkButton $ liftM castPtr $ + withUTFString label $ \labelPtr -> + {# call unsafe button_new_with_mnemonic #} + labelPtr --- | Create a stock (predefined appearance) button. +-- | Creates a new 'Button' containing the image and text from a stock item. -- -buttonNewFromStock :: String -> IO Button -buttonNewFromStock stockId = withUTFString stockId (\strPtr -> +-- If @stockId@ is unknown, then it will be treated as a mnemonic label (as +-- for 'buttonNewWithMnemonic'). +-- +buttonNewFromStock :: + String -- ^ @stockId@ - the name of the stock item + -> IO Button +buttonNewFromStock stockId = makeNewObject mkButton $ liftM castPtr $ + withUTFString stockId $ \stockIdPtr -> throwIfNull "buttonNewFromStock: Invalid stock identifier." $ - {#call unsafe button_new_from_stock#} strPtr) + {# call unsafe button_new_from_stock #} + stockIdPtr -------------------- -- Methods --- | Depress the button, i.e. emit the pressed signal. +-- | Emits the button pressed signal for the given 'Button'. -- -buttonPressed :: ButtonClass b => b -> IO () -buttonPressed b = {#call button_pressed#} (toButton b) +buttonPressed :: ButtonClass self => self -> IO () +buttonPressed self = + {# call button_pressed #} + (toButton self) --- | Release the button, i.e. emit the released signal. +-- | Emits the button released signal for the given 'Button'. -- -buttonReleased :: ButtonClass b => b -> IO () -buttonReleased b = {#call button_released#} (toButton b) +buttonReleased :: ButtonClass self => self -> IO () +buttonReleased self = + {# call button_released #} + (toButton self) --- | Emit the clicked signal on the button. +-- | Emits the button clicked signal for the given 'Button'. -- --- * This is similar to calling 'buttonPressed' and --- 'buttonReleased' in sequence. +-- This is similar to calling 'buttonPressed' and 'buttonReleased' in sequence. -- -buttonClicked :: ButtonClass b => b -> IO () -buttonClicked b = {#call button_clicked#} (toButton b) +buttonClicked :: ButtonClass self => self -> IO () +buttonClicked self = + {# call button_clicked #} + (toButton self) -- | Emit the cursor enters signal to the button. -- -buttonEnter :: ButtonClass b => b -> IO () -buttonEnter b = {#call button_enter#} (toButton b) +buttonEnter :: ButtonClass self => self -> IO () +buttonEnter self = + {# call button_enter #} + (toButton self) -- | Emit the cursor leaves signal to the button. -- -buttonLeave :: ButtonClass b => b -> IO () -buttonLeave b = {#call button_leave#} (toButton b) +buttonLeave :: ButtonClass self => self -> IO () +buttonLeave self = + {# call button_leave #} + (toButton self) --- | Set the style of the button edges. +-- | Sets the relief style of the edges of the given 'Button' widget. Three +-- styles exist, 'ReliefNormal', 'ReliefHalf', 'ReliefNone'. The default style +-- is, as one can guess, 'ReliefNormal'. -- -buttonSetRelief :: ButtonClass b => b -> ReliefStyle -> IO () -buttonSetRelief b rs = - {#call button_set_relief#} (toButton b) ((fromIntegral.fromEnum) rs) +buttonSetRelief :: ButtonClass self => self + -> ReliefStyle -- ^ @newstyle@ - The 'ReliefStyle' as described above. + -> IO () +buttonSetRelief self newstyle = + {# call button_set_relief #} + (toButton self) + ((fromIntegral . fromEnum) newstyle) --- | Get the current relief style. +-- | Returns the current relief style of the given 'Button'. -- -buttonGetRelief :: ButtonClass b => b -> IO ReliefStyle -buttonGetRelief b = liftM (toEnum.fromIntegral) $ - {#call unsafe button_get_relief#} (toButton b) +buttonGetRelief :: ButtonClass self => self + -> IO ReliefStyle -- ^ returns The current 'ReliefStyle' +buttonGetRelief self = + liftM (toEnum . fromIntegral) $ + {# call unsafe button_get_relief #} + (toButton self) --- | Set the text of the button. +-- | Sets the text of the label of the button. This text is also used +-- to select the stock item if 'buttonSetUseStock' is used. -- -buttonSetLabel :: ButtonClass b => b -> String -> IO () -buttonSetLabel b lbl = withUTFString lbl $ \strPtr -> - {#call button_set_label#} (toButton b) strPtr - --- | Get the current text on the button. +-- This will also clear any previously set labels. -- --- * The method returns the empty string in case the button does not have --- a label (e.g. it was created with 'buttonNew'. +buttonSetLabel :: ButtonClass self => self -> String -> IO () +buttonSetLabel self label = + withUTFString label $ \labelPtr -> + {# call button_set_label #} + (toButton self) + labelPtr + +-- | Gets the text from the label of the button, as set by +-- 'buttonSetLabel'. If the label text has not been set the return value will +-- be @\"\"@. +-- This will be the case if you create an empty button with 'buttonNew' to use +-- as a container. -- -buttonGetLabel :: ButtonClass b => b -> IO String -buttonGetLabel b = do - strPtr <- {#call unsafe button_get_label#} (toButton b) +buttonGetLabel :: ButtonClass self => self -> IO String +buttonGetLabel self = do + strPtr <- {# call unsafe button_get_label #} + (toButton self) if strPtr==nullPtr then return "" else peekUTFString strPtr --- | Set if the label is a stock identifier. +-- | If true, the label set on the button is used as a stock id to select the +-- stock item for the button. -- --- * Setting this property to @True@ will make the button lookup --- its label in the table of stock items. If there is a match, the button --- will use the stock item instead of the label. You need to set this --- flag before you change the label. +-- Setting this property to @True@ will make the button lookup its label in +-- the table of stock items. If there is a match, the button will use the +-- stock item instead of the label. You need to set this flag before you +-- change the label. -- -buttonSetUseStock :: ButtonClass b => b -> Bool -> IO () -buttonSetUseStock b flag = - {#call button_set_use_stock#} (toButton b) (fromBool flag) +buttonSetUseStock :: ButtonClass self => self + -> Bool -- ^ @useStock@ - @True@ if the button should use a stock item + -> IO () +buttonSetUseStock self useStock = + {# call button_set_use_stock #} + (toButton self) + (fromBool useStock) --- | Get the current flag for stock lookups. +-- | Returns whether the button label is a stock item. -- -buttonGetUseStock :: ButtonClass b => b -> IO Bool -buttonGetUseStock b = liftM toBool $ - {#call unsafe button_get_use_stock#} (toButton b) +buttonGetUseStock :: ButtonClass self => self + -> IO Bool -- ^ returns @True@ if the button label is used to select a stock + -- item instead of being used directly as the label text. +buttonGetUseStock self = + liftM toBool $ + {# call unsafe button_get_use_stock #} + (toButton self) --- | Set if the label has accelerators. +-- | If true, an underline in the text of the button label indicates the next +-- character should be used for the mnemonic accelerator key. -- --- * Setting this property will make the button join any underline character --- into the following letter and inserting this letter as a keyboard --- shortcut. You need to set this flag before you change the label. +-- Setting this property will make the button join any underline character +-- into the following letter and inserting this letter as a keyboard shortcut. +-- You need to set this flag before you change the label. -- -buttonSetUseUnderline :: ButtonClass b => b -> Bool -> IO () -buttonSetUseUnderline b flag = - {#call button_set_use_underline#} (toButton b) (fromBool flag) +buttonSetUseUnderline :: ButtonClass self => self + -> Bool -- ^ @useUnderline@ - @True@ if underlines in the text indicate + -- mnemonics + -> IO () +buttonSetUseUnderline self useUnderline = + {# call button_set_use_underline #} + (toButton self) + (fromBool useUnderline) --- | Query if the underlines are mnemonics. +-- | Returns whether an embedded underline in the button label indicates a +-- mnemonic. See 'buttonSetUseUnderline'. -- -buttonGetUseUnderline :: ButtonClass b => b -> IO Bool -buttonGetUseUnderline b = liftM toBool $ - {#call unsafe button_get_use_underline#} (toButton b) +buttonGetUseUnderline :: ButtonClass self => self + -> IO Bool -- ^ returns @True@ if an embedded underline in the button label + -- indicates the mnemonic accelerator keys. +buttonGetUseUnderline self = + liftM toBool $ + {# call unsafe button_get_use_underline #} + (toButton self) #if GTK_CHECK_VERSION(2,4,0) --- | Sets whether the button will grab focus when it is clicked with the mouse. +-- | Sets whether the button will grab focus when it is clicked with the +-- mouse. Making mouse clicks not grab focus is useful in places like toolbars +-- where you don't want the keyboard focus removed from the main area of the +-- application. -- -buttonSetFocusOnClick :: ButtonClass b => b -> Bool -> IO () -buttonSetFocusOnClick b focus = - {#call unsafe button_set_focus_on_click#} (toButton b) (fromBool focus) +-- * Available since Gtk version 2.4 +-- +buttonSetFocusOnClick :: ButtonClass self => self + -> Bool -- ^ @focusOnClick@ - whether the button grabs focus when clicked + -- with the mouse + -> IO () +buttonSetFocusOnClick self focusOnClick = + {# call unsafe button_set_focus_on_click #} + (toButton self) + (fromBool focusOnClick) --- | Gets whether the button grabs focus when it is clicked with the mouse. +-- | Returns whether the button grabs focus when it is clicked with the mouse. +-- See 'buttonSetFocusOnClick'. -- -buttonGetFocusOnClick :: ButtonClass b => b -> IO Bool -buttonGetFocusOnClick b = liftM toBool $ - {#call unsafe button_get_focus_on_click#} (toButton b) +-- * Available since Gtk version 2.4 +-- +buttonGetFocusOnClick :: ButtonClass self => self + -> IO Bool -- ^ returns @True@ if the button grabs focus when it is clicked + -- with the mouse. +buttonGetFocusOnClick self = + liftM toBool $ + {# call unsafe button_get_focus_on_click #} + (toButton self) -- | Sets the alignment of the child. This has no effect unless the child --- derives from "Misc" "Aligment". +-- 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) +-- * Available since Gtk version 2.4 +-- +buttonSetAlignment :: ButtonClass self => self + -> (Float, Float) -- ^ @(xalign, yalign)@ - the horizontal position of the + -- child (0.0 is left aligned, 1.0 is right aligned) and + -- the vertical position of the child (0.0 is top aligned, + -- 1.0 is bottom aligned) + -> IO () +buttonSetAlignment self (xalign, yalign) = + {# call unsafe button_set_alignment #} + (toButton self) + (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 +-- * Available since Gtk version 2.4 +-- +buttonGetAlignment :: ButtonClass self => self + -> IO (Float, Float) -- ^ @(xalign,yalign)@ - horizontal and vertical + -- alignment +buttonGetAlignment self = + alloca $ \xalignPtr -> + alloca $ \yalignPtr -> do + {# call unsafe button_get_alignment #} + (toButton self) + xalignPtr + yalignPtr xalign <- peek xalignPtr yalign <- peek yalignPtr return (realToFrac xalign, realToFrac yalign) @@ -353,18 +452,8 @@ onPressed = connect_NONE__NONE "pressed" False afterPressed = connect_NONE__NONE "pressed" True - -- | The button is released. -- onReleased, afterReleased :: ButtonClass b => b -> IO () -> IO (ConnectId b) onReleased = connect_NONE__NONE "released" False afterReleased = connect_NONE__NONE "released" True - - - - - - - - - |