Esempio n. 1
0
        public TextArea(TextEditor editor)
        {
            this.editor = editor;

            CanGetFocus = true;

            lineNumberMargin = new LineNumberMargin(editor);
            paddingMargin = new PaddingMargin(5);
            textViewMargin = new TextViewMargin(editor);

            margins.Add(lineNumberMargin);
            margins.Add(paddingMargin);
            margins.Add(textViewMargin);

            contextMenu = new Menu();

            cutMenuItem = new MenuItem("Cut");
            cutMenuItem.Clicked += (sender, e) => Cut();
            contextMenu.Items.Add(cutMenuItem);

            copyMenuItem = new MenuItem("Copy");
            copyMenuItem.Clicked += (sender, e) => Copy();
            contextMenu.Items.Add(copyMenuItem);

            pasteMenuItem = new MenuItem("Paste");
            pasteMenuItem.Clicked += (sender, e) => Paste();
            contextMenu.Items.Add(pasteMenuItem);

            contextMenu.Items.Add(new SeparatorMenuItem());

            selectallMenuItem = new MenuItem("Select All");
            selectallMenuItem.Clicked += (sender, e) => SelectAll();
            contextMenu.Items.Add(selectallMenuItem);

            ButtonPressed += HandleButtonPressed;
        }
Esempio n. 2
0
        private void Build()
        {
            this.Icon = Xwt.Drawing.Image.FromResource("URMSimulator.Resources.urm.png");
            this.Title = "URM Simulator";
            this.Width = 800;
            this.Height = 600;
            this.Padding = 0;

            vbox1 = new VBox();

            vpanned1 = new VPaned();

            te1 = new TextEditor();
            te1.Document.MimeType = "text/x-urm";
            te1.Document.Text = savedContent;
            te1.OnUndoRedoStackChanged += (sender, e) => ReloadMenuAndTitleEnding();

            vpanned1.Panel1.Content = te1;
            vpanned1.Panel1.Resize = true;

            vbox2 = new VBox();

            label1 = new Label("Input:");
            label1.MarginLeft = 5;
            vbox2.PackStart(label1, false);

            entry1 = new TextEntry();
            entry1.PlaceholderText = "0 0 0 0 0 0 0 0 0 0";
            vbox2.PackStart(entry1, false);

            hbox1 = new HBox();

            label2 = new Label("Output:");
            label2.MarginLeft = 5;
            hbox1.PackStart(label2, true);

            label3 = new Label("Register length:");
            hbox1.PackStart(label3, false);

            sb1 = new SpinButton();
            sb1.MinimumValue = 1;
            sb1.Digits = 0;
            sb1.IncrementValue = 1;
            sb1.MaximumValue = 100;
            sb1.Value = regCount;
            sb1.ValueChanged += (sender, e) => regCount = (int)sb1.Value;
            sb1.TextInput += (sender, e) => regCount = (int)sb1.Value;
            hbox1.PackStart(sb1, false);

            vbox2.PackStart(hbox1, false);

            scroll1 = new ScrollView();
            scroll1.HeightRequest = 80;
            scroll1.VerticalScrollPolicy = ScrollPolicy.Never;
            scroll1.BorderVisible = true;

            web1 = new WebView();
            web1.WidthRequest = 2000;
            scroll1.Content = web1;

            vbox2.PackStart(scroll1, true);

            vpanned1.Panel2.Content = vbox2;
            vpanned1.Panel2.Resize = false;

            if (Toolkit.CurrentEngine.Type == ToolkitType.Wpf)
                vpanned1.Position = this.Height - 120;

            vbox1.PackStart(vpanned1, true);

            button1 = new Button("Continue Debugging");
            button1.Visible = false;
            button1.Clicked += (sender, e) => ContinueDebugging();
            vbox1.PackStart(button1, false);

            this.Content = vbox1;
            te1.SetFocus();

            BuildMenu();
        }
Esempio n. 3
0
        private void Build()
        {
            if(Toolkit.CurrentEngine.Type == ToolkitType.Wpf)
                this.BackgroundColor = (new Button()).BackgroundColor;

            vbox1 = new VBox();

            label1 = new Label("Select Font:");
            label1.MarginTop = 4;
            label1.MarginRight = 4;
            label1.MarginLeft = 4;
            vbox1.PackStart(label1);

            table1 = new Table();
            table1.MarginRight = 4;
            table1.MarginLeft = 4;

            radioButton1 = new RadioButton("From System: ");
            table1.Add(radioButton1, 0, 0);

            combo_font = new ComboBox();

            List<string> fonts = new List<string>();
            foreach (System.Drawing.FontFamily font in System.Drawing.FontFamily.Families)
                fonts.Add(font.Name);
            fonts.Sort();
            foreach (string font in fonts)
                combo_font.Items.Add(font);

            if(combo_font.Items.Contains("Arial"))
                combo_font.SelectedText = "Arial";
            else if(combo_font.Items.Count > 0)
                combo_font.SelectedIndex = 0;
            combo_font.Font = Xwt.Drawing.Font.FromName(combo_font.SelectedText).WithSize(combo_font.Font.Size);

            table1.Add(combo_font, 1, 0, 1, 1, true);

            radioButton2 = new RadioButton();
            radioButton2.Label = "From File: ";
            radioButton2.Sensitive = true;
            radioButton2.Group = radioButton1.Group;
            table1.Add(radioButton2, 0, 1);

            hbox1 = new HBox();

            entry_font = new TextEntry();
            entry_font.Sensitive = false;
            hbox1.PackStart(entry_font, true);

            button_font = new Button("Browse");
            button_font.Sensitive = false;
            hbox1.PackStart(button_font);

            table1.Add(hbox1, 1, 1);

            vbox1.PackStart(table1);

            notebook1 = new Notebook();
            notebook1.ExpandHorizontal = true;
            notebook1.ExpandVertical = true;

            table2 = new Table();
            table2.Margin = 4;

            label4 = new Label("Style:");
            table2.Add(label4, 0, 0);

            hbox2 = new HBox();

            check_bold = new CheckBox("Bold ");
            check_bold.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_bold);

            check_italic = new CheckBox("Italic ");
            check_italic.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_italic);

            check_kerning = new CheckBox("Kerning ");
            check_kerning.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            hbox2.PackStart(check_kerning);

            table2.Add(hbox2, 0, 1, 1, 1);

            label2 = new Label("Size:");
            table2.Add(label2, 0, 2);

            entry_size = new NumericEntry("0", "WARNING: Size needs to be a number");
            table2.Add(entry_size, 0, 3, 1, 1, true);

            label3 = new Label("Spacing:");
            table2.Add(label3, 0, 4);

            entry_spacing = new NumericEntry("0", "WARNING: Spacing needs to be a number");
            table2.Add(entry_spacing, 0, 5, 1, 1, true);

            check_defchar = new CheckBox("Default Character:");
            check_defchar.BackgroundColor = Color.FromBytes(0, 0, 0, 0);
            table2.Add(check_defchar, 0, 6);

            entry_defchar = new TextEntry();
            entry_defchar.Sensitive = false;
            entry_defchar.TextAlignment = Alignment.Center;
            table2.Add(entry_defchar, 0, 7, 1, 1, true);

            notebook1.Add(table2, "Global");

            hbox3 = new HBox();

            listView1 = new ListView();
            hbox3.PackStart(listView1, true);

            vbox2 = new VBox();
            vbox2.MarginRight = 5;
            vbox2.MarginTop = 5;

            label8 = new Label(" Main:");
            vbox2.PackStart(label8);

            button_plus = new Button("Add");
            vbox2.PackStart(button_plus);

            button_minus = new Button("Remove");
            button_minus.Sensitive = false;
            vbox2.PackStart(button_minus);

            button_edit = new Button("Edit");
            button_edit.Sensitive = false;
            vbox2.PackStart(button_edit);

            vbox2.PackStart(new HSeparator());

            label9 = new Label(" Move:");
            vbox2.PackStart(label9);

            button_up  = new Button("Up");
            button_up.Sensitive = false;
            vbox2.PackStart(button_up);

            button_down  = new Button("Down");
            button_down.Sensitive = false;
            vbox2.PackStart(button_down);

            hbox3.PackStart(vbox2);

            notebook1.Add(hbox3, "Characters");

            var pa = new VBox();

            textEditor1 = new TextEditor();
            textEditor1.Document.MimeType = "application/xml";

            pa.PackStart(textEditor1, true);
            notebook1.Add(pa, "Xml");

            vbox3 = new VBox();

            hbox4 = new HBox();
            hbox4.Margin = 5;

            label5 = new Label("Font Color: ");
            hbox4.PackStart(label5);

            color_font = new ColorPicker();
            color_font.Color = Color.FromBytes(0, 0, 0);
            color_font.SupportsAlpha = false;
            hbox4.PackStart(color_font);

            label6 = new Label("Background Color: ");
            hbox4.PackStart(label6);

            color_back = new ColorPicker();
            color_back.Color = Color.FromBytes(224, 224, 209);
            color_back.SupportsAlpha = false;
            hbox4.PackStart(color_back);

            vbox3.PackStart(hbox4);

            hbox5 = new HBox();
            hbox5.MarginLeft = 5;
            hbox5.MarginRight = 5;

            label7 = new Label("Text: ");
            hbox5.PackStart(label7);

            entry_text = new TextEntry();
            entry_text.Text = "The quick brown fox jumps over the lazy dog";
            hbox5.PackStart(entry_text, true);

            button_preview = new Button("Preview");
            hbox5.PackStart(button_preview);

            vbox3.PackStart(hbox5);

            web1 = new WebView();

            scrollView2 = new ScrollView();
            scrollView2.HorizontalScrollPolicy = ScrollPolicy.Automatic;
            scrollView2.VerticalScrollPolicy = ScrollPolicy.Automatic;

            if (Toolkit.CurrentEngine.Type != ToolkitType.Gtk)
                scrollView2.Content = web1;

            vbox3.PackStart(scrollView2, true);

            notebook1.Add(vbox3, "Preview");

            vbox1.PackStart(notebook1, true);

            this.Content = vbox1;
        }
Esempio n. 4
0
 public int GetVisualColumn(TextEditor editor, int logicalColumn)
 {
     int result = 1;
     int offset = Offset;
     if (editor.Options.IndentStyle == IndentStyle.Virtual && Length == 0 && logicalColumn > DocumentLocation.MinColumn)
     {
         foreach (char ch in editor.GetIndentationString(Offset))
         {
             if (ch == '\t')
             {
                 result += editor.Options.TabSize;
                 continue;
             }
             result++;
         }
         return result;
     }
     for (int i = 0; i < logicalColumn - 1; i++)
     {
         if (i < Length && editor.Document.GetCharAt(offset + i) == '\t')
         {
             result = TextViewMargin.GetNextTabstop(editor, result);
         }
         else
         {
             result++;
         }
     }
     return result;
 }
Esempio n. 5
0
 public int GetLogicalColumn(TextEditor editor, int visualColumn)
 {
     int curVisualColumn = 1;
     int offset = Offset;
     int max = offset + Length;
     for (int i = offset; i < max; i++)
     {
         if (i < editor.Document.TextLength && editor.Document.GetCharAt(i) == '\t')
         {
             curVisualColumn = TextViewMargin.GetNextTabstop(editor, curVisualColumn);
         }
         else
         {
             curVisualColumn++;
         }
         if (curVisualColumn > visualColumn)
             return i - offset + 1;
     }
     return Length + (visualColumn - curVisualColumn) + 1;
 }
		public override void Update (TextEditor editor)
		{
			//editor.TextViewMargin.PurgeLayoutCache ();
			editor.RedrawLines (start, end);
		}
		public override void Update (TextEditor editor)
		{
			editor.RedrawLine (line);
		}
		public override void Update (TextEditor editor)
		{
			editor.QueueDraw ();
		}
		public override void Update (TextEditor editor)
		{
			editor.RedrawPosition (line, column);
		}
		public abstract void Update (TextEditor editor);