blob: 478ca9f9b53751a12f9867b58617e9b9835caa40 (
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
|
unit view_impl;
{$mode objfpc}{$H+}
interface
uses
Classes, gui_listbox, gui_combobox, basic_intf;
type
TListBoxView = class(TfpgListBox, IObserver)
private
procedure IObserver.Update = ObserverUpdate;
procedure ObserverUpdate(const ASubject: IInterface);
end;
TComboBoxView = class(TfpgComboBox, IObserver)
private
procedure IObserver.Update = ObserverUpdate;
procedure ObserverUpdate(const ASubject: IInterface);
end;
implementation
{ TListBoxView }
procedure TListBoxView.ObserverUpdate(const ASubject: IInterface);
var
Obj: IListModel;
i: integer;
begin
ASubject.QueryInterface(IListModel, Obj);
if Obj <> nil then
begin
Items.BeginUpdate;
Items.Clear;
// for i := 0 to Obj.Count-1 do
// Items.Add(Obj.Item[i]);
Items.EndUpdate;
end;
end;
{ TComboBoxView }
procedure TComboBoxView.ObserverUpdate(const ASubject: IInterface);
var
Obj: IListModel;
i: integer;
begin
ASubject.QueryInterface(IListModel, Obj);
if Obj <> nil then
begin
Items.BeginUpdate;
Items.Clear;
// for i := 0 to Obj.Count-1 do
// Items.Add(Obj.Item[i]);
FocusItem := 1;
Items.EndUpdate;
end;
end;
end.
|