From 2d5b6397c7f583fcaad81bf98c6af5623e759592 Mon Sep 17 00:00:00 2001 From: graemeg Date: Thu, 10 Apr 2008 21:51:37 +0000 Subject: * The start of a MVP implementation for tiOPF and fpGUI. --- extras/tiopf/mvp/view_impl.pas | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 extras/tiopf/mvp/view_impl.pas (limited to 'extras/tiopf/mvp/view_impl.pas') diff --git a/extras/tiopf/mvp/view_impl.pas b/extras/tiopf/mvp/view_impl.pas new file mode 100644 index 00000000..272da1dc --- /dev/null +++ b/extras/tiopf/mvp/view_impl.pas @@ -0,0 +1,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. + -- cgit v1.2.3-70-g09d2