Merge 'master' into 'gtk3'.
[pspp] / src / ui / gui / pspp-sheet-selection.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17 /* gtktreeselection.h
18  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Library General Public
22  * License as published by the Free Software Foundation; either
23  * version 2 of the License, or (at your option) any later version.
24  *
25  * This library is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28  * Library General Public License for more details.
29  *
30  * You should have received a copy of the GNU Library General Public
31  * License along with this library; if not, write to the
32  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33  * Boston, MA 02111-1307, USA.
34  */
35
36 #ifndef __PSPP_SHEET_SELECTION_H__
37 #define __PSPP_SHEET_SELECTION_H__
38
39 #include <gtk/gtk.h>
40
41 G_BEGIN_DECLS
42
43
44 #define PSPP_TYPE_SHEET_SELECTION                       (pspp_sheet_selection_get_type ())
45 #define PSPP_SHEET_SELECTION(obj)                       (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPP_TYPE_SHEET_SELECTION, PsppSheetSelection))
46 #define PSPP_SHEET_SELECTION_CLASS(klass)               (G_TYPE_CHECK_CLASS_CAST ((klass), PSPP_TYPE_SHEET_SELECTION, PsppSheetSelectionClass))
47 #define PSPP_IS_SHEET_SELECTION(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPP_TYPE_SHEET_SELECTION))
48 #define PSPP_IS_SHEET_SELECTION_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPP_TYPE_SHEET_SELECTION))
49 #define PSPP_SHEET_SELECTION_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), PSPP_TYPE_SHEET_SELECTION, PsppSheetSelectionClass))
50
51 typedef enum
52   {
53     /* Same as GtkSelectionMode. */
54     PSPP_SHEET_SELECTION_NONE = GTK_SELECTION_NONE,
55     PSPP_SHEET_SELECTION_SINGLE = GTK_SELECTION_SINGLE,
56     PSPP_SHEET_SELECTION_BROWSE = GTK_SELECTION_BROWSE,
57     PSPP_SHEET_SELECTION_MULTIPLE = GTK_SELECTION_MULTIPLE,
58
59     /* PsppSheetView extension. */
60     PSPP_SHEET_SELECTION_RECTANGLE = 10
61   }
62 PsppSheetSelectionMode;
63
64 typedef gboolean (* PsppSheetSelectionFunc)    (PsppSheetSelection  *selection,
65                                               GtkTreeModel      *model,
66                                               GtkTreePath       *path,
67                                               gboolean           path_currently_selected,
68                                               gpointer           data);
69 typedef void (* PsppSheetSelectionForeachFunc) (GtkTreeModel      *model,
70                                               GtkTreePath       *path,
71                                               GtkTreeIter       *iter,
72                                               gpointer           data);
73
74 struct _PsppSheetSelection
75 {
76   GObject parent;
77
78   /*< private >*/
79
80   PsppSheetView *PSEAL (tree_view);
81   PsppSheetSelectionMode PSEAL (type);
82 };
83
84 struct _PsppSheetSelectionClass
85 {
86   GObjectClass parent_class;
87
88   void (* changed) (PsppSheetSelection *selection);
89
90   /* Padding for future expansion */
91   void (*_gtk_reserved1) (void);
92   void (*_gtk_reserved2) (void);
93   void (*_gtk_reserved3) (void);
94   void (*_gtk_reserved4) (void);
95 };
96
97
98 GType            pspp_sheet_selection_get_type            (void) G_GNUC_CONST;
99
100 void             pspp_sheet_selection_set_mode            (PsppSheetSelection            *selection,
101                                                          PsppSheetSelectionMode             type);
102 PsppSheetSelectionMode pspp_sheet_selection_get_mode        (PsppSheetSelection            *selection);
103 void             pspp_sheet_selection_set_select_function (PsppSheetSelection            *selection,
104                                                          PsppSheetSelectionFunc         func,
105                                                          gpointer                     data,
106                                                          GDestroyNotify               destroy);
107 gpointer         pspp_sheet_selection_get_user_data       (PsppSheetSelection            *selection);
108 PsppSheetView*     pspp_sheet_selection_get_tree_view       (PsppSheetSelection            *selection);
109
110 PsppSheetSelectionFunc pspp_sheet_selection_get_select_function (PsppSheetSelection        *selection);
111
112 /* Only meaningful if PSPP_SHEET_SELECTION_SINGLE or PSPP_SHEET_SELECTION_BROWSE is set */
113 /* Use selected_foreach or get_selected_rows for
114    PSPP_SHEET_SELECTION_MULTIPLE */
115 gboolean         pspp_sheet_selection_get_selected        (PsppSheetSelection            *selection,
116                                                          GtkTreeModel               **model,
117                                                          GtkTreeIter                 *iter);
118 GList *          pspp_sheet_selection_get_selected_rows   (PsppSheetSelection            *selection,
119                                                          GtkTreeModel               **model);
120 gint             pspp_sheet_selection_count_selected_rows (PsppSheetSelection            *selection);
121 void             pspp_sheet_selection_selected_foreach    (PsppSheetSelection            *selection,
122                                                          PsppSheetSelectionForeachFunc  func,
123                                                          gpointer                     data);
124 void             pspp_sheet_selection_select_path         (PsppSheetSelection            *selection,
125                                                          GtkTreePath                 *path);
126 void             pspp_sheet_selection_unselect_path       (PsppSheetSelection            *selection,
127                                                          GtkTreePath                 *path);
128 void             pspp_sheet_selection_select_iter         (PsppSheetSelection            *selection,
129                                                          GtkTreeIter                 *iter);
130 void             pspp_sheet_selection_unselect_iter       (PsppSheetSelection            *selection,
131                                                          GtkTreeIter                 *iter);
132 gboolean         pspp_sheet_selection_path_is_selected    (PsppSheetSelection            *selection,
133                                                          GtkTreePath                 *path);
134 gboolean         pspp_sheet_selection_iter_is_selected    (PsppSheetSelection            *selection,
135                                                          GtkTreeIter                 *iter);
136 void             pspp_sheet_selection_select_all          (PsppSheetSelection            *selection);
137 void             pspp_sheet_selection_unselect_all        (PsppSheetSelection            *selection);
138 void             pspp_sheet_selection_select_range        (PsppSheetSelection            *selection,
139                                                          GtkTreePath                 *start_path,
140                                                          GtkTreePath                 *end_path);
141 void             pspp_sheet_selection_unselect_range      (PsppSheetSelection            *selection,
142                                                          GtkTreePath                 *start_path,
143                                                          GtkTreePath                 *end_path);
144 struct range_set *pspp_sheet_selection_get_range_set (PsppSheetSelection *selection);
145
146
147 GList *          pspp_sheet_selection_get_selected_columns (PsppSheetSelection            *selection);
148 gint             pspp_sheet_selection_count_selected_columns (PsppSheetSelection            *selection);
149 void             pspp_sheet_selection_select_all_columns (PsppSheetSelection        *selection);
150 void             pspp_sheet_selection_unselect_all_columns (PsppSheetSelection        *selection);
151 void             pspp_sheet_selection_select_column        (PsppSheetSelection        *selection,
152                                                             PsppSheetViewColumn       *column);
153 void             pspp_sheet_selection_select_column_range  (PsppSheetSelection        *selection,
154                                                             PsppSheetViewColumn       *first,
155                                                             PsppSheetViewColumn       *last);
156
157 G_END_DECLS
158
159 #endif /* __PSPP_SHEET_SELECTION_H__ */