~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/gtk/examples/pixmap.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{
 
2
 
 
3
  This file extracted from the GTK tutorial.
 
4
  pixmap.c
 
5
 
 
6
  Converted from C to Pascal by Frank Loemker
 
7
  <floemker@techfak.uni-bielefeld.de>
 
8
}
 
9
program pixmap;
 
10
uses
 
11
  glib,gdk,gtk;
 
12
 
 
13
{ XPM data of Open-File icon }
 
14
 
 
15
const
 
16
  xpm_data:array[0..19] of pchar =
 
17
  ('16 16 3 1',
 
18
   '       c None',
 
19
   '.      c #000000000000',
 
20
   'X      c #FFFFFFFFFFFF',
 
21
   '                ',
 
22
   '   ......       ',
 
23
   '   .XXX.X.      ',
 
24
   '   .XXX.XX.     ',
 
25
   '   .XXX.XXX.    ',
 
26
   '   .XXX.....    ',
 
27
   '   .XXXXXXX.    ',
 
28
   '   .XXXXXXX.    ',
 
29
   '   .XXXXXXX.    ',
 
30
   '   .XXXXXXX.    ',
 
31
   '   .XXXXXXX.    ',
 
32
   '   .XXXXXXX.    ',
 
33
   '   .XXXXXXX.    ',
 
34
   '   .........    ',
 
35
   '                ',
 
36
   '                ');
 
37
{ when invoked (via signal delete_event), terminates the application. }
 
38
procedure close_application(widget : pGtkWidget ; event: pGdkEvent ; data: pgpointer); cdecl;
 
39
begin
 
40
  gtk_main_quit();
 
41
end;
 
42
 
 
43
{ is invoked when the button is clicked.  It just prints a message. }
 
44
procedure button_clicked(widget : pGtkWidget ; data: pgpointer); cdecl;
 
45
begin
 
46
  writeln ('button clicked');
 
47
end;
 
48
 
 
49
{ GtkWidget is the storage type for widgets }
 
50
var window, pixmapwid, button : pGtkWidget;
 
51
  thepixmap                   : pGdkPixmap;
 
52
  mask                        : pGdkBitmap;
 
53
  style                       : pGtkStyle;
 
54
begin
 
55
  { create the main window, and attach delete_event signal to terminating
 
56
   the application }
 
57
  gtk_init( @argc, @argv );
 
58
  gtk_rc_init;
 
59
 
 
60
  window := gtk_window_new( GTK_WINDOW_TOPLEVEL );
 
61
  gtk_signal_connect (pGTKOBJECT (window), 'delete_event',
 
62
                      GTK_SIGNAL_FUNC (@close_application), NIL );
 
63
  gtk_container_set_border_width( pGTKCONTAINER (window), 10 );
 
64
  gtk_widget_show( window );
 
65
 
 
66
  { now for the pixmap from gdk }
 
67
  style := gtk_widget_get_style( window );
 
68
  thepixmap := gdk_pixmap_create_from_xpm_d( window^.window,  @mask,
 
69
                                        @style^.bg[GTK_STATE_NORMAL],
 
70
                                        ppgchar (xpm_data ));
 
71
 
 
72
  { a pixmap widget to contain the pixmap }
 
73
  pixmapwid := gtk_pixmap_new( thepixmap, mask );
 
74
  gtk_widget_show( pixmapwid );
 
75
 
 
76
  { a button to contain the pixmap widget }
 
77
  button := gtk_button_new();
 
78
  gtk_container_add( pGTKCONTAINER(button), pixmapwid );
 
79
  gtk_container_add( pGTKCONTAINER(window), button );
 
80
  gtk_widget_show( button );
 
81
 
 
82
  gtk_signal_connect (pGTKOBJECT(button), 'clicked',
 
83
                      GTK_SIGNAL_FUNC(@button_clicked), NIL );
 
84
 
 
85
  { show the window }
 
86
  gtk_main ();
 
87
end.