From: Duncan C. <dun...@us...> - 2005-01-08 15:10:53
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Abstract In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30601/gtk/Graphics/UI/Gtk/Abstract Added Files: Scale.chs Range.chs Misc.chs Box.chs Bin.chs Log Message: hierarchical namespace conversion --- NEW FILE: Misc.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Misc -- -- Author : Manuel M. T. Chakravarty, -- Axel Simon -- -- Created: 2 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:10:43 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- module Graphics.UI.Gtk.Abstract.Misc ( Misc, MiscClass, castToMisc, miscSetAlignment, miscGetAlignment, miscSetPadding, miscGetPadding ) where import Monad (liftM) import System.Glib.FFI {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {# context lib="gtk" prefix="gtk" #} -- Misc type declaration -- methods -- | Set the alignment of the widget. -- miscSetAlignment :: MiscClass m => m -> Double -> Double -> IO () 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) --- NEW FILE: Range.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Range -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:10:42 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- An abstract base class to handle widgets that represent some value range. -- -- * For signals regarding a change in the range or increments, refer to -- 'Adjustment' which is contained in the 'Range' object. -- module Graphics.UI.Gtk.Abstract.Range ( Range, RangeClass, castToRange, rangeGetAdjustment, rangeSetAdjustment, UpdateType(..), rangeGetUpdatePolicy, rangeSetUpdatePolicy, rangeGetInverted, rangeSetInverted, rangeGetValue, rangeSetValue, rangeSetIncrements, rangeSetRange, ScrollType(..), rangeSetIncrements, rangeSetRange, rangeSetValue, rangeGetValue, onMoveSlider, afterMoveSlider ) where import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.General.Enums (UpdateType(..), ScrollType(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Extract the 'Adjustment' object. -- rangeGetAdjustment :: RangeClass r => r -> IO Adjustment rangeGetAdjustment r = makeNewObject mkAdjustment $ {#call unsafe range_get_adjustment#} (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 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) -- | Set how the internal 'Adjustment' object is updated. -- -- * The value of 'UpdateType' determines how frequently value-changed -- signals are emitted on the internal 'Adjustment' object. -- rangeSetUpdatePolicy :: RangeClass r => r -> UpdateType -> IO () rangeSetUpdatePolicy r up = {#call range_set_update_policy#} (toRange r) ((fromIntegral.fromEnum) up) -- | Get the inverted flag (determines if the range is reversed). -- rangeGetInverted :: RangeClass r => r -> IO Bool rangeGetInverted r = liftM toBool $ {#call unsafe range_get_inverted#} (toRange r) -- | Set the inverted flag. -- rangeSetInverted :: RangeClass r => r -> Bool -> IO () rangeSetInverted r inv = {#call range_set_inverted#} (toRange r) (fromBool inv) -- | Gets the current value of the range. -- rangeGetValue :: RangeClass r => r -> IO Double rangeGetValue r = liftM realToFrac $ {#call unsafe range_get_value#} (toRange r) -- | 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) -- | 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) -- signals -- | The slide has moved. The arguments give -- detailed information what happend. -- onMoveSlider, afterMoveSlider :: RangeClass r => r -> (ScrollType -> IO ()) -> IO (ConnectId r) onMoveSlider = connect_ENUM__NONE "move-slider" False afterMoveSlider = connect_ENUM__NONE "move-slider" True --- NEW FILE: Bin.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Bin -- -- Author : Duncan Coutts -- -- Created: 25 April 2004 -- -- Copyright (c) 2004 Duncan Coutts -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- This abstract widget implements a container with just one child. -- module Graphics.UI.Gtk.Abstract.Bin ( Bin, BinClass, binGetChild ) where import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {# context lib="gtk" prefix="gtk" #} binGetChild :: BinClass bin => bin -> IO Widget binGetChild bin = makeNewObject mkWidget $ {# call gtk_bin_get_child #} (toBin bin) --- NEW FILE: Box.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Box -- -- Author : Axel Simon -- -- Created: 15 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:10:43 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- This abstract container class is instatiated by using HBox or VBox. It -- supplies all methods to add and remove children. -- module Graphics.UI.Gtk.Abstract.Box ( Box, BoxClass, castToBox, Packing(..), boxPackStart, boxPackEnd, boxPackStartDefaults, boxPackEndDefaults, boxGetHomogeneous, boxSetHomogeneous, boxGetSpacing, boxSetSpacing, boxReorderChild, boxQueryChildPacking, boxSetChildPacking ) where import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.General.Enums (PackType(..), Packing(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Insert a widget at the beginning of the box -- container. -- -- * The 'Packing' parameter determines how the child behaves in the -- horizontal or vertical way in an HBox or VBox, respectively. -- 'PackNatural' means the child is as big as it reqests. It will -- move to the left in an 'HBox' or to the top in an -- 'VBox' if there is more space availble. -- All children -- that have choosen 'PackRepel' for @p@ will be padded -- on both sides with -- additional space. 'PackGrow' will increase the size of the -- so that is covers the available space. -- boxPackStart :: (BoxClass b, WidgetClass w) => b -> w -> Packing -> Int -> IO () boxPackStart b w p pad = {#call box_pack_start#} (toBox b) (toWidget w) (fromBool $ p/=PackNatural) (fromBool $ p==PackGrow) (fromIntegral pad) -- | Insert a widget at the end of the box container. -- -- * See 'boxPackStart'. The option 'Natural' will -- move a child to the right in an 'HBox' or to the bottom in an -- 'VBox' if there is more space availble. -- boxPackEnd :: (BoxClass b, WidgetClass w) => b -> w -> Packing -> Int -> IO () boxPackEnd b w p pad = {#call box_pack_end#} (toBox b) (toWidget w) (fromBool $ p/=PackNatural) (fromBool $ p==PackGrow) (fromIntegral pad) -- | Like 'boxPackStart' but uses the -- default parameters 'PackRepel' and 0 for padding. -- boxPackStartDefaults :: (BoxClass b, WidgetClass w) => b -> w -> IO () boxPackStartDefaults b w = {#call box_pack_start_defaults#} (toBox b) (toWidget w) -- | Like 'boxPackEnd' but uses the -- default parameters 'PackRepel' and 0 for padding. -- boxPackEndDefaults :: (BoxClass b, WidgetClass w) => b -> w -> IO () boxPackEndDefaults b w = {#call box_pack_end_defaults#} (toBox b) (toWidget w) -- | Set if all children should be spread homogeneous -- within the box. -- boxSetHomogeneous :: BoxClass b => b -> Bool -> IO () boxSetHomogeneous b homo = {#call box_set_homogeneous#} (toBox b) (fromBool homo) -- | Get whether the box is homogeneous. -- boxGetHomogeneous :: BoxClass b => b -> IO Bool boxGetHomogeneous b = liftM toBool $ {#call box_get_homogeneous#} (toBox b) -- | Set the standard spacing between two children. -- -- * This space is in addition to the padding parameter that is given for each -- child. -- boxSetSpacing :: BoxClass b => b -> Int -> IO () boxSetSpacing b spacing = {#call box_set_spacing#} (toBox b) (fromIntegral spacing) -- | Move @child@ to a new @position@ -- (counted from 0) in the box. -- boxReorderChild :: (BoxClass b, WidgetClass w) => b -> w -> Int -> IO () boxReorderChild b w position = {#call box_reorder_child#} (toBox b) (toWidget w) (fromIntegral position) -- | Query the packing parameter of a child. -- -- * Returns information on the behaviour if free space is available -- (in 'Packing'), the additional padding for this widget and -- if the widget -- was inserted at the start or end of the container ('PackType'). -- boxQueryChildPacking :: (BoxClass b, WidgetClass w) => b -> w -> IO (Packing,Int,PackType) boxQueryChildPacking b w = alloca $ \expandPtr -> alloca $ \fillPtr -> alloca $ \paddingPtr -> alloca $ \packPtr -> do {#call unsafe box_query_child_packing#} (toBox b) (toWidget w) expandPtr fillPtr paddingPtr packPtr expand <- liftM toBool $ peek expandPtr fill <- liftM toBool $ peek fillPtr padding <- liftM fromIntegral $ peek paddingPtr pack <- liftM (toEnum.fromIntegral) $ peek packPtr return (if fill then PackGrow else (if expand then PackRepel else PackNatural), padding,pack) -- | Set the packing parameter of a child. -- boxSetChildPacking :: (BoxClass b, WidgetClass w) => b -> w -> Packing -> Int -> PackType -> IO () boxSetChildPacking b w pack pad pt = {#call box_set_child_packing#} (toBox b) (toWidget w) (fromBool $ pack/=PackNatural) (fromBool $ pack==PackGrow) (fromIntegral pad) ((fromIntegral.fromEnum) pt) -- | Retrieves the standard spacing between widgets. -- boxGetSpacing :: BoxClass b => b -> IO Int boxGetSpacing b = liftM fromIntegral $ {#call unsafe box_get_spacing#} (toBox b) --- NEW FILE: Scale.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Scale -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:10:42 $ -- -- Copyright (c) 1999..2002 Axel Simon -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This file is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- | -- -- This is the abstract base class for HScale and VScale. It implements the -- management of an adjustable value. -- module Graphics.UI.Gtk.Abstract.Scale ( Scale, ScaleClass, castToScale, scaleSetDigits, scaleGetDigits, scaleSetDrawValue, scaleGetDrawValue, PositionType(..), scaleSetValuePos, scaleGetValuePos ) where import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} import Graphics.UI.Gtk.General.Enums (PositionType(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Set the number of displayed digits after the comma. -- scaleSetDigits :: ScaleClass s => s -> Int -> IO () scaleSetDigits s prec = {#call scale_set_digits#} (toScale s) (fromIntegral prec) -- | 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) -- | 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) |