~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/extra/forms/demo/browserall.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{ This is a demo that shows the different types of browsers.  }
2
 
 
3
 
 
4
 
uses xforms,strings;
5
 
 
6
 
var
7
 
form : PFL_FORM;
8
 
br : array[0..3] of PFL_OBJECT;
9
 
exitobj, readout : PFL_OBJECT;
10
 
 
11
 
 
12
 
const
13
 
bnames : array[0..3] of pchar =
14
 
(
15
 
    'NORMAL_BROWSER', 'SELECT_BROWSER', 'HOLD_BROWSER', 'MULTI_BROWSER'
16
 
);
17
 
 
18
 
 
19
 
procedure deselect(obj  : PFL_OBJECT ; arg : longint);cdecl;
20
 
var
21
 
  i : longint ;
22
 
begin
23
 
  for i:=0 to 3 do
24
 
     fl_deselect_browser(br[i]);
25
 
end;
26
 
 
27
 
procedure set_size(obj : PFL_OBJECT; arg : longint);cdecl;
28
 
var
29
 
  i : longint;
30
 
begin
31
 
  for i:=0 to 3 do
32
 
     fl_set_browser_fontsize(br[i],arg);
33
 
end;
34
 
 
35
 
procedure set_style(obj : PFL_OBJECT; arg :  longint);cdecl;
36
 
var
37
 
  i : longint;
38
 
 
39
 
begin
40
 
  for i:=0 to 3 do
41
 
     fl_set_browser_fontstyle(br[i], arg);
42
 
end;
43
 
 
44
 
procedure br_callback(ob : PFL_OBJECT; arg : longint);cdecl;
45
 
var
46
 
    buf : string[255];
47
 
const
48
 
    mb : array[0..3] of pchar = ('','left','middle','right');
49
 
 
50
 
var i,b : longint;
51
 
 
52
 
begin
53
 
    b:=fl_mouse_button;
54
 
    if (b < FL_SHORTCUT) then
55
 
      buf :='In '+strpas(bnames[arg]) +'['+strpas(mb[b])+']'#0
56
 
    else
57
 
      buf:='In '+strpas(bnames[arg])+#0;
58
 
    i := fl_get_browser(ob);
59
 
    if i>0 then
60
 
      begin
61
 
      buf:=buf+strpas(fl_get_browser_line(ob,i));
62
 
      buf:=buf+' was selected'#0
63
 
      end
64
 
    else
65
 
      begin
66
 
      buf:=buf+strpas(fl_get_browser_line(ob,-i));
67
 
      buf:=buf+' was deselected'#0
68
 
      end;
69
 
    fl_set_object_label(readout,@buf[1]);
70
 
end;
71
 
 
72
 
 
73
 
procedure create_form;
74
 
var
75
 
  obj : PFL_OBJECT;
76
 
 
77
 
begin
78
 
  form := fl_bgn_form(FL_UP_BOX,700,570);
79
 
  readout := fl_add_text(FL_NORMAL_TEXT,50,30,600,50,'');
80
 
  fl_set_object_lsize(readout,FL_LARGE_SIZE);
81
 
  fl_set_object_lalign(readout,FL_ALIGN_CENTER);
82
 
  fl_set_object_lstyle(readout,FL_BOLD_STYLE);
83
 
  fl_set_object_boxtype(readout,FL_UP_BOX);
84
 
 
85
 
  fl_set_object_color(readout,FL_MAGENTA,FL_MAGENTA);
86
 
 
87
 
  obj:= fl_add_browser(FL_NORMAL_BROWSER,20,120,150,290,bnames[0]);
88
 
  br[0] := obj ;
89
 
    fl_set_object_callback(obj, PFL_CALLBACKPTR(@br_callback), 0);
90
 
  obj:= fl_add_browser(FL_SELECT_BROWSER,190,120,150,290,bnames[1]);
91
 
  br[1] := obj ;
92
 
    fl_set_object_callback(obj, PFL_CALLBACKPTR(@br_callback), 1);
93
 
  obj := fl_add_browser(FL_HOLD_BROWSER,360,120,150,290,bnames[2]);
94
 
  br[2] := obj ;
95
 
    fl_set_object_color(obj,FL_COL1,FL_GREEN);
96
 
    fl_set_object_callback(obj, PFL_CALLBACKPTR(@br_callback), 2);
97
 
  obj := fl_add_browser(FL_MULTI_BROWSER,530,120,150,290,bnames[3]);
98
 
  br[3] := obj;
99
 
    fl_set_object_color(br[3],FL_COL1,FL_CYAN);
100
 
    fl_set_object_callback(obj, PFL_CALLBACKPTR(@br_callback), 3);
101
 
 
102
 
  obj  := fl_add_button(FL_NORMAL_BUTTON,560,510,120,30,'Exit');
103
 
  exitobj := obj;
104
 
     obj := fl_add_button(FL_NORMAL_BUTTON,560,460,120,30,'Deselect');
105
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@deselect),0);
106
 
 
107
 
  fl_bgn_group();
108
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,20,500,100,30,'Tiny');
109
 
    fl_set_object_lsize(obj,FL_TINY_SIZE);
110
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),obj^.lsize);
111
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,130,500,100,30,'Small');
112
 
    fl_set_object_lsize(obj,FL_SMALL_SIZE);
113
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),obj^.lsize);
114
 
    fl_set_button(obj,1);
115
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,240,500,100,30,'Normal');
116
 
    fl_set_object_lsize(obj,FL_NORMAL_SIZE);
117
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),obj^.lsize);
118
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,350,500,100,30,'Large');
119
 
    fl_set_object_lsize(obj,FL_LARGE_SIZE);
120
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_size),obj^.lsize);
121
 
  fl_end_group;
122
 
 
123
 
  fl_bgn_group;
124
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,20,450,100,30,'Normal');
125
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_style),FL_NORMAL_STYLE);
126
 
    fl_set_button(obj,1);
127
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,120,450,100,30,'Bold');
128
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_style),FL_BOLD_STYLE);
129
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,220,450,100,30,'Italic');
130
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_style),FL_ITALIC_STYLE);
131
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,320,450,100,30,'BoldItalic');
132
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_style),FL_BOLDITALIC_STYLE);
133
 
  obj := fl_add_lightbutton(FL_RADIO_BUTTON,420,450,100,30,'Fixed');
134
 
    fl_set_object_callback(obj,PFL_CALLBACKPTR(@set_style),FL_FIXED_STYLE);
135
 
  fl_end_group;
136
 
  fl_end_form;
137
 
end;
138
 
 
139
 
 
140
 
procedure fill_browsers;
141
 
var
142
 
  i, j : longint;
143
 
  buf : string[128];
144
 
 
145
 
begin
146
 
  for i:=0 to 3 do
147
 
    for j:=1 to 100 do
148
 
      begin
149
 
      if ( j = 5) then
150
 
        begin
151
 
        str(j,buf);
152
 
        buf:='@NLine with qb '+buf+#0;
153
 
        end
154
 
      else if ( j = 10) then
155
 
        buf:='@-'#0
156
 
      else if ( j = 40 ) then
157
 
        begin
158
 
        str(j,buf);
159
 
        buf:='@mLine with qb '+buf+#0;
160
 
        end
161
 
      else
162
 
        begin
163
 
        str(j,buf);
164
 
        buf:='Line with qb '+buf+#0;
165
 
        end;
166
 
      fl_add_browser_line(br[i],@buf[1]);
167
 
      end
168
 
end;
169
 
 
170
 
 
171
 
begin
172
 
  fl_initialize(@argc, argv, 'FormDemo', nil, 0);
173
 
  create_form;
174
 
  fill_browsers;
175
 
  fl_show_form(form,FL_PLACE_CENTER,FL_TRANSIENT,'All Browsers');
176
 
  fl_do_forms;
177
 
  fl_hide_form(form);
178
 
end.