diff --git a/docs/src/assets/GAccessor.text.png b/docs/src/assets/GAccessor.text.png new file mode 100644 index 00000000..c6a2cc12 Binary files /dev/null and b/docs/src/assets/GAccessor.text.png differ diff --git a/docs/src/assets/automatic line wrapping.png b/docs/src/assets/automatic line wrapping.png new file mode 100644 index 00000000..6fc93cc0 Binary files /dev/null and b/docs/src/assets/automatic line wrapping.png differ diff --git a/docs/src/assets/gtkentry.png b/docs/src/assets/gtkentry.png new file mode 100644 index 00000000..80732852 Binary files /dev/null and b/docs/src/assets/gtkentry.png differ diff --git a/docs/src/assets/gtklabel.png b/docs/src/assets/gtklabel.png new file mode 100644 index 00000000..259bc30e Binary files /dev/null and b/docs/src/assets/gtklabel.png differ diff --git a/docs/src/assets/markup function.png b/docs/src/assets/markup function.png new file mode 100644 index 00000000..49b7484a Binary files /dev/null and b/docs/src/assets/markup function.png differ diff --git a/docs/src/doc/text-widgets.md b/docs/src/doc/text-widgets.md new file mode 100644 index 00000000..dfc0df72 --- /dev/null +++ b/docs/src/doc/text-widgets.md @@ -0,0 +1,128 @@ +# Text Widgets +--- +There are two basic widgets available for rendering simple text. The one is for displaying non-editable text GtkLabel the other is for editable text GtkEntry. + +## Label +A GtkLabel is the most basic text widget that has already been used behind the scene in any previous example involving a GtkButton. A GtkLabel is constructed by calling + +>label = GtkLabel("My text") + +The text of a label can be changed using + +>GAccessor.text(label,"My other text") + +Furthermore, a label has limited support for adding formatted text. This is done using the markup function: + +>GAccessor.markup(label,"""My bold text\n
+ + title=\"Our website\">GTK+ website""") + +The syntax for this markup text is borrowed from html and explained here. + +A label can be made selectable using + +>GAccessor.selectable(label,true) + +This can be used if the user should be allowed to copy the text. + +The justification of a label can be changed in the following way: + +>GAccessor.justify(label,Gtk.GConstants.GtkJustification.RIGHT) + +Possible values of the enum GtkJustification are LEFT,RIGHT,CENTER, and FILL. + +Automatic line wrapping can be enabled using + +>GAccessor.text(label,repeat("Very long text! ",20))
+>GAccessor.line_wrap(label,true) + +Note that this will only happen, if the size of the widget is limited using layout constraints. + +## Entry +The entry widget allows the user to enter text. The entered text can be read and write using + +>ent = GtkEntry()
+>set_gtk_property!(ent,:text,"My String")
+>str = get_gtk_property(ent,:text,String) + +The maximum number of characters can be limited using set_gtk_property!(ent,:max_length,10). + +Sometimes you might want to make the widget non-editable. This can be done by a call + +>GAccessor.editable(GtkEditable(ent),false)
+>set_gtk_property!(ent,:editable,false) + +If you want to use the entry to retrieve passwords you can hide the visibility of the entered text. This can be achieve by calling + +>set_gtk_property!(ent,:visibility,false) + +To get notified by changes to the entry one can listen the "changed" event. + +TODO: setting progress and setting icons in entry + +## Search Entry +A special variant of the entry that can be used as a search box is GtkSearchEntry. It is equipped with a button to clear the entry. + +## Examples +### GtkLabel +>using Gtk +> +>win = GtkWindow("My First Gtk.jl Program", 400, 200)
+>label = GtkLabel("Hello World")
+>push!(win,label)
+> +>showall(win) + +![alt text](https://github.com/mikolajhojda/Gtk.jl/blob/master/docs/src/assets/gtklabel.png) + +#### GAccessor.text +>using Gtk +> +>win = GtkWindow("My First Gtk.jl Program", 400, 200)
+>label = GtkLabel("Hello World")
+>GAccessor.text(label,"My other text")
+>push!(win,label) +> +>showall(win) + +![alt text](https://github.com/mikolajhojda/Gtk.jl/blob/master/docs/src/assets/GAccessor.text.png) + +#### markup function +>using Gtk +> +>win = GtkWindow("My First Gtk.jl Program", 400, 200)
+>label = GtkLabel("Hello World")
+>GAccessor.markup(label,"""My bold text\n
+> +> title=\"Our website\">GTK+ website""")
+>push!(win,label) +> +>showall(win) + +![alt text](https://github.com/mikolajhojda/Gtk.jl/blob/master/docs/src/assets/markup%20function.png) + +#### Automatic line wrapping +>using Gtk +> +>win = GtkWindow("My First Gtk.jl Program", 400, 200)
+>label = GtkLabel("Hello World")
+>GAccessor.text(label,repeat("Very long text! ",20))
+>GAccessor.line_wrap(label,true)
+>push!(win,label) +> +>showall(win) + +![alt text](https://github.com/mikolajhojda/Gtk.jl/blob/master/docs/src/assets/automatic%20line%20wrapping.png) + +### GtkEntry +>using Gtk +> +>win = GtkWindow("My First Gtk.jl Program", 400, 200)
+>ent = GtkEntry()
+>set_gtk_property!(ent,:text,"My String")
+>str = get_gtk_property(ent,:text,String)
+>push!(win,ent) +> +>showall(win) + +![alt text](https://github.com/mikolajhojda/Gtk.jl/blob/master/docs/src/assets/gtkentry.png)