File: ToolItemGroup.chs

package info (click to toggle)
haskell-gtk 0.15.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,964 kB
  • sloc: haskell: 3,346; ansic: 826; makefile: 161
file content (293 lines) | stat: -rw-r--r-- 9,019 bytes parent folder | download | duplicates (8)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget ToolItemGroup
--
--  Author : Andy Stewart
--
--  Created: 08 Sep 2010
--
--  Copyright (C) 2010 Andy Stewart
--
--  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)
--
-- A sub container used in a tool palette
--
-- * Module available since Gtk+ version 2.20
--
module Graphics.UI.Gtk.MenuComboToolbar.ToolItemGroup (

-- * Detail
-- | A 'ToolItemGroup' is used together with 'ToolPalette' to add 'ToolItems' to a palette like
-- container with different categories and drag and drop support.

-- * Class Hierarchy
-- |
-- @
-- |  'GObject'
-- |   +----'Object'
-- |         +----'Widget'
-- |               +----'Container'
-- |                     +----'ToolItemGroup'
-- @

#if GTK_CHECK_VERSION(2,20,0)
-- * Types
  ToolItemGroup,
  ToolItemGroupClass,
  castToToolItemGroup,
  toToolItemGroup,

-- * Constructors
  toolItemGroupNew,

-- * Methods
  toolItemGroupGetDropItem,
  toolItemGroupGetItemPosition,
  toolItemGroupGetNItems,
  toolItemGroupGetNthItem,
  toolItemGroupInsert,
  toolItemGroupSetItemPosition,

-- * Attributes
  toolItemGroupCollapsed,
  toolItemGroupEllipsize,
  toolItemGroupHeaderRelief,
  toolItemGroupLabel,
  toolItemGroupLabelWidget,

-- * Child Attributes
  toolItemGroupChildExpand,
  toolItemGroupChildFill,
  toolItemGroupChildHomogeneous,
  toolItemGroupChildNewRow,
  toolItemGroupChildPosition,
#endif
) where

import Control.Monad    (liftM)

import System.Glib.FFI
import System.Glib.Attributes
import System.Glib.Properties
import System.Glib.UTFString
import Graphics.Rendering.Pango.Enums   (EllipsizeMode (..))
import Graphics.UI.Gtk.General.Enums    (ReliefStyle(..))
import Graphics.UI.Gtk.Abstract.Object  (makeNewObject)
{#import Graphics.UI.Gtk.Types#}

{# context lib="gtk" prefix="gtk" #}

#if GTK_CHECK_VERSION(2,20,0)
-- | Creates a new tool item group with label label.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupNew :: GlibString string => string -- ^ @label@   the label of the new group
                 -> IO ToolItemGroup -- ^ returns a new 'ToolItemGroup'.
toolItemGroupNew label =
  makeNewObject mkToolItemGroup $
  liftM (castPtr :: Ptr Widget -> Ptr ToolItemGroup) $
  withUTFString label $ \ labelPtr ->
    {#call gtk_tool_item_group_new #}
      labelPtr

-- | Gets the tool item at position (x, y).
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupGetDropItem :: ToolItemGroupClass self => self
                         -> (Int, Int)
                         -> IO ToolItem
toolItemGroupGetDropItem group (x, y) =
  makeNewObject mkToolItem $
  {#call gtk_tool_item_group_get_drop_item #}
    (toToolItemGroup group)
    (fromIntegral x)
    (fromIntegral y)

-- | Gets the position of item in group as index.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupGetItemPosition :: (ToolItemGroupClass group, ToolItemClass item)
                               => group -- ^ @group@   a 'ToolItemGroup'
                               -> item -- ^ @item@    a 'ToolItem'
                               -> IO Int -- ^ returns the index of item in group or -1 if item is no child of group
toolItemGroupGetItemPosition group item =
    liftM fromIntegral $
    {#call gtk_tool_item_group_get_item_position #}
      (toToolItemGroup group)
      (toToolItem item)

-- | Gets the number of tool items in group.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupGetNItems :: ToolItemGroupClass group => group
                       -> IO Int -- ^ returns the number of tool items in group
toolItemGroupGetNItems group =
    liftM fromIntegral $
    {#call gtk_tool_item_group_get_n_items #}
      (toToolItemGroup group)

-- | Gets the tool item at index in group.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupGetNthItem :: ToolItemGroupClass group => group
                        -> Int  -- ^ @index@   the index
                        -> IO ToolItem  -- ^ returns the 'ToolItem' at index
toolItemGroupGetNthItem group index =
  makeNewObject mkToolItem $
  {#call gtk_tool_item_group_get_nth_item #}
    (toToolItemGroup group)
    (fromIntegral index)

-- | Inserts item at position in the list of children of group.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupInsert :: (ToolItemGroupClass group, ToolItemClass item)
                     => group -- ^ @group@    a 'ToolItemGroup'
                     -> item -- ^ @item@     the 'ToolItem' to insert into group
                     -> Int -- ^ @position@ the position of item in group, starting with 0.
                           -- The position -1 means end of list.
                     -> IO ()
toolItemGroupInsert group item position =
  {#call gtk_tool_item_group_insert #}
    (toToolItemGroup group)
    (toToolItem item)
    (fromIntegral position)

-- | Sets the position of item in the list of children of group.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupSetItemPosition :: (ToolItemGroupClass group, ToolItemClass item)
                               => group -- ^ @group@    a 'ToolItemGroup'
                               -> item -- ^ @item@     the 'ToolItem' to move to a new position, should be a child of group.
                               -> Int  -- ^ @position@ the new position of item in group, starting with 0. The position -1 means end of list.
                               -> IO ()
toolItemGroupSetItemPosition group item position =
  {#call gtk_tool_item_group_set_item_position #}
    (toToolItemGroup group)
    (toToolItem item)
    (fromIntegral position)

-- | Wether the group has been collapsed and items are hidden.
--
-- Default value: 'False'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupCollapsed :: ToolItemGroupClass group => Attr group Bool
toolItemGroupCollapsed =
  newAttrFromBoolProperty "collapsed"

-- | Ellipsize for item group headers.
--
-- Default value: EllipsizeNone
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupEllipsize :: ToolItemGroupClass group => Attr group EllipsizeMode
toolItemGroupEllipsize =
  newAttrFromEnumProperty "ellipsize"
     {# call pure unsafe pango_ellipsize_mode_get_type #}

-- | Relief of the group header button.
--
-- Default value: 'ReliefNormal'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupHeaderRelief :: ToolItemGroupClass group => Attr group ReliefStyle
toolItemGroupHeaderRelief =
  newAttrFromEnumProperty "header-relief"
     {# call pure unsafe gtk_relief_style_get_type #}

-- | The human-readable title of this item group.
--
-- Default value: \"\"
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupLabel :: GlibString string => ToolItemGroupClass group => Attr group string
toolItemGroupLabel =
  newAttrFromStringProperty "label"

-- | A widget to display in place of the usual label.
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupLabelWidget :: ToolItemGroupClass group => Attr group Widget
toolItemGroupLabelWidget =
  newAttrFromObjectProperty "label-widget"
      {# call pure unsafe gtk_widget_get_type #}

-- | Whether the item should receive extra space when the group grows.
--
-- Default value: 'False'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupChildExpand :: ToolItemGroupClass group => Attr group Bool
toolItemGroupChildExpand =
  newAttrFromBoolProperty "expand"

-- | Whether the item should fill the available space.
--
-- Default value: 'True'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupChildFill :: ToolItemGroupClass group => Attr group Bool
toolItemGroupChildFill =
  newAttrFromBoolProperty "fill"

-- | Whether the item should be the same size as other homogeneous items.
--
-- Default value: 'True'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupChildHomogeneous :: ToolItemGroupClass group => Attr group Bool
toolItemGroupChildHomogeneous =
  newAttrFromBoolProperty "homogeneous"

-- | Whether the item should start a new row.
--
-- Default value: 'False'
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupChildNewRow :: ToolItemGroupClass group => Attr group Bool
toolItemGroupChildNewRow =
  newAttrFromBoolProperty "new-row"

-- | Position of the item within this group.
--
-- Allowed values: >= 0
--
-- Default value: 0
--
-- * Available since Gtk+ version 2.20
--
toolItemGroupChildPosition :: ToolItemGroupClass group => Attr group Int
toolItemGroupChildPosition =
  newAttrFromIntProperty "position"
#endif