File: toolbar.pp

package info (click to toggle)
lazarus 0.9.28.2-12
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 93,096 kB
  • ctags: 89,312
  • sloc: pascal: 820,189; xml: 202,194; makefile: 110,323; sh: 2,460; perl: 395; sql: 174; ansic: 133
file content (156 lines) | stat: -rw-r--r-- 4,326 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
 {
 /***************************************************************************
                          toolbar - example
                          ------------------


                   Initial Revision  : Wed Dec 29 1999

                   by Shane Miller

 ***************************************************************************/

 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 ***************************************************************************
}
program Toolbar;

{$mode objfpc}{$H+}

uses
  Interfaces, Classes, StdCtrls, Forms, Buttons, Menus, ComCtrls,
  SysUtils, ExtCtrls, Controls;

type
        TForm1 = class(TFORM)
        public
          Toolbar1 : TToolbar;
          Toolbutton1 : TToolbutton;
          Toolbutton2 : TToolbutton;
          Toolbutton3 : TToolbutton;
          ComboBox1 : TComboBox;
          constructor Create(AOwner: TComponent); override;
        protected
        Procedure Button1Click(Sender : TObject);
        Procedure Button2Click(Sender : TObject);
        Procedure Button3Click(Sender : TObject);
        end;

var
Form1 : TForm1;

constructor TForm1.Create(AOwner: TComponent);
begin
   inherited Create(AOwner);
   Name:='Form1';
   Caption := 'Toolbar Demo v0.1';
   {  set the height and width }
   Height := 350;
   Width := 700;

ToolBar1 := TToolbar.Create(Self);
  with Toolbar1 do
  begin
    Name:='ToolBar1';
    Parent := Self;
  end;

Toolbutton1 := TToolButton.Create(Toolbar1);
with ToolButton1 do
  Begin
    Name:='Toolbutton1';
    Parent := Toolbar1;
    Caption := '1';
    Style := tbsButton;
    OnClick := @Button1Click;
    Show;
  end;
Toolbutton2 := TToolButton.Create(Toolbar1);
with ToolButton2 do
  Begin
    Name:='Toolbutton2';
    Parent := Toolbar1;
    Caption := '2';
    Style := tbsButton;
    OnClick := @Button2Click;
    Show;
  end;
Toolbutton3 := TToolButton.Create(Toolbar1);
with ToolButton3 do
  Begin
    Parent := Toolbar1;
    Caption := '3';
    Style := tbsButton;
    OnClick := @Button3Click;
    Show;
  end;


ComboBox1 := TComboBox.Create(Self);
with ComboBox1 do
  Begin
    Parent := Toolbar1;
    Items.Add('Item1');
    Items.Add('Item2');
    Items.Add('Item3');
    Items.Add('Item4');
    Items.Add('Item5');
    Items.Add('Item6');
    ItemIndex := 0;
    Show;
  end;

Toolbar1.ShowCaptions := True;
Toolbar1.Height := 25;
Toolbar1.Top := 1;
Toolbar1.Width := ClientWidth;
Toolbar1.Show;


end;

Procedure TFORM1.Button1Click(Sender : TObject);
Begin
Writeln('******************');
Writeln('Toolbar button  1  clicked!');
Writeln('******************');
end;

Procedure TFORM1.Button2Click(Sender : TObject);
Begin
Writeln('******************');
Writeln('Toolbar button  2  clicked!');
Writeln('******************');
end;

Procedure TFORM1.Button3Click(Sender : TObject);
Begin
Writeln('******************');
Writeln('Toolbar button  3  clicked!');
Writeln('******************');
end;



begin
   Application.Initialize; { calls InitProcedure which starts up GTK }
   Application.CreateForm(TForm1, Form1);
   Application.Run;
end.