2008-08-14 Alberto Garcia <agarcia@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 <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  * HildonPannableAreaMovDirection:
69  * @HILDON_PANNABLE_AREA_MOV_MODE_HORIZ:
70  * @HILDON_PANNABLE_AREA_MOV_MODE_VERT:
71  *
72  * Used to control the movement of the pannable, we can allow or
73  * disallow horizontal or vertical movement. This way the applications
74  * can control the movement using scroll_to and jump_to functions
75  */
76 typedef enum {
77   HILDON_PANNABLE_AREA_MOV_MODE_HORI = 1 << 1,
78   HILDON_PANNABLE_AREA_MOV_MODE_VERT = 1 << 2,
79   HILDON_PANNABLE_AREA_MOV_MODE_BOTH = 0x000006
80 } HildonPannableAreaMovMode;
81
82 /**
83  * HildonPannableAreaMovDirection:
84  * @HILDON_PANNABLE_AREA_MOV_UP:
85  * @HILDON_PANNABLE_AREA_MOV_DOWN:
86  * @HILDON_PANNABLE_AREA_MOV_LEFT:
87  * @HILDON_PANNABLE_AREA_MOV_RIGHT:
88  *
89  * Used to point out the direction of the movement
90  */
91 typedef enum {
92   HILDON_PANNABLE_AREA_MOV_UP,
93   HILDON_PANNABLE_AREA_MOV_DOWN,
94   HILDON_PANNABLE_AREA_MOV_LEFT,
95   HILDON_PANNABLE_AREA_MOV_RIGHT
96 } HildonPannableAreaMovDirection;
97
98 typedef enum {
99     HILDON_PANNABLE_AREA_INDICATOR_MODE_AUTO,
100     HILDON_PANNABLE_AREA_INDICATOR_MODE_SHOW,
101     HILDON_PANNABLE_AREA_INDICATOR_MODE_HIDE
102 } HildonPannableAreaIndicatorMode;
103
104 /**
105  * HildonPannableArea:
106  *
107  * HildonPannableArea has no publicly accessible fields
108  */
109 typedef struct                                  _HildonPannableArea HildonPannableArea;
110 typedef struct                                  _HildonPannableAreaClass HildonPannableAreaClass;
111
112 struct                                          _HildonPannableArea
113 {
114     GtkBin parent;
115 };
116
117 struct                                          _HildonPannableAreaClass
118 {
119     GtkBinClass parent_class;
120
121   void (* horizontal_movement) (HildonPannableArea *area,
122                                 HildonPannableAreaIndicatorMode direction,
123                                 gdouble x, gdouble y);
124   void (* vertical_movement) (HildonPannableArea *area,
125                               HildonPannableAreaIndicatorMode direction,
126                               gdouble x, gdouble y);
127 };
128
129 GType hildon_pannable_area_get_type             (void);
130
131 GtkWidget* hildon_pannable_area_new             (void);
132 GtkWidget* hildon_pannable_area_new_full        (gint mode, gboolean enabled,
133                                                  gdouble vel_min, gdouble vel_max,
134                                                  gdouble decel, guint sps);
135 void hildon_pannable_area_add_with_viewport     (HildonPannableArea *area,
136                                                  GtkWidget *child);
137 void hildon_pannable_area_scroll_to             (HildonPannableArea *area,
138                                                  const gint x, const gint y);
139 void hildon_pannable_area_jump_to               (HildonPannableArea *area,
140                                                  const gint x, const gint y);
141 void hildon_pannable_area_scroll_to_child       (HildonPannableArea *area,
142                                                  GtkWidget *child);
143 void hildon_pannable_area_jump_to_child         (HildonPannableArea *area,
144                                                  GtkWidget *child);
145 GtkWidget* hildon_pannable_get_child_widget_at  (HildonPannableArea *area,
146                                                  gdouble x, gdouble y);
147
148 G_END_DECLS
149
150 #endif /* _HILDON_PANNABLE_AREA */