summaryrefslogtreecommitdiff
path: root/endless/eosflexygrid.h
blob: 43ceca746559712a47413e462ff36c1fecd75b1f (plain)
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
/* Copyright 2013 Endless Mobile, Inc. */

#ifndef EOS_FLEXY_GRID_H
#define EOS_FLEXY_GRID_H

#include "eostypes.h"

#include <gtk/gtk.h>

G_BEGIN_DECLS

#define EOS_TYPE_FLEXY_GRID                     (eos_flexy_grid_get_type ())
#define EOS_FLEXY_GRID(obj)                     (G_TYPE_CHECK_INSTANCE_CAST ((obj), EOS_TYPE_FLEXY_GRID, EosFlexyGrid))
#define EOS_IS_FLEXY_GRID(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EOS_TYPE_FLEXY_GRID))
#define EOS_FLEXY_GRID_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST ((klass), EOS_TYPE_FLEXY_GRID, EosFlexyGridClass))
#define EOS_IS_FLEXY_GRID_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE ((klass), EOS_TYPE_FLEXY_GRID))
#define EOS_FLEXY_GRID_GET_CLASS(obj)           (G_TYPE_INSTANCE_GET_CLASS ((obj), EOS_TYPE_FLEXY_GRID, EosFlexyGridClass))

#define EOS_TYPE_FLEXY_GRID_CELL                (eos_flexy_grid_cell_get_type ())
#define EOS_FLEXY_GRID_CELL(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), EOS_TYPE_FLEXY_GRID_CELL, EosFlexyGridCell))
#define EOS_IS_FLEXY_GRID_CELL(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EOS_TYPE_FLEXY_GRID_CELL))
#define EOS_FLEXY_GRID_CELL_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), EOS_TYPE_FLEXY_GRID_CELL, EosFlexyGridCellClass))
#define EOS_IS_FLEXY_GRID_CELL_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), EOS_TYPE_FLEXY_GRID_CELL))
#define EOS_FLEXY_GRID_CELL_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), EOS_TYPE_FLEXY_GRID_CELL, EosFlexyGridCellClass))

/**
 * EOS_STYLE_CLASS_FLEXY_GRID:
 *
 * A CSS class to match a grid with flexible layout, used by #EosFlexyGrid.
 */
#define EOS_STYLE_CLASS_FLEXY_GRID      "flexy-grid"
/**
 * EOS_STYLE_CLASS_FLEXY_GRID_CELL:
 *
 * A CSS class to match a cell inside a grid with flexible layout, used by
 * #EosFlexyGrid.
 */
#define EOS_STYLE_CLASS_FLEXY_GRID_CELL "flexy-grid-cell"

/**
 * EosFlexyGrid:
 *
 * This structure contains no public members.
 */
typedef struct _EosFlexyGrid            EosFlexyGrid;
typedef struct _EosFlexyGridClass       EosFlexyGridClass;

/**
 * EosFlexyGridCell:
 *
 * This structure contains no public members.
 */
typedef struct _EosFlexyGridCell        EosFlexyGridCell;
typedef struct _EosFlexyGridCellClass   EosFlexyGridCellClass;

/**
 * EosFlexyGridSortFunc:
 * @cell_a: first cell to compare
 * @cell_b: second cell to compare
 * @user_data: data passed to eos_flexy_grid_set_sort_func()
 *
 * Type for functions that determine the sort order of two cells inside the
 * grid.
 *
 * Returns: -1 if @cell_a should come before @cell_b, 1 if @cell_a should come
 * after @cell_b, or 0 if @cell_a and @cell_b are identical.
 */
typedef gint (* EosFlexyGridSortFunc) (EosFlexyGridCell *cell_a,
                                       EosFlexyGridCell *cell_b,
                                       gpointer          user_data);

struct _EosFlexyGrid
{
  /*< private >*/
  GtkContainer parent_instance;

  gpointer priv;
};

struct _EosFlexyGridClass
{
  /*< private >*/
  GtkContainerClass parent_class;

  void (* cell_selected)  (EosFlexyGrid     *grid,
                           EosFlexyGridCell *cell);
  void (* cell_activated) (EosFlexyGrid     *grid,
                           EosFlexyGridCell *cell);

  gpointer _padding[8];
};

EOS_SDK_ALL_API_VERSIONS
GType eos_flexy_grid_get_type (void) G_GNUC_CONST;

EOS_SDK_ALL_API_VERSIONS
GtkWidget *             eos_flexy_grid_new                      (void);
EOS_SDK_ALL_API_VERSIONS
void                    eos_flexy_grid_set_cell_size            (EosFlexyGrid         *grid,
                                                                 int                   size);
EOS_SDK_ALL_API_VERSIONS
guint                   eos_flexy_grid_get_cell_size            (EosFlexyGrid         *grid);
EOS_SDK_ALL_API_VERSIONS
void                    eos_flexy_grid_set_cell_spacing         (EosFlexyGrid         *grid,
                                                                 int                   spacing);
EOS_SDK_ALL_API_VERSIONS
guint                   eos_flexy_grid_get_cell_spacing         (EosFlexyGrid         *grid);
EOS_SDK_ALL_API_VERSIONS
void                    eos_flexy_grid_insert                   (EosFlexyGrid         *grid,
                                                                 GtkWidget            *child,
                                                                 int                   index_);
EOS_SDK_ALL_API_VERSIONS
void                    eos_flexy_grid_set_sort_func            (EosFlexyGrid         *grid,
                                                                 EosFlexyGridSortFunc  sort_func,
                                                                 gpointer              data,
                                                                 GDestroyNotify        notify);
EOS_SDK_ALL_API_VERSIONS
EosFlexyGridCell *      eos_flexy_grid_get_cell_at_coords       (EosFlexyGrid         *grid,
                                                                 double                x_pos,
                                                                 double                y_pos);

struct _EosFlexyGridCell
{
  /*< private >*/
  GtkBin parent_instance;

  gpointer priv;
};

struct _EosFlexyGridCellClass
{
  /*< private >*/
  GtkBinClass parent_class;

  gpointer _padding[8];
};

EOS_SDK_ALL_API_VERSIONS
GType eos_flexy_grid_cell_get_type (void) G_GNUC_CONST;

EOS_SDK_ALL_API_VERSIONS
GtkWidget *     eos_flexy_grid_cell_new                 (void);
EOS_SDK_ALL_API_VERSIONS
void            eos_flexy_grid_cell_set_shape           (EosFlexyGridCell *cell,
                                                         EosFlexyShape     shape);
EOS_SDK_ALL_API_VERSIONS
EosFlexyShape   eos_flexy_grid_cell_get_shape           (EosFlexyGridCell *cell);

G_END_DECLS

#endif /* EOS_FLEXY_GRID_H */