2008-07-29 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / src / hildon-pannable-area.h
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2008 Nokia Corporation, all rights reserved.
5  *
6  * Contact: Karl Lattimer <karl.lattimer@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 <glib-object.h>
28 #include <gtk/gtk.h>
29
30 G_BEGIN_DECLS
31
32 #define                                         HILDON_TYPE_PANNABLE_AREA \
33                                                 hildon_pannable_area_get_type()
34
35 #define                                         HILDON_PANNABLE_AREA(obj) \
36                                                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
37                                                 HILDON_TYPE_PANNABLE_AREA, HildonPannableArea))
38
39 #define                                         HILDON_PANNABLE_AREA_CLASS(klass) \
40                                                 (G_TYPE_CHECK_CLASS_CAST ((klass), \
41                                                 HILDON_TYPE_PANNABLE_AREA, HildonPannableAreaClass))
42
43 #define                                         HILDON_IS_PANNABLE_AREA(obj) \
44                                                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_PANNABLE_AREA))
45
46 #define                                         HILDON_IS_PANNABLE_AREA_CLASS(klass) \
47                                                 (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_PANNABLE_AREA))
48
49 #define                                         HILDON_PANNABLE_AREA_GET_CLASS(obj) \
50                                                 (G_TYPE_INSTANCE_GET_CLASS ((obj), \
51                                                 HILDON_TYPE_PANNABLE_AREA, HildonPannableAreaClass))
52
53 /**
54  * HildonPannableAreaMode:
55  * @HILDON_PANNABLE_AREA_MODE_PUSH: Areaing follows pointer
56  * @HILDON_PANNABLE_AREA_MODE_ACCEL: Areaing uses physics to "spin" the widget
57  * @HILDON_PANNABLE_AREA_MODE_AUTO: Automatically chooses between push and accel
58  * modes, depending on input.
59  *
60  * Used to change the behaviour of the pannable areaing
61  */
62 typedef enum {
63   HILDON_PANNABLE_AREA_MODE_PUSH,
64   HILDON_PANNABLE_AREA_MODE_ACCEL,
65   HILDON_PANNABLE_AREA_MODE_AUTO
66 } HildonPannableAreaMode;
67
68 /**
69  * HildonPannableAreaMovDirection:
70  * @HILDON_PANNABLE_AREA_MOV_MODE_HORIZ:
71  * @HILDON_PANNABLE_AREA_MOV_MODE_VERT:
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_PANNABLE_AREA_MOV_MODE_HORI = 1 << 1,
79   HILDON_PANNABLE_AREA_MOV_MODE_VERT = 1 << 2,
80   HILDON_PANNABLE_AREA_MOV_MODE_BOTH = 0x000006
81 } HildonPannableAreaMovMode;
82
83 /**
84  * HildonPannableAreaMovDirection:
85  * @HILDON_PANNABLE_AREA_MOV_UP:
86  * @HILDON_PANNABLE_AREA_MOV_DOWN:
87  * @HILDON_PANNABLE_AREA_MOV_LEFT:
88  * @HILDON_PANNABLE_AREA_MOV_RIGHT:
89  *
90  * Used to point out the direction of the movement
91  */
92 typedef enum {
93   HILDON_PANNABLE_AREA_MOV_UP,
94   HILDON_PANNABLE_AREA_MOV_DOWN,
95   HILDON_PANNABLE_AREA_MOV_LEFT,
96   HILDON_PANNABLE_AREA_MOV_RIGHT
97 } HildonPannableAreaMovDirection;
98
99 typedef enum {
100     HILDON_PANNABLE_AREA_INDICATOR_MODE_AUTO,
101     HILDON_PANNABLE_AREA_INDICATOR_MODE_SHOW,
102     HILDON_PANNABLE_AREA_INDICATOR_MODE_HIDE
103 } HildonPannableAreaIndicatorMode;
104
105 /**
106  * HildonPannableArea:
107  *
108  * HildonPannableArea has no publicly accessible fields
109  */
110 typedef struct                                  _HildonPannableArea HildonPannableArea;
111 typedef struct                                  _HildonPannableAreaClass HildonPannableAreaClass;
112
113 struct                                          _HildonPannableArea
114 {
115     GtkBin parent;
116 };
117
118 struct                                          _HildonPannableAreaClass
119 {
120     GtkBinClass parent_class;
121
122   void (* horizontal_movement) (HildonPannableArea *area,
123                                 HildonPannableAreaIndicatorMode direction,
124                                 gdouble x, gdouble y);
125   void (* vertical_movement) (HildonPannableArea *area,
126                               HildonPannableAreaIndicatorMode direction,
127                               gdouble x, gdouble y);
128 };
129
130 GType hildon_pannable_area_get_type             (void);
131
132 GtkWidget* hildon_pannable_area_new             (void);
133 GtkWidget* hildon_pannable_area_new_full        (gint mode, gboolean enabled,
134                                                  gdouble vel_min, gdouble vel_max,
135                                                  gdouble decel, guint sps);
136 void hildon_pannable_area_add_with_viewport     (HildonPannableArea *area,
137                                                  GtkWidget *child);
138 void hildon_pannable_area_scroll_to             (HildonPannableArea *area,
139                                                  const gint x, const gint y);
140 void hildon_pannable_area_jump_to               (HildonPannableArea *area,
141                                                  const gint x, const gint y);
142 void hildon_pannable_area_scroll_to_child       (HildonPannableArea *area,
143                                                  GtkWidget *child);
144 void hildon_pannable_area_jump_to_child         (HildonPannableArea *area,
145                                                  GtkWidget *child);
146 GtkWidget* hildon_pannable_get_child_widget_at  (HildonPannableArea *area,
147                                                  gdouble x, gdouble y);
148
149 G_END_DECLS
150
151 #endif /* _HILDON_PANNABLE_AREA */