1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * gdl-dock-item.h
4 *
5 * Author: Gustavo Giráldez <gustavo.giraldez@gmx.net>
6 *
7 * Based on GnomeDockItem/BonoboDockItem. Original copyright notice follows.
8 *
9 * Copyright (C) 1998 Ettore Perazzoli
10 * Copyright (C) 1998 Elliot Lee
11 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
12 * All rights reserved.
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Library General Public
16 * License as published by the Free Software Foundation; either
17 * version 2 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with this library; if not, write to the
26 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 * Boston, MA 02111-1307, USA.
28 */
30 #ifndef __GDL_DOCK_ITEM_H__
31 #define __GDL_DOCK_ITEM_H__
33 #include "libgdl/gdl-dock-object.h"
35 G_BEGIN_DECLS
37 /* standard macros */
38 #define GDL_TYPE_DOCK_ITEM (gdl_dock_item_get_type ())
39 #define GDL_DOCK_ITEM(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem))
40 #define GDL_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass))
41 #define GDL_IS_DOCK_ITEM(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM))
42 #define GDL_IS_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM))
43 #define GDL_DOCK_ITEM_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass))
45 /* data types & structures */
46 typedef enum {
47 GDL_DOCK_ITEM_BEH_NORMAL = 0,
48 GDL_DOCK_ITEM_BEH_NEVER_FLOATING = 1 << 0,
49 GDL_DOCK_ITEM_BEH_NEVER_VERTICAL = 1 << 1,
50 GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL = 1 << 2,
51 GDL_DOCK_ITEM_BEH_LOCKED = 1 << 3,
52 GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP = 1 << 4,
53 GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM = 1 << 5,
54 GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT = 1 << 6,
55 GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT = 1 << 7,
56 GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8,
57 GDL_DOCK_ITEM_BEH_CANT_CLOSE = 1 << 9,
58 GDL_DOCK_ITEM_BEH_CANT_ICONIFY = 1 << 10,
59 GDL_DOCK_ITEM_BEH_NO_GRIP = 1 << 11
60 } GdlDockItemBehavior;
62 typedef enum {
63 GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT,
64 GDL_DOCK_IN_PREDRAG = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1),
65 GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2),
66 /* for general use: indicates the user has started an action on
67 the dock item */
68 GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3)
69 } GdlDockItemFlags;
71 typedef struct _GdlDockItem GdlDockItem;
72 typedef struct _GdlDockItemClass GdlDockItemClass;
73 typedef struct _GdlDockItemPrivate GdlDockItemPrivate;
75 struct _GdlDockItem {
76 GdlDockObject object;
78 GtkWidget *child;
79 GdlDockItemBehavior behavior;
80 GtkOrientation orientation;
82 guint resize : 1;
84 gint dragoff_x, dragoff_y; /* these need to be
85 accesible from
86 outside */
87 GdlDockItemPrivate *_priv;
88 };
90 struct _GdlDockItemClass {
91 GdlDockObjectClass parent_class;
93 gboolean has_grip;
95 /* virtuals */
96 void (* dock_drag_begin) (GdlDockItem *item);
97 void (* dock_drag_motion) (GdlDockItem *item,
98 gint x,
99 gint y);
100 void (* dock_drag_end) (GdlDockItem *item,
101 gboolean cancelled);
102 void (* move_focus_child) (GdlDockItem *item,
103 GtkDirectionType direction);
105 void (* set_orientation) (GdlDockItem *item,
106 GtkOrientation orientation);
107 };
109 /* additional macros */
110 #define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags)
111 #define GDL_DOCK_ITEM_IN_DRAG(item) \
112 ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0)
113 #define GDL_DOCK_ITEM_IN_PREDRAG(item) \
114 ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_PREDRAG) != 0)
115 #define GDL_DOCK_ITEM_ICONIFIED(item) \
116 ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_ICONIFIED) != 0)
117 #define GDL_DOCK_ITEM_USER_ACTION(item) \
118 ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_USER_ACTION) != 0)
119 #define GDL_DOCK_ITEM_NOT_LOCKED(item) !((item)->behavior & GDL_DOCK_ITEM_BEH_LOCKED)
120 #define GDL_DOCK_ITEM_NO_GRIP(item) ((item)->behavior & GDL_DOCK_ITEM_BEH_NO_GRIP)
122 #define GDL_DOCK_ITEM_SET_FLAGS(item,flag) \
123 G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) |= (flag)); } G_STMT_END
124 #define GDL_DOCK_ITEM_UNSET_FLAGS(item,flag) \
125 G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) &= ~(flag)); } G_STMT_END
127 #define GDL_DOCK_ITEM_HAS_GRIP(item) ((GDL_DOCK_ITEM_GET_CLASS (item)->has_grip)&& \
128 ! GDL_DOCK_ITEM_NO_GRIP (item))
130 #define GDL_DOCK_ITEM_CANT_CLOSE(item) \
131 ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)|| \
132 ! GDL_DOCK_ITEM_NOT_LOCKED(item))
134 #define GDL_DOCK_ITEM_CANT_ICONIFY(item) \
135 ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)|| \
136 ! GDL_DOCK_ITEM_NOT_LOCKED(item))
138 /* public interface */
140 GtkWidget *gdl_dock_item_new (const gchar *name,
141 const gchar *long_name,
142 GdlDockItemBehavior behavior);
143 GtkWidget *gdl_dock_item_new_with_stock (const gchar *name,
144 const gchar *long_name,
145 const gchar *stock_id,
146 GdlDockItemBehavior behavior);
148 GtkWidget *gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
149 const gchar *long_name,
150 const GdkPixbuf *pixbuf_icon,
151 GdlDockItemBehavior behavior);
153 GType gdl_dock_item_get_type (void);
155 void gdl_dock_item_dock_to (GdlDockItem *item,
156 GdlDockItem *target,
157 GdlDockPlacement position,
158 gint docking_param);
160 void gdl_dock_item_set_orientation (GdlDockItem *item,
161 GtkOrientation orientation);
163 GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item);
164 void gdl_dock_item_set_tablabel (GdlDockItem *item,
165 GtkWidget *tablabel);
166 void gdl_dock_item_hide_grip (GdlDockItem *item);
167 void gdl_dock_item_show_grip (GdlDockItem *item);
169 /* bind and unbind items to a dock */
170 void gdl_dock_item_bind (GdlDockItem *item,
171 GtkWidget *dock);
173 void gdl_dock_item_unbind (GdlDockItem *item);
175 void gdl_dock_item_hide_item (GdlDockItem *item);
177 void gdl_dock_item_iconify_item (GdlDockItem *item);
179 void gdl_dock_item_show_item (GdlDockItem *item);
181 void gdl_dock_item_lock (GdlDockItem *item);
183 void gdl_dock_item_unlock (GdlDockItem *item);
185 void gdl_dock_item_set_default_position (GdlDockItem *item,
186 GdlDockObject *reference);
188 void gdl_dock_item_preferred_size (GdlDockItem *item,
189 GtkRequisition *req);
191 gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item);
193 G_END_DECLS
195 #endif