internal TextWidgetUndoData(InternalTextEditWidget textEditWidget) { undoString = textEditWidget.Text; charIndexToInsertBefore = textEditWidget.CharIndexToInsertBefore; selectionIndexToStartBefore = textEditWidget.SelectionIndexToStartBefore; selecting = textEditWidget.Selecting; }
internal void ExtractData(InternalTextEditWidget textEditWidget) { textEditWidget.Text = undoString; textEditWidget.CharIndexToInsertBefore = charIndexToInsertBefore; textEditWidget.SelectionIndexToStartBefore = selectionIndexToStartBefore; textEditWidget.Selecting = selecting; }
public TextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0, TypeFace typeFace = null) { internalTextEditWidget = new InternalTextEditWidget(text, pointSize, multiLine, tabIndex, typeFace: typeFace); HookUpToInternalWidget(pixelWidth, pixelHeight); OriginRelativeParent = new Vector2(x, y); Multiline = multiLine; }
internal TextWidgetUndoCommand(InternalTextEditWidget textEditWidget) { this.textEditWidget = textEditWidget; undoString = textEditWidget.Text; charIndexToInsertBefore = textEditWidget.CharIndexToInsertBefore; selectionIndexToStartBefore = textEditWidget.SelectionIndexToStartBefore; selecting = textEditWidget.Selecting; }
/// <summary> /// Make this widget the focus of keyboard input. /// </summary> public override void Focus() { #if DEBUG if (Parent == null) { throw new Exception("Don't call Focus() until you have a Parent.\nCalling focus without a parent will not result in the focus chain pointing to the widget, so it will not work."); } #endif InternalTextEditWidget.Focus(); }
public TextEditWidget(string text = "", double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool multiLine = false, int tabIndex = 0) { internalTextEditWidget = new InternalTextEditWidget(text, pointSize, multiLine, tabIndex); HookUpToInternalWidget(pixelWidth, pixelHeight); OriginRelativeParent = new Vector2(x, y); Multiline = multiLine; }
private GuiWidget CreateQuickMenu(OrganizerSettingsData settingData, GuiWidget content, InternalTextEditWidget internalTextWidget) { string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); FlowLayoutWidget totalContent = new FlowLayoutWidget(); StyledDropDownList selectableOptions = new StyledDropDownList("Custom", maxHeight: 200); selectableOptions.Margin = new BorderDouble(0, 0, 10, 0); foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) { string valueLocal = nameValue.Value; MenuItem newItem = selectableOptions.AddItem(nameValue.MenuName); if (sliceSettingValue == valueLocal) { selectableOptions.SelectedLabel = nameValue.MenuName; } newItem.Selected += (sender, e) => { SaveSetting(settingData.SlicerConfigName, valueLocal); CallEventsOnSettingsChange(settingData); internalTextWidget.Text = valueLocal; internalTextWidget.OnEditComplete(null); }; } // put in the custom menu to allow direct editing MenuItem customMenueItem = selectableOptions.AddItem("Custom"); totalContent.AddChild(selectableOptions); content.VAnchor = VAnchor.ParentCenter; totalContent.AddChild(content); internalTextWidget.EditComplete += (sender, e) => { bool foundSetting = false; foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) { string localName = nameValue.MenuName; string newSliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName); if (newSliceSettingValue == nameValue.Value) { selectableOptions.SelectedLabel = localName; foundSetting = true; break; } } if (!foundSetting) { selectableOptions.SelectedLabel = "Custom"; } }; return totalContent; }
public TextEditPage() : base("Text Edit Widget") { FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); BackgroundColor = new RGBA_Bytes(210, 210, 255); topToBottom.Padding = new BorderDouble(20); topToBottom.AddChild(new TextWidget("testing underline jpqy", underline: true)); topToBottom.AddChild(new TextWidget("testing1\ntest2\ntest3")); topToBottom.AddChild(new TextWidget("this is some multiline\ntext\nwith centering", justification: Justification.Center)); int tabIndex = 0; #if true InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("line1\nline2\nline3", 12, true, tabIndex++); //InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", 12, true); topToBottom.AddChild(internalMultiLine); #endif // show some masking for passwords { FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.Margin = new BorderDouble(3); TextEditWidget passwordeTextEdit = new TextEditWidget("Password", tabIndex: tabIndex++); //passwordeTextEdit.InternalTextEditWidget.MaskCharacter = '*'; passwordeTextEdit.Margin = new BorderDouble(4, 0); leftToRight.AddChild(passwordeTextEdit); TextWidget description = new TextWidget("Content:"); leftToRight.AddChild(description); TextWidget passwordContent = new TextWidget("Password"); leftToRight.AddChild(passwordContent); passwordeTextEdit.TextChanged += (sender, e) => { passwordContent.Text = passwordeTextEdit.Text; }; topToBottom.AddChild(leftToRight); } TextEditWidget singleLineTextEdit = new TextEditWidget("Single Line Edit Text Control", tabIndex: tabIndex++); topToBottom.AddChild(singleLineTextEdit); TextEditWidget multiLineTextConrol = new TextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", tabIndex: tabIndex++); multiLineTextConrol.Multiline = true; topToBottom.AddChild(multiLineTextConrol); TextEditWidget longTextWidget = new TextEditWidget("This is some really long text.", pixelWidth: 100, tabIndex: tabIndex++); topToBottom.AddChild(longTextWidget); topToBottom.AddChild(new TextWidget("Integer Text Control:")); topToBottom.AddChild(new NumberEdit(512102416, tabIndex: tabIndex++)); topToBottom.AddChild(new TextWidget("Floating Point Text Control:")); topToBottom.AddChild(new NumberEdit(512102416, allowNegatives: true, allowDecimals: true, tabIndex: tabIndex++)); TextWidget paddingAdjustText = new TextWidget("Padding: 0"); paddingAdjustText.AutoExpandBoundsToText = true; topToBottom.AddChild(paddingAdjustText); TextEditWidget paddingAdjustTextEdit = new TextEditWidget("Edit With Padding", tabIndex: tabIndex++); GuiWidget paddingAroundTextEdit = new GuiWidget(100, 16); topToBottom.AddChild(paddingAroundTextEdit); paddingAroundTextEdit.AddChild(paddingAdjustTextEdit); paddingAdjustText.SetBoundsToEncloseChildren(); //AddChild(new TextEditWidget("Multiline Edit Text Widget line 1\nline 2\nline 3", 200, 400, 200, 80, multiLine: true)); AddChild(topToBottom); foreach (GuiWidget child in topToBottom.Children) { //child.Padding = new BorderDouble(4); child.HAnchor = UI.HAnchor.ParentCenter; child.BackgroundColor = RGBA_Bytes.White; //child.Margin = new BorderDouble(3); if (child is TextWidget) { child.BackgroundColor = new RGBA_Bytes(255, 200, 200); } } Slider textPaddingSlider = new Slider(new Vector2(), 200, 0, 10); topToBottom.AddChild(textPaddingSlider); textPaddingSlider.ValueChanged += (sender, e) => { double padding = ((Slider)sender).Value; paddingAdjustText.Padding = new BorderDouble(padding); paddingAroundTextEdit.Padding = new BorderDouble(padding); paddingAroundTextEdit.SetBoundsToEncloseChildren(); ((Slider)sender).Parent.SetBoundsToEncloseChildren(); }; topToBottom.HAnchor = UI.HAnchor.ParentCenter; topToBottom.VAnchor = UI.VAnchor.ParentCenter; }
private static GuiWidget CreateQuickMenu(SliceSettingData settingData, PrinterSettingsLayer persistenceLayer, GuiWidget content, InternalTextEditWidget internalTextWidget, List<PrinterSettingsLayer> layerCascade) { string sliceSettingValue = GetActiveValue(settingData.SlicerConfigName, layerCascade); FlowLayoutWidget totalContent = new FlowLayoutWidget(); DropDownList selectableOptions = new DropDownList("Custom", maxHeight: 200); selectableOptions.Margin = new BorderDouble(0, 0, 10, 0); foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) { string valueLocal = nameValue.Value; MenuItem newItem = selectableOptions.AddItem(nameValue.MenuName); if (sliceSettingValue == valueLocal) { selectableOptions.SelectedLabel = nameValue.MenuName; } newItem.Selected += (sender, e) => { ActiveSliceSettings.Instance.SetValue(settingData.SlicerConfigName, valueLocal, persistenceLayer); OnSettingsChanged(settingData); internalTextWidget.Text = valueLocal; internalTextWidget.OnEditComplete(null); }; } // put in the custom menu to allow direct editing MenuItem customMenueItem = selectableOptions.AddItem("Custom"); totalContent.AddChild(selectableOptions); content.VAnchor = VAnchor.ParentCenter; totalContent.AddChild(content); EventHandler localUnregisterEvents = null; SettingChanged.RegisterEvent((sender, e) => { bool foundSetting = false; foreach (QuickMenuNameValue nameValue in settingData.QuickMenuSettings) { string localName = nameValue.MenuName; string newSliceSettingValue = GetActiveValue(settingData.SlicerConfigName, layerCascade); if (newSliceSettingValue == nameValue.Value) { selectableOptions.SelectedLabel = localName; foundSetting = true; break; } } if (!foundSetting) { selectableOptions.SelectedLabel = "Custom"; } }, ref localUnregisterEvents); totalContent.Closed += (s, e) => { localUnregisterEvents?.Invoke(s, e); }; return totalContent; }
public void ClearUndoHistory() { InternalTextEditWidget.ClearUndoHistory(); }