~ubuntu-branches/ubuntu/feisty/fpc/feisty

« back to all changes in this revision

Viewing changes to docs/gtk1ex/ex3.pp

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-01-27 20:08:50 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070127200850-9mrptaqqjsx9nwa7
Tags: 2.0.4-5
* Fixed Build-Depends.
* Add myself to Uploaders in debian/control.
* Make sure that the sources are really patched before building them.
* Build unit 'libc' on powerpc too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
program ex3;
2
 
 
3
 
{$mode objfpc}
4
 
 
5
 
uses
6
 
 glib,gtk;
7
 
 
8
 
function newbutton(ALabel : PChar) : PGtkWidget;
9
 
 
10
 
begin
11
 
  Result:=gtk_button_new_with_label(ALabel);
12
 
  gtk_widget_show(result);
13
 
end;
14
 
 
15
 
procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
16
 
begin
17
 
  gtk_main_quit();
18
 
end;
19
 
 
20
 
var
21
 
  window,
22
 
  totalbox,
23
 
  hbox,vbox : PgtkWidget;
24
 
 
25
 
begin
26
 
  gtk_init (@argc, @argv);
27
 
  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
28
 
  // Box to divide window in 2 halves:
29
 
  totalbox := gtk_vbox_new(true,10);
30
 
  gtk_widget_show(totalbox);
31
 
  // A box for each half of the screen:
32
 
  hbox := gtk_hbox_new(false,5);
33
 
  gtk_widget_show(hbox);
34
 
  vbox := gtk_vbox_new(true,5);
35
 
  gtk_widget_show(vbox);
36
 
  // Put boxes in their halves
37
 
  gtk_box_pack_start(GTK_BOX(totalbox),hbox,true,true,0);
38
 
  gtk_box_pack_start(GTK_BOX(totalbox),vbox,true,true,0);
39
 
  // Now fill boxes with buttons.
40
 
  // Horizontal box
41
 
  gtk_box_pack_start(GTK_BOX(hbox),newbutton('Button 1'),false,false,0);
42
 
  gtk_box_pack_start(GTK_BOX(hbox),newbutton('Button 2'),false,false,0);
43
 
  gtk_box_pack_start(GTK_BOX(hbox),newbutton('Button 3'),false,false,0);
44
 
  // Vertical box
45
 
  gtk_box_pack_start(GTK_BOX(vbox),newbutton('Button A'),true,true,0);
46
 
  gtk_box_pack_start(GTK_BOX(vbox),newbutton('Button B'),true,true,0);
47
 
  gtk_box_pack_start(GTK_BOX(vbox),newbutton('Button C'),true,true,0);
48
 
  // Put totalbox in window
49
 
  gtk_container_set_border_width(GTK_CONTAINER(Window),5);
50
 
  gtk_container_add(GTK_Container(window),totalbox);
51
 
  gtk_signal_connect (PGTKOBJECT (window), 'destroy',
52
 
                      GTK_SIGNAL_FUNC (@destroy), NULL);
53
 
  gtk_widget_show (window);
54
 
  gtk_main ();
55
 
end.