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

« back to all changes in this revision

Viewing changes to fpcdocs/gtk1ex/ex9.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 ex9;
 
2
 
 
3
uses
 
4
 gdk,glib,gtk,strings;
 
5
 
 
6
procedure destroy(widget : pGtkWidget ; data: pgpointer ); cdecl;
 
7
begin
 
8
  gtk_main_quit();
 
9
end;
 
10
 
 
11
Const
 
12
  Inside  : PChar ='Mouse is over label';
 
13
  OutSide : PChar ='Mouse is not over label';
 
14
 
 
15
var
 
16
  window, button1,Button2, Alabel,stackbox : PGtkWidget;
 
17
  buttonstyle : pgtkstyle;
 
18
  OverButton : boolean;
 
19
 
 
20
Procedure ChangeLabel(P : PGtkWidget;
 
21
                      Event : PGdkEventCrossing;
 
22
                      Var Data : Boolean);cdecl;
 
23
 
 
24
begin
 
25
 If Not Data then
 
26
    gtk_label_set_text(PGTKLABEL(ALabel),Inside)
 
27
  else
 
28
    gtk_label_set_text(PGTKLABEL(ALabel),Outside);
 
29
 Data := Not Data;
 
30
end;
 
31
 
 
32
begin
 
33
  gtk_init (@argc, @argv);
 
34
  window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
35
  stackbox:=gtk_vbox_new(TRUE,10);
 
36
  button1 := gtk_button_new_with_label(strnew('Move mouse over button'));
 
37
  buttonstyle := gtk_style_copy(gtk_widget_get_style(Button1));
 
38
    With ButtonStyle^.bg[GTK_STATE_PRELIGHT] do
 
39
      begin
 
40
      pixel:=0;
 
41
      red:=$ffff;
 
42
      blue:=0;
 
43
      green:=0;
 
44
      end;
 
45
  gtk_widget_set_style(button1,buttonstyle);
 
46
  button2 := gtk_button_new;
 
47
  ALabel:=gtk_label_new(Outside);
 
48
  gtk_container_add(GTK_CONTAINER(button2),ALAbel);
 
49
  gtk_box_pack_start(GTK_BOX(stackbox),button1,TRUE,TRUE,0);
 
50
  gtk_box_pack_start(GTK_BOX(stackbox),button2,TRUE,TRUE,0);
 
51
  gtk_container_set_border_width(GTK_CONTAINER(Window),5);
 
52
  gtk_container_add(GTK_Container(window),stackbox);
 
53
  gtk_signal_connect(PGTKOBJECT (window), 'destroy',
 
54
                     GTK_SIGNAL_FUNC (@destroy), NULL);
 
55
  overbutton:=False;
 
56
  gtk_signal_connect(PGTKOBJECT(button1),'enter_notify_event',
 
57
                     GTK_SIGNAL_FUNC (@ChangeLabel), @OverButton);
 
58
  gtk_signal_connect(PGTKOBJECT(button1),'leave_notify_event',
 
59
                     GTK_SIGNAL_FUNC (@ChangeLabel), @OverButton);
 
60
  gtk_widget_show_all (window);
 
61
  gtk_main ();
 
62
end.