class KOMPONENTEN_CONTAINER inherit WEL_STANDARD_COLORS creation make feature -- Initialisierung make (fenster:MAIN_WINDOW) is do benutzer_fenster:=fenster; !!komponenten_liste.make; nummer:=0; zaehler:=0; end; feature {NONE} nummer, zaehler:INTEGER; benutzer_fenster:MAIN_WINDOW; komponenten_liste:LINKED_LIST[KOMPONENTE]; feature {MAIN_WINDOW} zeichne_alles (dc:WEL_CLIENT_DC) is local akt_komp:KOMPONENTE; do if zaehler>0 then akt_komp:=gib_akt_komp; end; from komponenten_liste.start until komponenten_liste.after loop if zaehler>0 then if komponenten_liste.item.is_equal(akt_komp) then else komponenten_liste.item.set_color(black); end; end; komponenten_liste.item.zeichne(dc); komponenten_liste.forth; end; if zaehler>0 then zeichne_akt_komp(dc); end; end; komponente_hinzufuegen (komponente:KOMPONENTE) is local hilfstr:STRING; do nummer:=nummer+1; zaehler:=zaehler+1; komponente.set_number(nummer); komponenten_liste.extend(komponente); hilfstr:=clone(komponente.gib_name); hilfstr.append_integer(komponente.gib_nummer); benutzer_fenster.Box.add_string(hilfstr); benutzer_fenster.Box.select_item(benutzer_fenster.Box.count-1); end; gib_akt_komp:KOMPONENTE is local hilfstr,hilfstr2:STRING; gefunden:BOOLEAN; do gefunden:=false; hilfstr:=(benutzer_fenster.Box.selected_string); from komponenten_liste.start until ((komponenten_liste.after) or(gefunden)) loop hilfstr2:=clone(komponenten_liste.item.gib_name); hilfstr2.append_integer(komponenten_liste.item.gib_nummer); if (hilfstr.is_equal(hilfstr2)) then gefunden:=true; else komponenten_liste.forth; end; end; if gefunden then Result:=komponenten_liste.item; end; end; loesche_akt_komp is local hilfstr, hilfstr2:STRING; gefunden:BOOLEAN; do gefunden:=false; hilfstr:=benutzer_fenster.Box.selected_string; from komponenten_liste.start until ((komponenten_liste.after)or(gefunden)) loop hilfstr2:=clone(komponenten_liste.item.gib_name); hilfstr2.append_integer(komponenten_liste.item.gib_nummer); if (hilfstr.is_equal(hilfstr2)) then gefunden:=true; else komponenten_liste.forth; end; end; if gefunden then benutzer_fenster.Box.delete_string(benutzer_fenster.Box.find_string(0, hilfstr2)); komponenten_liste.remove; zaehler:=zaehler-1; if benutzer_fenster.Box.count>0 then benutzer_fenster.Box.select_item(0); end; benutzer_fenster.invalidate; end; end; feature {NONE} zeichne_akt_komp(dc:WEL_CLIENT_DC) is local stift:WEL_PEN; hilfstr, hilfstr2:STRING; gefunden:BOOLEAN; color:WEL_COLOR_REF; do gefunden:=false; hilfstr:=benutzer_fenster.Box.selected_string; from komponenten_liste.start until ((komponenten_liste.after)or(gefunden)) loop hilfstr2:=clone(komponenten_liste.item.gib_name); hilfstr2.append_integer(komponenten_liste.item.gib_nummer); if (hilfstr.is_equal(hilfstr2)) then gefunden:=true; else komponenten_liste.forth; end; end; if gefunden then komponenten_liste.item.set_color(red); end; end; end