Programmation GTK2 en Pascal/GtkHSeparator

Programmation GTK2 en Pascal

Présentation modifier

Le contrôle GtkHSeparator permet de dessiner une ligne horizontale entre des contrôles.

Hiérarchie modifier

Hiérarchie
GObject
  └─GtkObject
      └─GtkWidget
          └─GtkSeparator
              └─GtkHSeparator

Utilisation de base modifier

Création modifier

Ce contrôle n'a qu'une seule fonction : sa fonction de création :

function gtk_hseparator_new : PGtkWidget;

Il n'y a rien de plus à dire à propos de ce contrôle.

Programme exemple modifier

Voilà le fichier gtk040.pas :

program gtk040;

uses glib2, gtk2;

var
  pFenetre   : PGtkWidget;
  pVBox      : PGtkWidget;
  pLabel1    : PGtkWidget;
  pSeparateur : PGtkWidget;
  pLabel2    : PGtkWidget;

begin
  gtk_init(@argc, @argv);
  pFenetre := gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(pFenetre), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(pFenetre), 320, 200);
  gtk_window_set_title(GTK_WINDOW(pFenetre), 'Gtk040 : Séparateur');
  gtk_signal_connect(G_OBJECT(pFenetre), 'destroy', G_CALLBACK(gtk_main_quit), NULL);

  // Création de la GtkVBox
  pVBox := gtk_vbox_new(FALSE, 5);
  gtk_container_add(GTK_CONTAINER(pFenetre), pVBox);

  // Création du label 1
  pLabel1 := gtk_label_new('Label 1');
  gtk_box_pack_start(GTK_BOX(pVBox), pLabel1, FALSE, FALSE, 0);

  // Création du séparateur
  pSeparateur := gtk_hseparator_new;
  gtk_box_pack_start(GTK_BOX(pVBox), pSeparateur, FALSE, FALSE, 0);
    
  // Création du label 2
  pLabel2 := gtk_label_new('Label 2');
  gtk_box_pack_start(GTK_BOX(pVBox), pLabel2, FALSE, FALSE, 0);

  gtk_widget_show_all(pFenetre);
  gtk_main;
end.

Voilà ce que donne l'exécution du programme gtk040 :

 


Décorations : GtkFrame ~ GtkHSeparator ~ GtkVSeparator