' Label.bas
' Translated from C to FB by TinyCla, 2006
'
' Reviewed by TJF (2011-2014)
' Details: http://developer.gnome.org/gtk/

#INCLUDE ONCE "Gir/Gtk-3.0.bi"
'#INCLUDE ONCE "Gir/Gtk-2.0.bi"
#INCLUDE ONCE "Gir/_GObjectMacros-2.0.bi"

' ==============================================
' Main
' ==============================================

' Initialize the toolkit
gtk_init(@__FB_ARGC__, @__FB_ARGV__)

VAR win = gtk_window_new (GTK_WINDOW_TOPLEVEL)
g_signal_connect (G_OBJECT (win), "delete-event", _
                  G_CALLBACK (@gtk_main_quit), NULL)

gtk_window_set_title (GTK_WINDOW (win), "Label")
VAR vbox = gtk_vbox_new (FALSE, 5)
VAR hbox = gtk_hbox_new (FALSE, 5)
gtk_container_add (GTK_CONTAINER (win), hbox)
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0)
gtk_container_set_border_width (GTK_CONTAINER (win), 5)

VAR frame = gtk_frame_new ("Normal Label")
VAR label = gtk_label_new ("This is a Normal label")
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

frame = gtk_frame_new ("Multi-line Label")
label = gtk_label_new (!"This is a Multi-line label.\nSecond line\nThird line")
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

frame = gtk_frame_new ("Left Justified Label")
label = gtk_label_new (!"This is a Left-Justified\\nMulti-line label.\nThird      line")
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT)
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

frame = gtk_frame_new ("Right Justified Label")
label = gtk_label_new (!"This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)")
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT)
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

vbox = gtk_vbox_new (FALSE, 5)
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0)
frame = gtk_frame_new ("Line wrapped label")
VAR buffer = @( _
  "This is an example of a line-wrapped label.  It should not be taking up the entire " _
  "width allocated to it, but automatically " _
  "wraps the words to fit.  " _
  "The time has come, for all good men, to come to " _
  "the aid of their party.  " _
  !"The sixth sheik's six sheep's sick.\n" _
  "     It supports multiple paragraphs correctly, " _
  "and  correctly   adds " _
  "many          extra  spaces. " _
  )

label = gtk_label_new (buffer)
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE)
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

frame = gtk_frame_new ("Filled, wrapped label")
buffer = @( _
  "This is an example of a line-wrapped, filled label.  " _
  "It should be taking " _
  "up the entire              width allocated to it.  " _
  "Here is a sentence to prove " _
  "my point.  Here is another sentence. " _
  !"Here comes the sun, do de do de do.\n" _
  !"    This is a new paragraph.\n" _
  "    This is another newer, longer, better " _
  "paragraph.  It is coming to an end, " _
  "unfortunately." _
  )
label = gtk_label_new (buffer)
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL)
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE)
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

frame = gtk_frame_new ("Underlined label")
label = gtk_label_new (!"This label is underlined!\nThis one is underlined in quite a funky fashion")
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT)
gtk_label_set_pattern (GTK_LABEL (label), "_________________________ _ _________ _ ______     __ _______ ___")
gtk_container_add (GTK_CONTAINER (frame), label)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0)

gtk_widget_show_all (win)

gtk_main ()
