TextView (Vala) Tiffany Antopolski tiffany.antopolski@gmail.com 2012 Un widget que muestra un GtkTextBuffer Daniel Mustieles daniel.mustieles@gmail.com 2011 - 2017 Nicolás Satragno nsatragno@gmail.com 2012 - 2013 Jorge González jorgegonz@svn.gnome.org 2011 Widget TextView

Si se pulsa «Intro» se obtiene una línea nueva.

Si se pulsa «Intro» más veces entonces hay líneas en la ventana de tamaño predeterminado, y después aparece una barra de desplazamiento vertical.

Si se escribe una frase larga, el texto se ajustará a los saltos de línea entre palabras.

Si es escribe una palabra laaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaarga, aparecerá una barra de desplazamiento horizontal.

Esto es un ejemplo de Gtk.TextView

/* This is the application. */ public class MyApplication : Gtk.Application { /* Override the 'activate' signal of GLib.Application. */ protected override void activate () { /* Create the window of this application. */ new MyWindow (this).show_all (); } } /* This is the window. */ class MyWindow: Gtk.ApplicationWindow { internal MyWindow (MyApplication app) { Object (application: app, title: "TextView Example"); this.set_default_size (220, 200); var buffer = new Gtk.TextBuffer (null); //stores text to be displayed var textview = new Gtk.TextView.with_buffer (buffer); //displays TextBuffer textview.set_wrap_mode (Gtk.WrapMode.WORD); //sets line wrapping var scrolled_window = new Gtk.ScrolledWindow (null, null); scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC); scrolled_window.add (textview); scrolled_window.set_border_width (5); this.add (scrolled_window); } } /* main creates and runs the application. */ public int main (string[] args) { return new MyApplication ().run (args); }

En este ejemplo se usa lo siguiente:

Gtk.TextBuffer

Gtk.TextView

Gtk.ScrolledWindow

Gtk.WrapMode

Gtk.PolicyType