gtkmm: Gtk::TextView Class Reference

Multi-line text editing widget. More...

Inheritance diagram for Gtk::TextView:
Collaboration diagram for Gtk::TextView:

List of all members.

Public Member Functions

virtual ~TextView ()
GtkTextView* gobj ()
 Provides access to the underlying C GtkObject.

const GtkTextView* gobj () const
 Provides access to the underlying C GtkObject.

 TextView ()
 TextView (const Glib::RefPtr< TextBuffer >& buffer)
void set_buffer (const Glib::RefPtr< TextBuffer >& buffer)
 Sets buffer as the buffer being displayed by text_view.

Glib::RefPtr< TextBufferget_buffer ()
 Returns the Gtk::TextBuffer being displayed by this text view.

Glib::RefPtr< const TextBufferget_buffer () const
 Returns the Gtk::TextBuffer being displayed by this text view.

bool scroll_to (TextBuffer::iterator& iter, double within_margin=0)
 Scrolls the TextView so that iter is on the screen, by scrolling the minimal distance to get the mark onscreen, possibly not scrolling at all.

bool scroll_to (TextBuffer::iterator& iter, double within_margin, double xalign, double yalign)
 Scrolls the TextView so that iter is on the screen, in the position indicated by xalign and yalign, possibly not scrolling at all.

void scroll_to (const Glib::RefPtr< TextBuffer::Mark >& mark, double within_margin=0)
 Scrolls text_view so that mark is on the screen, by scrolling the minimal distance to get the mark onscreen, possibly not scrolling at all.

void scroll_to (const Glib::RefPtr< TextBuffer::Mark >& mark, double within_margin, double xalign, double yalign)
 Scrolls the TextView so that iter is on the screen, in the position indicated by xalign and yalign, possibly not scrolling at all.

bool move_mark_onscreen (const Glib::RefPtr< TextBuffer::Mark >& mark)
 Moves a mark within the buffer so that it's located within the currently-visible text area.

bool place_cursor_onscreen ()
 Moves the cursor to the currently visible region of the buffer, it it isn't there already.

void get_visible_rect (Gdk::Rectangle& visible_rect) const
 Fills visible_rect with the currently-visible region of the buffer, in buffer coordinates.

void set_cursor_visible (bool setting=true)
 Toggles whether the insertion point is displayed.

bool get_cursor_visible () const
 Find out whether the cursor is being displayed.

void get_cursor_locations (const TextBuffer::iterator& iter, Gdk::Rectangle& strong, Gdk::Rectangle& weak) const
void get_iter_location (const TextBuffer::iterator& iter, Gdk::Rectangle& location) const
 Gets a rectangle which roughly contains the character at iter.

void get_iter_at_location (TextBuffer::iterator& iter, int x, int y) const
 Retrieves the iterator at buffer coordinates x and y.

void get_iter_at_position (TextBuffer::iterator& iter, int& trailing, int x, int y) const
 Retrieves the iterator pointing to the character at buffer coordinates x and y.

void get_line_yrange (const TextBuffer::iterator& iter, int& y, int& height) const
 Gets the y coordinate of the top of the line containing iter, and the height of the line.

void get_line_at_y (TextBuffer::iterator& target_iter, int y, int& line_top) const
 Gets the Gtk::TextIter at the start of the line containing the coordinate y.

void buffer_to_window_coords (TextWindowType win, int buffer_x, int buffer_y, int& window_x, int& window_y) const
 Converts coordinate ( buffer_x, buffer_y) to coordinates for the window win, and stores the result in ( window_x, window_y).

void window_to_buffer_coords (TextWindowType win, int window_x, int window_y, int& buffer_x, int& buffer_y) const
 Converts coordinates on the window identified by win to buffer coordinates, storing the result in ( buffer_x, buffer_y).

Glib::RefPtr< Gdk::Windowget_window (TextWindowType win)
 Retrieves the Gdk::Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer.

Glib::RefPtr< const Gdk::Windowget_window (TextWindowType win) const
 Retrieves the Gdk::Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer.

TextWindowType get_window_type (const Glib::RefPtr< Gdk::Window >& window)
 Usually used to find out which window an event corresponds to.

void set_border_window_size (TextWindowType type, int size)
 Sets the width of Gtk::TEXT_WINDOW_LEFT or Gtk::TEXT_WINDOW_RIGHT, or the height of Gtk::TEXT_WINDOW_TOP or Gtk::TEXT_WINDOW_BOTTOM.

int get_border_window_size (TextWindowType type) const
 Gets the width of the specified border window.

bool forward_display_line (TextBuffer::iterator& iter)
 Moves the given iter forward by one display (wrapped) line.

bool backward_display_line (TextBuffer::iterator& iter)
 Moves the given iter backward by one display (wrapped) line.

bool forward_display_line_end (TextBuffer::iterator& iter)
 Moves the given iter forward to the next display line end.

bool backward_display_line_start (TextBuffer::iterator& iter)
 Moves the given iter backward to the next display line start.

bool starts_display_line (const TextBuffer::iterator& iter)
 Determines whether iter is at the start of a display line.

bool move_visually (TextBuffer::iterator& iter, int count)
 Move the iterator a given number of characters visually, treating it as the strong cursor position.

bool im_context_filter_keypress (GdkEventKey* event)
 Allow the Gtk::TextView input method to internally handle key press and release events.

void reset_im_context ()
 Reset the input method context of the text view if needed.

void add_child_at_anchor (Widget& child, const Glib::RefPtr< TextBuffer::ChildAnchor >& anchor)
 Adds a child widget in the text buffer, at the given anchor.

void add_child_in_window (Widget& child, TextWindowType which_window, int xpos, int ypos)
 Adds a child at fixed coordinates in one of the text widget's windows.

void move_child (Widget& child, int xpos, int ypos)
 Updates the position of a child, as for add_child_in_window().

void set_wrap_mode (WrapMode wrap_mode)
 Sets the line wrapping for the view.

WrapMode get_wrap_mode () const
 Gets the line wrapping for the view.

void set_editable (bool setting=true)
 Sets the default editability of the Gtk::TextView.

bool get_editable () const
 Returns the default editability of the Gtk::TextView.

void set_pixels_above_lines (int pixels_above_lines)
 Sets the default number of blank pixels above paragraphs in text_view.

int get_pixels_above_lines () const
 Gets the default number of pixels to put above paragraphs.

void set_pixels_below_lines (int pixels_below_lines)
 Sets the default number of pixels of blank space to put below paragraphs in text_view.

int get_pixels_below_lines () const
 Gets the value set by set_pixels_below_lines().

void set_pixels_inside_wrap (int pixels_inside_wrap)
 Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.

int get_pixels_inside_wrap () const
 Gets the value set by set_pixels_inside_wrap().

void set_justification (Justification justification)
 Sets the default justification of text in text_view.

Justification get_justification () const
 Gets the default justification of paragraphs in text_view.

void set_left_margin (int left_margin)
 Sets the default left margin for text in text_view.

int get_left_margin () const
 Gets the default left margin size of paragraphs in the text_view.

void set_right_margin (int right_margin)
 Sets the default right margin for text in the text view.

int get_right_margin () const
 Gets the default right margin for text in text_view.

void set_indent (int indent)
 Sets the default indentation for paragraphs in text_view.

int get_indent () const
 Gets the default indentation of paragraphs in text_view.

void set_tabs (Pango::TabArray& tabs)
 Sets the default tab stops for paragraphs in text_view.

Pango::TabArray get_tabs () const
 Gets the default tabs for text_view.

TextAttributes get_default_attributes () const
 Obtains a copy of the default text attributes.

void set_overwrite (bool overwrite=true)
 Changes the Gtk::TextView overwrite mode.

bool get_overwrite () const
 Returns whether the Gtk::TextView is in overwrite mode or not.

void set_accepts_tab (bool accepts_tab=true)
 Sets the behavior of the text widget when the Tab key is pressed.

bool get_accepts_tab () const
 Returns whether pressing the Tab key inserts a tab characters.

Glib::SignalProxy1< void, Menu* > signal_populate_popup ()
Glib::SignalProxy0< void > signal_set_anchor ()
Glib::SignalProxy1< void,

const Glib::ustring& > 
signal_insert_at_cursor ()
Glib::PropertyProxy< int > property_pixels_above_lines ()
 Pixels of blank space above paragraphs.

Glib::PropertyProxy_ReadOnly< int > property_pixels_above_lines () const
 Pixels of blank space above paragraphs.

Glib::PropertyProxy< int > property_pixels_below_lines ()
 Pixels of blank space below paragraphs.

Glib::PropertyProxy_ReadOnly< int > property_pixels_below_lines () const
 Pixels of blank space below paragraphs.

Glib::PropertyProxy< int > property_pixels_inside_wrap ()
 Pixels of blank space between wrapped lines in a paragraph.

Glib::PropertyProxy_ReadOnly< int > property_pixels_inside_wrap () const
 Pixels of blank space between wrapped lines in a paragraph.

Glib::PropertyProxy< bool > property_editable ()
 Whether the text can be modified by the user.

Glib::PropertyProxy_ReadOnly

< bool > 
property_editable () const
 Whether the text can be modified by the user.

Glib::PropertyProxy< WrapModeproperty_wrap_mode ()
 Whether to wrap lines never, at word boundaries, or at character boundaries.

Glib::PropertyProxy_ReadOnly

< WrapMode
property_wrap_mode () const
 Whether to wrap lines never, at word boundaries, or at character boundaries.

Glib::PropertyProxy

< Justification
property_justification ()
 Left, right, or center justification.

Glib::PropertyProxy_ReadOnly

< Justification
property_justification () const
 Left, right, or center justification.

Glib::PropertyProxy< int > property_left_margin ()
 Width of the left margin in pixels.

Glib::PropertyProxy_ReadOnly< int > property_left_margin () const
 Width of the left margin in pixels.

Glib::PropertyProxy< int > property_right_margin ()
 Width of the right margin in pixels.

Glib::PropertyProxy_ReadOnly< int > property_right_margin () const
 Width of the right margin in pixels.

Glib::PropertyProxy< int > property_indent ()
 Amount to indent the paragraph, in pixels.

Glib::PropertyProxy_ReadOnly< int > property_indent () const
 Amount to indent the paragraph, in pixels.

Glib::PropertyProxy

< Pango::TabArray
property_tabs ()
 Custom tabs for this text.

Glib::PropertyProxy_ReadOnly

< Pango::TabArray
property_tabs () const
 Custom tabs for this text.

Glib::PropertyProxy< bool > property_cursor_visible ()
 If the insertion cursor is shown.

Glib::PropertyProxy_ReadOnly

< bool > 
property_cursor_visible () const
 If the insertion cursor is shown.

Glib::PropertyProxy

< Glib::RefPtr< TextBuffer > > 
property_buffer ()
 The buffer which is displayed.

Glib::PropertyProxy_ReadOnly

< Glib::RefPtr< TextBuffer > > 
property_buffer () const
 The buffer which is displayed.

Glib::PropertyProxy< bool > property_overwrite ()
 Whether entered text overwrites existing contents.

Glib::PropertyProxy_ReadOnly

< bool > 
property_overwrite () const
 Whether entered text overwrites existing contents.

Glib::PropertyProxy< bool > property_accepts_tab ()
 Whether Tab will result in a tab character being entered.

Glib::PropertyProxy_ReadOnly

< bool > 
property_accepts_tab () const
 Whether Tab will result in a tab character being entered.

Glib::PropertyProxy

< Glib::ustring
property_im_module ()
 Which IM module should be used.

Glib::PropertyProxy_ReadOnly

< Glib::ustring
property_im_module () const
 Which IM module should be used.

Protected Member Functions

virtual void on_populate_popup (Menu* menu)
virtual void on_set_anchor ()
virtual void on_insert_at_cursor (const Glib::ustring& str)

Related Functions

(Note that these are not member functions.)

Gtk::TextViewwrap (GtkTextView* object, bool take_copy=false)
 A Glib::wrap() method for this object.


Detailed Description

Multi-line text editing widget.

It displays a Gtk::TextBuffer.

The TextView widget looks like this:

textview1.png

Constructor & Destructor Documentation

virtual Gtk::TextView::~TextView ( ) [virtual]
Gtk::TextView::TextView ( )
Gtk::TextView::TextView ( const Glib::RefPtr< TextBuffer >&  buffer) [explicit]

Member Function Documentation

void Gtk::TextView::add_child_at_anchor ( Widget child,
const Glib::RefPtr< TextBuffer::ChildAnchor >&  anchor 
)

Adds a child widget in the text buffer, at the given anchor.

Parameters:
childA Gtk::Widget.
anchorA Gtk::TextChildAnchor in the Gtk::TextBuffer for text_view.
void Gtk::TextView::add_child_in_window ( Widget child,
TextWindowType  which_window,
int  xpos,
int  ypos 
)

Adds a child at fixed coordinates in one of the text widget's windows.

The window must have nonzero size (see set_border_window_size()). Note that the child coordinates are given relative to the Gdk::Window in question, and that these coordinates have no sane relationship to scrolling. When placing a child in Gtk::TEXT_WINDOW_WIDGET, scrolling is irrelevant, the child floats above all scrollable areas. But when placing a child in one of the scrollable windows (border windows or text window), you'll need to compute the child's correct position in buffer coordinates any time scrolling occurs or buffer changes occur, and then call move_child() to update the child's position. Unfortunately there's no good way to detect that scrolling has occurred, using the current API; a possible hack would be to update all child positions when the scroll adjustments change or the text buffer changes. See bug 64518 on bugzilla.gnome.org for status of fixing this issue.

Parameters:
childA Gtk::Widget.
which_windowWhich window the child should appear in.
xposX position of child in window coordinates.
yposY position of child in window coordinates.
bool Gtk::TextView::backward_display_line ( TextBuffer::iterator iter)

Moves the given iter backward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.

Parameters:
iterA Gtk::TextIter.
Returns:
true if iter was moved and is not on the end iterator.
bool Gtk::TextView::backward_display_line_start ( TextBuffer::iterator iter)

Moves the given iter backward to the next display line start.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.

Parameters:
iterA Gtk::TextIter.
Returns:
true if iter was moved and is not on the end iterator.
void Gtk::TextView::buffer_to_window_coords ( TextWindowType  win,
int  buffer_x,
int  buffer_y,
int &  window_x,
int &  window_y 
) const

Converts coordinate ( buffer_x, buffer_y) to coordinates for the window win, and stores the result in ( window_x, window_y).

Note that you can't convert coordinates for a nonexisting window (see set_border_window_size()).

Parameters:
winA Gtk::TextWindowType except Gtk::TEXT_WINDOW_PRIVATE.
buffer_xBuffer x coordinate.
buffer_yBuffer y coordinate.
window_xWindow x coordinate return location or 0.
window_yWindow y coordinate return location or 0.
bool Gtk::TextView::forward_display_line ( TextBuffer::iterator iter)

Moves the given iter forward by one display (wrapped) line.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.

Parameters:
iterA Gtk::TextIter.
Returns:
true if iter was moved and is not on the end iterator.
bool Gtk::TextView::forward_display_line_end ( TextBuffer::iterator iter)

Moves the given iter forward to the next display line end.

A display line is different from a paragraph. Paragraphs are separated by newlines or other paragraph separator characters. Display lines are created by line-wrapping a paragraph. If wrapping is turned off, display lines and paragraphs will be the same. Display lines are divided differently for each view, since they depend on the view's width; paragraphs are the same in all views, since they depend on the contents of the Gtk::TextBuffer.

Parameters:
iterA Gtk::TextIter.
Returns:
true if iter was moved and is not on the end iterator.
bool Gtk::TextView::get_accepts_tab ( ) const

Returns whether pressing the Tab key inserts a tab characters.

set_accepts_tab().

Since gtkmm 2.4:
Returns:
true if pressing the Tab key inserts a tab character, false if pressing the Tab key moves the keyboard focus.
int Gtk::TextView::get_border_window_size ( TextWindowType  type) const

Gets the width of the specified border window.

See set_border_window_size().

Parameters:
typeWindow to return size from.
Returns:
Width of window.
Glib::RefPtr<const TextBuffer> Gtk::TextView::get_buffer ( ) const

Returns the Gtk::TextBuffer being displayed by this text view.

The reference count on the buffer is not incremented; the caller of this function won't own a new reference.

Returns:
A Gtk::TextBuffer.
Glib::RefPtr<TextBuffer> Gtk::TextView::get_buffer ( )

Returns the Gtk::TextBuffer being displayed by this text view.

The reference count on the buffer is not incremented; the caller of this function won't own a new reference.

Returns:
A Gtk::TextBuffer.
void Gtk::TextView::get_cursor_locations ( const TextBuffer::iterator iter,
Gdk::Rectangle strong,
Gdk::Rectangle weak 
) const
bool Gtk::TextView::get_cursor_visible ( ) const

Find out whether the cursor is being displayed.

Returns:
Whether the insertion mark is visible.
TextAttributes Gtk::TextView::get_default_attributes ( ) const

Obtains a copy of the default text attributes.

These are the attributes used for text unless a tag overrides them. You'd typically pass the default attributes in to Gtk::TextIter::get_attributes() in order to get the attributes in effect at a given text position.

Returns:
A new Gtk::TextAttributes.
bool Gtk::TextView::get_editable ( ) const

Returns the default editability of the Gtk::TextView.

Tags in the buffer may override this setting for some ranges of text.

Returns:
Whether text is editable by default.
int Gtk::TextView::get_indent ( ) const

Gets the default indentation of paragraphs in text_view.

Tags in the view's buffer may override the default. The indentation may be negative.

Returns:
Number of pixels of indentation.
void Gtk::TextView::get_iter_at_location ( TextBuffer::iterator iter,
int  x,
int  y 
) const

Retrieves the iterator at buffer coordinates x and y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

Parameters:
iterA Gtk::TextIter.
xX position, in buffer coordinates.
yY position, in buffer coordinates.
void Gtk::TextView::get_iter_at_position ( TextBuffer::iterator iter,
int &  trailing,
int  x,
int  y 
) const

Retrieves the iterator pointing to the character at buffer coordinates x and y.

Buffer coordinates are coordinates for the entire buffer, not just the currently-displayed portion. If you have coordinates from an event, you have to convert those to buffer coordinates with window_to_buffer_coords().

Note that this is different from get_iter_at_location(), which returns cursor locations, i.e. positions between characters.

Since gtkmm 2.6:
Parameters:
iterA Gtk::TextIter.
trailingIf non-0, location to store an integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the trailing edge of the grapheme.
xX position, in buffer coordinates.
yY position, in buffer coordinates.
void Gtk::TextView::get_iter_location ( const TextBuffer::iterator iter,
Gdk::Rectangle location 
) const

Gets a rectangle which roughly contains the character at iter.

The rectangle position is in buffer coordinates; use buffer_to_window_coords() to convert these coordinates to coordinates for one of the windows in the text view.

Parameters:
iterA Gtk::TextIter.
locationBounds of the character at iter.
Justification Gtk::TextView::get_justification ( ) const

Gets the default justification of paragraphs in text_view.

Tags in the buffer may override the default.

Returns:
Default justification.
int Gtk::TextView::get_left_margin ( ) const

Gets the default left margin size of paragraphs in the text_view.

Tags in the buffer may override the default.

Returns:
Left margin in pixels.
void Gtk::TextView::get_line_at_y ( TextBuffer::iterator target_iter,
int  y,
int &  line_top 
) const

Gets the Gtk::TextIter at the start of the line containing the coordinate y.

y is in buffer coordinates, convert from window coordinates with window_to_buffer_coords(). If non-0, line_top will be filled with the coordinate of the top edge of the line.

Parameters:
target_iterA Gtk::TextIter.
yA y coordinate.
line_topReturn location for top coordinate of the line.
void Gtk::TextView::get_line_yrange ( const TextBuffer::iterator iter,
int &  y,
int &  height 
) const

Gets the y coordinate of the top of the line containing iter, and the height of the line.

The coordinate is a buffer coordinate; convert to window coordinates with buffer_to_window_coords().

Parameters:
iterA Gtk::TextIter.
yReturn location for a y coordinate.
heightReturn location for a height.
bool Gtk::TextView::get_overwrite ( ) const

Returns whether the Gtk::TextView is in overwrite mode or not.

Since gtkmm 2.4:
Returns:
Whether text_view is in overwrite mode or not.
int Gtk::TextView::get_pixels_above_lines ( ) const

Gets the default number of pixels to put above paragraphs.

Returns:
Default number of pixels above paragraphs.
int Gtk::TextView::get_pixels_below_lines ( ) const

Gets the value set by set_pixels_below_lines().

Returns:
Default number of blank pixels below paragraphs.
int Gtk::TextView::get_pixels_inside_wrap ( ) const

Gets the value set by set_pixels_inside_wrap().

Returns:
Default number of pixels of blank space between wrapped lines.
int Gtk::TextView::get_right_margin ( ) const

Gets the default right margin for text in text_view.

Tags in the buffer may override the default.

Returns:
Right margin in pixels.
Pango::TabArray Gtk::TextView::get_tabs ( ) const

Gets the default tabs for text_view.

Tags in the buffer may override the defaults. The returned array will be empty if "standard" (8-space) tabs are used.

Returns:
Copy of default tab array, or an empty array if "standard" tabs are used.
void Gtk::TextView::get_visible_rect ( Gdk::Rectangle visible_rect) const

Fills visible_rect with the currently-visible region of the buffer, in buffer coordinates.

Convert to window coordinates with buffer_to_window_coords().

Parameters:
visible_rectRectangle to fill.
Glib::RefPtr<Gdk::Window> Gtk::TextView::get_window ( TextWindowType  win)

Retrieves the Gdk::Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer.

Windows are 0 and nonexistent if their width or height is 0, and are nonexistent before the widget has been realized.

Parameters:
winWindow to get.
Returns:
A Gdk::Window, or 0.
Glib::RefPtr<const Gdk::Window> Gtk::TextView::get_window ( TextWindowType  win) const

Retrieves the Gdk::Window corresponding to an area of the text view; possible windows include the overall widget window, child windows on the left, right, top, bottom, and the window that displays the text buffer.

Windows are 0 and nonexistent if their width or height is 0, and are nonexistent before the widget has been realized.

Parameters:
winWindow to get.
Returns:
A Gdk::Window, or 0.
TextWindowType Gtk::TextView::get_window_type ( const Glib::RefPtr< Gdk::Window >&  window)

Usually used to find out which window an event corresponds to.

If you connect to an event signal on text_view, this function should be called on event->window to see which window it was.

Parameters:
windowA window type.
Returns:
The window type.
WrapMode Gtk::TextView::get_wrap_mode ( ) const

Gets the line wrapping for the view.

Returns:
The line wrap setting.
const GtkTextView* Gtk::TextView::gobj ( ) const [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

GtkTextView* Gtk::TextView::gobj ( ) [inline]

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

bool Gtk::TextView::im_context_filter_keypress ( GdkEventKey *  event)

Allow the Gtk::TextView input method to internally handle key press and release events.

If this function returns true, then no further processing should be done for this key event. See gtk_im_context_filter_keypress().

Note that you are expected to call this function from your handler when overriding key event handling. This is needed in the case when you need to insert your own key handling between the input method and the default key event handling of the Gtk::TextView.

|[ static bool gtk_foo_bar_key_press_event (GtkWidget *widget, GdkEventKey *event) { if ((key->keyval == GDK_Return || key->keyval == GDK_KP_Enter)) { if (gtk_text_view_im_context_filter_keypress (GTK_TEXT_VIEW (view), event)) return true; }

/ * Do some stuff * /

return GTK_WIDGET_CLASS (gtk_foo_bar_parent_class)->key_press_event (widget, event); } ]|

Since gtkmm 2.22:
Parameters:
eventThe key event.
Returns:
true if the input method handled the key event.
void Gtk::TextView::move_child ( Widget child,
int  xpos,
int  ypos 
)

Updates the position of a child, as for add_child_in_window().

Parameters:
childChild widget already added to the text view.
xposNew X position in window coordinates.
yposNew Y position in window coordinates.
bool Gtk::TextView::move_mark_onscreen ( const Glib::RefPtr< TextBuffer::Mark >&  mark)

Moves a mark within the buffer so that it's located within the currently-visible text area.

Parameters:
markA Gtk::TextMark.
Returns:
true if the mark moved (wasn't already onscreen).
bool Gtk::TextView::move_visually ( TextBuffer::iterator iter,
int  count 
)

Move the iterator a given number of characters visually, treating it as the strong cursor position.

If count is positive, then the new strong cursor position will be count positions to the right of the old cursor position. If count is negative then the new strong cursor position will be count positions to the left of the old cursor position.

In the presence of bi-directional text, the correspondence between logical and visual order will depend on the direction of the current run, and there may be jumps when the cursor is moved off of the end of a run.

Parameters:
iterA Gtk::TextIter.
countNumber of characters to move (negative moves left, positive moves right).
Returns:
true if iter moved and is not on the end iterator.
virtual void Gtk::TextView::on_insert_at_cursor ( const Glib::ustring str) [protected, virtual]
virtual void Gtk::TextView::on_populate_popup ( Menu menu) [protected, virtual]
virtual void Gtk::TextView::on_set_anchor ( ) [protected, virtual]
bool Gtk::TextView::place_cursor_onscreen ( )

Moves the cursor to the currently visible region of the buffer, it it isn't there already.

Returns:
true if the cursor had to be moved.
Glib::PropertyProxy_ReadOnly<bool> Gtk::TextView::property_accepts_tab ( ) const

Whether Tab will result in a tab character being entered.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::TextView::property_accepts_tab ( )

Whether Tab will result in a tab character being entered.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TextBuffer> > Gtk::TextView::property_buffer ( ) const

The buffer which is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy< Glib::RefPtr<TextBuffer> > Gtk::TextView::property_buffer ( )

The buffer which is displayed.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::TextView::property_cursor_visible ( )

If the insertion cursor is shown.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<bool> Gtk::TextView::property_cursor_visible ( ) const

If the insertion cursor is shown.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::TextView::property_editable ( )

Whether the text can be modified by the user.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<bool> Gtk::TextView::property_editable ( ) const

Whether the text can be modified by the user.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Glib::ustring> Gtk::TextView::property_im_module ( ) const

Which IM module should be used.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<Glib::ustring> Gtk::TextView::property_im_module ( )

Which IM module should be used.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_indent ( )

Amount to indent the paragraph, in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_indent ( ) const

Amount to indent the paragraph, in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<Justification> Gtk::TextView::property_justification ( )

Left, right, or center justification.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Justification> Gtk::TextView::property_justification ( ) const

Left, right, or center justification.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_left_margin ( ) const

Width of the left margin in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_left_margin ( )

Width of the left margin in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<bool> Gtk::TextView::property_overwrite ( )

Whether entered text overwrites existing contents.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<bool> Gtk::TextView::property_overwrite ( ) const

Whether entered text overwrites existing contents.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_pixels_above_lines ( )

Pixels of blank space above paragraphs.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_pixels_above_lines ( ) const

Pixels of blank space above paragraphs.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_pixels_below_lines ( )

Pixels of blank space below paragraphs.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_pixels_below_lines ( ) const

Pixels of blank space below paragraphs.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_pixels_inside_wrap ( )

Pixels of blank space between wrapped lines in a paragraph.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_pixels_inside_wrap ( ) const

Pixels of blank space between wrapped lines in a paragraph.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<int> Gtk::TextView::property_right_margin ( )

Width of the right margin in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<int> Gtk::TextView::property_right_margin ( ) const

Width of the right margin in pixels.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<Pango::TabArray> Gtk::TextView::property_tabs ( )

Custom tabs for this text.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<Pango::TabArray> Gtk::TextView::property_tabs ( ) const

Custom tabs for this text.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy<WrapMode> Gtk::TextView::property_wrap_mode ( )

Whether to wrap lines never, at word boundaries, or at character boundaries.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
Glib::PropertyProxy_ReadOnly<WrapMode> Gtk::TextView::property_wrap_mode ( ) const

Whether to wrap lines never, at word boundaries, or at character boundaries.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.
void Gtk::TextView::reset_im_context ( )

Reset the input method context of the text view if needed.

This can be necessary in the case where modifying the buffer would confuse on-going input method behavior.

Since gtkmm 2.22:
bool Gtk::TextView::scroll_to ( TextBuffer::iterator iter,
double  within_margin,
double  xalign,
double  yalign 
)

Scrolls the TextView so that iter is on the screen, in the position indicated by xalign and yalign, possibly not scrolling at all.

The effective screen for purposes of this function is reduced by a margin of size within_margin.

Note:
This function uses the currently-computed height of the lines in the text buffer. Note that line heights are computed in an idle handler; so this function may not have the desired effect if it's called before the height computations. To avoid oddness, consider using gtk_text_view_scroll_to_mark() which saves a point to be scrolled to after line validation.
Parameters:
iterAn iterator pointing to the position that should be made visible by scrolling.
within_marginmargin as a [0.0,0.5] fraction of screen size.
xalignhorizontal alignment of mark within visible area. An alignment of 0.0 indicates left, 1.0 indicates right, 0.5 means center.
yalignvertical alignment of mark within visible area. An alignment of 0.0 indicates top, 1.0 indicates bottom, 0.5 means center.
Returns:
true if scrolling occurred.
void Gtk::TextView::scroll_to ( const Glib::RefPtr< TextBuffer::Mark >&  mark,
double  within_margin,
double  xalign,
double  yalign 
)

Scrolls the TextView so that iter is on the screen, in the position indicated by xalign and yalign, possibly not scrolling at all.

The effective screen for purposes of this function is reduced by a margin of size within_margin.

Parameters:
markAn mark pointing to the position that should be made visible by scrolling.
within_marginmargin as a [0.0,0.5] fraction of screen size.
xalignhorizontal alignment of mark within visible area. An alignment of 0.0 indicates left, 1.0 indicates right, 0.5 means center.
yalignvertical alignment of mark within visible area. An alignment of 0.0 indicates top, 1.0 indicates bottom, 0.5 means center.
bool Gtk::TextView::scroll_to ( TextBuffer::iterator iter,
double  within_margin = 0 
)

Scrolls the TextView so that iter is on the screen, by scrolling the minimal distance to get the mark onscreen, possibly not scrolling at all.

The effective screen for purposes of this function is reduced by a margin of size within_margin.

Note:
This function uses the currently-computed height of the lines in the text buffer. Note that line heights are computed in an idle handler; so this function may not have the desired effect if it's called before the height computations. To avoid oddness, consider using gtk_text_view_scroll_to_mark() which saves a point to be scrolled to after line validation.
Parameters:
iterAn iterator pointing to the position that should be made visible by scrolling.
within_marginmargin as a [0.0,0.5] fraction of screen size.
Returns:
true if scrolling occurred.
void Gtk::TextView::scroll_to ( const Glib::RefPtr< TextBuffer::Mark >&  mark,
double  within_margin = 0 
)

Scrolls text_view so that mark is on the screen, by scrolling the minimal distance to get the mark onscreen, possibly not scrolling at all.

The effective screen for purposes of this function is reduced by a margin of size within_margin.

Parameters:
markAn mark pointing to the position that should be made visible by scrolling.
within_marginmargin as a [0.0,0.5] fraction of screen size.
void Gtk::TextView::set_accepts_tab ( bool  accepts_tab = true)

Sets the behavior of the text widget when the Tab key is pressed.

If accepts_tab is true, a tab character is inserted. If accepts_tab is false the keyboard focus is moved to the next widget in the focus chain.

Since gtkmm 2.4:
Parameters:
accepts_tabtrue if pressing the Tab key should insert a tab character, false, if pressing the Tab key should move the keyboard focus.
void Gtk::TextView::set_border_window_size ( TextWindowType  type,
int  size 
)

Sets the width of Gtk::TEXT_WINDOW_LEFT or Gtk::TEXT_WINDOW_RIGHT, or the height of Gtk::TEXT_WINDOW_TOP or Gtk::TEXT_WINDOW_BOTTOM.

Automatically destroys the corresponding window if the size is set to 0, and creates the window if the size is set to non-zero. This function can only be used for the "border windows," it doesn't work with Gtk::TEXT_WINDOW_WIDGET, Gtk::TEXT_WINDOW_TEXT, or Gtk::TEXT_WINDOW_PRIVATE.

Parameters:
typeWindow to affect.
sizeWidth or height of the window.
void Gtk::TextView::set_buffer ( const Glib::RefPtr< TextBuffer >&  buffer)

Sets buffer as the buffer being displayed by text_view.

The previous buffer displayed by the text view is unreferenced, and a reference is added to buffer. If you owned a reference to buffer before passing it to this function, you must remove that reference yourself; Gtk::TextView will not "adopt" it.

Parameters:
bufferA Gtk::TextBuffer.
void Gtk::TextView::set_cursor_visible ( bool  setting = true)

Toggles whether the insertion point is displayed.

A buffer with no editable text probably shouldn't have a visible cursor, so you may want to turn the cursor off.

Parameters:
settingWhether to show the insertion cursor.
void Gtk::TextView::set_editable ( bool  setting = true)

Sets the default editability of the Gtk::TextView.

You can override this default setting with tags in the buffer, using the "editable" attribute of tags.

Parameters:
settingWhether it's editable.
void Gtk::TextView::set_indent ( int  indent)

Sets the default indentation for paragraphs in text_view.

Tags in the buffer may override the default.

Parameters:
indentIndentation in pixels.
void Gtk::TextView::set_justification ( Justification  justification)

Sets the default justification of text in text_view.

Tags in the view's buffer may override the default.

Parameters:
justificationJustification.
void Gtk::TextView::set_left_margin ( int  left_margin)

Sets the default left margin for text in text_view.

Tags in the buffer may override the default.

Parameters:
left_marginLeft margin in pixels.
void Gtk::TextView::set_overwrite ( bool  overwrite = true)

Changes the Gtk::TextView overwrite mode.

Since gtkmm 2.4:
Parameters:
overwritetrue to turn on overwrite mode, false to turn it off.
void Gtk::TextView::set_pixels_above_lines ( int  pixels_above_lines)

Sets the default number of blank pixels above paragraphs in text_view.

Tags in the buffer for text_view may override the defaults.

Parameters:
pixels_above_linesPixels above paragraphs.
void Gtk::TextView::set_pixels_below_lines ( int  pixels_below_lines)

Sets the default number of pixels of blank space to put below paragraphs in text_view.

May be overridden by tags applied to text_view's buffer.

Parameters:
pixels_below_linesPixels below paragraphs.
void Gtk::TextView::set_pixels_inside_wrap ( int  pixels_inside_wrap)

Sets the default number of pixels of blank space to leave between display/wrapped lines within a paragraph.

May be overridden by tags in text_view's buffer.

Parameters:
pixels_inside_wrapDefault number of pixels between wrapped lines.
void Gtk::TextView::set_right_margin ( int  right_margin)

Sets the default right margin for text in the text view.

Tags in the buffer may override the default.

Parameters:
right_marginRight margin in pixels.
void Gtk::TextView::set_tabs ( Pango::TabArray tabs)

Sets the default tab stops for paragraphs in text_view.

Tags in the buffer may override the default.

Parameters:
tabsTabs as a Pango::TabArray.
void Gtk::TextView::set_wrap_mode ( WrapMode  wrap_mode)

Sets the line wrapping for the view.

Parameters:
wrap_modeA Gtk::WrapMode.
Glib::SignalProxy1< void,const Glib::ustring& > Gtk::TextView::signal_insert_at_cursor ( )
Prototype:
void on_my_insert_at_cursor(const Glib::ustring& str)
Glib::SignalProxy1< void,Menu* > Gtk::TextView::signal_populate_popup ( )
Prototype:
void on_my_populate_popup(Menu* menu)
Glib::SignalProxy0< void > Gtk::TextView::signal_set_anchor ( )
Prototype:
void on_my_set_anchor()
bool Gtk::TextView::starts_display_line ( const TextBuffer::iterator iter)

Determines whether iter is at the start of a display line.

See forward_display_line() for an explanation of display lines vs. paragraphs.

Parameters:
iterA Gtk::TextIter.
Returns:
true if iter begins a wrapped line.
void Gtk::TextView::window_to_buffer_coords ( TextWindowType  win,
int  window_x,
int  window_y,
int &  buffer_x,
int &  buffer_y 
) const

Converts coordinates on the window identified by win to buffer coordinates, storing the result in ( buffer_x, buffer_y).

Note that you can't convert coordinates for a nonexisting window (see set_border_window_size()).

Parameters:
winA Gtk::TextWindowType except Gtk::TEXT_WINDOW_PRIVATE.
window_xWindow x coordinate.
window_yWindow y coordinate.
buffer_xBuffer x coordinate return location or 0.
buffer_yBuffer y coordinate return location or 0.

Friends And Related Function Documentation

Gtk::TextView* wrap ( GtkTextView *  object,
bool  take_copy = false 
) [related]

A Glib::wrap() method for this object.

Parameters:
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns:
A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:
  • gtkmm/textview.h