summaryrefslogtreecommitdiff
path: root/examples/apps/uidesigner/vfdwidgets.pas
blob: c628ebf00b8223c1d511c31dec9a429d25ff9a26 (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
{
    fpGUI  -  Free Pascal GUI Library

    Copyright (C) 2006 - 2007 See the file AUTHORS.txt, included in this
    distribution, for details of the copyright.

    See the file COPYING.modifiedLGPL, included in this distribution,
    for details about redistributing fpGUI.

    This program 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.

    Description:
      Setting up of widgets, properties and images.
}

unit vfdwidgets;

{$mode objfpc}{$H+}

interface

uses
  SysUtils,
  Classes,
  vfdwidgetclass,
  vfdprops,
  typinfo;

procedure RegisterWidgets;
procedure RegisterVFDWidget(awc: TVFDWidgetClass);
function  VFDWidgetCount: integer;
function  VFDWidget(ind: integer): TVFDWidgetClass;
function  VFDFormWidget: TVFDWidgetClass;

var
  VFDOtherWidget: TVFDWidgetClass;

implementation

uses
  vfddesigner,
  gui_form,
  gui_label,
  gui_edit,
  gui_button,
  gui_listbox,
  gui_memo,
  gui_combobox,
  gui_grid,
  gui_checkbox,
  gui_bevel,
  fpgfx
  ;

var
  FVFDFormWidget: TVFDWidgetClass;
  FVFDWidgets: TList;

function VFDFormWidget: TVFDWidgetClass;
begin
  Result := FVFDFormWidget;
end;

function VFDWidgetCount: integer;
begin
  Result := FVFDWidgets.Count;
end;

function VFDWidget(ind: integer): TVFDWidgetClass;
begin
  Result := TVFDWidgetClass(FVFDWidgets[ind - 1]);
end;

procedure RegisterVFDWidget(awc: TVFDWidgetClass);
begin
  FVFDWidgets.Add(awc);
end;

{$I icons.inc}

procedure LoadIcons;
begin
  fpgImages.AddMaskedBMP(
    'vfd.arrow', @stdimg_vfd_arrow,
    sizeof(stdimg_vfd_arrow),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.label', @stdimg_vfd_label,
    sizeof(stdimg_vfd_label),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.edit', @stdimg_vfd_edit,
    sizeof(stdimg_vfd_edit),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.memo', @stdimg_vfd_memo,
    sizeof(stdimg_vfd_memo),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.button', @stdimg_vfd_button,
    sizeof(stdimg_vfd_button),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.checkbox', @stdimg_vfd_checkbox,
    sizeof(stdimg_vfd_checkbox),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.listbox', @stdimg_vfd_listbox,
    sizeof(stdimg_vfd_listbox),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.choicelist', @stdimg_vfd_choicelist,
    sizeof(stdimg_vfd_choicelist),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.panel', @stdimg_vfd_panel,
    sizeof(stdimg_vfd_panel),
    0, 0);

  fpgImages.AddMaskedBMP(
    'vfd.other', @stdimg_vfd_other,
    sizeof(stdimg_vfd_other),
    0, 0);

  fpgImages.AddMaskedBMP(
                   'vfd.dbgrid',
            @stdimg_vfd_dbgrid,
      sizeof(stdimg_vfd_dbgrid),
            15,0 );

  {
  fpgImages.AddMaskedBMP(
                   'vfd.',
            @stdimg_vfd_,
      sizeof(stdimg_vfd_),
            0,0 );
}
end;

procedure AddWidgetPosProps(wgc: TVFDWidgetClass);
begin
  wgc.AddProperty('Left', TPropertyInteger, '');
  wgc.AddProperty('Top', TPropertyInteger, '');
  wgc.AddProperty('Width', TPropertyInteger, '');
  wgc.AddProperty('Height', TPropertyInteger, '');
end;

procedure RegisterWidgets;
var
  wc: TVFDWidgetClass;
  //wp : TVFDWidgetProperty;
begin
  LoadIcons;

  wc          := TVFDWidgetClass.Create(TfpgForm);
  wc.NameBase := 'frm';
  wc.AddProperty('WindowTitle', TPropertyString, '');
  FVFDFormWidget := wc;

  // Label
  wc          := TVFDWidgetClass.Create(TfpgLabel);
  wc.NameBase := 'lb';
  wc.AddProperty('Text', TPropertyString, 'Label text');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the label text');
  wc.WidgetIconName := 'vfd.label';
  RegisterVFDWidget(wc);

  // Edit
  wc          := TVFDWidgetClass.Create(TfpgEdit);
  wc.NameBase := 'ed';
  wc.AddProperty('Text', TPropertyString, 'Initial text');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.WidgetIconName := 'vfd.edit';
  RegisterVFDWidget(wc);

  // Memo
  wc          := TVFDWidgetClass.Create(TfpgMemo);
  wc.NameBase := 'memo';
  wc.AddProperty('Lines', TPropertyStringList, '');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.WidgetIconName := 'vfd.memo';
  RegisterVFDWidget(wc);

  // Button
  wc          := TVFDWidgetClass.Create(TfpgButton);
  wc.NameBase := 'btn';
  wc.AddProperty('Text', TPropertyString, 'Initial text');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.AddProperty('ImageName', TPropertyString, '');
//  wc.AddProperty('ShowImage', TPropertyEnum, '');
  wc.AddProperty('ModalResult', TPropertyInteger, '');
  wc.WidgetIconName := 'vfd.button';
  RegisterVFDWidget(wc);

  // CheckBox
  wc          := TVFDWidgetClass.Create(TfpgCheckBox);
  wc.NameBase := 'cb';
  wc.AddProperty('Text', TPropertyString, 'Initial text');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.WidgetIconName := 'vfd.checkbox';
  RegisterVFDWidget(wc);

  // ChoiceList
  wc          := TVFDWidgetClass.Create(TfpgComboBox);
  wc.NameBase := 'chl';
  //wc.AddProperty('Text',TPropertyString16,'');
  wc.AddProperty('Items', TPropertyStringList, '');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.WidgetIconName := 'vfd.choicelist';
  RegisterVFDWidget(wc);

  // TextListBox
  wc          := TVFDWidgetClass.Create(TfpgListBox);
  wc.NameBase := 'lst';
  //wc.AddProperty('Text',TPropertyString16,'');
  wc.AddProperty('Items', TPropertyStringList, '');
  wc.AddProperty('FontDesc', TPropertyString, 'The font used displaying the text');
  wc.WidgetIconName := 'vfd.listbox';
  RegisterVFDWidget(wc);

  // StringGrid
  wc := TVFDWidgetClass.Create(TfpgStringGrid);
  wc.NameBase := 'grid';
//  wc.AddProperty('Columns',TPropertyDBColumns,'');
  wc.AddProperty('FontDesc',TPropertyString,'');
  wc.AddProperty('HeaderFontName',TPropertyString,'');
  wc.WidgetIconName := 'vfd.dbgrid';
  RegisterVFDWidget(wc);

  // Panel
  wc           := TVFDWidgetClass.Create(TfpgBevel);
  wc.NameBase  := 'panel';
  wc.AddProperty('shape', TPropertyEnum, '');
  wc.AddProperty('style', TPropertyEnum, '');
  wc.WidgetIconName := 'vfd.panel';
  wc.Container := True;
  RegisterVFDWidget(wc);

  // Other - do not delete!!! this should be the last...
  wc          := TVFDWidgetClass.Create(TOtherWidget);
  wc.NameBase := 'wg';
  wc.WidgetIconName := 'vfd.other';
  RegisterVFDWidget(wc);
  VFDOtherWidget := wc;
end;

initialization
  begin
    FVFDWidgets := TList.Create;
  end;

end.