VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Mediator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa Mediator
Private copyButton As CommandButton
Private clearButton As CommandButton
Private txtBox As TextBox
Private kidList As ListBox
Private pickedList As ListBox
'-----
Public Sub registerCopy(cpBut As CommandButton)
  Set copyButton = cpBut          'Skopiuj przycisk
End Sub
'-----
Public Sub copyClicked()
  pickedList.AddItem txtBox.Text  'Dodaj tekst do listy
  clearButton.Enabled = True      'Aktywuj przycisk clear
  kidList.ListIndex = -1          'Kasuj wybór na liście
End Sub
'-----
Public Sub registerClear(clrBut As CommandButton)
  Set clearButton = clrBut
End Sub
'-----
Public Sub clearClicked()
  txtBox.Text = ""                'Wyczyść pole tekstowe
  copyButton.Enabled = False      'Dezaktywuj przyciski
  clearButton.Enabled = False
  pickedList.Clear                'Wyczyść listę
  kidList.ListIndex = -1          'Kasuj wybór
End Sub
'-----
Public Sub registerText(txt As TextBox)
  Set txtBox = txt
End Sub
'-----
Public Sub registerKidList(klist As ListBox)
  Set kidList = klist
End Sub
'-----
Public Sub registerPicked(plist As ListBox)
  Set pickedList = plist
End Sub
'-----
Public Sub listClicked()
  Dim i As Integer
  i = kidList.ListIndex
  If (i >= 0) Then
    txtBox.Text = kidList.Text
  End If
  copyButton.Enabled = True
End Sub
'-----
Public Sub init()
  Dim kds As New Kids
  Dim kd As Kid
  Dim iter As Iterator
 
  kds.init App.Path & "\50free.txt"  'Przeczytaj plik
  Set iter = kds.getIterator         'Pobierz iterator
  While iter.hasMoreElements      'Umieść nazwiska na liście
    Set kd = iter.nextElement
    kidList.AddItem kd.getFrname & " " & kd.getLname
  Wend
  clearClicked                    'Przywróc stan wyjściowy
End Sub
