1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
-- -*-haskell-*-
-- GIMP Toolkit (GTK) Widget Misc
--
-- Author : Manuel M. T. Chakravarty, Axel Simon
--
-- Created: 2 May 2001
--
-- Copyright (C) 1999-2005 Axel Simon
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 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
-- Lesser General Public License for more details.
--
-- |
-- Maintainer : gtk2hs-users@lists.sourceforge.net
-- Stability : provisional
-- Portability : portable (depends on GHC)
--
-- Base class for widgets with alignments and padding
--
module Graphics.UI.Gtk.Abstract.Misc (
-- * Detail
--
-- | The 'Misc' widget is an abstract widget which is not useful itself, but
-- is used to derive subclasses which have alignment and padding attributes.
--
-- The horizontal and vertical padding attributes allows extra space to be
-- added around the widget.
--
-- The horizontal and vertical alignment attributes enable the widget to be
-- positioned within its allocated area. Note that if the widget is added to a
-- container in such a way that it expands automatically to fill its allocated
-- area, the alignment settings will not alter the widgets position.
-- * Class Hierarchy
-- |
-- @
-- | 'GObject'
-- | +----'Object'
-- | +----'Widget'
-- | +----Misc
-- | +----'Label'
-- | +----'Arrow'
-- | +----'Image'
-- | +----'Pixmap'
-- @
-- * Types
Misc,
MiscClass,
castToMisc, gTypeMisc,
toMisc,
-- * Methods
miscSetAlignment,
miscGetAlignment,
miscSetPadding,
miscGetPadding,
-- * Attributes
miscXalign,
miscYalign,
miscXpad,
miscYpad,
) where
import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
{#import Graphics.UI.Gtk.Types#}
{# context lib="gtk" prefix="gtk" #}
--------------------
-- Methods
-- | Sets the alignment of the widget.
--
miscSetAlignment :: MiscClass self => self
-> Float -- ^ @xalign@ - the horizontal alignment, from 0 (left) to 1
-- (right).
-> Float -- ^ @yalign@ - the vertical alignment, from 0 (top) to 1 (bottom).
-> IO ()
miscSetAlignment self xalign yalign =
{# call misc_set_alignment #}
(toMisc self)
(realToFrac xalign)
(realToFrac yalign)
-- | Gets the X and Y alignment of the widget within its allocation. See
-- 'miscSetAlignment'.
--
miscGetAlignment :: MiscClass self => self
-> IO (Double, Double)
miscGetAlignment self =
alloca $ \xalignPtr ->
alloca $ \yalignPtr -> do
{# call unsafe misc_get_alignment #}
(toMisc self)
xalignPtr
yalignPtr
xalign <- peek xalignPtr
yalign <- peek yalignPtr
return (realToFrac xalign, realToFrac yalign)
-- | Sets the amount of space to add around the widget.
--
miscSetPadding :: MiscClass self => self
-> Int -- ^ @xpad@ - the amount of space to add on the left and right of
-- the widget, in pixels.
-> Int -- ^ @ypad@ - the amount of space to add on the top and bottom of
-- the widget, in pixels.
-> IO ()
miscSetPadding self xpad ypad =
{# call misc_set_padding #}
(toMisc self)
(fromIntegral xpad)
(fromIntegral ypad)
-- | Gets the padding in the X and Y directions of the widget. See
-- 'miscSetPadding'.
--
miscGetPadding :: MiscClass self => self
-> IO (Int, Int)
miscGetPadding self =
alloca $ \xpadPtr ->
alloca $ \ypadPtr -> do
{# call unsafe misc_get_padding #}
(toMisc self)
xpadPtr
ypadPtr
xpad <- peek xpadPtr
ypad <- peek ypadPtr
return (fromIntegral xpad, fromIntegral ypad)
--------------------
-- Attributes
-- | The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL
-- layouts.
--
-- Allowed values: [0,1]
--
-- Default value: 0.5
--
miscXalign :: MiscClass self => Attr self Float
miscXalign = newAttrFromFloatProperty "xalign"
-- | The vertical alignment, from 0 (top) to 1 (bottom).
--
-- Allowed values: [0,1]
--
-- Default value: 0.5
--
miscYalign :: MiscClass self => Attr self Float
miscYalign = newAttrFromFloatProperty "yalign"
-- | The amount of space to add on the left and right of the widget, in
-- pixels.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
miscXpad :: MiscClass self => Attr self Int
miscXpad = newAttrFromIntProperty "xpad"
-- | The amount of space to add on the top and bottom of the widget, in
-- pixels.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
miscYpad :: MiscClass self => Attr self Int
miscYpad = newAttrFromIntProperty "ypad"
|