1
/*
2
 * This file is a part of hildon
3
 *
4
 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
5
 *
6
 * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
7
 *
8
 * This widget is based on MokoFingerScroll from libmokoui
9
 * OpenMoko Application Framework UI Library
10
 * Authored by Chris Lord <chris@openedhand.com>
11
 * Copyright (C) 2006-2007 OpenMoko Inc.
12
 *
13
 * This program is free software; you can redistribute it and/or modify
14
 * it under the terms of the GNU Lesser Public License as published by
15
 * the Free Software Foundation; version 2 of the license.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU Lesser Public License for more details.
21
 *
22
 */
23
24
#ifndef _HILDON_PANNABLE_AREA
25
#define _HILDON_PANNABLE_AREA
26
27
#include <gtk/gtk.h>
28
29
G_BEGIN_DECLS
30
31
#define                                         HILDON_TYPE_PANNABLE_AREA \
32
                                                hildon_pannable_area_get_type()
33
34
#define                                         HILDON_PANNABLE_AREA(obj) \
35
                                                (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
36
                                                HILDON_TYPE_PANNABLE_AREA, HildonPannableArea))
37
38
#define                                         HILDON_PANNABLE_AREA_CLASS(klass) \
39
                                                (G_TYPE_CHECK_CLASS_CAST ((klass), \
40
                                                HILDON_TYPE_PANNABLE_AREA, HildonPannableAreaClass))
41
42
#define                                         HILDON_IS_PANNABLE_AREA(obj) \
43
                                                (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_PANNABLE_AREA))
44
45
#define                                         HILDON_IS_PANNABLE_AREA_CLASS(klass) \
46
                                                (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_PANNABLE_AREA))
47
48
#define                                         HILDON_PANNABLE_AREA_GET_CLASS(obj) \
49
                                                (G_TYPE_INSTANCE_GET_CLASS ((obj), \
50
                                                HILDON_TYPE_PANNABLE_AREA, HildonPannableAreaClass))
51
52
/**
53
 * HildonPannableAreaMode:
54
 * @HILDON_PANNABLE_AREA_MODE_PUSH: Areaing follows pointer
55
 * @HILDON_PANNABLE_AREA_MODE_ACCEL: Areaing uses physics to "spin" the widget
56
 * @HILDON_PANNABLE_AREA_MODE_AUTO: Automatically chooses between push and accel
57
 * modes, depending on input.
58
 *
59
 * Used to change the behaviour of the pannable areaing
60
 */
61
typedef enum {
62
  HILDON_PANNABLE_AREA_MODE_PUSH,
63
  HILDON_PANNABLE_AREA_MODE_ACCEL,
64
  HILDON_PANNABLE_AREA_MODE_AUTO
65
} HildonPannableAreaMode;
66
67
/**
68
 * HildonMovementMode:
69
 * @HILDON_MOVEMENT_MODE_HORIZ:
70
 * @HILDON_MOVEMENT_MODE_VERT:
71
 * @HILDON_MOVEMENT_MODE_BOTH:
72
 *
73
 * Used to control the movement of the pannable, we can allow or
74
 * disallow horizontal or vertical movement. This way the applications
75
 * can control the movement using scroll_to and jump_to functions
76
 */
77
typedef enum {
78
  HILDON_MOVEMENT_MODE_HORIZ = 1 << 1,
79
  HILDON_MOVEMENT_MODE_VERT = 1 << 2,
80
  HILDON_MOVEMENT_MODE_BOTH = 0x000006
81
} HildonMovementMode;
82
83
/**
84
 * HildonMovementDirection:
85
 * @HILDON_MOVEMENT_UP:
86
 * @HILDON_MOVEMENT_DOWN:
87
 * @HILDON_MOVEMENT_LEFT:
88
 * @HILDON_MOVEMENT_RIGHT:
89
 *
90
 * Used to point out the direction of the movement
91
 */
92
typedef enum {
93
  HILDON_MOVEMENT_UP,
94
  HILDON_MOVEMENT_DOWN,
95
  HILDON_MOVEMENT_LEFT,
96
  HILDON_MOVEMENT_RIGHT
97
} HildonMovementDirection;
98
99
/**
100
 * HildonSizeRequestPolicy:
101
 * @HILDON_SIZE_REQUEST_MINIMUM: The minimum size the widget could use
102
 * to paint itself
103
 * @HILDON_SIZE_REQUEST_CHILDREN: The minimum size of the children of
104
 * the widget
105
 *
106
 * Used to control the size request policy of the widget
107
 *
108
 * Deprecated: This define and the policy request is deprecated, DO
109
 * NOT use it in future code. Check
110
 * #hildon_pannable_area_set_size_request_policy documentation for
111
 * more information.
112
 */
113
#ifndef HILDON_DISABLE_DEPRECATED
114
typedef enum {
115
  HILDON_SIZE_REQUEST_MINIMUM,
116
  HILDON_SIZE_REQUEST_CHILDREN
117
} HildonSizeRequestPolicy;
118
#endif
119
120
/**
121
 * HildonPannableArea:
122
 *
123
 * HildonPannableArea has no publicly accessible fields
124
 */
125
typedef struct                                  _HildonPannableArea HildonPannableArea;
126
typedef struct                                  _HildonPannableAreaClass HildonPannableAreaClass;
127
typedef struct                                  _HildonPannableAreaPrivate HildonPannableAreaPrivate;
128
129
struct                                          _HildonPannableArea
130
{
131
    GtkBin parent;
132
133
    /* private */
134
    HildonPannableAreaPrivate *priv;
135
};
136
137
struct                                          _HildonPannableAreaClass
138
{
139
    GtkBinClass parent_class;
140
141
  void (* horizontal_movement) (HildonPannableArea *area,
142
                                HildonMovementDirection direction,
143
                                gdouble x, gdouble y);
144
  void (* vertical_movement) (HildonPannableArea *area,
145
                              HildonMovementDirection direction,
146
                              gdouble x, gdouble y);
147
};
148
149
GType hildon_pannable_area_get_type             (void);
150
151
GtkWidget* hildon_pannable_area_new             (void);
152
GtkWidget* hildon_pannable_area_new_full        (gint mode, gboolean enabled,
153
                                                 gdouble vel_min, gdouble vel_max,
154
                                                 gdouble decel, guint sps);
155
void hildon_pannable_area_add_with_viewport     (HildonPannableArea *area,
156
                                                 GtkWidget *child);
157
void hildon_pannable_area_scroll_to             (HildonPannableArea *area,
158
						 const gint x, const gint y);
159
void hildon_pannable_area_jump_to               (HildonPannableArea *area,
160
 						 const gint x, const gint y);
161
void hildon_pannable_area_scroll_to_child       (HildonPannableArea *area,
162
 						 GtkWidget *child);
163
void hildon_pannable_area_jump_to_child         (HildonPannableArea *area,
164
                                                 GtkWidget *child);
165
GtkWidget* hildon_pannable_get_child_widget_at  (HildonPannableArea *area,
166
                                                 gdouble x, gdouble y);
167
#ifndef HILDON_DISABLE_DEPRECATED
168
HildonSizeRequestPolicy hildon_pannable_area_get_size_request_policy (HildonPannableArea *area);
169
void hildon_pannable_area_set_size_request_policy (HildonPannableArea *area,
170
                                                   HildonSizeRequestPolicy size_request_policy);
171
#endif
172
GtkAdjustment* hildon_pannable_area_get_hadjustment (HildonPannableArea *area);
173
GtkAdjustment* hildon_pannable_area_get_vadjustment (HildonPannableArea *area);
174
gboolean hildon_pannable_area_get_center_on_child_focus (HildonPannableArea *area);
175
void hildon_pannable_area_set_center_on_child_focus (HildonPannableArea *area,
176
                                                     gboolean value);
177
178
G_END_DECLS
179
180
#endif /* _HILDON_PANNABLE_AREA */