File: gdl-dock-item.h

package info (click to toggle)
anjuta 1.2.2-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 24,732 kB
  • ctags: 12,398
  • sloc: ansic: 82,587; cpp: 35,104; sh: 8,591; xml: 7,210; makefile: 981; python: 157
file content (164 lines) | stat: -rw-r--r-- 6,638 bytes parent folder | download | duplicates (2)
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * gdl-dock-item.h
 *
 * Author: Gustavo Girldez <gustavo.giraldez@gmx.net>
 *
 * Based on GnomeDockItem/BonoboDockItem.  Original copyright notice follows.
 *
 * Copyright (C) 1998 Ettore Perazzoli
 * Copyright (C) 1998 Elliot Lee
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 
 * All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#ifndef __GDL_DOCK_ITEM_H__
#define __GDL_DOCK_ITEM_H__

#include <gdl/gdl-dock-object.h>

G_BEGIN_DECLS

/* standard macros */
#define GDL_TYPE_DOCK_ITEM            (gdl_dock_item_get_type ())
#define GDL_DOCK_ITEM(obj)            (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem))
#define GDL_DOCK_ITEM_CLASS(klass)    (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass))
#define GDL_IS_DOCK_ITEM(obj)         (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM))
#define GDL_IS_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM))
#define GDL_DOCK_ITEM_GET_CLASS(obj)  (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass))

/* data types & structures */
typedef enum {
    GDL_DOCK_ITEM_BEH_NORMAL           = 0,
    GDL_DOCK_ITEM_BEH_NEVER_FLOATING   = 1 << 0,
    GDL_DOCK_ITEM_BEH_NEVER_VERTICAL   = 1 << 1,
    GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL = 1 << 2,
    GDL_DOCK_ITEM_BEH_LOCKED           = 1 << 3,
    GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP    = 1 << 4,
    GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM = 1 << 5,
    GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT   = 1 << 6,
    GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT  = 1 << 7,
    GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8
} GdlDockItemBehavior;

typedef enum {
    GDL_DOCK_IN_DRAG             = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT,
    GDL_DOCK_IN_PREDRAG          = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1),
    /* for general use: indicates the user has started an action on
       the dock item */
    GDL_DOCK_USER_ACTION         = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2)
} GdlDockItemFlags;

typedef struct _GdlDockItem        GdlDockItem;
typedef struct _GdlDockItemClass   GdlDockItemClass;
typedef struct _GdlDockItemPrivate GdlDockItemPrivate;

struct _GdlDockItem {
    GdlDockObject        object;

    GtkWidget           *child;
    GdlDockItemBehavior  behavior;
    GtkOrientation       orientation;

    guint                resize : 1;

    gint                 dragoff_x, dragoff_y;    /* these need to be
                                                     accesible from
                                                     outside */
    GdlDockItemPrivate  *_priv;
};

struct _GdlDockItemClass {
    GdlDockObjectClass  parent_class;

    gboolean            has_grip;
    
    /* virtuals */
    void     (* dock_drag_begin)  (GdlDockItem    *item);
    void     (* dock_drag_motion) (GdlDockItem    *item,
                                   gint            x,
                                   gint            y);
    void     (* dock_drag_end)    (GdlDockItem    *item,
                                   gboolean        cancelled);
                                   
    void     (* set_orientation)  (GdlDockItem    *item,
                                   GtkOrientation  orientation);
};

/* additional macros */
#define GDL_DOCK_ITEM_FLAGS(item)     (GDL_DOCK_OBJECT (item)->flags)
#define GDL_DOCK_ITEM_IN_DRAG(item) \
    ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0)
#define GDL_DOCK_ITEM_IN_PREDRAG(item) \
    ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_PREDRAG) != 0)
#define GDL_DOCK_ITEM_USER_ACTION(item) \
    ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_USER_ACTION) != 0)
   
#define GDL_DOCK_ITEM_SET_FLAGS(item,flag) \
    G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) |= (flag)); } G_STMT_END
#define GDL_DOCK_ITEM_UNSET_FLAGS(item,flag) \
    G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) &= ~(flag)); } G_STMT_END

#define GDL_DOCK_ITEM_HAS_GRIP(item) (GDL_DOCK_ITEM_GET_CLASS (item)->has_grip)

/* public interface */
 
GtkWidget     *gdl_dock_item_new               (const gchar         *name,
                                                const gchar         *long_name,
                                                GdlDockItemBehavior  behavior);

GType          gdl_dock_item_get_type          (void);

void           gdl_dock_item_dock_to           (GdlDockItem      *item,
                                                GdlDockItem      *target,
                                                GdlDockPlacement  position,
                                                gint              docking_param);

void           gdl_dock_item_set_orientation   (GdlDockItem    *item,
                                                GtkOrientation  orientation);

GtkWidget     *gdl_dock_item_get_tablabel      (GdlDockItem *item);
void           gdl_dock_item_set_tablabel      (GdlDockItem *item,
                                                GtkWidget   *tablabel);
void           gdl_dock_item_hide_grip         (GdlDockItem *item);
void           gdl_dock_item_show_grip         (GdlDockItem *item);

/* bind and unbind items to a dock */
void           gdl_dock_item_bind              (GdlDockItem *item,
                                                GtkWidget   *dock);

void           gdl_dock_item_unbind            (GdlDockItem *item);

void           gdl_dock_item_hide_item         (GdlDockItem *item);

void           gdl_dock_item_show_item         (GdlDockItem *item);

void           gdl_dock_item_lock              (GdlDockItem *item);

void           gdl_dock_item_unlock            (GdlDockItem *item);

void        gdl_dock_item_set_default_position (GdlDockItem      *item,
                                                GdlDockObject    *reference);

void        gdl_dock_item_preferred_size       (GdlDockItem      *item,
                                                GtkRequisition   *req);


G_END_DECLS

#endif