gtktexttag.h 6.82 KB
Newer Older
1 2 3
#ifndef GTK_TEXT_TAG_H
#define GTK_TEXT_TAG_H

Manish Singh's avatar
Manish Singh committed
4
#include <glib-object.h>
5
#include <gdk/gdk.h>
Manish Singh's avatar
Manish Singh committed
6 7 8 9
#include <gtk/gtkenums.h>

/* Not needed, retained for compatibility -Yosh */
#include <gtk/gtkobject.h>
10

11 12 13 14 15 16 17
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

typedef struct _GtkTextIter GtkTextIter;
typedef struct _GtkTextTagTable GtkTextTagTable;

18
typedef struct _GtkTextAttributes GtkTextAttributes;
19

20
#define GTK_TYPE_TEXT_TAG            (gtk_text_tag_get_type ())
21 22 23 24 25
#define GTK_TEXT_TAG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_TAG, GtkTextTag))
#define GTK_TEXT_TAG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
#define GTK_IS_TEXT_TAG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_TAG))
#define GTK_IS_TEXT_TAG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_TAG))
#define GTK_TEXT_TAG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_TAG, GtkTextTagClass))
26

27 28
#define GTK_TYPE_TEXT_ATTRIBUTES     (gtk_text_attributes_get_type ())

29 30 31
typedef struct _GtkTextTag GtkTextTag;
typedef struct _GtkTextTagClass GtkTextTagClass;

Havoc Pennington's avatar
Havoc Pennington committed
32 33
struct _GtkTextTag
{
34
  GObject parent_instance;
35 36

  GtkTextTagTable *table;
37 38 39 40 41 42

  char *name;                   /* Name of this tag.  This field is actually
                                 * a pointer to the key from the entry in
                                 * tkxt->tagTable, so it needn't be freed
                                 * explicitly. */
  int priority;         /* Priority of this tag within widget.  0
43 44 45 46 47 48 49 50 51 52 53
                         * means lowest priority.  Exactly one tag
                         * has each integer value between 0 and
                         * numTags-1. */
  /*
   * Information for displaying text with this tag.  The information
   * belows acts as an override on information specified by lower-priority
   * tags.  If no value is specified, then the next-lower-priority tag
   * on the text determins the value.  The text widget itself provides
   * defaults if no tag specifies an override.
   */

54
  GtkTextAttributes *values;
55
  
56 57 58
  /* Flags for whether a given value is set; if a value is unset, then
   * this tag does not affect it.
   */
59 60 61
  guint bg_color_set : 1;
  guint bg_stipple_set : 1;
  guint fg_color_set : 1;
Havoc Pennington's avatar
Havoc Pennington committed
62
  guint scale_set : 1;
63
  guint fg_stipple_set : 1;
64
  guint justification_set : 1;
65
  guint left_margin_set : 1;
66
  guint indent_set : 1;
67
  guint rise_set : 1;
68
  guint strikethrough_set : 1;
69 70 71 72
  guint right_margin_set : 1;
  guint pixels_above_lines_set : 1;
  guint pixels_below_lines_set : 1;
  guint pixels_inside_wrap_set : 1;
73
  guint tabs_set : 1;
74 75 76
  guint underline_set : 1;
  guint wrap_mode_set : 1;
  guint bg_full_height_set : 1;
77
  guint invisible_set : 1;
78
  guint editable_set : 1;
79
  guint language_set : 1;
80 81 82 83 84
  guint pad1 : 1;
  guint pad2 : 1;
  guint pad3 : 1;
};

85
struct _GtkTextTagClass
86
{
87
  GObjectClass parent_class;
88

89 90 91 92
  gboolean (* event) (GtkTextTag        *tag,
                      GObject           *event_object, /* widget, canvas item, whatever */
                      GdkEvent          *event,        /* the event itself */
                      const GtkTextIter *iter);        /* location of event in buffer */
93

94 95 96 97 98
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
99 100
};

101
GType        gtk_text_tag_get_type     (void) G_GNUC_CONST;
102
GtkTextTag  *gtk_text_tag_new          (const gchar       *name);
103
gint         gtk_text_tag_get_priority (GtkTextTag        *tag);
104
void         gtk_text_tag_set_priority (GtkTextTag        *tag,
105
                                        gint               priority);
106
gboolean     gtk_text_tag_event        (GtkTextTag        *tag,
107
                                        GObject           *event_object,
108 109
                                        GdkEvent          *event,
                                        const GtkTextIter *iter);
110

111 112 113 114 115 116 117 118
/*
 * Style object created by folding a set of tags together
 */

typedef struct _GtkTextAppearance GtkTextAppearance;

struct _GtkTextAppearance
{
Soren Sandmann's avatar
Soren Sandmann committed
119
  /*< public >*/
120 121 122 123 124
  GdkColor bg_color;
  GdkColor fg_color;
  GdkBitmap *bg_stipple;
  GdkBitmap *fg_stipple;

125 126
  /* super/subscript rise, can be negative */
  gint rise;
127

Soren Sandmann's avatar
Soren Sandmann committed
128
  /*< private >*/
129 130 131 132
  /* I'm not sure this can really be used without breaking some things
   * an app might do :-/
   */
  gpointer padding1;
Soren Sandmann's avatar
Soren Sandmann committed
133 134

  /*< public >*/
135
  guint underline : 4;          /* PangoUnderline */
136
  guint strikethrough : 1;
137 138 139 140

  /* Whether to use background-related values; this is irrelevant for
   * the values struct when in a tag, but is used for the composite
   * values struct; it's true if any of the tags being composited
141 142
   * had background stuff set.
   */
143
  guint draw_bg : 1;
144 145
  
  /* These are only used when we are actually laying out and rendering
146
   * a paragraph; not when a GtkTextAppearance is part of a
147
   * GtkTextAttributes.
148 149
   */
  guint inside_selection : 1;
150
  guint is_text : 1;
151

Soren Sandmann's avatar
Soren Sandmann committed
152
  /*< private >*/
153 154 155 156
  guint pad1 : 1;
  guint pad2 : 1;
  guint pad3 : 1;
  guint pad4 : 1;
157 158
};

159
struct _GtkTextAttributes
160
{
Soren Sandmann's avatar
Soren Sandmann committed
161
  /*< private >*/
162 163
  guint refcount;

Soren Sandmann's avatar
Soren Sandmann committed
164
  /*< public >*/
165
  GtkTextAppearance appearance;
166

167
  GtkJustification justification;
168
  GtkTextDirection direction;
169

170
  /* Individual chunks of this can be set/unset as a group */
171
  PangoFontDescription *font;
172

Havoc Pennington's avatar
Havoc Pennington committed
173 174
  gdouble font_scale;
  
175
  gint left_margin;
176

177
  gint indent;  
178

179 180 181 182 183 184 185 186
  gint right_margin;

  gint pixels_above_lines;

  gint pixels_below_lines;

  gint pixels_inside_wrap;

187
  PangoTabArray *tabs;
188 189 190 191

  GtkWrapMode wrap_mode;        /* How to handle wrap-around for this tag.
                                 * Must be GTK_WRAPMODE_CHAR,
                                 * GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
192 193
                                 */

194
  PangoLanguage *language;
195

Soren Sandmann's avatar
Soren Sandmann committed
196
  /*< private >*/
197 198 199 200
  /* I'm not sure this can really be used without breaking some things
   * an app might do :-/
   */
  gpointer padding1;
Soren Sandmann's avatar
Soren Sandmann committed
201 202

  /*< public >*/
203 204 205 206
  /* hide the text  */
  guint invisible : 1;

  /* Background is fit to full line height rather than
207 208
   * baseline +/- ascent/descent (font height)
   */
209
  guint bg_full_height : 1;
210

211 212 213 214 215 216
  /* can edit this text */
  guint editable : 1;

  /* colors are allocated etc. */
  guint realized : 1;

Soren Sandmann's avatar
Soren Sandmann committed
217
  /*< private >*/
218 219 220 221 222 223
  guint pad1 : 1;
  guint pad2 : 1;
  guint pad3 : 1;
  guint pad4 : 1;
};

224 225 226 227 228 229 230
GtkTextAttributes* gtk_text_attributes_new         (void);
GtkTextAttributes* gtk_text_attributes_copy        (GtkTextAttributes *src);
void               gtk_text_attributes_copy_values (GtkTextAttributes *src,
                                                    GtkTextAttributes *dest);
void               gtk_text_attributes_unref       (GtkTextAttributes *values);
void               gtk_text_attributes_ref         (GtkTextAttributes *values);

Matthias Clasen's avatar
Matthias Clasen committed
231
GType              gtk_text_attributes_get_type    (void) G_GNUC_CONST;
232

233

234 235 236 237 238 239
#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif