summaryrefslogtreecommitdiff
path: root/eel/eel-editable-label.h
blob: 249a3367b7a5dc8421298aad95582dc97f690bcc (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
/* GTK - The GIMP Toolkit
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that 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 library; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/*
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
 */

#ifndef __EEL_EDITABLE_LABEL_H__
#define __EEL_EDITABLE_LABEL_H__


#include <gdk/gdk.h>
#include <gtk/gtk.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#define EEL_TYPE_EDITABLE_LABEL eel_editable_label_get_type()
#define EEL_EDITABLE_LABEL(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_EDITABLE_LABEL, EelEditableLabel))
#define EEL_EDITABLE_LABEL_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_EDITABLE_LABEL, EelEditableLabelClass))
#define EEL_IS_EDITABLE_LABEL(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_EDITABLE_LABEL))
#define EEL_IS_EDITABLE_LABEL_CLASS(klass) \
  (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_EDITABLE_LABEL))
#define EEL_EDITABLE_LABEL_GET_CLASS(obj) \
  (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_EDITABLE_LABEL, EelEditableLabelClass))

    typedef struct _EelEditableLabel       EelEditableLabel;
    typedef struct _EelEditableLabelClass  EelEditableLabelClass;

    typedef struct _EelEditableLabelSelectionInfo EelEditableLabelSelectionInfo;

    struct _EelEditableLabel
    {
        GtkMisc misc;

        /*< private >*/
        guint   jtype : 2;
        guint   wrap : 1;
        guint   overwrite_mode : 1;
        guint   draw_outline : 1;
        PangoWrapMode  wrap_mode;

        gchar  *text;
        int text_size; /* allocated size, in bytes */
        int n_bytes;	 /* length in use (not including terminating zero), in bytes */

        PangoLayout *layout;
        guint        layout_includes_preedit : 1;

        int selection_anchor; /* cursor pos, byte index */
        int selection_end; /* byte index */

        GtkWidget *popup_menu;

        GtkIMContext *im_context;
        gboolean need_im_reset;
        int preedit_length;	/* length of preedit string, in bytes */
        int preedit_cursor;	/* offset of cursor within preedit string, in chars */

        GdkGC *primary_cursor_gc;
        GdkGC *secondary_cursor_gc;

        PangoFontDescription *font_desc;
    };

    struct _EelEditableLabelClass
    {
        GtkMiscClass parent_class;

        void (* move_cursor)        (EelEditableLabel  *label,
                                     GtkMovementStep    step,
                                     gint               count,
                                     gboolean           extend_selection);
        void (* insert_at_cursor)   (EelEditableLabel  *label,
                                     const gchar       *str);
        void (* delete_from_cursor) (EelEditableLabel  *label,
                                     GtkDeleteType      type,
                                     gint               count);
        void (* cut_clipboard)      (EelEditableLabel  *label);
        void (* copy_clipboard)     (EelEditableLabel  *label);
        void (* paste_clipboard)    (EelEditableLabel  *label);
        void (* toggle_overwrite)   (EelEditableLabel  *label);

        /* Hook to customize right-click popup for selectable labels */
        void (* populate_popup)   (EelEditableLabel  *label,
                                   GtkMenu           *menu);
    };

    GType                 eel_editable_label_get_type          (void) G_GNUC_CONST;
    GtkWidget*            eel_editable_label_new                  (const char       *str);
    void                  eel_editable_label_set_text             (EelEditableLabel *label,
            const char       *str);
    const gchar* eel_editable_label_get_text(EelEditableLabel* label);
    void                  eel_editable_label_set_justify          (EelEditableLabel *label,
            GtkJustification  jtype);
    GtkJustification      eel_editable_label_get_justify          (EelEditableLabel *label);
    void                  eel_editable_label_set_line_wrap        (EelEditableLabel *label,
            gboolean          wrap);
    void                  eel_editable_label_set_line_wrap_mode   (EelEditableLabel *label,
            PangoWrapMode     mode);
    gboolean              eel_editable_label_get_line_wrap        (EelEditableLabel *label);
    void                  eel_editable_label_set_draw_outline     (EelEditableLabel *label,
            gboolean          wrap);
    void                  eel_editable_label_select_region        (EelEditableLabel *label,
            gint              start_offset,
            gint              end_offset);
    gboolean              eel_editable_label_get_selection_bounds (EelEditableLabel *label,
            gint             *start,
            gint             *end);
    PangoLayout *         eel_editable_label_get_layout           (EelEditableLabel *label);
    void                  eel_editable_label_get_layout_offsets   (EelEditableLabel *label,
            gint             *x,
            gint             *y);
    PangoFontDescription *eel_editable_label_get_font_description (EelEditableLabel *label);
    void                  eel_editable_label_set_font_description (EelEditableLabel *label,
            const PangoFontDescription *desc);

#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif /* __EEL_EDITABLE_LABEL_H__ */