summaryrefslogtreecommitdiff
path: root/extras/tiopf/mvp/view_impl.pas
diff options
context:
space:
mode:
Diffstat (limited to 'extras/tiopf/mvp/view_impl.pas')
-rw-r--r--extras/tiopf/mvp/view_impl.pas66
1 files changed, 66 insertions, 0 deletions
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.
+