From: Duncan C. <dun...@us...> - 2005-01-08 15:28:11
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1620/gtk/Graphics/UI/Gtk/Misc Added Files: Adjustment.chs DrawingArea.chs GArrow.chs HandleBox.chs SizeGroup.chs Viewport.chs Log Message: hierarchical namespace conversion --- NEW FILE: DrawingArea.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget DrawingArea -- -- Author : Axel Simon -- -- Created: 22 September 2002 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:28:02 $ -- -- 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. -- -- | -- -- A user-defined widget. -- -- * The 'DrawingArea' widget is used for creating custom -- user interface elements. It's essentially a blank widget. Drawing on -- the 'Drawable' returned by 'drawingAreaGetWindow' -- has to be done each time the window manager sends @\"expose\"@ -- events. Note that the library automatically clears the exposed area to -- the background color before sending the expose event, and that drawing -- is implicitly clipped to the exposed area. Other events which are -- interesting for interacting are mouse and butten events defined in -- 'Widget'. If the widget changes in size (which it does -- initially), a @\"configure\"@ event is emitted. -- module Graphics.UI.Gtk.Misc.DrawingArea ( DrawingArea, DrawingAreaClass, castToDrawingArea, drawingAreaNew, drawingAreaGetDrawWindow, drawingAreaGetSize) 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.Structs (drawingAreaGetDrawWindow, drawingAreaGetSize) {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new custom widget. -- drawingAreaNew :: IO DrawingArea drawingAreaNew = makeNewObject mkDrawingArea $ liftM castPtr {#call unsafe drawing_area_new#} --- NEW FILE: HandleBox.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget HandleBox -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:28:02 $ -- -- 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. -- -- | -- -- Add a handle to some other widget so that it can be detached and -- reattached from the main application. -- -- * The GtkHandleBox widget allows a portion of a window to be \"torn off\". It -- is a bin widget which displays its child and a handle that the user can -- drag to tear off a separate window (the float window) containing the -- child widget. A thin ghost is drawn in the original location of the -- handlebox. By dragging the separate window back to its original location, -- it can be reattached. -- When reattaching, the ghost and float window, must be aligned along one -- of the edges, the snap edge. This either can be specified by the -- application programmer explicitely, or GTK+ will pick a reasonable -- default based on the handle position. -- To make detaching and reattaching the handlebox as minimally confusing -- as possible to the user, it is important to set the snap edge so that -- the snap edge does not move when the handlebox is deattached. For -- instance, if the handlebox is packed at the bottom of a 'VBox', -- then when -- the handlebox is detached, the bottom edge of the handlebox's allocation -- will remain fixed as the height of the handlebox shrinks, so the snap -- edge should be set to 'PosBottom'. -- module Graphics.UI.Gtk.Misc.HandleBox ( HandleBox, HandleBoxClass, castToHandleBox, handleBoxNew, ShadowType(..), handleBoxSetShadowType, handleBoxGetShadowType, PositionType(..), handleBoxSetHandlePosition, handleBoxGetHandlePosition, handleBoxSetSnapEdge, handleBoxGetSnapEdge, onChildAttached, afterChildAttached, onChildDetached, afterChildDetached ) 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 (ShadowType(..), PositionType(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new handle box. -- handleBoxNew :: IO HandleBox handleBoxNew = makeNewObject mkHandleBox $ liftM castPtr {#call unsafe handle_box_new#} -- | Set the shadow type of the detached box. -- handleBoxSetShadowType :: HandleBoxClass hb => hb -> ShadowType -> IO () handleBoxSetShadowType hb shadow = {#call handle_box_set_shadow_type#} (toHandleBox hb) ((fromIntegral.fromEnum) shadow) -- | Get the shadow type of the detached box. -- handleBoxGetShadowType :: HandleBoxClass hb => hb -> IO ShadowType handleBoxGetShadowType hb = liftM (toEnum.fromIntegral) $ {#call unsafe handle_box_get_shadow_type#} (toHandleBox hb) -- | Set the position of the handle. -- handleBoxSetHandlePosition :: HandleBoxClass hb => hb -> PositionType -> IO () handleBoxSetHandlePosition hb pos = {#call handle_box_set_handle_position#} (toHandleBox hb) ((fromIntegral.fromEnum) pos) -- | Get the position of the handle. -- handleBoxGetHandlePosition :: HandleBoxClass hb => hb -> IO PositionType handleBoxGetHandlePosition hb = liftM (toEnum.fromIntegral) $ {#call unsafe handle_box_get_handle_position#} (toHandleBox hb) -- | Set the snap edge of the HandleBox. -- -- * The snap edge is the edge of the detached child that must be aligned with -- the corresponding edge of the \"ghost\" left behind when the child was -- detached to reattach the torn-off window. Usually, the snap edge should -- be chosen so that it stays in the same place on the screen when the -- handlebox is torn off. If the snap edge is not set, then an appropriate -- value will be guessed from the handle position. If the handle position is -- 'PosRight' or 'PosLeft', then the snap edge will -- be 'PosTop', otherwise it will be 'PosLeft'. -- handleBoxSetSnapEdge :: HandleBoxClass hb => hb -> PositionType -> IO () handleBoxSetSnapEdge hb pos = {#call handle_box_set_snap_edge#} (toHandleBox hb) ((fromIntegral.fromEnum) pos) -- | Gets the edge used for determining reattachment of the handle box. See -- 'handleBoxSetSnapEdge'. -- handleBoxGetSnapEdge :: HandleBoxClass hb => hb -> IO PositionType handleBoxGetSnapEdge hb = liftM (toEnum.fromIntegral) $ {#call unsafe handle_box_get_snap_edge#} (toHandleBox hb) -- signals -- | Emitted when the contents of the handlebox -- are reattached to the main window. -- -- * (INTERNAL) We ignore the given Widget. -- onChildAttached, afterChildAttached :: HandleBoxClass hb => hb -> IO () -> IO (ConnectId hb) onChildAttached = connect_NONE__NONE "child-attached" False afterChildAttached = connect_NONE__NONE "child-attached" True -- | Emitted when the 'HandleBox' is -- detached form the main window. -- onChildDetached, afterChildDetached :: HandleBoxClass hb => hb -> IO () -> IO (ConnectId hb) onChildDetached = connect_NONE__NONE "child-detached" False afterChildDetached = connect_NONE__NONE "child-detached" True --- NEW FILE: Adjustment.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Adjustment -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:28:02 $ -- -- 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 adjustment is a bounded value controlled by the user. -- -- An Adjustment object contains a value with maximum bounds and a step size. -- It is used to represent the value of a scoll bar and similar widgets. In -- particular it is contained in the abstract 'Range' widget. -- module Graphics.UI.Gtk.Misc.Adjustment ( Adjustment, AdjustmentClass, castToAdjustment, adjustmentNew, adjustmentSetLower, adjustmentGetLower, adjustmentSetPageIncrement, adjustmentGetPageIncrement, adjustmentSetPageSize, adjustmentGetPageSize, adjustmentSetStepIncrement, adjustmentGetStepIncrement, adjustmentSetUpper, adjustmentGetUpper, adjustmentSetValue, adjustmentGetValue, adjustmentClampPage, onAdjChanged, afterAdjChanged, onValueChanged, afterValueChanged ) where import Monad (liftM) import System.Glib.FFI import Graphics.UI.Gtk.Abstract.Object (makeNewObject, objectSetProperty, objectGetProperty) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {#import System.Glib.GValue#} {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new Adjustment object. -- -- * The creation function take every value that is contained in the object: -- @value@ is the initial value and should be between the -- @upper@ and @lower@ bounds of the slider. Clicking on the -- arrows increases this value by @stepIncrement@. Clicking in the -- slider advances by @pageIncrement@. The @pageSize@ is -- needed to determine if the end of the slider is still in the range. -- adjustmentNew :: Double -> Double -> Double -> Double -> Double -> Double -> IO Adjustment adjustmentNew pageSize value lower upper stepIncrement pageIncrement = makeNewObject mkAdjustment $ liftM castPtr $ {#call unsafe adjustment_new#} (realToFrac value) (realToFrac lower) (realToFrac upper) (realToFrac stepIncrement) (realToFrac pageIncrement) (realToFrac pageSize) -- | Set the lower value. adjustmentSetLower :: Adjustment -> Double -> IO () adjustmentSetLower a val = objectSetProperty a "lower" (GVdouble val) -- | Retrieve the lower value. adjustmentGetLower :: Adjustment -> IO Double adjustmentGetLower a = do (GVdouble res) <- objectGetProperty a "lower" return res -- | Set the page increment value. adjustmentSetPageIncrement :: Adjustment -> Double -> IO () adjustmentSetPageIncrement a val = objectSetProperty a "page-increment" (GVdouble val) -- | Retrieve the pageincrement value. adjustmentGetPageIncrement :: Adjustment -> IO Double adjustmentGetPageIncrement a = do (GVdouble res) <- objectGetProperty a "page-increment" return res -- | Set the page size value. adjustmentSetPageSize :: Adjustment -> Double -> IO () adjustmentSetPageSize a val = objectSetProperty a "page_size" (GVdouble val) -- | Retrieve the page size value. adjustmentGetPageSize :: Adjustment -> IO Double adjustmentGetPageSize a = do (GVdouble res) <- objectGetProperty a "page_size" return res -- | Set the step-increment value. adjustmentSetStepIncrement :: Adjustment -> Double -> IO () adjustmentSetStepIncrement a val = objectSetProperty a "step-increment" (GVdouble val) -- | Retrieve the step-increment value. adjustmentGetStepIncrement :: Adjustment -> IO Double adjustmentGetStepIncrement a = do (GVdouble res) <- objectGetProperty a "step-increment" return res -- | Set the upper value. adjustmentSetUpper :: Adjustment -> Double -> IO () adjustmentSetUpper a val = objectSetProperty a "upper" (GVdouble val) -- | Retrieve the upper value. adjustmentGetUpper :: Adjustment -> IO Double adjustmentGetUpper a = do (GVdouble res) <- objectGetProperty a "upper" return res -- | Set the current value of the Adjustment object. -- adjustmentSetValue :: Adjustment -> Double -> IO () adjustmentSetValue adj value = {#call adjustment_set_value#} adj (realToFrac value) -- | Get the current value of the Adjustment object. -- adjustmentGetValue :: Adjustment -> IO Double adjustmentGetValue adj = liftM realToFrac $ {#call adjustment_get_value#} adj -- | Ensure that the alignment is within these bounds. -- -- * Updates the Adjustment value to ensure that the range between lower and -- upper is in the current page (i.e. between value and value + page_size). -- If the range is larger than the page size, then only the start of it will -- be in the current page. A \"changed\" signal will be emitted if the value -- is changed. -- adjustmentClampPage :: Adjustment -> Double -> Double -> IO () adjustmentClampPage a lower upper = {#call adjustment_clamp_page#} a (realToFrac lower) (realToFrac upper) -- signals -- | This signal is emitted if some value of -- Adjustment except @value@ itself changes. -- onAdjChanged, afterAdjChanged :: Adjustment -> IO () -> IO (ConnectId Adjustment) onAdjChanged = connect_NONE__NONE "changed" False afterAdjChanged = connect_NONE__NONE "changed" True -- | This signal is emitted if the value of the -- Alignment object changed. -- onValueChanged, afterValueChanged :: Adjustment -> IO () -> IO (ConnectId Adjustment) onValueChanged = connect_NONE__NONE "value-changed" False afterValueChanged = connect_NONE__NONE "value-changed" True --- NEW FILE: Viewport.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Viewport -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:28:02 $ -- -- 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. -- -- | -- -- A 'Viewport' a helper widget that adds Adjustment slots to a -- widget, i.e. the widget becomes scrollable. It can then be put into -- 'ScrolledWindow' and will behave as expected. -- -- * The binding of this widget is superfluous as far as I can tell. -- -- * The only signal this widget registers is \"set-scroll-adjustments\". It is -- not bound because it is meant to be received by the 'Viewport' -- and sent by 'ScrolledWindow'. -- module Graphics.UI.Gtk.Misc.Viewport ( Viewport, ViewportClass, castToViewport, viewportNew, viewportGetHAdjustment, viewportGetVAdjustment, viewportSetHAdjustment, viewportSetVAdjustment, ShadowType(..), viewportSetShadowType, viewportGetShadowType ) 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 (ShadowType(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new 'Viewport'. -- viewportNew :: Adjustment -> Adjustment -> IO Viewport viewportNew vAdj hAdj = makeNewObject mkViewport $ liftM castPtr $ {#call unsafe viewport_new#} hAdj vAdj -- | Retrieve the horizontal -- 'Adjustment' of the 'Viewport'. -- viewportGetHAdjustment :: ViewportClass v => v -> IO Adjustment viewportGetHAdjustment v = makeNewObject mkAdjustment $ {#call unsafe viewport_get_hadjustment#} (toViewport v) -- | Retrieve the vertical 'Adjustment' -- of the 'Viewport'. -- viewportGetVAdjustment :: ViewportClass v => v -> IO Adjustment viewportGetVAdjustment v = makeNewObject mkAdjustment $ {#call unsafe viewport_get_vadjustment#} (toViewport v) -- | Set the horizontal 'Adjustment' of -- the 'Viewport'. -- viewportSetHAdjustment :: ViewportClass v => v -> Adjustment -> IO () viewportSetHAdjustment v adj = {#call viewport_set_hadjustment#} (toViewport v) adj -- | Set the vertical 'Adjustment' of the 'Viewport'. -- viewportSetVAdjustment :: ViewportClass v => v -> Adjustment -> IO () viewportSetVAdjustment v adj = {#call viewport_set_vadjustment#} (toViewport v) adj -- | Specify if and how an outer frame should be drawn around the child. -- viewportSetShadowType :: ViewportClass v => v -> ShadowType -> IO () viewportSetShadowType v st = {#call viewport_set_shadow_type#} (toViewport v) ((fromIntegral.fromEnum) st) -- | Get the current shadow type of the 'Viewport'. -- viewportGetShadowType :: ViewportClass v => v -> IO ShadowType viewportGetShadowType v = liftM (toEnum.fromIntegral) $ {#call unsafe viewport_get_shadow_type#} (toViewport v) -- signals --- NEW FILE: GArrow.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget GArrow -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:28:02 $ -- -- 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 Arrow pointing to one of the four cardinal direction. -- module Graphics.UI.Gtk.Misc.GArrow ( Arrow, ArrowClass, castToArrow, ArrowType(..), ShadowType(..), arrowNew, arrowSet ) 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 (ArrowType(..), ShadowType(..)) {# context lib="gtk" prefix="gtk" #} -- methods -- | Create a new arrow with display options. -- arrowNew :: ArrowType -> ShadowType -> IO Arrow arrowNew at st = makeNewObject mkArrow $ liftM castPtr $ {#call unsafe arrow_new#} ((fromIntegral.fromEnum) at) ((fromIntegral.fromEnum) st) -- | Change the visual appearance of this widget. -- arrowSet :: ArrowClass a => a -> ArrowType -> ShadowType -> IO () arrowSet a at st = {#call arrow_set#} (toArrow a) ((fromIntegral.fromEnum) at) ((fromIntegral.fromEnum) st) --- NEW FILE: SizeGroup.chs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget SizeGroup -- -- Author : Duncan Coutts -- Created: 2 August 2004 -- -- Copyright (c) 2004 Duncan Coutts -- documentation Copyright (c) 1995..2000 the GTK+ Team -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library 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 -- Library General Public License for more details. -- -- | -- -- SizeGroup provides a mechanism for grouping a number of widgets together so -- they all request the same amount of space. This is typically useful when you -- want a column of widgets to have the same size, but you can't use a "Table" -- widget. -- module Graphics.UI.Gtk.Misc.SizeGroup ( sizeGroupNew, SizeGroupMode(..), sizeGroupSetMode, sizeGroupGetMode, sizeGroupAddWidget, sizeGroupRemoveWidget ) where import Monad (liftM) import System.Glib.FFI import System.Glib.GObject (makeNewGObject) {#import Graphics.UI.Gtk.Types#} {#import Graphics.UI.Gtk.Signals#} {# context lib="gtk" prefix="gtk" #} {#enum SizeGroupMode {underscoreToCase}#} -- | Create a new SizeGroup. -- sizeGroupNew :: SizeGroupMode -> IO SizeGroup sizeGroupNew mode = makeNewGObject mkSizeGroup $ {#call unsafe size_group_new#} ((fromIntegral.fromEnum) mode) -- | Adds a widget to a SizeGroup. In the future, the requisition of the widget -- will be determined as the maximum of its requisition and the requisition of -- the other widgets in the size group. Whether this applies horizontally, -- vertically, or in both directions depends on the mode of the size group. See -- 'sizeGroupSetMode'. -- sizeGroupAddWidget :: (SizeGroupClass obj, WidgetClass widget) => obj -> widget -> IO () sizeGroupAddWidget obj widget = {#call size_group_add_widget#} (toSizeGroup obj) (toWidget widget) -- | Gets the current mode of the size group. -- sizeGroupGetMode :: SizeGroupClass obj => obj -> IO SizeGroupMode sizeGroupGetMode obj = liftM (toEnum.fromIntegral) $ {#call unsafe size_group_get_mode#} (toSizeGroup obj) -- | Removes the widget from the SizeGroup. -- sizeGroupRemoveWidget :: (SizeGroupClass obj, WidgetClass widget) => obj -> widget -> IO () sizeGroupRemoveWidget obj widget = {#call size_group_remove_widget#} (toSizeGroup obj) (toWidget widget) -- | Sets the 'SizeGroupMode' of the size group. The mode of the size group -- determines whether the widgets in the size group should all have the same -- horizontal requisition 'sizeGroupModeHorizontal' all have the same vertical -- requisition 'sizeGroupModeVertical', or should all have the same requisition -- in both directions 'sizeGroupModeBoth'. -- sizeGroupSetMode :: SizeGroupClass obj => obj -> SizeGroupMode -> IO () sizeGroupSetMode obj mode = {#call size_group_set_mode#} (toSizeGroup obj) ((fromIntegral.fromEnum) mode) |