classdef Hauptfenster < handle 
    properties 
        HauptFigure    % Hauptfenster 
        button_hinzu         %Button zum Hinzufügen neuer Textboxen 
        textbox = matlab.ui.control.UIControl.empty; % neue Textbox anlegen <-- auf leer initialisiert, *alle* Textboxen speichern
    end 
    methods (Access = public)  % Methoden des Hauptfensters <-- Constructor nicht static
        
        function obj = Hauptfenster() 
            obj.HauptFigure=figure();  % HauptFigure wird erstellt 
            scrsz = get(0,'ScreenSize');  % Bildschirmgröße auslesen 
            set(obj.HauptFigure, ... 
                'Position',[0.3*scrsz(3),0.3*scrsz(4),0.6*scrsz(3),0.6*scrsz(4)],... 
                'Units','normalized',... 
                'Resize','on',... 
                'MenuBar','none',... 
                'Name','Gearboxtool 2015',... 
                'NumberTitle','off'); 
            
            obj.button_hinzu = uicontrol();    %Button erstellen 
            set(obj.button_hinzu, ... 
                'style', 'pushbutton', ... 
                'FontName', 'Arial', ... 
                'FontSize', 10, ... 
                'string', 'Hinzufügen', ... 
                'Units','normalized', ... 
                'Position', [.89,.15,.1,.07], ... 
                'Callback', @obj.button_hinzu_Callback);  % <-- angepasst
        end 
    end 
    methods (Access = private) % <-- nicht static      
        function button_hinzu_Callback(obj, ~, ~) % <-- Interface angepasst
            num_existing = numel(obj.textbox);
            offset = 0.15*num_existing;
            obj.textbox(end+1) = uicontrol(...  % <-- neue Textbox wird drangehängt
                'style', 'text', ... 
                'FontName', 'Arial', ... 
                'FontSize', 10, ... 
                'string', 'Nummer x', ... 
                'HorizontalAlignment', 'left', ... 
                'Units','normalized', ... 
                'Position',[0.02 0.85-offset 0.1 0.1], ... 
                'BackgroundColor', 'green'); 
            %Hauptfenster.erstelleTextbox; 
        end         
    end 
end 
