File: EventBox.chs

package info (click to toggle)
haskell-gtk 0.11.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,920 kB
  • ctags: 82
  • sloc: haskell: 1,929; ansic: 714; sh: 5; makefile: 3
file content (179 lines) | stat: -rw-r--r-- 5,075 bytes parent folder | download | duplicates (3)
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
{-# LANGUAGE CPP #-}
-- -*-haskell-*-
--  GIMP Toolkit (GTK) Widget EventBox
--
--  Author : Axel Simon
--
--  Created: 23 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)
--
-- A widget used to catch events for widgets which do not have their own
-- window
--
module Graphics.UI.Gtk.Misc.EventBox (
-- * Detail
-- 
-- | The 'EventBox' widget is a subclass of 'Bin' which also has its own
-- window. It is useful since it allows you to catch events for widgets which
-- do not have their own window.

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

-- * Types
  EventBox,
  EventBoxClass,
  castToEventBox, gTypeEventBox,
  toEventBox,

-- * Constructors
  eventBoxNew,

-- * Methods
#if GTK_CHECK_VERSION(2,4,0)
  eventBoxSetVisibleWindow,
  eventBoxGetVisibleWindow,
  eventBoxSetAboveChild,
  eventBoxGetAboveChild,

-- * Attributes
  eventBoxVisibleWindow,
  eventBoxAboveChild,
#endif
  ) where

import Control.Monad	(liftM)

import System.Glib.FFI
import System.Glib.Attributes
import Graphics.UI.Gtk.Abstract.Object	(makeNewObject)
{#import Graphics.UI.Gtk.Types#}

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

--------------------
-- Constructors

-- | Creates a new 'EventBox'.
--
eventBoxNew :: IO EventBox
eventBoxNew =
  makeNewObject mkEventBox $
  liftM (castPtr :: Ptr Widget -> Ptr EventBox) $
  {# call unsafe event_box_new #}

--------------------
-- Methods

#if GTK_CHECK_VERSION(2,4,0)
-- | Set whether the event box uses a visible or invisible child window. The
-- default is to use visible windows.
--
-- In an invisible window event box, the window that that the event box
-- creates is a \"input only\" window, which means that it is invisible and only
-- serves to receive events.
--
-- A visible window event box creates a visible (\"input output\") window that
-- acts as the parent window for all the widgets contained in the event box.
--
-- You should generally make your event box invisible if you just want to
-- trap events. Creating a visible window may cause artifacts that are visible
-- to the user, especially if the user is using a theme with gradients or
-- pixmaps.
--
-- The main reason to create a non input-only event box is if you want to
-- set the background to a different color or draw on it.
--
-- * Available since Gtk+ version 2.4
--
eventBoxSetVisibleWindow :: EventBox -> Bool -> IO ()
eventBoxSetVisibleWindow self visibleWindow =
  {# call event_box_set_visible_window #}
    self
    (fromBool visibleWindow)

-- | Returns whether the event box has a visible window. See
-- 'eventBoxSetVisibleWindow' for details.
--
-- * Available since Gtk+ version 2.4
--
eventBoxGetVisibleWindow :: EventBox -> IO Bool
eventBoxGetVisibleWindow self =
  liftM toBool $
  {# call unsafe event_box_get_visible_window #}
    self

-- | Set whether the event box window is positioned above the windows of its
-- child, as opposed to below it. If the window is above, all events inside the
-- event box will go to the event box. If the window is below, events in
-- windows of child widgets will first got to that widget, and then to its
-- parents.
--
-- The default is to keep the window below the child.
--
-- * Available since Gtk+ version 2.4
--
eventBoxSetAboveChild :: EventBox -> Bool -> IO ()
eventBoxSetAboveChild self aboveChild =
  {# call event_box_set_above_child #}
    self
    (fromBool aboveChild)

-- | Returns whether the event box window is above or below the windows of its
-- child. See 'eventBoxSetAboveChild' for details.
--
-- * Available since Gtk+ version 2.4
--
eventBoxGetAboveChild :: EventBox -> IO Bool
eventBoxGetAboveChild self =
  liftM toBool $
  {# call unsafe event_box_get_above_child #}
    self

--------------------
-- Attributes

-- | Whether the event box is visible, as opposed to invisible and only used
-- to trap events.
--
-- Default value: @True@
--
eventBoxVisibleWindow :: Attr EventBox Bool
eventBoxVisibleWindow = newAttr
  eventBoxGetVisibleWindow
  eventBoxSetVisibleWindow

-- | Whether the event-trapping window of the eventbox is above the window of
-- the child widget as opposed to below it.
--
-- Default value: @False@
--
eventBoxAboveChild :: Attr EventBox Bool
eventBoxAboveChild = newAttr
  eventBoxGetAboveChild
  eventBoxSetAboveChild
#endif