示例#1
0
        private void buildContent()
        {
            BackColor = SystemColors.Control;

            generate      = new Button();
            generate.Text = "Generate";

            quit      = new Button();
            quit.Text = "Quit";

            options      = new Button();
            options.Text = "Options";

            stop      = new Button();
            stop.Text = "Stop";

            dirChoose      = new Button();
            dirChoose.Text = "Browse";

            dir       = new TextBox();
            dir.Width = calculate_char_width(10, dir);

            specChoose      = new Button();
            specChoose.Text = "Browse";

            spec       = new TextBox();
            spec.Width = calculate_char_width(10, spec);

            messages            = new RichTextBox();
            messages.Multiline  = true;
            messages.ScrollBars = RichTextBoxScrollBars.Both;
            messages.Font       = new Font(FontFamily.GenericMonospace, messages.Font.Size, messages.Font.Style, messages.Font.Unit);
            messages.Width      = calculate_char_width(80, messages);
            messages.Height     = calculate_lines_height(10, messages);
            messages.ReadOnly   = true;
            messages.MaxLength  = int.MaxValue;

            generate.Click   += new EventHandler(generate_Click);
            options.Click    += new EventHandler(options_Click);
            quit.Click       += new EventHandler(quit_Click);
            stop.Click       += new EventHandler(stop_Click);
            specChoose.Click += new EventHandler(specChoose_Click);
            dirChoose.Click  += new EventHandler(dirChoose_Click);
            spec.KeyPress    += new KeyPressEventHandler(spec_KeyPress);
            spec.TextChanged += new EventHandler(spec_TextChanged);
            dir.KeyPress     += new KeyPressEventHandler(dir_KeyPress);
            dir.TextChanged  += new EventHandler(dir_TextChanged);

            GridPanel north = new GridPanel(5, 4, 10, 10);

            north.setInsets(new Insets(10, 5, 5, 10));

            Label lblLexicalSpecification = new Label();

            lblLexicalSpecification.AutoSize = true;
            lblLexicalSpecification.Text     = "Lexical specification:";

            Label lblOutputDirectory = new Label();

            lblOutputDirectory.AutoSize = true;
            lblOutputDirectory.Text     = "Output directory:";

            north.add(4, 0, quit);
            north.add(4, 1, generate);
            north.add(4, 2, options);
            north.add(4, 3, stop);

            north.add(0, 0, Handles.BOTTOM, lblLexicalSpecification);
            north.add(0, 1, 2, 1, spec);
            north.add(2, 1, specChoose);

            north.add(0, 2, Handles.BOTTOM, lblOutputDirectory);
            north.add(0, 3, 2, 1, dir);
            north.add(2, 3, dirChoose);

            Panel true_north = new Panel();

            true_north.Controls.Add(north);

            Label lblMessages = new Label();

            lblMessages.TextAlign = ContentAlignment.MiddleCenter;
            lblMessages.Text      = "Messages:";
            lblMessages.Dock      = DockStyle.Top;

            Panel center = new Panel();

            center.Controls.Add(lblMessages);
            center.Controls.Add(messages);

            north.Size = north.getPreferredSize();
            north.doLayout();

            true_north.Size = north.Size;

            north.Anchor = AnchorStyles.Top | AnchorStyles.Left;

            true_north.Dock = DockStyle.Top;

            center.Anchor   = (AnchorStyles)15;
            center.Location = new Point(0, north.Height);
            center.Size     = new Size(ClientSize.Width, ClientSize.Height - north.Height);

            SuspendLayout();
            Controls.Add(true_north);
            Controls.Add(center);
            ResumeLayout(false);

            messages.Top    = lblMessages.Bottom;
            messages.Left   = 4;
            messages.Width  = center.Width - 8;
            messages.Height = center.Height - lblMessages.Height - 4;
            messages.Anchor = (AnchorStyles)15;

            this.ClientSize  = new Size(north.Width + 8, ClientSize.Height);
            this.MinimumSize = this.ClientSize;

            setEnabledAll(false);

            Out.setGUIMode(messages);
        }
示例#2
0
        public void setup()
        {
            // create components
            ok      = new Button();
            ok.Text = "Ok";

            defaults      = new Button();
            defaults.Text = "Defaults";

            skelBrowse      = new Button();
            skelBrowse.Text = " Browse";

            skelFile          = new TextBox();
            skelFile.ReadOnly = true;

            dump      = new CheckBox();
            dump.Text = " dump";

            verbose      = new CheckBox();
            verbose.Text = " verbose";

            jlex      = new CheckBox();
            jlex.Text = " JLex compatibility";

            no_minimize      = new CheckBox();
            no_minimize.Text = " skip minimization";

            no_backup      = new CheckBox();
            no_backup.Text = " no backup file";

            time      = new CheckBox();
            time.Text = " time statistics";

            dot      = new CheckBox();
            dot.Text = " dot graph files";

            csharp      = new CheckBox();
            csharp.Text = " C# output";

            tableG      = new RadioButton();
            tableG.Text = " table";

            switchG      = new RadioButton();
            switchG.Text = " switch";

            packG      = new RadioButton();
            packG.Text = " pack";

            switch (Options.gen_method)
            {
            case Options.TABLE:  tableG.Checked = true;   break;

            case Options.SWITCH: switchG.Checked = true;  break;

            case Options.PACK:   packG.Checked = true;    break;
            }

            // setup interaction
            ok.Click                   += new EventHandler(ok_Click);
            defaults.Click             += new EventHandler(defaults_Click);
            skelBrowse.Click           += new EventHandler(skelBrowse_Click);
            tableG.CheckedChanged      += new EventHandler(tableG_CheckedChanged);
            switchG.CheckedChanged     += new EventHandler(switchG_CheckedChanged);
            packG.CheckedChanged       += new EventHandler(packG_CheckedChanged);
            verbose.CheckedChanged     += new EventHandler(verbose_CheckedChanged);
            dump.CheckedChanged        += new EventHandler(dump_CheckedChanged);
            jlex.CheckedChanged        += new EventHandler(jlex_CheckedChanged);
            no_minimize.CheckedChanged += new EventHandler(no_minimize_CheckedChanged);
            no_backup.CheckedChanged   += new EventHandler(no_backup_CheckedChanged);
            dot.CheckedChanged         += new EventHandler(dot_CheckedChanged);
            csharp.CheckedChanged      += new EventHandler(csharp_CheckedChanged);
            time.CheckedChanged        += new EventHandler(time_CheckedChanged);

            // setup layout
            GridPanel panel = new GridPanel(4, 7, 10, 10);

            panel.setInsets(new Insets(10, 5, 5, 10));

            panel.add(3, 0, ok);
            panel.add(3, 1, defaults);

            Label lblSkeletonFile = new Label();

            lblSkeletonFile.AutoSize = true;
            lblSkeletonFile.Text     = "skeleton file:";

            Label lblCode = new Label();

            lblCode.AutoSize = true;
            lblCode.Text     = "code:";

            panel.add(0, 0, 2, 1, Handles.BOTTOM, lblSkeletonFile);
            panel.add(0, 1, 2, 1, skelFile);
            panel.add(2, 1, 1, 1, Handles.TOP, skelBrowse);

            panel.add(0, 2, 1, 1, Handles.BOTTOM, lblCode);
            panel.add(0, 3, 1, 1, tableG);
            panel.add(0, 4, 1, 1, switchG);
            panel.add(0, 5, 1, 1, packG);

            panel.add(1, 3, 1, 1, dump);
            panel.add(1, 4, 1, 1, verbose);
            panel.add(1, 5, 1, 1, time);

            panel.add(2, 3, 1, 1, no_minimize);
            panel.add(2, 4, 1, 1, no_backup);
            panel.add(2, 5, 1, 1, csharp);

            panel.add(3, 3, 1, 1, jlex);
            panel.add(3, 4, 1, 1, dot);

            panel.Size = panel.getPreferredSize();
            panel.doLayout();

            Size panel_size       = panel.Size;
            Size client_area_size = this.ClientSize;
            Size left_over        = new Size(client_area_size.Width - panel_size.Width, client_area_size.Height - panel_size.Height);

            Controls.Add(panel);

            panel.Location   = new Point(0, 8);
            this.ClientSize  = new Size(panel.Width + 8, panel.Height + 8);
            this.MaximumSize = this.MinimumSize = this.ClientSize;

            updateState();
        }