summaryrefslogtreecommitdiffstats
path: root/src/st/st-widget.h
blob: f00c98733f67cfc7246d6a705022dfd57e07a66f (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
 * st-widget.h: Base class for St actors
 *
 * Copyright 2007 OpenedHand
 * Copyright 2008, 2009 Intel Corporation.
 * Copyright 2009, 2010 Red Hat, Inc.
 * Copyright 2009 Abderrahim Kitouni
 * Copyright 2010 Florian Müllner
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU Lesser General Public License,
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#if !defined(ST_H_INSIDE) && !defined(ST_COMPILATION)
#error "Only <st/st.h> can be included directly.h"
#endif

#ifndef __ST_WIDGET_H__
#define __ST_WIDGET_H__

#include <clutter/clutter.h>
#include <st/st-types.h>
#include <st/st-theme.h>
#include <st/st-theme-node.h>

G_BEGIN_DECLS

#define ST_TYPE_WIDGET                 (st_widget_get_type ())
G_DECLARE_DERIVABLE_TYPE (StWidget, st_widget, ST, WIDGET, ClutterActor)

/**
 * StDirectionType:
 * @ST_DIR_TAB_FORWARD: Move forward.
 * @ST_DIR_TAB_BACKWARD: Move backward.
 * @ST_DIR_UP: Move up.
 * @ST_DIR_DOWN: Move down.
 * @ST_DIR_LEFT: Move left.
 * @ST_DIR_RIGHT: Move right.
 *
 * Enumeration for focus direction.
 */
typedef enum
{
  ST_DIR_TAB_FORWARD,
  ST_DIR_TAB_BACKWARD,
  ST_DIR_UP,
  ST_DIR_DOWN,
  ST_DIR_LEFT,
  ST_DIR_RIGHT,
} StDirectionType;

typedef struct _StWidgetClass          StWidgetClass;

/**
 * StWidgetClass:
 *
 * Base class for stylable actors.
 */
struct _StWidgetClass
{
  /*< private >*/
  ClutterActorClass parent_class;

  /* signals */
  void     (* style_changed)       (StWidget         *self);
  void     (* popup_menu)          (StWidget         *self);

  /* vfuncs */

  /**
   * StWidgetClass::navigate_focus:
   * @self: the "top level" container
   * @from: (nullable): the actor that the focus is coming from
   * @direction: the direction focus is moving in
   */
  gboolean (* navigate_focus)      (StWidget         *self,
                                    ClutterActor     *from,
                                    StDirectionType   direction);
  GType    (* get_accessible_type) (void);

  GList *  (* get_focus_chain)     (StWidget         *widget);
};

void                  st_widget_set_style_pseudo_class    (StWidget        *actor,
                                                           const gchar     *pseudo_class_list);
void                  st_widget_add_style_pseudo_class    (StWidget        *actor,
                                                           const gchar     *pseudo_class);
void                  st_widget_remove_style_pseudo_class (StWidget        *actor,
                                                           const gchar     *pseudo_class);
const gchar *         st_widget_get_style_pseudo_class    (StWidget        *actor);
gboolean              st_widget_has_style_pseudo_class    (StWidget        *actor,
                                                           const gchar     *pseudo_class);

void                  st_widget_set_style_class_name      (StWidget        *actor,
                                                           const gchar     *style_class_list);
void                  st_widget_add_style_class_name      (StWidget        *actor,
                                                           const gchar     *style_class);
void                  st_widget_remove_style_class_name   (StWidget        *actor,
                                                           const gchar     *style_class);
const gchar *         st_widget_get_style_class_name      (StWidget        *actor);
gboolean              st_widget_has_style_class_name      (StWidget        *actor,
                                                           const gchar     *style_class);

void                  st_widget_set_style                 (StWidget        *actor,
                                                           const gchar     *style);
const gchar *         st_widget_get_style                 (StWidget        *actor);
void                  st_widget_set_track_hover           (StWidget        *widget,
                                                           gboolean         track_hover);
gboolean              st_widget_get_track_hover           (StWidget        *widget);
void                  st_widget_set_hover                 (StWidget        *widget,
                                                           gboolean         hover);
void                  st_widget_sync_hover                (StWidget        *widget);
gboolean              st_widget_get_hover                 (StWidget        *widget);
void                  st_widget_popup_menu                (StWidget        *self);

void                  st_widget_ensure_style              (StWidget        *widget);

void                  st_widget_set_can_focus             (StWidget        *widget,
                                                           gboolean         can_focus);
gboolean              st_widget_get_can_focus             (StWidget        *widget);
gboolean              st_widget_navigate_focus            (StWidget        *widget,
                                                           ClutterActor    *from,
                                                           StDirectionType  direction,
                                                           gboolean         wrap_around);

ClutterActor *        st_widget_get_label_actor           (StWidget        *widget);
void                  st_widget_set_label_actor           (StWidget        *widget,
                                                           ClutterActor    *label);

/* Only to be used by sub-classes of StWidget */
void                  st_widget_style_changed             (StWidget        *widget);
StThemeNode *         st_widget_get_theme_node            (StWidget        *widget);
StThemeNode *         st_widget_peek_theme_node           (StWidget        *widget);

GList *               st_widget_get_focus_chain           (StWidget        *widget);
void                  st_widget_paint_background          (StWidget            *widget,
                                                           ClutterPaintContext *paint_context);

/* debug methods */
char  *st_describe_actor       (ClutterActor *actor);

/* accessibility methods */
void                  st_widget_set_accessible_role      (StWidget    *widget,
                                                          AtkRole      role);
AtkRole               st_widget_get_accessible_role      (StWidget    *widget);
void                  st_widget_add_accessible_state     (StWidget    *widget,
                                                          AtkStateType state);
void                  st_widget_remove_accessible_state  (StWidget    *widget,
                                                          AtkStateType state);
void                  st_widget_set_accessible_name      (StWidget    *widget,
                                                          const gchar *name);
const gchar *         st_widget_get_accessible_name      (StWidget    *widget);
void                  st_widget_set_accessible           (StWidget    *widget,
                                                          AtkObject   *accessible);
G_END_DECLS

#endif /* __ST_WIDGET_H__ */