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

« back to all changes in this revision

Viewing changes to fpcdocs/gtk1ex/ex4.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 ex4;
 
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
  maintable:  PgtkWidget;
 
23
 
 
24
procedure AddToTable(Widget : PGtkWidget;
 
25
                     Left,Right, Top,Bottom : guint);
 
26
begin
 
27
  gtk_table_attach_defaults (GTK_TABLE(MainTable),Widget,
 
28
                             Left,right,top,bottom);
 
29
end;
 
30
 
 
31
begin
 
32
  gtk_init (@argc, @argv);
 
33
  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
34
  Maintable := gtk_table_new(6,6,True);
 
35
  gtk_widget_show(MainTable);
 
36
  AddToTable(newbutton('1,1 At 1,1'),1,2,1,2);
 
37
  AddToTable(newbutton('2,2 At 3,1'),3,5,1,3);
 
38
  AddToTable(newbutton('4,1 At 4,1'),1,5,4,5);
 
39
  // Put all in window
 
40
  gtk_container_set_border_width(GTK_CONTAINER(Window),5);
 
41
  gtk_container_add(GTK_Container(window),maintable);
 
42
  gtk_signal_connect (PGTKOBJECT (window), 'destroy',
 
43
                      GTK_SIGNAL_FUNC (@destroy), NULL);
 
44
  gtk_widget_show (window);
 
45
  gtk_main ();
 
46
end.