PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 0ms

/packages/xforms/examples/longlabel.pp

https://github.com/slibre/freepascal
Puppet | 58 lines | 46 code | 12 blank | 0 comment | 0 complexity | 42526e058ef4fd5ef58f0641ac501053 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
 1{ Demo of the Use of a very long label }
 2program longlabel;
 3
 4uses xforms;
 5
 6Const
 7label1 : pchar = 'This demo shows the use of some very'#10+
 8              'long labels. The dynamic storage allocation'#10+
 9              'for such long labels should guarantee that'#10+
10              'all of this works without any problem.';
11{ This shows a funny bug in FPK 0.9.1 :) MVC.}
12
13label2 : pchar ='This is the second string that should again'#10+
14             'be a bit larger such that a new, larger amount'#10+
15             'of storage has to be allocated for the label.'#10+
16             'This is of course no problem. By the way,'#10+
17             'dynamic allocation of storage saves a lot'#10+
18             'of memory because for most objects the label'#10+
19             'is much shorter than the 64 bytes that were'#10+
20             'allocated for it in the previous version of'#10+
21             'the Forms Library';
22
23label3 : pchar ='And now back to the first one:'#10#10+
24             'This demo shows the use of some very'#10+
25             'long labels. The dynamic storage allocation'#10+
26             'for such long labels should guarantee that'#10+
27             'all of this works without any problem.';
28
29var
30   form : PFL_FORM;
31   strobj, but : PFL_OBJECT;
32
33begin
34  fl_initialize(@argc, argv, 'FormDemo', nil, 0);
35
36  form := fl_bgn_form(FL_UP_BOX,400,300);
37    strobj := fl_add_box(FL_DOWN_BOX,10,10,380,240,'Press Next');
38    fl_set_object_lsize(strobj,FL_NORMAL_SIZE);
39    but := fl_add_button(FL_NORMAL_BUTTON,160,260,80,30,'Next');
40  fl_end_form();
41
42  fl_set_form_hotobject(form, but);
43  fl_show_form(form,FL_PLACE_HOTSPOT,FL_TRANSIENT,nil);
44
45  fl_do_forms();
46  fl_set_object_label(strobj,label1);
47
48  fl_do_forms();
49  fl_set_object_label(strobj,label2);
50
51  fl_do_forms();
52  fl_set_object_label(strobj, 'Now we turn to a short label');
53  fl_do_forms();
54  fl_set_object_label(strobj,label3);
55
56  fl_set_object_label(but,'Quit');
57  fl_do_forms();
58end.