class MAIN_WINDOW inherit WEL_FRAME_WINDOW redefine on_paint, on_menu_command, on_control_command, closeable end APPLICATION_IDS export {NONE} all end WEL_WINDOWS_ROUTINES export {NONE} all end creation make feature {NONE} -- Initialization make is local komponente:KOMPONENTE; text_komponente:TEXT_KOMPONENTE; do make_top(Title); resize(400,400); set_menu(main_menu); bearbeiten_menu.disable_position(1); bearbeiten_menu.disable_position(3); bearbeiten_menu.disable_position(4); !!Box.make(Current,0,0,250,200,-1); !!dc.make(current); dc.get; !!komponenten_container.make(Current); end komponenten_container:KOMPONENTEN_CONTAINER; dc:WEL_CLIENT_DC; feature text_kompo_erstellen (text_anzeige:STRING; x1, y1, length:INTEGER) is local text_komponente:TEXT_KOMPONENTE; do !!text_komponente.make(text_anzeige); text_komponente.setze_neue_koordinaten(x1,y1,x1+(length)*7,y1+16); text_komponente.zeichne(dc); komponenten_container.komponente_hinzufuegen(text_komponente); bearbeiten_menu.enable_position(1); bearbeiten_menu.enable_position(3); bearbeiten_menu.enable_position(4); end; komponente_verschieben(x1, y1:INTEGER) is do komponenten_container.gib_akt_komp.verschiebe(x1, y1); Current.invalidate; end; feature {KOMPONENTEN_CONTAINER} -- ComboBox Box:WEL_DROP_DOWN_LIST_COMBO_BOX_MY; feature {NONE} -- Implementation on_paint(paint_dc:WEL_PAINT_DC; invalid_rect:WEL_RECT) is do komponenten_container.zeichne_alles(dc); end on_menu_command (menu_id: INTEGER) is -- `menu_id' has been selected local text_kompo_erst_dlg:TEXT_KOMPO_ERST_DLG; text_komponente:TEXT_KOMPONENTE; deko:DEKORIERER; norm_rahmen_dekorierer:NORMAL_RAHMEN_DEKORIERER; dash_rahmen_dekorierer:DASH_RAHMEN_DEKORIERER; einfach_kodier_dekorierer:EINFACH_KODIER_DEKORIERER; komplex_kodier_dekorierer:KOMPLEX_KODIER_DEKORIERER; komp:KOMPONENTE; do inspect menu_id when Beenden_id then if closeable then destroy end when Erstellen_id then !!text_kompo_erst_dlg.make(Current); text_kompo_erst_dlg.set_erst_mode; text_kompo_erst_dlg.show; when normal_id then if Box.selected then !!norm_rahmen_dekorierer.make(komponenten_container.gib_akt_komp); komponenten_container.loesche_akt_komp; norm_rahmen_dekorierer.zeichne(dc); komponenten_container.komponente_hinzufuegen(norm_rahmen_dekorierer); end; when entfernen_id then if Box.selected then !!text_komponente.make("nichts"); komp:=komponenten_container.gib_akt_komp; if komp.same_type(text_komponente) then else komp:=komp.loesche_komp; komp.zeichne(dc); komponenten_container.loesche_akt_komp; komponenten_container.komponente_hinzufuegen(komp); end; current.invalidate; end; when tentfernen_id then if Box.selected then !!text_komponente.make("nichts"); komp:=komponenten_container.gib_akt_komp; if komp.same_type(text_komponente) then komponenten_container.loesche_akt_komp; end; current.invalidate; end; when dash_id then if Box.selected then !!dash_rahmen_dekorierer.make(komponenten_container.gib_akt_komp); komponenten_container.loesche_akt_komp; dash_rahmen_dekorierer.zeichne(dc); komponenten_container.komponente_hinzufuegen(dash_rahmen_dekorierer); end; when einfach_id then if Box.selected then !!einfach_kodier_dekorierer.make(komponenten_container.gib_akt_komp); komponenten_container.loesche_akt_komp; einfach_kodier_dekorierer.zeichne(dc); komponenten_container.komponente_hinzufuegen(einfach_kodier_dekorierer); end; when komplex_id then if Box.selected then !!komplex_kodier_dekorierer.make(komponenten_container.gib_akt_komp); komponenten_container.loesche_akt_komp; komplex_kodier_dekorierer.zeichne(dc); komponenten_container.komponente_hinzufuegen(komplex_kodier_dekorierer); end; when verschieben_id then if Box.selected then !!text_kompo_erst_dlg.make(Current); text_kompo_erst_dlg.set_text("Verschieben nach:"); text_kompo_erst_dlg.set_versch_mode; text_kompo_erst_dlg.show; end; else end end on_control_command (control:WEL_CONTROL) is do if control=Box then komponenten_container.zeichne_alles(dc); end; end main_menu: WEL_MENU is -- The main menu once !! Result.make; Result.append_popup (datei_menu, "&Datei"); Result.append_popup(bearbeiten_menu,"&Bearbeiten"); ensure result_not_void: Result /= Void end datei_menu: WEL_MENU is -- Das Datei-Menu once !! Result.make; Result.append_string ("&Beenden", Beenden_id); ensure result_not_void: Result /= Void; end feature {KOMPONENTEN_CONTAINER} bearbeiten_menu:WEL_MENU is -- Das Bearbeiten_Menu once !! Result.make; Result.append_string("Text &erstellen ...", erstellen_id); Result.append_string("Text e&ntfernen", tentfernen_id); Result.append_separator; Result.append_popup(hinzufuegen_menu,"Dekorierer &hinzufügen"); Result.append_string("Dekorierer ent&fernen", entfernen_id); Result.append_separator; Result.append_string("Komponente &verschieben...", verschieben_id); ensure result_not_void: Result /=Void; end hinzufuegen_menu:WEL_MENU is -- Das Dekorierer-Hinzufügen-Menu once !! Result.make; Result.append_popup(Kodierung_menu, "&Kodierer"); Result.append_popup(Rahmen_menu, "&Rahmen"); ensure result_not_void: Result /= Void; end Kodierung_menu:WEL_MENU is -- Das Kodierung-Menu once !! Result.make; Result.append_string("&einfach", einfach_id); Result.append_string("&komplex", komplex_id); ensure result_not_void: Result /= Void; end Rahmen_menu:WEL_MENU is -- Das Rahmen_Menu once !! Result.make Result.append_string("&normal", normal_id); Result.append_string("&dash", dash_id); ensure result_not_void: Result /= Void; end closeable: BOOLEAN is -- When the user can close the window? do Result := message_box ("Möchten Sie wirklich beenden?", "Exit", Mb_yesno + Mb_iconquestion) = Idyes end Beenden_id, Erstellen_id, hinzufuegen_id, normal_id, tentfernen_id, dash_id, komplex_id, einfach_id, entfernen_id, verschieben_id: INTEGER is unique Title: STRING is "Entwurfsmuster-Dekorierer" -- Window's title end -- class MAIN_WINDOW