1{
2 ***************************************************************************
3 *                                                                         *
4 *   This source is free software; you can redistribute it and/or modify   *
5 *   it under the terms of the GNU General Public License as published by  *
6 *   the Free Software Foundation; either version 2 of the License, or     *
7 *   (at your option) any later version.                                   *
8 *                                                                         *
9 *   This code is distributed in the hope that it will be useful, but      *
10 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
12 *   General Public License for more details.                              *
13 *                                                                         *
14 *   A copy of the GNU General Public License is available on the World    *
15 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
16 *   obtain it by writing to the Free Software Foundation,                 *
17 *   Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.   *
18 *                                                                         *
19 ***************************************************************************
20}
21program MemoTest;
22
23{$mode objfpc}{$H+}
24
25uses
26  Interfaces, Buttons, Classes, Forms, StdCtrls, SysUtils;
27
28type
29  TMemoTestForm = class(TForm)
30  public
31    Button1, Button2, Button3, Button4, Button5, Button6:   TButton;
32    Memo1, Memo2:  TMemo;
33    MyLabel: TLabel;
34    Edit1: TEdit;
35    constructor Create(AOwner: TComponent); override;
36    procedure Button1Click(Sender: TObject);
37    procedure Button2Click(Sender: TObject);
38    procedure Button3Click(Sender: TObject);
39    procedure Button4Click(Sender: TObject);
40    procedure Button5Click(Sender: TObject);
41    procedure Button6Click(Sender: TObject);
42  end;
43
44var
45  MemoTestForm: TMemoTestForm;
46
47{------------------------------------------------------------------------------}
48{  TMemoTestorm                                          }
49{------------------------------------------------------------------------------}
50constructor TMemoTestForm.Create(AOwner: TComponent);
51begin
52  inherited CreateNew(AOwner, 1);
53  Width := 350;
54  Height := 245;
55  Left := 200;
56  Top := 200;
57
58  // create children
59  Button5 := TButton.Create(Self);
60  Button5.OnClick := @button5click;
61  Button5.Parent := Self;
62  Button5.left := 10;
63  Button5.top := 210;
64  Button5.width := 50;
65  Button5.height := 25;
66  Button5.caption := 'Add';
67  Button5.Show;
68
69  Button3 := TButton.Create(Self);
70  Button3.OnClick := @Button3Click;
71  Button3.Parent := Self;
72  Button3.left := 65;
73  Button3.top := 210;
74  Button3.width := 50;
75  Button3.height := 25;
76  Button3.caption := 'Clear 1';
77  Button3.Show;
78
79  Button1 := TButton.Create(Self);
80  Button1.OnClick := @Button1Click;
81  Button1.Parent := Self;
82  Button1.left := 120;
83  Button1.top :=  210;
84  Button1.width := 50;
85  Button1.height := 25;
86  Button1.caption := '->';
87  Button1.Show;
88
89  Button2 := TButton.Create(Self);
90  Button2.OnClick := @Button2Click;
91  Button2.Parent := Self;
92  Button2.left := 175;
93  Button2.top := 210;
94  Button2.width := 50;
95  Button2.height := 25;
96  Button2.caption := '<-';
97  Button2.Show;
98
99  Button4 := TButton.Create(Self);
100  Button4.OnClick := @button4click;
101  Button4.Parent := Self;
102  Button4.left := 230;
103  Button4.top := 210;
104  Button4.width := 50;
105  Button4.height := 25;
106  Button4.caption := 'Clear 2';
107  Button4.Show;
108
109  Button6 := TButton.Create(Self);
110  Button6.OnClick := @button6click;
111  Button6.Parent := Self;
112  Button6.left := 285;
113  Button6.top := 210;
114  Button6.width := 50;
115  Button6.height := 25;
116  Button6.caption := 'Add';
117  Button6.Show;
118
119  Edit1 := TEdit.Create(Self);
120  Edit1.Parent := Self;
121  Edit1.Top := 180;
122  Edit1.Height := 25;
123  Edit1.Left := 10;
124  Edit1.Width := 325;
125  Edit1.Visible := True;
126
127  MyLabel := TLabel.Create(Self);
128  with MyLabel
129  do begin
130    Parent := Self;
131    Top := 1;
132    Left := 10;
133    Width := 150;
134    Height := 16;
135    Caption := 'These are 2 TMemo:';
136    Show;
137  end;
138
139  Memo1 := TMemo.Create(Self);
140  with Memo1
141  do begin
142    WordWrap := True;
143    Parent := Self;
144    Left := 10;
145    Top := 20;
146    Width := 160;
147    Height := 155;
148    Scrollbars := ssVertical;
149    Show;
150  end;
151
152  Memo2 := TMemo.Create(Self);
153  with Memo2
154  do begin
155    WordWrap := False;
156    Parent := Self;
157    Left := 175;
158    Top := 20;
159    Width := 160;
160    Height := 155;
161    Scrollbars := ssBoth;
162    Show;
163  end;
164end;
165
166procedure TMemoTestForm.Button1Click(Sender: TObject);
167begin
168  Memo2.Text := Memo1.Text;
169end;
170
171procedure TMemoTestForm.Button2Click(Sender: TObject);
172begin
173  Memo1.Text := Memo2.Text;
174end;
175
176procedure TMemoTestForm.Button3Click(Sender: TObject);
177begin
178  Memo1.Text := '';
179end;
180
181procedure TMemoTestForm.Button4Click(Sender: TObject);
182begin
183  Memo2.Text := '';
184end;
185
186procedure TMemoTestForm.Button5Click(Sender: TObject);
187begin
188  Memo1.Append(Edit1.Text);
189end;
190
191procedure TMemoTestForm.Button6Click(Sender: TObject);
192begin
193  Memo2.Append(Edit1.Text);
194end;
195
196begin
197   Application.Initialize;
198   Application.CreateForm(TMemoTestForm, MemoTestForm);
199   Application.Run;
200end.
201