blob: 272da1dc59937535937e2313aa16696ba5408815 (
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(Subject: IInterface);
end;
TComboBoxView = class(TfpgComboBox, IObserver)
private
procedure IObserver.Update = ObserverUpdate;
procedure ObserverUpdate(Subject: IInterface);
end;
implementation
{ TListBoxView }
procedure TListBoxView.ObserverUpdate(Subject: IInterface);
var
Obj: IListModel;
i: integer;
begin
Subject.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(Subject: IInterface);
var
Obj: IListModel;
i: integer;
begin
Subject.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.
|