From fb24fb02f71c7f881b95bf3cb32e1bf5735a3ecb Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Tue, 11 May 2021 22:56:04 -0400 Subject: [PATCH] implementing CellRenderer from UWT - requires MBS.Framework.UserInterface @ a75f688 --- .../Editors/FileSystem/FileSystemEditor.glade | 32 ++++++++++++------- .../Controls/GenericBrowserButton.cs | 4 +-- .../Editors/Database/Views/ScriptView.cs | 2 +- .../Editors/FileSystem/FileSystemEditor.cs | 20 ++++++++---- .../MainWindow.cs | 2 +- .../Panels/DocumentExplorerPanel.cs | 2 +- .../Panels/ErrorListPanel.cs | 12 +++---- .../Panels/SolutionExplorerPanel.cs | 2 +- 8 files changed, 45 insertions(+), 31 deletions(-) diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/FileSystem/FileSystemEditor.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/FileSystem/FileSystemEditor.glade index 10526e60..a9518a3f 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/Editors/FileSystem/FileSystemEditor.glade +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/FileSystem/FileSystemEditor.glade @@ -2,6 +2,20 @@ + + + + + + + + + + + + + + False @@ -45,6 +59,12 @@ Name True True + + + + 4 + + @@ -107,16 +127,4 @@ - - - - - - - - - - - - diff --git a/Libraries/UniversalEditor.UserInterface/Controls/GenericBrowserButton.cs b/Libraries/UniversalEditor.UserInterface/Controls/GenericBrowserButton.cs index 23b13c8c..1b32dc43 100644 --- a/Libraries/UniversalEditor.UserInterface/Controls/GenericBrowserButton.cs +++ b/Libraries/UniversalEditor.UserInterface/Controls/GenericBrowserButton.cs @@ -94,8 +94,8 @@ namespace UniversalEditor.UserInterface.Controls lv = new ListViewControl(); lv.Model = tm; - lv.Columns.Add (new ListViewColumnText (lv.Model.Columns [0], "Name")); - lv.Columns.Add (new ListViewColumnText (lv.Model.Columns [1], "Description")); + lv.Columns.Add(new ListViewColumn("Name", new CellRenderer[] { new CellRendererText(lv.Model.Columns[0]) })); + lv.Columns.Add(new ListViewColumn("Description", new CellRenderer[] { new CellRendererText(lv.Model.Columns[1]) })); lv.HeaderStyle = ColumnHeaderStyle.None; ctObjectModel.Controls.Add (lv, new BoxLayout.Constraints (true, true)); diff --git a/Libraries/UniversalEditor.UserInterface/Editors/Database/Views/ScriptView.cs b/Libraries/UniversalEditor.UserInterface/Editors/Database/Views/ScriptView.cs index 70dc57db..2da24655 100644 --- a/Libraries/UniversalEditor.UserInterface/Editors/Database/Views/ScriptView.cs +++ b/Libraries/UniversalEditor.UserInterface/Editors/Database/Views/ScriptView.cs @@ -353,7 +353,7 @@ namespace UniversalEditor.UserInterface.Editors.Database.Views DefaultTreeModel tmResults = new DefaultTreeModel(list.ToArray()); for (int i = 0; i < db.Tables[0].Fields.Count; i++) { - lvResults.Columns.Add(new ListViewColumnText(tmResults.Columns[i], db.Tables[0].Fields[i].Name)); + lvResults.Columns.Add(new ListViewColumn(db.Tables[0].Fields[i].Name, new CellRenderer[] { new CellRendererText(tmResults.Columns[i]) })); } foreach (DatabaseRecord rec in db.Tables[0].Records) { diff --git a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs index 06defd6a..e9aa7fed 100644 --- a/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs +++ b/Libraries/UniversalEditor.UserInterface/Editors/FileSystem/FileSystemEditor.cs @@ -38,6 +38,7 @@ using MBS.Framework; using MBS.Framework.UserInterface.Controls; using System.Text; using System.Diagnostics.Contracts; +using MBS.Framework.UserInterface.Drawing; namespace UniversalEditor.Editors.FileSystem { @@ -48,6 +49,8 @@ namespace UniversalEditor.Editors.FileSystem private DefaultTreeModel tm = null; private TextBox txtPath; + private const int DELIVERED_COLUMNS_COUNT = 5; + [EventHandler(nameof(txtPath), "KeyDown")] private void txtPath_KeyDown(object sender, KeyEventArgs e) { @@ -337,7 +340,8 @@ namespace UniversalEditor.Editors.FileSystem new TreeModelRowColumn(tm.Columns[0], f.Name), new TreeModelRowColumn(tm.Columns[1], String.Format("{0} items", (f.Files.Count + f.Folders.Count))), new TreeModelRowColumn(tm.Columns[2], "Folder"), - new TreeModelRowColumn(tm.Columns[3], now.ToString()) + new TreeModelRowColumn(tm.Columns[3], now.ToString()), + new TreeModelRowColumn(tm.Columns[4], Image.FromStock(StockType.Folder, 16)) }); row.RowColumns[1].RawValue = (f.Folders.Count + f.Files.Count); row.RowColumns[3].RawValue = now.ToBinary(); @@ -606,7 +610,8 @@ namespace UniversalEditor.Editors.FileSystem new TreeModelRowColumn(tm.Columns[0], f.Name), new TreeModelRowColumn(tm.Columns[1], (f.Folders.Count + f.Files.Count).ToString() + " items"), new TreeModelRowColumn(tm.Columns[2], "Folder"), - new TreeModelRowColumn(tm.Columns[3], "") + new TreeModelRowColumn(tm.Columns[3], ""), + new TreeModelRowColumn(tm.Columns[4], Image.FromStock(StockType.Folder, 16)) }); r.RowColumns[1].RawValue = (long)(f.Folders.Count + f.Files.Count); r.RowColumns[3].RawValue = (long)0; @@ -633,14 +638,15 @@ namespace UniversalEditor.Editors.FileSystem new TreeModelRowColumn(tm.Columns[0], f.Name), new TreeModelRowColumn(tm.Columns[1], UserInterface.Common.FileInfo.FormatSize(f.Size)), new TreeModelRowColumn(tm.Columns[2], "File"), - new TreeModelRowColumn(tm.Columns[3], f.ModificationTimestamp.ToString()) + new TreeModelRowColumn(tm.Columns[3], f.ModificationTimestamp.ToString()), + new TreeModelRowColumn(tm.Columns[4], Image.FromStock(StockType.File, 16)) }); r.RowColumns[1].RawValue = f.Size; r.RowColumns[3].RawValue = f.ModificationTimestamp.ToBinary(); for (int i = 0; i < fsom.AdditionalDetails.Count; i++) { - r.RowColumns.Add(new TreeModelRowColumn(tm.Columns[4 + i], f.GetAdditionalDetail(fsom.AdditionalDetails[i].Name))); + r.RowColumns.Add(new TreeModelRowColumn(tm.Columns[DELIVERED_COLUMNS_COUNT + i], f.GetAdditionalDetail(fsom.AdditionalDetails[i].Name))); } } r.SetExtraData("item", fso); @@ -769,14 +775,14 @@ namespace UniversalEditor.Editors.FileSystem FileSystemObjectModel fsom = (ObjectModel as FileSystemObjectModel); if (fsom == null) return; - for (int i = 4; i < tv.Columns.Count; i++) + for (int i = DELIVERED_COLUMNS_COUNT; i < tv.Columns.Count; i++) { tv.Columns.Remove(tv.Columns[i]); } for (int i = 0; i < fsom.AdditionalDetails.Count; i++) { tm.Columns.Add(new TreeModelColumn(typeof(string))); - tv.Columns.Add(new ListViewColumnText(tm.Columns[tm.Columns.Count - 1], fsom.AdditionalDetails[i].Title)); + tv.Columns.Add(new ListViewColumn(fsom.AdditionalDetails[i].Title, new CellRenderer[] { new CellRendererText(tm.Columns[tm.Columns.Count - 1]) })); } tv.Model = tm; @@ -917,7 +923,7 @@ namespace UniversalEditor.Editors.FileSystem if (!IsCreated) return; - for (int i = 4; i < tm.Columns.Count; i++) + for (int i = DELIVERED_COLUMNS_COUNT; i < tm.Columns.Count; i++) { tm.Columns.RemoveAt(i); } diff --git a/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/Libraries/UniversalEditor.UserInterface/MainWindow.cs index c2f043b9..cc2cdcdc 100644 --- a/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -215,7 +215,7 @@ namespace UniversalEditor.UserInterface ListViewControl lvToolbox = new ListViewControl(); lvToolbox.RowActivated += LvToolbox_RowActivated; lvToolbox.Model = tmToolbox; - lvToolbox.Columns.Add(new ListViewColumnText(tmToolbox.Columns[0], "Item")); + lvToolbox.Columns.Add(new ListViewColumn("Item", new CellRenderer[] { new CellRendererText(tmToolbox.Columns[0]) })); lvToolbox.HeaderStyle = ColumnHeaderStyle.None; AddPanel("Toolbox", DockingItemPlacement.Left, lvToolbox); diff --git a/Libraries/UniversalEditor.UserInterface/Panels/DocumentExplorerPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/DocumentExplorerPanel.cs index 9709b922..ef594bc6 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/DocumentExplorerPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/DocumentExplorerPanel.cs @@ -23,7 +23,7 @@ namespace UniversalEditor.UserInterface.Panels tm = new DefaultTreeModel(new Type[] { typeof(string) }); lv.Model = tm; lv.HeaderStyle = ColumnHeaderStyle.None; - lv.Columns.Add(new ListViewColumnText(tm.Columns[0], "Item")); + lv.Columns.Add(new ListViewColumn("Item", new CellRenderer[] { new CellRendererText(tm.Columns[0]) })); Controls.Add(lv, new BoxLayout.Constraints(true, true)); } diff --git a/Libraries/UniversalEditor.UserInterface/Panels/ErrorListPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/ErrorListPanel.cs index d81f3780..8b969c14 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/ErrorListPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/ErrorListPanel.cs @@ -53,12 +53,12 @@ namespace UniversalEditor.UserInterface.Panels tvErrorList.Model = tm; - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[0], "Line")); - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[1], "Description")); - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[2], "File")); - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[3], "Project")); - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[4], "Path")); - tvErrorList.Columns.Add(new ListViewColumnText(tm.Columns[5], "Category")); + tvErrorList.Columns.Add(new ListViewColumn("Line", new CellRenderer[] { new CellRendererText(tm.Columns[0]) })); + tvErrorList.Columns.Add(new ListViewColumn("Description", new CellRenderer[] { new CellRendererText(tm.Columns[1]) } )); + tvErrorList.Columns.Add(new ListViewColumn("File", new CellRenderer[] { new CellRendererText(tm.Columns[2]) } )); + tvErrorList.Columns.Add(new ListViewColumn("Project", new CellRenderer[] { new CellRendererText(tm.Columns[3]) } )); + tvErrorList.Columns.Add(new ListViewColumn("Path", new CellRenderer[] { new CellRendererText(tm.Columns[4]) } )); + tvErrorList.Columns.Add(new ListViewColumn("Category", new CellRenderer[] { new CellRendererText(tm.Columns[5]) })); (Application.Instance as IHostApplication).Messages.MessageAdded += (sender, e) => { diff --git a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs index 69749477..8e4f8c9f 100644 --- a/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs +++ b/Libraries/UniversalEditor.UserInterface/Panels/SolutionExplorerPanel.cs @@ -184,7 +184,7 @@ namespace UniversalEditor.UserInterface.Panels tvSolutionExplorer.RowActivated += tvSolutionExplorer_RowActivated; // (UniversalEditor.exe:24867): Gtk-CRITICAL **: 21:28:56.913: gtk_tree_store_set_value: assertion 'G_IS_VALUE (value)' failed - tvSolutionExplorer.Columns.Add(new ListViewColumnText(tmSolutionExplorer.Columns[0], "File Name")); + tvSolutionExplorer.Columns.Add(new ListViewColumn("File name", new CellRenderer[] { new CellRendererText(tmSolutionExplorer.Columns[0]) })); this.Controls.Add(tvSolutionExplorer, new BoxLayout.Constraints(true, true));