diff --git a/CodeCompletion/CodeFormatter.cs b/CodeCompletion/CodeFormatter.cs index 9612db299..7e6dbca98 100644 --- a/CodeCompletion/CodeFormatter.cs +++ b/CodeCompletion/CodeFormatter.cs @@ -3427,6 +3427,11 @@ namespace CodeFormatters //sb.Append("|"); } + public override void visit(double_question_node dn) + { + visit_node(dn.left); + visit_node(dn.right); + } #endregion } } \ No newline at end of file diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 2bd1493b4..8bbcf8c3d 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "6"; public const string Build = "3"; - public const string Revision = "2594"; + public const string Revision = "2595"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index 30581df77..4f169b13c 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%COREVERSION%=3 -%REVISION%=2594 %MINOR%=6 +%REVISION%=2595 +%COREVERSION%=3 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 53286c063..15b13dd63 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.3.2594 +3.6.3.2595 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index ff034d0a3..d22bcb03c 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.3.2594' +!define VERSION '3.6.3.2595' diff --git a/TestSuite/CompilationSamples/GraphWPF.pas b/TestSuite/CompilationSamples/GraphWPF.pas index cb86be1f3..e5d77d634 100644 --- a/TestSuite/CompilationSamples/GraphWPF.pas +++ b/TestSuite/CompilationSamples/GraphWPF.pas @@ -1531,7 +1531,7 @@ procedure DrawGraph(f: real -> real; a, b: real; r: GRect; title: string) := Dra procedure DrawGraph(f: real -> real; r: GRect; title: string) := DrawGraph(f, -5, 5, r, title); -procedure DrawGraph(f: real -> real; a, b: real; title: string) := DrawGraph(f, a, b, 0, 0, Window.Width - 1, Window.Height - 1, title); +procedure DrawGraph(f: real -> real; a, b: real; title: string) := DrawGraph(f, a, b, 0, 0, GraphWindow.Width - 1, GraphWindow.Height - 1, title); procedure DrawGraph(f: real -> real; title: string) := DrawGraph(f, -5, 5, title); diff --git a/bin/Lib/Controls.pas b/bin/Lib/Controls.pas index 1cf93c093..afa8d4ca1 100644 --- a/bin/Lib/Controls.pas +++ b/bin/Lib/Controls.pas @@ -24,6 +24,11 @@ type GPanel = System.Windows.Controls.Panel; GControl = System.Windows.Controls.Control; GStatusBar = System.Windows.Controls.Primitives.StatusBar; + MessageBox = System.Windows.MessageBox; + MessageBoxButton = System.Windows.MessageBoxButton; + MessageBoxResult = System.Windows.MessageBoxResult; + MessageBoxImage = System.Windows.MessageBoxImage; + /// Набор предопределённых цветов Colors = System.Windows.Media.Colors; Key = System.Windows.Input.Key; @@ -36,8 +41,9 @@ procedure InvokeP(p: procedure(r: real); r: real); type ///!# + /// Базовый класс для панелей PanelWPF = class - protected + private p: StackPanel; bb: Border; procedure CreateP(wh: real; d: Dock; c: Color; InternalMargin: real); @@ -80,6 +86,7 @@ type write Invoke(procedure -> p.Margin := new System.Windows.Thickness(internalMargin), value); end; + /// Класс левой панели LeftPanelWPF = class(PanelWPF) public constructor Create(width: real := 150; c: GColor := PanelsColor; internalMargin: real := 10); @@ -88,6 +95,7 @@ type end; end; + /// Класс правой панели RightPanelWPF = class(PanelWPF) public constructor Create(width: real := 150; c: GColor := PanelsColor; internalMargin: real := 10); @@ -97,8 +105,9 @@ type end; ///!# + /// Базовый класс для всех элементов управления CommonElementWPF = class - protected + private element: FrameworkElement; procedure Init0(el: FrameworkElement; width: real := 0; x: real := -1; y: real := -1); begin @@ -122,19 +131,27 @@ type procedure SetHP(h: real) := element.Height := h; procedure SetMP(m: real) := element.Margin := new Thickness(0,0,0,m); procedure SetEP(enabled: boolean) := element.IsEnabled := enabled; - public + public + /// Ширина элемента управления property Width: real read InvokeReal(()->element.Width) write Invoke(SetWP, value); + /// Высота элемента управления property Height: real read InvokeReal(()->element.Height) write Invoke(SetHP, value); virtual; + /// Нижний отступ элемента управления property Margin: real read InvokeReal(()->element.Margin.Bottom) write Invoke(SetMP, value); + /// Активирован ли элемент управления property Enabled: boolean read InvokeBoolean(()->element.IsEnabled) write Invoke(SetEP, value); end; CommonControlWPF = class(CommonElementWPF) private - procedure SetFSzP(size: real) := control.FontSize := size; property Control: GControl read element as GControl; + procedure SetFSzP(size: real) := control.FontSize := size; + procedure SetFontNameP(name: string) := control.FontFamily := new FontFamily(name); public + /// Размер шрифта property FontSize: real read InvokeReal(()->control.FontSize) write Invoke(SetFSzP, value); virtual; + /// Имя шрифта + property FontName: string write Invoke(SetFontNameP, value); virtual; end; ///!# @@ -146,18 +163,19 @@ type Click; end; public + /// Событие нажатия на элемент управления Click: procedure; end; - ///!# + /// Элемент управления "Изображение" ImageWPF = class(CommonControlWPF) - protected + private property im: Image read element as Image; procedure CreatePXY(x,y: real; name: string; width: real := 0); begin Init0(new Image(),width,x,y); im.Source := new BitmapImage(); - im.Source := new BitmapImage(new System.Uri(name)); + im.Source := new BitmapImage(new System.Uri(name,System.UriKind.RelativeOrAbsolute)); end; procedure CreateP(name: string) := CreatePXY(-1,-1,name,0); procedure CreatePP; @@ -174,19 +192,20 @@ type end; procedure SetNameP(value: string); begin - im.Source := new BitmapImage(new System.Uri(value)); + im.Source := new BitmapImage(new System.Uri(value,System.UriKind.RelativeOrAbsolute)); end; constructor (i: integer) := Invoke(CreatePP); // фиктивный первый параметр public constructor (name: string) := Invoke(CreateP,name); constructor (x,y: real; name: string; width: real := 0) := Invoke(CreatePXY,x,y,name,width); + /// Имя файла изображения property Name: string read InvokeString(GetNameP) write Invoke(SetNameP,value); end; - ///!# - ButtonWPF = class(CommonControlWPF) - protected + /// Элемент управления "Кнопка" + ButtonWPF = class(ClickableControlWPF) + private property b: GButton read element as GButton; procedure CreatePXY(x,y: real; Txt: string; width: real; fontSize: real); @@ -200,16 +219,16 @@ type procedure SetTextP(t: string) := b.Content := t; public - Click: procedure; constructor Create(Txt: string; fontSize: real := 12) := Invoke(CreateP, Txt, fontSize); constructor Create(x, y: real; Txt: string; width: real := 0; fontSize: real := 12) := Invoke(CreatePXY, x, y, Txt, width, fontSize); + /// Текст на кнопке property Text: string read InvokeString(()->b.Content as string) write Invoke(SetTextP, value); end; - ///!# + /// Элемент управления "Текст" TextBlockWPF = class(CommonElementWPF) - protected + private property tb: GTextBlock read element as GTextBlock; procedure CreatePXY(x, y: real; Txt: string; width: real; fontsize: real); @@ -223,14 +242,20 @@ type procedure SetTextP(t: string) := tb.Text := t; procedure SetFontSizeP(sz: real) := tb.FontSize := sz; + procedure SetFontNameP(name: string) := tb.FontFamily := new FontFamily(name); public constructor Create(Txt: string; fontsize: real := 12):= Invoke(CreateP, Txt, fontsize); constructor Create(x, y: real; Txt: string; width: real := 0; fontSize: real := 12):= Invoke(CreatePXY, x, y, Txt, width, fontSize); + /// Текст блока текста property Text: string read InvokeString(()->tb.Text) write Invoke(SetTextP, value); - property FontSize: real read InvokeReal(()->tb.FontSize) write Invoke(SetFontSizeP, value); + /// Размер шрифта + property FontSize: real read InvokeReal(()->tb.FontSize) write Invoke(SetFontSizeP, value); virtual; + /// Имя шрифта + property FontName: string write Invoke(SetFontNameP, value); virtual; end; + /// Элемент управления "Целое число" IntegerBlockWPF = class(TextBlockWPF) private val := 0; @@ -246,9 +271,11 @@ type constructor Create(message: string; initValue: integer := 0; fontSize: real := 12) := Invoke(CreateP, message, initValue, fontSize); constructor Create(x, y: real; message: string; width: real := 0; initValue: integer := 0; fontSize: real := 12) := Invoke(CreatePXY, x, y, message, width, initValue, fontSize); + /// Значение целого property Value: integer read val write begin val := value; Text := message + ' ' + val; end; end; + /// Элемент управления "Вещественное число" RealBlockWPF = class(TextBlockWPF) private val := 0.0; @@ -264,11 +291,13 @@ type constructor Create(message: string; initValue: real := 0; fontSize: real := 12) := Invoke(CreateP, message, initValue, fontSize); constructor Create(x, y: real; message: string; width: real := 0; initValue: real := 0; fontSize: real := 12) := Invoke(CreatePXY, x, y, message, width, initValue, fontSize); + /// Значение вещественного property Value: real read val write begin val := value; Text := message + ' ' + val.ToString(FracDigits); end; + /// Количество цифр после десятичной точки auto property FracDigits: integer := 1; end; - ///!# + /// Элемент управления "Текстовое поле" TextBoxNoTitleWPF = class(CommonControlWPF) private property tb: GTextBox read element as GTextBox; @@ -289,25 +318,40 @@ type begin element := new TextBox(); element.Focusable := False; - tb.TextWrapping := TextWrapping.Wrap; + tb.AcceptsReturn := True; + //tb.TextWrapping := TextWrapping.Wrap; + tb.VerticalScrollBarVisibility := ScrollBarVisibility.Auto; + tb.HorizontalScrollBarVisibility := ScrollBarVisibility.Auto; MainDockPanel.children.RemoveAt(MainDockPanel.children.Count-1); MainDockPanel.children.Add(element); end; + procedure SetReadOnlyP(value: boolean); + begin + element.Focusable := not value; + end; constructor Create(i: integer) := Invoke(CreatePP); public + /// Событие изменения текста TextChanged: procedure; constructor Create(text: string := '') := Invoke(CreateP, text); constructor Create(x,y: real; text: string := ''; width: real := 0) := Invoke(CreatePXY, x, y, text, width); + /// Текст в текстовом поле property Text: string read InvokeString(()->tb.Text) write Invoke(SetTextP, value); + /// Добавление строки в конец procedure Print(s: string); begin Text += s + ' '; end; + /// Добавление строки в конец и переход на новую строку procedure Println(s: string); begin Text += s + NewLine; end; + /// Очистка текста в текстовом поле + procedure Clear := Text := ''; + /// Разрешено ли ручное редактирование текста + property Focusable: boolean read InvokeBoolean(()->not element.Focusable) write Invoke(SetReadOnlyP,value); end; ///!# @@ -342,15 +386,28 @@ type var sp := CreateStackPanel(el,title); Init0(sp,width,x,y); end; - procedure SetFSzP(size: real) := MainElement.FontSize := size; + procedure SetFSzP(size: real); + begin + tb.FontSize := size; + MainElement.FontSize := size; + end; + procedure SetFontNameP(name: string); + begin + tb.FontFamily := new FontFamily(name); + MainElement.FontFamily := new FontFamily(name); + end; public - + /// Заголовок property Title: string read InvokeString(()->tb.Text) write Invoke(SetTitleP, value); + /// Высота элемента управления property Height: real read InvokeReal(()->MainElement.ActualHeight) write Invoke(SetHP, value); override; - property FontSize: real read InvokeReal(()->MainElement.FontSize) write Invoke(SetFSzP, value); virtual; + /// Размер шрифта + property FontSize: real read InvokeReal(()->MainElement.FontSize) write Invoke(SetFSzP, value); override; + /// Имя шрифта + property FontName: string write Invoke(SetFontNameP, value); override; end; - ///!# + /// Элемент управления "Текстовое поле с заголовком" TextBoxWPF = class(ControlWithTitleWPF) private property tbx: GTextBox read MainElement as TextBox; @@ -376,15 +433,20 @@ type procedure CreateP(title,text: string) := CreatePXY(-1,-1,title,text,0); constructor Create(i: integer) := Invoke(CreateAsMainControlP); public + /// Событие "текст изменился" TextChanged: procedure; constructor Create(title: string := '') := Invoke(CreateP, title, ''); constructor Create(x,y: real; title: string := ''; width: real := 120) := Invoke(CreatePXY, x, y, title,'', width); + /// Очистка текста в текстовом поле procedure Clear := Text := ''; + /// Текст в текстовом поле property Text: string read InvokeString(()->tbx.Text) write Invoke(SetTextP, value); + /// Разрешено ли несколько строк в текстовом поле property MultiLine: boolean read InvokeBoolean(()->tbx.TextWrapping = TextWrapping.Wrap) write Invoke(SetMultiLineP, value); end; + /// Элемент управления "Целое поле" IntegerBoxWPF = class(TextBoxWPF) private function GetValue: integer; @@ -392,16 +454,16 @@ type if Trim(Text) = '' then Result := 0 else Result := integer.Parse(Text); - Result := Result.Clamp(Min,Max); + Result := Result.Clamp(Minimum,Maximum); end; - procedure SetValue(x: integer) := Text := x.Clamp(Min,Max).ToString; + procedure SetValue(x: integer) := Text := x.Clamp(Minimum,Maximum).ToString; procedure Rest(min,max:integer); begin Invoke(()-> begin - Self.Min := min; - Self.Max := max; - Value := Min; + Self.Minimum := min; + Self.Maximum := max; + Value := Minimum; tbx.MouseWheel += (o, e) -> begin if e.Delta > 0 then Value := Value + 1 @@ -426,13 +488,15 @@ type Rest(min,max); end; - auto property Min: integer := 0; - auto property Max: integer := 100; - + /// Минимальное значение в тектовом поле + auto property Minimum: integer := 0; + /// Максимальное значение в тектовом поле + auto property Maximum: integer := 100; + /// Текущее значение текстового поля property Value: integer read GetValue write SetValue; end; - ///!# + /// Элемент управления "Список" ListBoxWPF = class(ControlWithTitleWPF) protected function lb: GListBox := MainElement as GListBox; @@ -461,20 +525,28 @@ type procedure SortP := lb.Items.SortDescriptions.Add(new SortDescription('Content', ListSortDirection.Ascending)); procedure SortPDescending := lb.Items.SortDescriptions.Add(new SortDescription('Content', ListSortDirection.Descending)); public + /// Событие, возникающее при изменении текущего выделения SelectionChanged: procedure; constructor Create(title: string := ''; height: real := 150):= Invoke(CreateP, title, height); constructor Create(x,y: real; title: string := ''; width: real := 150; height: real := 150):= Invoke(CreatePXY, x, y, title, width, height); + /// Сортировка строк в списке по возрастанию procedure Sort := Invoke(SortP); + /// Сортировка строк в списке по убыванию procedure SortDescending := Invoke(SortPDescending); + /// Добавляет элемент в список procedure Add(s: string) := Invoke(AddP, s); - procedure AddRange(ss: sequence of string) := Invoke(AddRangeP, ss); + /// Добавляет набор элементов в список + procedure AddRange(params ss: array of string) := Invoke(AddRangeP, ss); + /// Количество элементов в списке property Count: integer read InvokeInteger(()->lb.Items.Count); + /// Индекс выбранного элемента property SelectedIndex: integer read InvokeInteger(()->lb.SelectedIndex) write Invoke(procedure(t: integer) -> lb.SelectedIndex := t, value); + /// Текст выбранного элемента property SelectedText: string read InvokeString(()->(lb.SelectedItem as ListBoxItem).Content.ToString) write Invoke(procedure(t: string) -> (lb.SelectedItem as ListBoxItem).Content := t, value); end; - ///!# + /// Элемент управления "Раскрывающийся список" ComboBoxWPF = class(ControlWithTitleWPF) private property cb: ComboBox read MainElement as ComboBox; @@ -497,15 +569,20 @@ type AddP(s); end; public + /// Событие, возникающее при изменении текущего выделения SelectionChanged: procedure; constructor Create(title: string := '') := Invoke(CreateP, title); constructor Create(x,y: real; title: string := ''; width: real := 120) := Invoke(CreatePXY, x, y, title,'', width); + /// Добавляет элемент в список procedure Add(s: string) := Invoke(AddP, s); + /// Добавляет набор элементов в список procedure AddRange(params ss: array of string) := Invoke(AddRangeP, ss); + /// Выбранная строка function SelectedString := InvokeString(()->cb.SelectedItem as string); end; + /// Элемент управления "Слайдер" SliderWPF = class(CommonControlWPF) private function sl: Slider := element as Slider; @@ -539,15 +616,21 @@ type procedure ValueChangedP := if ValueChanged <> nil then ValueChanged; public + /// Событие, возникающее при изменении значения ValueChanged: procedure; constructor Create(min, max: real; val: real := real.MinValue; freq: real := 0) := Invoke(CreateP, min, max, val, freq); constructor Create(x,y: real; min, max: real; width: real; val: real := real.MinValue; freq: real := 0) := Invoke(CreatePXY, x,y,min, max, val, freq, width); + /// Минимальное значение property Minimum: real read GetMinimum write SetMinimum; + /// Максимальное значение property Maximum: real read GetMaximum write SetMaximum; + /// Текущее значение property Value: real read GetValue write SetValue; + /// Интервал между делениями property Frequency: real read GetFrequency write SetFrequency; end; + /// Элемент управления "Флажок" CheckBoxWPF = class(ClickableControlWPF) private property cb: CheckBox read element as CheckBox; @@ -563,10 +646,13 @@ type constructor Create(text: string) := Invoke(CreateP, text); constructor Create(x,y: real; text: string; width: real := 0) := Invoke(CreatePXY, x,y,text,width); + /// Текст элемента управления property Text: string read InvokeString(()->cb.Content as string) write Invoke(procedure(t: string) -> cb.Content := t, value); - property IsChecked: boolean read InvokeBoolean(()->cb.IsChecked.Value) write Invoke(procedure(t: boolean) -> cb.IsChecked := t, value); + /// Включен ли флажок + property Checked: boolean read InvokeBoolean(()->cb.IsChecked.Value) write Invoke(procedure(t: boolean) -> cb.IsChecked := t, value); end; + /// Элемент управления "Радиокнопка" RadioButtonWPF = class(ClickableControlWPF) private property rb: RadioButton read element as RadioButton; @@ -582,10 +668,13 @@ type constructor Create(text: string) := Invoke(CreateP, text); constructor Create(x,y: real; text: string; width: real := 0) := Invoke(CreatePXY, x,y,text,width); + /// Текст элемента управления property Text: string read InvokeString(()->rb.Content as string) write Invoke(procedure(t: string) -> rb.Content := t, value); - property IsChecked: boolean read InvokeBoolean(()->rb.IsChecked.Value) write Invoke(procedure(t: boolean) -> rb.IsChecked := t, value); + /// Включена ли радиокнопка + property Checked: boolean read InvokeBoolean(()->rb.IsChecked.Value) write Invoke(procedure(t: boolean) -> rb.IsChecked := t, value); end; - + + /// Элемент управления "Строка статуса" StatusBarWPF = class(CommonControlWPF) private property sb: GStatusBar read element as GStatusBar; @@ -621,15 +710,18 @@ type end; public constructor Create(height: real := 24; itemWidth: real := 0) := Invoke(CreateP,height,itemWidth); + /// Добавить текстовое поле указанной ширины к строке статуса procedure AddText(text: string; itemWidth: real := 0) := Invoke(AddItemP,text,itemWidth); + /// Текст основного текстового поля в строке статуса property Text: string read InvokeString(()->(sb.Items[0] as StatusBarItem).Content as string) write Invoke(SetTextP,value); - property ItemText[i: integer]: string read InvokeString(()->(sb.Items[0] as StatusBarItem).Content as string) + /// Текст i-того текстового поля в строке статуса + property ItemText[i: integer]: string read InvokeString(()->(sb.Items[i] as StatusBarItem).Content as string) write Invoke(SetTextPI,i,value); end; - ///!# + /// Элемент управления "Канва" CanvasWPF = class(CommonControlWPF) protected property can: Canvas read element as Canvas; @@ -648,6 +740,7 @@ type end; function GetColorP := (can.Background as SolidColorBrush).Color; public + /// Цвет элемента управления property Color: GColor read Invoke&(GetColorP) write Invoke(SetColorP, value); end; @@ -655,7 +748,7 @@ function GetProperties(t1: T): sequence of string; function GetFields(t1: T): sequence of string; type - ///!# + /// Элемент управления "Список данных" ListViewWPF = class(CommonControlWPF) private gv: GridView; @@ -671,11 +764,12 @@ type end; function ColumnCountP: integer := gv.Columns.Count; function RowCountP: integer := lv.Items.Count; - public constructor (i: integer); begin Invoke(CreatePP); end; + public + /// Заполнить элемент управления данными procedure Fill(data: sequence of T); begin Invoke(()-> begin @@ -692,12 +786,14 @@ type lv.ItemsSource := data; end); end; + /// Очистить данные procedure Clear; begin Invoke(()-> begin gv.Columns.Clear; end); end; + /// Установить заголовки для данных procedure SetHeaders(params a: array of string); begin Invoke(()-> begin @@ -705,13 +801,18 @@ type gv.Columns[i].Header := a[i]; end); end; + /// Число столбцов данных function ColumnCount: integer := InvokeInteger(ColumnCountP); + /// Число строк данных function RowCount: integer := InvokeInteger(RowCountP); end; - + + ///!# + /// Пункт меню MenuItemWPF = class private mi: MenuItem; + litem := new List; procedure CreateP(mii: MenuItem; text: string); begin mi := mii; @@ -725,21 +826,47 @@ type begin mi.Header := text; end; - function AddMenuItemP(text: string): MenuItemWPF; + function AddMenuItemP(text: string; p: procedure): MenuItemWPF; begin + if text='-' then + begin + mi.Items.Add(new Separator); + exit + end; var mii := new MenuItem; mii.Header := text; mi.Items.Add(mii); - Result := new MenuItemWPF(mii,text) + mii.Click += (o,e)->if Click<>nil then Click; + Result := new MenuItemWPF(mii,text); + Result.Click := p; + litem.Add(Result); end; + procedure AddSeparatorP := mi.Items.Add(new Separator); public + /// Событие выбора пункта меню Click: procedure; + /// Текст пункта меню property Text: string read InvokeString(()-> mi.Header as string) write Invoke(SetTextP,text); - function Add(text: string): MenuItemWPF := Invoke&(()->AddMenuItemP(text)); + /// Набор пунктов меню + property Items[i: integer]: MenuItemWPF read Invoke&(()->litem[i]); default; + /// Добавить пункт подменю + function Add(text: string; p: procedure := nil): MenuItemWPF + := Invoke&(()->AddMenuItemP(text,p)); + + /// Добавить разделитель + procedure AddSeparator := Invoke(AddSeparatorP); + /// Добавить набор пунктов меню + procedure AddRange(params items: array of string); + begin + foreach var it in items do + Add(it); + end; end; + /// Элемент управления "Главное меню" MenuWPF = class(CommonControlWPF) private + litem := new List; property m: Menu read element as Menu; procedure CreatePP; begin @@ -753,15 +880,25 @@ type var mi := new MenuItem; mi.Header := text; m.Items.Add(mi); - Result := new MenuItemWPF(mi,text) + Result := new MenuItemWPF(mi,text); + litem.Add(Result); end; public constructor Create := Invoke(CreatePP); + property Items[i: integer]: MenuItemWPF read Invoke&(()->litem[i]); default; + + /// Добавить пункт горизонтального меню function Add(text: string): MenuItemWPF := Invoke&(()->AddMenuItemP(text)); + /// Добавить набор пунктов меню + procedure AddRange(params items: array of string); + begin + foreach var it in items do + Add(it); + end; end; ///!# - /// Статический класс для создания главных контролов + /// Статический класс для создания главных элементов управления SetMainControl = static class public static function AsImage: ImageWPF := new ImageWPF(0); @@ -770,49 +907,130 @@ type static function AsTextBox: TextBoxNoTitleWPF := new TextBoxNoTitleWPF(0); end; + ///!# + /// Базовый класс стандартных окон диалога + FileDialogWPF = class + private + d: Microsoft.Win32.FileDialog; + procedure SetFilterP(value: string) := d.Filter := value; + procedure SetInitialDirectoryP(value: string) := d.InitialDirectory := value; + function ShowDialogP: boolean; + begin + var r := d.ShowDialog; + Result := r.HasValue and r.Value; + end; + public + function ShowDialog: boolean := InvokeBoolean(ShowDialogP); + function FileName: string := InvokeString(()->d.FileName); + property Filter: string read InvokeString(()->d.Filter) write Invoke(SetFilterP,value); + property InitialDirectory: string read InvokeString(()->d.InitialDirectory) write Invoke(SetInitialDirectoryP,value); + end; + + /// Стандартное окно диалога открытия файла + OpenFileDialogWPF = class(FileDialogWPF) + private + procedure CreateP(initDirectory,filter: string); + begin + d := new Microsoft.Win32.OpenFileDialog; + d.InitialDirectory := initDirectory; + d.Filter := filter; + end; + public + constructor Create(initDirectory: string := ''; filter: string := '') := Invoke(CreateP,initDirectory,filter); + end; + + /// Стандартное окно диалога сохранения файла + SaveFileDialogWPF = class(FileDialogWPF) + private + procedure CreateP(initDirectory,filter: string); + begin + d := new Microsoft.Win32.SaveFileDialog; + d.InitialDirectory := initDirectory; + d.Filter := filter; + end; + public + constructor Create(initDirectory: string := ''; filter: string := '') := Invoke(CreateP,initDirectory,filter); + end; + {-----------------------------------------------------} // Для каждого контрола - пара функций. // Функция без координат и ширины рассчитана на создание внутри вертикальной StackPanel (LeftPanel, RightPanel) // Panel - вспомогательная, нужна только для создания LeftPanel, RightPanel +/// Элемент управления "Кнопка" function Button(Txt: string; fontSize: real := 12): ButtonWPF; +/// Элемент управления "Кнопка" с заданными координатами function Button(x, y: real; Txt: string; width: real := 0; fontSize: real := 12): ButtonWPF; +/// Элемент управления "Текст" function TextBlock(Txt: string; fontSize: real := 12): TextBlockWPF; +/// Элемент управления "Текст" с заданными координатами function TextBlock(x, y: real; Txt: string; width: real := 0; fontSize: real := 12): TextBlockWPF; +/// Элемент управления "Целое число" function IntegerBlock(message: string; initValue: integer := 0; fontSize: real := 12): IntegerBlockWPF; +/// Элемент управления "Целое число" с заданными координатами function IntegerBlock(x, y: real; message: string; width: real := 0; initValue: integer := 0; fontSize: real := 12): IntegerBlockWPF; +/// Элемент управления "Вещественное число" function RealBlock(message: string; initValue: real := 0; fontSize: real := 12): RealBlockWPF; +/// Элемент управления "Вещественное число" с заданными координатами function RealBlock(x, y: real; message: string; width: real := 0; initValue: real := 0; fontSize: real := 12): RealBlockWPF; +/// Элемент управления "Текстовое поле с заголовком" function TextBox(text: string := ''): TextBoxWPF; +/// Элемент управления "Текстовое поле с заголовком" с заданными координатами function TextBox(x, y: real; text: string := ''; width: real := 0): TextBoxWPF; +/// Элемент управления "Целое поле" function IntegerBox(title: string; max: integer := 10): IntegerBoxWPF; +/// Элемент управления "Целое поле" с заданным диапазоном значений function IntegerBox(title: string; min,max: integer): IntegerBoxWPF; +/// Элемент управления "Целое поле" с заданными координатами function IntegerBox(x, y: real; title: string; min,max: integer; width: real := 0): IntegerBoxWPF; +/// Элемент управления "Список" function ListBox(title: string := ''; height: real := 150): ListBoxWPF; +/// Элемент управления "Список" с заданными координатами function ListBox(x,y: real; title: string := ''; width: real := 150; height: real := 150): ListBoxWPF; +/// Элемент управления "Слайдер" function Slider(): SliderWPF; +/// Элемент управления "Слайдер" с заданным диапазоном значений function Slider(min,max: real; val: real := real.MinValue; freq: real := 0): SliderWPF; +/// Элемент управления "Слайдер" с заданными координатами function Slider(x,y: real; min,max: real; width: real; val: real := real.MinValue; freq: real := 0): SliderWPF; +/// Элемент управления "Изображение" function Image(name: string): ImageWPF; +/// Элемент управления "Изображение" с заданными координатами function Image(x,y: real; name: string; width: real := 0): ImageWPF; +/// Элемент управления "Раскрывающийся список" +function ComboBox(title: string := ''): ComboBoxWPF; +/// Элемент управления "Раскрывающийся список" с заданными координатами +function ComboBox(x,y: real; title: string := ''; width: real := 120): ComboBoxWPF; +/// Элемент управления "Главное меню" +function Menu: MenuWPF; + +/// Стандартное окно диалога открытия файла +function OpenFileDialog(initDirectory: string := ''; filter: string := ''): OpenFileDialogWPF; +/// Стандартное окно диалога сохранения файла +function SaveFileDialog(initDirectory: string := ''; filter: string := ''): SaveFileDialogWPF; + +/// Элемент управления "Левая панель" function LeftPanel(width: real := 150; c: Color := PanelsColor; InternalMargin: real := 10): PanelWPF; +/// Элемент управления "Правая панель" function RightPanel(width: real := 150; c: Color := PanelsColor; InternalMargin: real := 10): PanelWPF; +/// Элемент управления "Строка статуса" function StatusBar(height: real := 24; itemWidth: real := 0): StatusBarWPF; - +/// Пустой блок для задания промежутков между компонентами procedure EmptyBlock(sz: integer := 16); +/// Графическое окно function Window: WindowTypeWPF; implementation @@ -862,9 +1080,15 @@ begin end; function Image(name: string): ImageWPF := new ImageWPF(name); -function Image(x,y: real; name: string; width: real): ImageWPF - := new ImageWPF(x,y,name,width); +function Image(x,y: real; name: string; width: real): ImageWPF := new ImageWPF(x,y,name,width); +function ComboBox(title: string): ComboBoxWPF := new ComboBoxWPF(title); +function ComboBox(x,y: real; title: string; width: real): ComboBoxWPF := new ComboBoxWPF(x,y,title,width); + +function Menu: MenuWPF := new MenuWPF; + +function OpenFileDialog(initDirectory: string; filter: string) := new OpenFileDialogWPF(initDirectory,filter); +function SaveFileDialog(initDirectory: string; filter: string) := new SaveFileDialogWPF(initDirectory,filter); function LeftPanel(width: real; c: Color; internalMargin: real) := new LeftPanelWPF(width,c,internalMargin); function RightPanel(width: real; c: Color; internalMargin: real) := new RightPanelWPF(width,c,internalMargin); diff --git a/bin/Lib/GraphWPF.pas b/bin/Lib/GraphWPF.pas index 251df112b..4a896a82f 100644 --- a/bin/Lib/GraphWPF.pas +++ b/bin/Lib/GraphWPF.pas @@ -1531,7 +1531,7 @@ procedure DrawGraph(f: real -> real; a, b: real; r: GRect; title: string) := Dra procedure DrawGraph(f: real -> real; r: GRect; title: string) := DrawGraph(f, -5, 5, r, title); -procedure DrawGraph(f: real -> real; a, b: real; title: string) := DrawGraph(f, a, b, 0, 0, Window.Width - 1, Window.Height - 1, title); +procedure DrawGraph(f: real -> real; a, b: real; title: string) := DrawGraph(f, a, b, 0, 0, GraphWindow.Width - 1, GraphWindow.Height - 1, title); procedure DrawGraph(f: real -> real; title: string) := DrawGraph(f, -5, 5, title);