From: Duncan C. <dun...@us...> - 2005-01-08 15:11:55
|
Update of /cvsroot/gtk2hs/gtk2hs/gtk/Graphics/UI/Gtk/Abstract In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30842/gtk/Graphics/UI/Gtk/Abstract Added Files: ButtonBox.chs.pp Object.chs.pp Paned.chs.pp Scrollbar.hs Separator.hs Log Message: hierarchical namespace conversion --- NEW FILE: Paned.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Paned -- -- Author : Axel Simon -- -- Created: 15 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:11:46 $ -- -- 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 widget provides a division line with a handle that can be -- used by the user to divide the given space between two widgets. The two -- concrete implementations are HPaned and VPaned. -- module Graphics.UI.Gtk.Abstract.Paned ( Paned, PanedClass, castToPaned, panedAdd1, panedAdd2, panedPack1, panedPack2, panedSetPosition, panedGetPosition #if GTK_CHECK_VERSION(2,4,0) ,panedGetChild1, panedGetChild2 #endif ) 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#} {# context lib="gtk" prefix="gtk" #} -- methods -- | Add a widget to the first (top or left) area. -- -- * The widget does not expand if 'Paned' expands. It does not shrink either. -- panedAdd1 :: (PanedClass p, WidgetClass w) => p -> w -> IO () panedAdd1 p w = {#call paned_add1#} (toPaned p) (toWidget w) -- | Add a widget to the second (bottom or right) area. -- -- * The widget does not expand if 'Paned' expands. But it does shrink. -- panedAdd2 :: (PanedClass p, WidgetClass w) => p -> w -> IO () panedAdd2 p w = {#call paned_add2#} (toPaned p) (toWidget w) -- | Add a widget to the first area and specify its resizing behaviour. -- panedPack1 :: (PanedClass p, WidgetClass w) => p -> w -> Bool -> Bool -> IO () panedPack1 p w expand shrink = {#call paned_pack1#} (toPaned p) (toWidget w) (fromBool expand) (fromBool shrink) -- | Add a widget to the second area and specify its resizing behaviour. -- panedPack2 :: (PanedClass p, WidgetClass w) => p -> w -> Bool -> Bool -> IO () panedPack2 p w expand shrink = {#call paned_pack2#} (toPaned p) (toWidget w) (fromBool expand) (fromBool shrink) -- | Set the gutter to the specified @position@ (in pixels). -- panedSetPosition :: PanedClass p => p -> Int -> IO () panedSetPosition p position = {#call paned_set_position#} (toPaned p) (fromIntegral position) -- | Get the gutter position (in pixels). -- panedGetPosition :: PanedClass p => p -> IO Int panedGetPosition p = liftM fromIntegral $ {#call unsafe paned_get_position#} (toPaned p) #if GTK_CHECK_VERSION(2,4,0) -- | Obtains the first child of the paned widget. -- panedGetChild1 :: PanedClass p => p -> IO Widget panedGetChild1 p = makeNewObject mkWidget $ {#call unsafe paned_get_child1#} (toPaned p) -- | Obtains the second child of the paned widget. -- panedGetChild2 :: PanedClass p => p -> IO Widget panedGetChild2 p = makeNewObject mkWidget $ {#call unsafe paned_get_child2#} (toPaned p) #endif --- NEW FILE: ButtonBox.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget ButtonBox -- -- Author : Matthew Walton -- -- Created: 28 April 2004 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:11:46 $ -- -- Copyright (c) 2004 Matthew Walton -- -- 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.ButtonBox ( ButtonBox, ButtonBoxClass, castToButtonBox, buttonBoxGetLayout, buttonBoxSetLayout, buttonBoxSetChildSecondary, #if GTK_CHECK_VERSION(2,4,0) buttonBoxGetChildSecondary #endif ) 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 (ButtonBoxStyle) {# context lib="gtk" prefix="gtk" #} -- methods -- | Retrieve the method being used to -- arrange the buttons in the button box -- buttonBoxGetLayout :: ButtonBoxClass b => b -> IO ButtonBoxStyle buttonBoxGetLayout b = liftM (toEnum . fromIntegral) $ {#call gtk_button_box_get_layout#} (toButtonBox b) #if GTK_CHECK_VERSION(2,4,0) -- | Returns whether child should appear -- in a secondary group of children -- -- * Since Gtk 2.4. buttonBoxGetChildSecondary :: (ButtonBoxClass b, WidgetClass w) => b -> w -> IO Bool buttonBoxGetChildSecondary b w = liftM toBool $ {#call gtk_button_box_get_child_secondary#} (toButtonBox b) (toWidget w) #endif -- | Changes the way buttons are arranged in their container -- buttonBoxSetLayout :: ButtonBoxClass b => b -> ButtonBoxStyle -> IO () buttonBoxSetLayout b l = {#call gtk_button_box_set_layout#} (toButtonBox b) ((fromIntegral . fromEnum) l) -- | Sets whether child should appear in a secondary -- group of children. A typical use of a secondary child is the help button in a dialog. -- -- * This group appears after the other children if the style is 'ButtonboxStart', -- 'ButtonboxSpread' or 'ButtonboxEdge', and before the the other children if the -- style is 'ButtonboxEnd'. For horizontal button boxes, the definition of before\/after -- depends on direction of the widget (see 'widgetSetDirection'). If the style is -- 'buttonBoxStart' or 'buttonBoxEnd', then the secondary children are aligned at -- the other end of the button box from the main children. For the other styles, -- they appear immediately next to the main children. -- buttonBoxSetChildSecondary :: (ButtonBoxClass b, WidgetClass w) => b -> w -> Bool -> IO () buttonBoxSetChildSecondary b w s = {#call gtk_button_box_set_child_secondary #} (toButtonBox b) (toWidget w) (fromBool s) --- NEW FILE: Object.chs.pp --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Object -- -- Author : Axel Simon -- -- Created: 9 April 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:11:46 $ -- -- Copyright (c) 2001 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. -- -- | -- -- Widget representation -- -- * Each widget is a represented as a purely abstract data type. It can only -- be accessed through and the special access functions that are defined -- in each widget file. -- module Graphics.UI.Gtk.Abstract.Object ( Object, ObjectClass, castToObject, objectSink, makeNewObject, objectSetProperty, objectGetProperty ) where import System.Glib.FFI import System.Glib.UTFString import System.Glib.GObject (objectRef, objectUnref) {#import Graphics.UI.Gtk.Signals#} {#import Graphics.UI.Gtk.Types#} {#import System.Glib.GValue#} import System.Glib.StoreValue {# context lib="gtk" prefix="gtk" #} -- methods -- turn the initial floating state to sunk -- -- * The floating\/sunk concept of a GTK object is not very useful to us. -- The following procedure circumvents the whole subject and ensures -- proper cleanup: -- on creation: objectRef, objectSink -- on finalization: objectUnref -- -- * This function cannot be bound by c2hs because it is not possible to -- override the pointer hook. objectSink :: ObjectClass obj => Ptr obj -> IO () objectSink = object_sink.castPtr #if __GLASGOW_HASKELL__>=504 foreign import ccall unsafe "gtk_object_sink" object_sink :: Ptr Object -> IO () #else foreign import ccall "gtk_object_sink" unsafe object_sink :: Ptr Object -> IO () #endif -- This is a convenience function to generate a new widget. It adds the -- finalizer with the method described under objectSink. -- -- * The constr argument is the contructor of the specific object. -- makeNewObject :: ObjectClass obj => (ForeignPtr obj -> obj) -> IO (Ptr obj) -> IO obj makeNewObject constr generator = do objPtr <- generator objectRef objPtr obj <- newForeignPtr objPtr (objectUnref objPtr) objectSink objPtr return $ constr obj -- Sets a specific attribute of this object. -- -- * Most attributes in a widget can be set and retrieved by passing the -- name (as a string) and the value to special set\/get functions. These -- are undocumented because each derived objects implements custom (and -- welltyped) set and get functions for most attributes. -- objectSetProperty :: GObjectClass gobj => gobj -> String -> GenericValue -> IO () objectSetProperty obj prop val = alloca $ \vaPtr -> withUTFString prop $ \sPtr -> poke vaPtr val >> {#call unsafe g_object_set_property#} (toGObject obj) sPtr vaPtr >> valueUnset vaPtr -- Gets a specific attribute of this object. -- -- * See 'objectSetProperty'. -- objectGetProperty :: GObjectClass gobj => gobj -> String -> IO GenericValue objectGetProperty obj prop = alloca $ \vaPtr -> withUTFString prop $ \str -> do {#call unsafe g_object_get_property#} (toGObject obj) str vaPtr res <- peek vaPtr valueUnset vaPtr return res --- NEW FILE: Separator.hs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Separator -- -- Author : Axel Simon -- -- Created: 23 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:11:47 $ -- -- 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 widget is the base class for HSeparator and VSeparator. -- module Graphics.UI.Gtk.Abstract.Separator ( Separator, SeparatorClass ) where import Graphics.UI.Gtk.Types (Separator, SeparatorClass) -- well this widget is very abstract! --- NEW FILE: Scrollbar.hs --- -- -*-haskell-*- -- GIMP Toolkit (GTK) Widget Scrollbar -- -- Author : Axel Simon -- -- Created: 15 May 2001 -- -- Version $Revision: 1.1 $ from $Date: 2005/01/08 15:11:46 $ -- -- 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 HScrollbar and VScrollbar. -- module Graphics.UI.Gtk.Abstract.Scrollbar ( Scrollbar, ScrollbarClass ) where import Graphics.UI.Gtk.Types (Scrollbar, ScrollbarClass) |