1 /* GTK - The GIMP Toolkit 2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library 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 GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library; if not, write to the Free 16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 /* 20 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS 21 * file for a list of people on the GTK+ Team. See the ChangeLog 22 * files for a list of changes. These files are distributed with 23 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 24 */ 25 26 #ifndef __EEL_EDITABLE_LABEL_H__ 27 #define __EEL_EDITABLE_LABEL_H__ 28 29 30 #include <gdk/gdk.h> 31 #include <gtk/gtk.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif /* __cplusplus */ 36 37 #define EEL_TYPE_EDITABLE_LABEL eel_editable_label_get_type() 38 #define EEL_EDITABLE_LABEL(obj) \ 39 (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_EDITABLE_LABEL, EelEditableLabel)) 40 #define EEL_EDITABLE_LABEL_CLASS(klass) \ 41 (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_EDITABLE_LABEL, EelEditableLabelClass)) 42 #define EEL_IS_EDITABLE_LABEL(obj) \ 43 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_EDITABLE_LABEL)) 44 #define EEL_IS_EDITABLE_LABEL_CLASS(klass) \ 45 (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_EDITABLE_LABEL)) 46 #define EEL_EDITABLE_LABEL_GET_CLASS(obj) \ 47 (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_EDITABLE_LABEL, EelEditableLabelClass)) 48 49 typedef struct _EelEditableLabel EelEditableLabel; 50 typedef struct _EelEditableLabelClass EelEditableLabelClass; 51 52 typedef struct _EelEditableLabelSelectionInfo EelEditableLabelSelectionInfo; 53 54 struct _EelEditableLabel 55 { 56 GtkWidget widget; 57 58 /*< private >*/ 59 guint jtype : 2; 60 guint wrap : 1; 61 guint overwrite_mode : 1; 62 guint draw_outline : 1; 63 PangoWrapMode wrap_mode; 64 65 gchar *text; 66 int text_size; /* allocated size, in bytes */ 67 int n_bytes; /* length in use (not including terminating zero), in bytes */ 68 69 PangoLayout *layout; 70 guint layout_includes_preedit : 1; 71 72 int selection_anchor; /* cursor pos, byte index */ 73 int selection_end; /* byte index */ 74 75 GtkWidget *popup_menu; 76 77 GtkIMContext *im_context; 78 gboolean need_im_reset; 79 int preedit_length; /* length of preedit string, in bytes */ 80 int preedit_cursor; /* offset of cursor within preedit string, in chars */ 81 82 PangoFontDescription *font_desc; 83 }; 84 85 struct _EelEditableLabelClass 86 { 87 GtkWidgetClass parent_class; 88 89 90 void (* move_cursor) (EelEditableLabel *label, 91 GtkMovementStep step, 92 gint count, 93 gboolean extend_selection); 94 void (* insert_at_cursor) (EelEditableLabel *label, 95 const gchar *str); 96 void (* delete_from_cursor) (EelEditableLabel *label, 97 GtkDeleteType type, 98 gint count); 99 void (* cut_clipboard) (EelEditableLabel *label); 100 void (* copy_clipboard) (EelEditableLabel *label); 101 void (* paste_clipboard) (EelEditableLabel *label); 102 void (* toggle_overwrite) (EelEditableLabel *label); 103 104 /* Hook to customize right-click popup for selectable labels */ 105 void (* populate_popup) (EelEditableLabel *label, 106 GtkMenu *menu); 107 }; 108 109 GType eel_editable_label_get_type (void) G_GNUC_CONST; 110 GtkWidget* eel_editable_label_new (const char *str); 111 void eel_editable_label_set_text (EelEditableLabel *label, 112 const char *str); 113 const gchar* eel_editable_label_get_text(EelEditableLabel* label); 114 void eel_editable_label_set_justify (EelEditableLabel *label, 115 GtkJustification jtype); 116 GtkJustification eel_editable_label_get_justify (EelEditableLabel *label); 117 void eel_editable_label_set_line_wrap (EelEditableLabel *label, 118 gboolean wrap); 119 void eel_editable_label_set_line_wrap_mode (EelEditableLabel *label, 120 PangoWrapMode mode); 121 gboolean eel_editable_label_get_line_wrap (EelEditableLabel *label); 122 void eel_editable_label_set_draw_outline (EelEditableLabel *label, 123 gboolean wrap); 124 void eel_editable_label_select_region (EelEditableLabel *label, 125 gint start_offset, 126 gint end_offset); 127 gboolean eel_editable_label_get_selection_bounds (EelEditableLabel *label, 128 gint *start, 129 gint *end); 130 PangoLayout * eel_editable_label_get_layout (EelEditableLabel *label); 131 void eel_editable_label_get_layout_offsets (EelEditableLabel *label, 132 gint *x, 133 gint *y); 134 PangoFontDescription *eel_editable_label_get_font_description (EelEditableLabel *label); 135 void eel_editable_label_set_font_description (EelEditableLabel *label, 136 const PangoFontDescription *desc); 137 138 #ifdef __cplusplus 139 } 140 #endif /* __cplusplus */ 141 142 143 #endif /* __EEL_EDITABLE_LABEL_H__ */ 144