GTK+ Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gtk/gtk.h> struct GtkText; struct GtkTextFont; struct GtkPropertyMark; GtkWidget* gtk_text_new (GtkAdjustment *hadj, GtkAdjustment *vadj); void gtk_text_set_editable (GtkText *text, gboolean editable); void gtk_text_set_word_wrap (GtkText *text, gint word_wrap); void gtk_text_set_line_wrap (GtkText *text, gint line_wrap); void gtk_text_set_adjustments (GtkText *text, GtkAdjustment *hadj, GtkAdjustment *vadj); void gtk_text_set_point (GtkText *text, guint index); guint gtk_text_get_point (GtkText *text); guint gtk_text_get_length (GtkText *text); void gtk_text_freeze (GtkText *text); void gtk_text_thaw (GtkText *text); void gtk_text_insert (GtkText *text, GdkFont *font, GdkColor *fore, GdkColor *back, const char *chars, gint length); gint gtk_text_backward_delete (GtkText *text, guint nchars); gint gtk_text_forward_delete (GtkText *text, guint nchars); #define GTK_TEXT_INDEX (t, index) |
"hadjustment" GtkAdjustment : Read / Write "vadjustment" GtkAdjustment : Read / Write "line_wrap" gboolean : Read / Write "word_wrap" gboolean : Read / Write |
"set-scroll-adjustments" void user_function (GtkText *text, GtkAdjustment arg1, GtkAdjustment arg2, gpointer user_data); |
A GtkText widget allows one to display any given text and manipulate it by deleting from one point to another, selecting a region, and various other functions as outlined below. It is inherited from GtkEditable.
struct GtkText; |
Most of the GtkText struct members should not be accessed directly. Listed below are a few exceptions and how to use them.
GtkAdjustment *hadj; | Allows you to see the state of an attached horizontal GtkScrollbar. See GtkAdjustment for more info. This allows easy access to the adjustments of the GtkText struct without having to keep track of ones that you initialize at widget creation. |
GtkAdjustment *vadj; | Same as hadj except it involves the vertical GtkScrollbar. |
struct GtkPropertyMark { /* Position in list. */ GList* property; /* Offset into that property. */ guint offset; /* Current index. */ guint index; }; |
Internal GtkText data type. Should not be access directly.
GtkWidget* gtk_text_new (GtkAdjustment *hadj, GtkAdjustment *vadj); |
Creates a new GtkText widget, initialized with the given pointers to GtkAdjustments. These pointers can be used to track the viewing position of the GtkText widget. Passing NULL to either or both of them will make the GtkText create it's own. You can set these later with the function gtk_text_set_adjustment()
hadj : | horizontal adjustment. |
vadj : | vertical adjustment. |
Returns : | the new GtkText widget. |
void gtk_text_set_editable (GtkText *text, gboolean editable); |
Set whether the GtkText widget can be edited by the user or not. This still allows you the programmer to make changes with the various GtkText functions.
text : | the GtkText widget |
editable : | TRUE makes it editable, FALSE makes it immutable by the user |
void gtk_text_set_word_wrap (GtkText *text, gint word_wrap); |
Sets whether the GtkText widget wraps words down to the next line if it can't be completed on the current line.
text : | the GtkText widget |
word_wrap : | TRUE makes it word wrap, FALSE disables word wrapping |
void gtk_text_set_line_wrap (GtkText *text, gint line_wrap); |
Controls how GtkText handles long lines of continuous text. If line wrap is on, the line is broken when it reaches the extent of the GtkText widget viewing area and the rest is displayed on the next line. If it is not set, the line continues regardless size of current viewing area. Similar to word wrap but it disregards word boundaries.
text : | the GtkText widget |
line_wrap : | TRUE turns line wrap on, FALSE turns it off |
void gtk_text_set_adjustments (GtkText *text, GtkAdjustment *hadj, GtkAdjustment *vadj); |
Allows you to set GtkAdjustment pointers which in turn allows you to keep track of the viewing position of the GtkText widget.
text : | the GtkText widget |
hadj : | the horizontal adjustment |
vadj : | the vertical adjustment |
void gtk_text_set_point (GtkText *text, guint index); |
Sets the cursor at the given point. In this case a point constitutes the number of characters from the extreme upper left corner of the GtkText widget.
text : | the GtkText widget |
index : | the number of characters from the upper left corner |
guint gtk_text_get_point (GtkText *text); |
Gets the current position of the cursor as the number of characters from the upper left corner of the GtkText widget.
text : | the GtkText widget |
Returns : | the number of characters from the upper left corner |
guint gtk_text_get_length (GtkText *text); |
Returns the length of the all the text contained within the GtkText widget; disregards current point position.
text : | the GtkText widget |
Returns : | the length of the text |
void gtk_text_freeze (GtkText *text); |
Freezes the GtkText widget which disallows redrawing of the widget until it is thawed. This is useful if a large number of changes are going to made to the text within the widget, reducing the amount of flicker seen by the user.
text : | the GtkText widget |
void gtk_text_thaw (GtkText *text); |
Allows the GtkText widget to be redrawn again by GTK.
text : | the GtkText widget |
void gtk_text_insert (GtkText *text, GdkFont *font, GdkColor *fore, GdkColor *back, const char *chars, gint length); |
Inserts given text into the GtkText widget with the given properties as outlined below.
gint gtk_text_backward_delete (GtkText *text, guint nchars); |
Deletes from the current point position backward the given number of characters.
text : | the GtkText widget |
nchars : | the number of characters to delete |
Returns : | TRUE if the operation was successful, otherwise returns FALSE |
gint gtk_text_forward_delete (GtkText *text, guint nchars); |
Deletes from the current point position forward the given number of characters.
text : | the GtkText widget |
nchars : | the number of characters to delete |
Returns : | TRUE if the operation was successful, otherwise returns FALSE |
Used by the GtkText widget to keep track of the size of it's horizontal text.
Used by the GtkText widget to keep track of the size of it's vertical text.
Boolean value indicating whether line wrap is enabled or not.
Boolean value indicated whether word wrap is enabled or not.
void user_function (GtkText *text, GtkAdjustment arg1, GtkAdjustment arg2, gpointer user_data); |
text : | the object which received the signal. |
arg1 : | |
arg2 : | |
user_data : | user data set when the signal handler was connected. |