Browse Source

+ Added examples from Artur Bac

michael 24 years ago
parent
commit
36c5f145e2

+ 155 - 0
packages/gtk/examples/paned.pp

@@ -0,0 +1,155 @@
+{
+  $Id$
+
+  Converted from C to Pascal by Artur Bac
+  <[email protected]>
+  Reda Poland
+}
+{$MODE objfpc}
+{$H+}
+{$S+}
+{$HINTS ON}
+{$ifdef win32}
+  {$define extdecl := stdcall;}
+  {$APPTYPE GUI}
+{$endif}
+{$ifdef linux}
+  {$define extdecl := cdecl;}
+{$endif}
+Program panned;
+uses glib,gtk;
+Function create_list : PGtkWidget; cdecl;
+Var
+    scrolled_window : PGtkWidget;
+    list            : PGtkWidget;
+    list_item       : PGtkWidget;
+    i               : longint;
+    buffer          : ansistring;
+    Ptr_Buffer      : PChar ;
+Begin
+    // Create a new scrolled window, with scrollbars only if needed
+    scrolled_window := gtk_scrolled_window_new (NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+        GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
+
+    // Create a new list and put it in the scrolled window
+    list := gtk_list_new ();
+    gtk_scrolled_window_add_with_viewport (
+               GTK_SCROLLED_WINDOW (scrolled_window), list);
+    gtk_widget_show (list);
+
+    // Add some messages to the window
+    for i:=0 to 10 do Begin
+        Str (i,buffer);
+        buffer := 'Message #' + buffer;
+        Ptr_buffer := PChar (buffer);
+        list_item := gtk_list_item_new_with_label (Ptr_buffer);
+        gtk_container_add (GTK_CONTAINER(list), list_item);
+        gtk_widget_show (list_item);
+    End;
+
+    create_list := scrolled_window;
+End;
+
+{ Add some text_ to our text_ widget - this is a callback that is invoked
+when our window is realized. We could also force our window to be
+realized with gtk_widget_realize, but it would have to be part of
+a hierarchy first }
+
+Procedure realize_text( text_ : PGtkWidget ;
+                   data : gpointer); cdecl;
+Var
+    style   : PGtkStyle;
+Begin
+    gtk_text_freeze (GTK_text (text_));
+    style := gtk_widget_get_style (text_);
+    gtk_text_insert (GTK_text (text_), NULL, @style^.black, NULL,
+    'From: [email protected]'+#10+
+    'To: [email protected]'+#10+
+    'Subject: Made it!'+#10+
+    +#10+
+    'We just got in this morning. The weather has been'+#10+
+    'great - clear but cold, and there are lots of fun sights.'+#10+
+    'Sojourner says hi. See you soon.'+#10+
+    ' -Path'+#10, -1);
+
+    gtk_text_thaw (GTK_text (text_));
+End;
+
+{ Create a scrolled text area that displays a 'message' }
+Function create_text : PGtkWidget; cdecl;
+Var
+    table,
+    text_,
+    hscrollbar,
+    vscrollbar : PGtkWidget;
+Begin
+    { Create a table to hold the text_ widget and scrollbars }
+    table:= gtk_table_new (2, 2, FALSE);
+
+    { Put a text_ widget in the upper left hand corner. Note the use of
+      GTK_SHRINK in the y direction }
+    text_ := gtk_text_new (NULL, NULL);
+    gtk_table_attach (GTK_TABLE (table), text_, 0, 1, 0, 1,
+            GTK_FILL  OR  GTK_EXPAND,
+            GTK_FILL  OR  GTK_EXPAND  OR  GTK_SHRINK, 0, 0);
+    gtk_widget_show (text_);
+
+    { Put a HScrollbar in the lower left hand corner }
+    hscrollbar := gtk_hscrollbar_new (GTK_text (text_)^.hadj);
+    gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 1, 2,
+            GTK_EXPAND  OR  GTK_FILL, GTK_FILL, 0, 0);
+    gtk_widget_show (hscrollbar);
+
+    { And a VScrollbar in the upper right }
+    vscrollbar := gtk_vscrollbar_new (GTK_text (text_)^.vadj);
+    gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
+            GTK_FILL, GTK_EXPAND  OR  GTK_FILL  OR  GTK_SHRINK, 0, 0);
+    gtk_widget_show (vscrollbar);
+
+    { Add a handler to put a message in the text_ widget when it is realized }
+    gtk_signal_connect (GTK_OBJECT (text_), 'realize',
+            GTK_SIGNAL_FUNC (@realize_text), NULL);
+
+    create_text := table;
+End;
+
+Var
+    window,
+    vpaned,
+    list,
+    text_ : PGtkWidget;
+Begin
+    gtk_set_locale ();
+    gtk_init (@argc, @argv);
+    gtk_rc_init;
+
+    window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
+    gtk_window_set_title (GTK_WINDOW (window), 'Paned Windows');
+    gtk_signal_connect (GTK_OBJECT (window), 'destroy',
+            GTK_SIGNAL_FUNC (@gtk_main_quit), NULL);
+    gtk_container_set_border_width (GTK_CONTAINER (window), 10);
+    gtk_widget_set_usize (GTK_WIDGET(window), 450, 400);
+
+    { create a vpaned widget and add it to our toplevel window }
+
+    vpaned := gtk_vpaned_new ();
+    gtk_container_add (GTK_CONTAINER(window), vpaned);
+    gtk_paned_set_handle_size (GTK_PANED(vpaned),
+                               10);
+//    gtk_paned_set_gutter_size (GTK_PANED(vpaned), 15);
+    gtk_widget_show (vpaned);
+
+    { Now create the contents of the two halves of the window }
+
+    list := create_list ();
+    gtk_paned_add1 (GTK_PANED(vpaned), list);
+    gtk_widget_show (list);
+
+    text_ := create_text ();
+    gtk_paned_add2 (GTK_PANED(vpaned), text_);
+    gtk_widget_show (text_);
+    gtk_widget_show (window);
+    gtk_main ();
+End.
+

+ 258 - 0
packages/gtk/examples/spinbutton.pp

@@ -0,0 +1,258 @@
+{
+  $Id$
+
+  Converted from C to Pascal by Artur Bac with liitle additions by me
+  <[email protected]>
+  Reda Poland
+}
+{$MODE objfpc}
+{$H+}
+{$S+}
+{$HINTS ON}
+{$ifdef win32}
+  {$define extdecl := stdcall;}
+  {$APPTYPE GUI}
+{$endif}
+{$ifdef linux}
+  {$define extdecl := cdecl;}
+{$endif}
+
+Program spinbutton;
+
+Uses glib,gtk;
+
+Type
+    PGInt = ^gint;
+Const
+    a : gint = 1;
+    b : gint = 2;
+Var
+ spinner1 ,
+ spinner2 : PGtkWidget;
+
+Function  GPOINTER_TO_INT (data : pgint) : gint;
+Begin
+    GPOINTER_TO_INT := data^;
+End;
+
+Procedure toggle_snap( widget : PGtkWidget;
+                         spin : PGtkSpinButton ); cdecl;
+Begin
+  gtk_spin_button_set_snap_to_ticks (spin,
+            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+End ;
+
+Procedure toggle_numeric( widget : PGtkWidget;
+                         spin : PGtkSpinButton ); cdecl;
+Begin
+  gtk_spin_button_set_numeric (spin,
+                            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)));
+End;
+
+Procedure change_digits( widget : PGtkWidget;
+	            spin : PGtkSpinButton ); cdecl;
+Begin
+  gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner1),
+                              gtk_spin_button_get_value_as_int (spin));
+End;
+
+Procedure  get_value( widget : PGtkWidget;
+                    data : gpointer ) ; cdecl;
+Var
+  Ptr_buf   : PGchar;
+  buf       : string;
+  label_l   : PGtkLabel ;
+  spin,spin2: PGtkSpinButton;
+Begin
+  spin := GTK_SPIN_BUTTON (spinner1);
+  spin2 := GTK_SPIN_BUTTON (spinner2);
+  label_l := GTK_LABEL (gtk_object_get_user_data (GTK_OBJECT (widget)));
+  if (GPOINTER_TO_INT (data) = 1) then
+    str(gtk_spin_button_get_value_as_int (spin),buf)
+  else
+    Str(gtk_spin_button_get_value_as_float (spin)
+                    :10:gtk_spin_button_get_value_as_int(spin2)  //This checks how many digits we have
+                    ,buf);
+  Ptr_buf:=PChar(buf); //We have to change ansistring to a pointer to char PChar == PGChar
+  gtk_label_set_text (label_l, Ptr_buf);
+End;
+
+
+Var
+  window,
+  frame,
+  hbox,
+  main_vbox,
+  vbox,
+  vbox2,
+  spinner,
+  button,
+  label_l,
+  val_label : PGtkWidget;
+  adj : PGtkAdjustment;
+Begin
+  // Initialise GTK
+  gtk_set_locale ();
+  gtk_init(@argc, @argv);
+  gtk_rc_init;
+
+  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+  gtk_signal_connect (GTK_OBJECT (window), 'destroy',
+		      GTK_SIGNAL_FUNC (@gtk_main_quit),
+		      NULL);
+
+  gtk_window_set_title (GTK_WINDOW (window), 'Spin Button');
+
+  main_vbox := gtk_vbox_new (FALSE, 5);
+  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 10);
+  gtk_container_add (GTK_CONTAINER (window), main_vbox);
+
+  frame := gtk_frame_new ('Not accelerated');
+  gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
+
+  vbox := gtk_vbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+  gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+  // Day, month, year spinners
+
+  hbox := gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
+
+  vbox2 := gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
+
+  label_l := gtk_label_new ('Day :');
+  gtk_misc_set_alignment (GTK_MISC (label_l), 0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox2), label_l, FALSE, TRUE, 0);
+
+  adj := PGtkAdjustment ( gtk_adjustment_new (1.0, 1.0, 31.0, 1.0,
+					      5.0, 0.0));
+  spinner := gtk_spin_button_new (adj, 0, 0);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE);
+  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
+				   GTK_SHADOW_OUT);
+  gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
+
+  vbox2 := gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
+
+  label_l := gtk_label_new ('Month :');
+  gtk_misc_set_alignment (GTK_MISC (label_l), 0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox2), label_l, FALSE, TRUE, 0);
+
+  adj := PGtkAdjustment (gtk_adjustment_new (1.0, 1.0, 12.0, 1.0,
+					      5.0, 0.0));
+  spinner := gtk_spin_button_new (adj, 0, 0);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), TRUE);
+  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
+				   GTK_SHADOW_ETCHED_IN);
+  gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
+
+  vbox2 := gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
+
+  label_l := gtk_label_new ('Year :');
+  gtk_misc_set_alignment (GTK_MISC (label_l), 0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox2), label_l, FALSE, TRUE, 0);
+
+  adj := PGtkAdjustment (gtk_adjustment_new (1998.0, 0.0, 2100.0,
+					      1.0, 100.0, 0.0));
+  spinner := gtk_spin_button_new (adj, 0, 0);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), FALSE);
+  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner),
+				   GTK_SHADOW_IN);
+  gtk_widget_set_usize (spinner, 55, 0);
+  gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
+
+  frame := gtk_frame_new ('Accelerated');
+  gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
+
+  vbox := gtk_vbox_new (FALSE, 0);
+  gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+  gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+  hbox := gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
+
+  vbox2 := gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
+
+  label_l := gtk_label_new ('Value :');
+  gtk_misc_set_alignment (GTK_MISC (label_l), 0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox2), label_l, FALSE, TRUE, 0);
+
+  adj := PGtkAdjustment (gtk_adjustment_new (0.0, -10000.0, 10000.0,
+					      0.5, 100.0, 0.0));
+  spinner1 := gtk_spin_button_new (adj, 1.0, 2);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner1), TRUE);
+  gtk_widget_set_usize (spinner1, 100, 0);
+  gtk_box_pack_start (GTK_BOX (vbox2), spinner1, FALSE, TRUE, 0);
+
+  vbox2 := gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 5);
+
+  label_l := gtk_label_new ('Digits :');
+  gtk_misc_set_alignment (GTK_MISC (label_l), 0, 0.5);
+  gtk_box_pack_start (GTK_BOX (vbox2), label_l, FALSE, TRUE, 0);
+
+  adj := PGtkAdjustment (gtk_adjustment_new (2, 1, 5, 1, 1, 0));
+  spinner2 := gtk_spin_button_new (adj, 0.0, 0);
+  gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner2), TRUE);
+  gtk_signal_connect (GTK_OBJECT (adj), 'value_changed',
+		      GTK_SIGNAL_FUNC (@change_digits),
+		      gpointer (spinner2));
+  gtk_box_pack_start (GTK_BOX (vbox2), spinner2, FALSE, TRUE, 0);
+
+  hbox := gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
+
+  button := gtk_check_button_new_with_label ('Snap to 0.5-ticks');
+  gtk_signal_connect (GTK_OBJECT (button), 'clicked',
+		      GTK_SIGNAL_FUNC (@toggle_snap),
+		      spinner1);
+  gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+
+  button := gtk_check_button_new_with_label ('Numeric only input mode');
+  gtk_signal_connect (GTK_OBJECT (button), 'clicked',
+		      GTK_SIGNAL_FUNC (@toggle_numeric),
+		      spinner1);
+  gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+
+  val_label := gtk_label_new ('');
+
+  hbox := gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
+  button := gtk_button_new_with_label ('Value as Int');
+  gtk_object_set_user_data (GTK_OBJECT (button), val_label);
+  gtk_signal_connect (GTK_OBJECT (button), 'clicked',
+          GTK_SIGNAL_FUNC (@get_value),@a);
+  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+
+  button := gtk_button_new_with_label ('Value as Float');
+  gtk_object_set_user_data (GTK_OBJECT (button), val_label);
+  gtk_signal_connect (GTK_OBJECT (button), 'clicked',
+              GTK_SIGNAL_FUNC (@get_value),@b);
+  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+
+  gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
+  gtk_label_set_text (GTK_LABEL (val_label), '0');
+
+  hbox := gtk_hbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
+
+  button := gtk_button_new_with_label ('Close');
+  gtk_signal_connect_object (GTK_OBJECT (button), 'clicked',
+			     GTK_SIGNAL_FUNC (@gtk_widget_destroy),
+			     GTK_OBJECT (window));
+  gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
+
+  gtk_widget_show_all (window);
+
+  // Enter the event loop
+  gtk_main ();
+
+End.

+ 88 - 0
packages/gtk/examples/statusbar.pp

@@ -0,0 +1,88 @@
+{
+  $Id$
+
+  Converted from C to Pascal by Artur Bac with liitle additions changes
+  <[email protected]>
+  Reda Poland
+}
+{$MODE objfpc}
+{$H+}
+{$S+}
+{$HINTS ON}
+{$ifdef win32}
+  {$define extdecl := stdcall;}
+  {$APPTYPE GUI}
+{$endif}
+{$ifdef linux}
+  {$define extdecl := cdecl;}
+{$endif}
+
+Program statusbar;
+Uses glib,gtk;
+Type
+    PGInt = ^gint;
+Var
+    status_bar : PGtkWidget;
+    count         : longint;
+Procedure push_item( widget : PGtkWidget;
+                data : PGInt); cdecl;
+    Var
+      buff          : ansistring;
+      ptr_buff      : PGChar;
+    Begin
+      Inc(count);
+      Str(count,buff);
+      buff := 'Item ' + buff;
+
+      Ptr_buff := PChar(buff); //changing type from ansistring to PGChar == PChar
+      gtk_statusbar_push(GTK_STATUSBAR(status_bar), data^, Ptr_buff);
+    End;
+Procedure pop_item( widget : PGtkWidget;
+               data : PGint); cdecl; //i used pointer to gint , not gpointer becouse we can
+                                     // read value directly from an adress specified in data
+Begin
+  gtk_statusbar_pop( GTK_STATUSBAR(status_bar), data^);
+End;
+
+Var
+    window,
+    vbox,
+    button1,button2 : PGtkWidget;
+
+    context_id : gint;
+Begin
+    gtk_set_locale ();
+    gtk_init (@argc, @argv);
+    gtk_rc_init;
+    count:=1;
+    //* create a new window
+    window := gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    gtk_widget_set_usize( GTK_WIDGET (window), 200, 100); // GTK_WIDGET == PGtkWidget
+    gtk_window_set_title(GTK_WINDOW (window), 'GTK Statusbar Example');
+
+    vbox := gtk_vbox_new(FALSE, 1);
+    gtk_container_add(GTK_CONTAINER(window), vbox);
+
+    status_bar := gtk_statusbar_new();
+    gtk_box_pack_start (GTK_BOX (vbox), status_bar, TRUE, TRUE, 0);
+
+    context_id := gtk_statusbar_get_context_id(
+                          GTK_STATUSBAR(status_bar), 'Statusbar example');
+
+    button1 := gtk_button_new_with_label('push item');
+    gtk_box_pack_start(GTK_BOX(vbox), button1, TRUE, TRUE, 2);
+
+    button2 := gtk_button_new_with_label('pop last item');
+    gtk_box_pack_start(GTK_BOX(vbox), button2, TRUE, TRUE, 2);
+
+
+    gtk_signal_connect(GTK_OBJECT (window), 'delete_event',
+                       Gtk_Signal_Func (@gtk_exit), NULL);
+    gtk_signal_connect(GTK_OBJECT(button1), 'clicked',
+        GTK_SIGNAL_FUNC (@push_item), @context_id );
+    gtk_signal_connect(GTK_OBJECT(button2), 'clicked',
+        GTK_SIGNAL_FUNC (@pop_item), @context_id );
+
+    gtk_widget_show_all (window);
+    gtk_main ();
+End.

+ 328 - 0
packages/gtk/examples/toolbar.pp

@@ -0,0 +1,328 @@
+{
+  $Id$
+
+  Converted from C to Pascal by Artur Bac
+  <[email protected]>
+  Reda Poland
+}
+{$MODE objfpc}
+{$H+}
+{$S+}
+{$HINTS ON}
+{$ifdef win32}
+  {$define extdecl := stdcall;}
+  {$APPTYPE GUI}
+{$endif}
+{$ifdef linux}
+  {$define extdecl := cdecl;}
+{$endif}
+
+Program tool_bar;
+uses glib,gdk,gtk;
+Const
+//* XPM */
+gtk_xpm : array[0..44]of pgchar = (
+'32 39 5 1',
+'.      c none',
+'+      c black',
+'@      c #3070E0',
+'#      c #F05050',
+'$      c #35E035',
+'................+...............',
+'..............+++++.............',
+'............+++++@@++...........',
+'..........+++++@@@@@@++.........',
+'........++++@@@@@@@@@@++........',
+'......++++@@++++++++@@@++.......',
+'.....+++@@@+++++++++++@@@++.....',
+'...+++@@@@+++@@@@@@++++@@@@+....',
+'..+++@@@@+++@@@@@@@@+++@@@@@++..',
+'.++@@@@@@+++@@@@@@@@@@@@@@@@@@++',
+'.+#+@@@@@@++@@@@+++@@@@@@@@@@@@+',
+'.+##++@@@@+++@@@+++++@@@@@@@@$@.',
+'.+###++@@@@+++@@@+++@@@@@++$$$@.',
+'.+####+++@@@+++++++@@@@@+@$$$$@.',
+'.+#####+++@@@@+++@@@@++@$$$$$$+.',
+'.+######++++@@@@@@@++@$$$$$$$$+.',
+'.+#######+##+@@@@+++$$$$$$@@$$+.',
+'.+###+++##+##+@@++@$$$$$$++$$$+.',
+'.+###++++##+##+@@$$$$$$$@+@$$@+.',
+'.+###++++++#+++@$$@+@$$@++$$$@+.',
+'.+####+++++++#++$$@+@$$++$$$$+..',
+'.++####++++++#++$$@+@$++@$$$$+..',
+'.+#####+++++##++$$++@+++$$$$$+..',
+'.++####+++##+#++$$+++++@$$$$$+..',
+'.++####+++####++$$++++++@$$$@+..',
+'.+#####++#####++$$+++@++++@$@+..',
+'.+#####++#####++$$++@$$@+++$@@..',
+'.++####++#####++$$++$$$$$+@$@++.',
+'.++####++#####++$$++$$$$$$$$+++.',
+'.+++####+#####++$$++$$$$$$$@+++.',
+'..+++#########+@$$+@$$$$$$+++...',
+'...+++########+@$$$$$$$$@+++....',
+'.....+++######+@$$$$$$$+++......',
+'......+++#####+@$$$$$@++........',
+'.......+++####+@$$$$+++.........',
+'.........++###+$$$@++...........',
+'..........++##+$@+++............',
+'...........+++++++..............',
+'.............++++...............');
+{ This function is connected to the Close button or
+  closing the window from the WM }
+function BOOL_TO_GINT(data : boolean) : gint;
+Begin
+    if data then
+       BOOL_TO_GINT:=1
+    else
+        BOOL_TO_GINT:=0;
+end;
+function delete_event (widget  : PGtkWidget ;
+                event : PGdkEvent;
+                data : gpointer) : boolean ; cdecl;
+Begin
+  gtk_main_quit ();
+  delete_event :=FALSE;
+end;
+
+{The above beginning seems for sure familiar to you if it's not your first GTK program.
+There is one additional thing though,
+we include a nice XPM picture to serve as an icon for all of the buttons.
+}
+Var
+    close_button : PGtkWidget; { This button will emit signal to close application }
+    tooltips_button : PGtkWidget; { to enable/disable tooltips }
+    text_button  : PGtkWidget;
+    icon_button  : PGtkWidget;
+    both_button  : PGtkWidget; { radio buttons for toolbar style }
+    entry        : PGtkWidget; { a text entry to show packing any widget into toolbar }
+
+//In fact not all of the above widgets are needed here,
+//but to make things clearer I put them all together.
+
+{ that's easy... when one of the buttons is toggled, we just
+ * check which one is active and set the style of the toolbar
+ * accordingly
+ * ATTENTION: our toolbar is passed as data to callback ! }
+Procedure radio_event (widget : PGTkWidget;  data : gpointer); cdecl;
+
+Begin
+  if (gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON (text_button))) then
+    gtk_toolbar_set_style(GTK_TOOLBAR ( data ), GTK_TOOLBAR_TEXT)
+  else begin
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (icon_button))) then
+        gtk_toolbar_set_style(GTK_TOOLBAR ( data ), GTK_TOOLBAR_ICONS);
+    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (both_button))) then
+        gtk_toolbar_set_style(GTK_TOOLBAR ( data ), GTK_TOOLBAR_BOTH);
+    end;
+End;
+
+{ even easier, just check given toggle button and enable/disable
+ * tooltips }
+Procedure toggle_event (widget : PGtkWidget; data : gpointer); cdecl;
+Begin
+{Due to gtk specification
+
+void        gtk_toolbar_set_tooltips        (GtkToolbar *toolbar,
+                                             gboolean enable);
+In Pasal unit this functioni is implemented as
+procedure gtk_toolbar_set_tooltips (toolbar:PGtkToolbar;
+                         enable:gint);
+                         cdecl;external gtkdll name 'gtk_toolbar_set_tooltips';
+so we have to change boolean to gint with function BOOL_TO_GINT implemented
+on the top of source
+}
+  gtk_toolbar_set_tooltips (GTK_TOOLBAR ( data ),
+                            BOOL_TO_GINT(
+                                gtk_toggle_button_get_active(
+                                    GTK_TOGGLE_BUTTON (widget))));
+End;
+
+{The above are just two callback functions that will be called
+when one of the buttons on a toolbar is pressed.
+You should already be familiar with things like this if you've already used toggle buttons
+and radio buttons.
+}
+Var
+  { Here is our main window (a dialog) and a handle for the handlebox }
+  dialog : PGtkWidget;
+  handlebox : PGtkWidget;
+
+  { Ok, we need a toolbar, an icon with a mask (one for all of
+     the buttons) and an icon widget to put this icon in (but
+     we'll create a separate widget for each button) }
+  toolbar : PGtkWidget;
+  icon : PGdkPixmap;
+  mask : PGdkBitmap;
+  iconw : PGtkWidget;
+  style : PGtkStyle;
+Begin
+  { this is called in all GTK application. }
+  gtk_set_locale (); //It important for apps taht use local language specific characters
+  gtk_init (@argc, @argv);
+  gtk_rc_init;
+
+  { create a new window with a given title, and nice size }
+  dialog := gtk_dialog_new ();
+  gtk_window_set_title ( GTK_WINDOW ( dialog ) , 'GTKToolbar Tutorial');
+  gtk_widget_set_usize( GTK_WIDGET ( dialog ) , 600 , 300 );
+  set_allow_shrink(PGtkWindow(dialog)^,BM_ALLOW_SHRINK);
+
+  { typically we quit if someone tries to close us }
+  gtk_signal_connect ( GTK_OBJECT ( dialog ), 'delete_event',
+                       GTK_SIGNAL_FUNC ( @delete_event ), NULL);
+
+  { we need to realize the window because we use pixmaps for
+   * items on the toolbar in the context of it }
+  gtk_widget_realize ( dialog );
+
+  { to make it nice we'll put the toolbar into the handle box,
+   * so that it can be detached from the main window }
+  handlebox := gtk_handle_box_new ();
+  gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG(dialog)^.vbox ),
+                       handlebox, FALSE, FALSE, 5 );
+
+{The above should be similar to any other GTK application.
+Just initialization of GTK, creating the window, etc.
+There is only one thing that probably needs some explanation:
+a handle box. A handle box is just another box that can be used to pack widgets in to.
+ The difference between it and typical boxes is that it can be detached from
+ a parent window (or, in fact, the handle box remains in the parent,
+ but it is reduced to a very small rectangle, while all of its contents
+  are reparented to a new freely floating window). It is usually nice
+  to have a detachable toolbar, so these two widgets occur together quite often.
+   toolbar will be horizontal, with both icons and text, and
+   * with 5pxl spaces between items and finally,
+   * we'll also put it into our handlebox }
+  toolbar := gtk_toolbar_new ( GTK_ORIENTATION_HORIZONTAL,
+                              GTK_TOOLBAR_BOTH );
+  gtk_container_set_border_width ( GTK_CONTAINER ( toolbar ) , 5 );
+  gtk_toolbar_set_space_size ( GTK_TOOLBAR ( toolbar ), 5 );
+  gtk_container_add ( GTK_CONTAINER ( handlebox ) , toolbar );
+
+  { now we create icon with mask: we'll reuse it to create
+   * icon widgets for toolbar items }
+  style := gtk_widget_get_style( dialog );
+  icon := gdk_pixmap_create_from_xpm_d ( dialog^.window, @mask,
+      @style^.fg_gc, gtk_xpm );
+
+{Well, what we do above is just a straightforward initialization of the toolbar widget
+ and creation of a GDK pixmap with its mask.
+  If you want to know something more about using pixmaps,
+   refer to GDK documentation or to the Pixmaps section earlier in this tutorial.}
+
+  { our first item is <close> button }
+  iconw := gtk_pixmap_new ( icon, mask ); { icon widget }
+  close_button :=
+  gtk_toolbar_append_item ( GTK_TOOLBAR (toolbar), { our toolbar }
+                              'Close',               { button label }
+                              'Closes this app',     { this button's tooltip }
+                              'Private',             { tooltip private info }
+                              iconw,                 { icon widget }
+                              GTK_SIGNAL_FUNC (@delete_event), { a signal }
+                               NULL );
+  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) ); { space after item }
+
+{In the above code you see the simplest case: adding a button to toolbar.
+ Just before appending a new item, we have to construct a pixmap widget
+ to serve as an icon for this item; this step will have to be repeated for each new item.
+ Just after the item we also add a space, so the following items will not touch each other.
+ As you see gtk_toolbar_append_item returns a pointer to our newly created button widget,
+  so that we can work with it in the normal way.}
+
+  { now, let's make our radio buttons group... }
+  iconw := gtk_pixmap_new ( icon, mask );
+  icon_button := gtk_toolbar_append_element(
+                    GTK_TOOLBAR(toolbar),
+                    GTK_TOOLBAR_CHILD_RADIOBUTTON, { a type of element }
+                    NULL,                          { pointer to widget }
+                    'Icon',                        { label }
+                    'Only icons in toolbar',       { tooltip }
+                    'Private',                     { tooltip private string }
+                    iconw,                         { icon }
+                    GTK_SIGNAL_FUNC (@radio_event), { signal }
+                    toolbar);                      { data for signal }
+  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) );
+
+{Here we begin creating a radio buttons group.
+To do this we use gtk_toolbar_append_element.
+In fact, using this function one can also +add simple items or even spaces
+(type := GTK_TOOLBAR_CHILD_SPACE or +GTK_TOOLBAR_CHILD_BUTTON).
+In the above case we start creating a radio group.
+In creating other radio buttons for this group a pointer to the previous button in the group
+is required, so that a list of buttons can be easily constructed
+(see the section on  Radio Buttons  earlier in this tutorial).
+
+   following radio buttons refer to previous ones }
+  iconw := gtk_pixmap_new ( icon, mask );
+  text_button :=
+    gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
+                               GTK_TOOLBAR_CHILD_RADIOBUTTON,
+                               icon_button,
+                               'Text',
+                               'Only texts in toolbar',
+                               'Private',
+                               iconw,
+                               GTK_SIGNAL_FUNC (@radio_event),
+                               toolbar);
+  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) );
+
+  iconw := gtk_pixmap_new ( icon, mask );
+  both_button :=
+    gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
+                               GTK_TOOLBAR_CHILD_RADIOBUTTON,
+                               text_button,
+                               'Both',
+                               'Icons and text in toolbar',
+                               'Private',
+                               iconw,
+                               GTK_SIGNAL_FUNC (@radio_event),
+                               toolbar);
+  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) );
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(both_button),TRUE);
+
+{In the end we have to set the state of one of the buttons manually
+(otherwise they all stay in active state, preventing us from switching between them).}
+
+  { here we have just a simple toggle button }
+  iconw := gtk_pixmap_new ( icon, mask );
+  tooltips_button :=
+    gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
+                               GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
+                               NULL,
+                               'Tooltips',
+                               'Toolbar with or without tips',
+                               'Private',
+                               iconw,
+                               GTK_SIGNAL_FUNC (@toggle_event),
+                               toolbar);
+  gtk_toolbar_append_space ( GTK_TOOLBAR ( toolbar ) );
+  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooltips_button),TRUE);
+
+{A toggle button can be created in the obvious way
+ (if one knows how to create radio buttons already).}
+
+  { to pack a widget into toolbar, we only have to
+    create it and append it with an appropriate tooltip }
+  entry := gtk_entry_new ();
+  gtk_toolbar_append_widget( GTK_TOOLBAR (toolbar),
+                             entry,
+                             'This is just an entry',
+                             'Private' );
+
+  { well, it isn't created within thetoolbar, so we must still show it }
+  gtk_widget_show ( entry );
+
+{As you see, adding any kind of widget to a toolbar is simple.
+The one thing you have to remember is that this widget must be shown manually
+ (contrary to other items which will be shown together with the toolbar).}
+
+  { that's it ! let's show everything. }
+  gtk_widget_show ( toolbar );
+  gtk_widget_show (handlebox);
+  gtk_widget_show ( dialog );
+
+  { rest in gtk_main and wait for the fun to begin! }
+  gtk_main ();
+
+End.
+