[ros-diffs] [cwittich] 35237: -implement opening source files -implement Firefox like Tab handling (closing with middle mouse button, context menu on right button)

cwittich at svn.reactos.org cwittich at svn.reactos.org
Sat Aug 9 17:36:25 CEST 2008


Author: cwittich
Date: Sat Aug  9 10:36:24 2008
New Revision: 35237

URL: http://svn.reactos.org/svn/reactos?rev=35237&view=rev
Log:
-implement opening source files
-implement Firefox like Tab handling (closing with middle mouse button, context menu on right button)

Modified:
    trunk/tools/reactosdbg/RosDBG/MainWindow.Designer.cs
    trunk/tools/reactosdbg/RosDBG/MainWindow.cs
    trunk/tools/reactosdbg/RosDBG/MainWindow.resx
    trunk/tools/reactosdbg/RosDBG/SourceView.Designer.cs
    trunk/tools/reactosdbg/RosDBG/SourceView.cs
    trunk/tools/reactosdbg/RosDBG/SourceView.resx

Modified: trunk/tools/reactosdbg/RosDBG/MainWindow.Designer.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/MainWindow.Designer.cs?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/MainWindow.Designer.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/MainWindow.Designer.cs [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -28,6 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
             this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -36,6 +37,7 @@
             this.connectSerialToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.connectPipeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.connectTCPIPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
             this.symbolDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
             this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -59,7 +61,8 @@
             this.WorkTabs = new System.Windows.Forms.TabControl();
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();
             this.RunStatus = new System.Windows.Forms.ToolStripStatusLabel();
-            this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
+            this.contextMenuTabStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
+            this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.splitContainer1.Panel1.SuspendLayout();
             this.splitContainer1.Panel2.SuspendLayout();
             this.splitContainer1.SuspendLayout();
@@ -68,6 +71,7 @@
             this.splitContainer2.Panel2.SuspendLayout();
             this.splitContainer2.SuspendLayout();
             this.statusStrip1.SuspendLayout();
+            this.contextMenuTabStrip.SuspendLayout();
             this.SuspendLayout();
             // 
             // splitContainer1
@@ -121,7 +125,6 @@
             // 
             // openSourceFileToolStripMenuItem
             // 
-            this.openSourceFileToolStripMenuItem.Enabled = false;
             this.openSourceFileToolStripMenuItem.Name = "openSourceFileToolStripMenuItem";
             this.openSourceFileToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
             this.openSourceFileToolStripMenuItem.Text = "Open Source File ...";
@@ -152,6 +155,11 @@
             this.connectTCPIPToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
             this.connectTCPIPToolStripMenuItem.Text = "Connect TCP/IP ...";
             this.connectTCPIPToolStripMenuItem.Click += new System.EventHandler(this.connectTCPIPToolStripMenuItem_Click);
+            // 
+            // toolStripMenuItem1
+            // 
+            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
+            this.toolStripMenuItem1.Size = new System.Drawing.Size(172, 6);
             // 
             // symbolDirectoryToolStripMenuItem
             // 
@@ -324,6 +332,7 @@
             this.WorkTabs.SelectedIndex = 0;
             this.WorkTabs.Size = new System.Drawing.Size(529, 357);
             this.WorkTabs.TabIndex = 1;
+            this.WorkTabs.MouseClick += new System.Windows.Forms.MouseEventHandler(this.WorkTabs_MouseClick);
             // 
             // statusStrip1
             // 
@@ -340,10 +349,19 @@
             this.RunStatus.Name = "RunStatus";
             this.RunStatus.Size = new System.Drawing.Size(0, 17);
             // 
-            // toolStripMenuItem1
-            // 
-            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
-            this.toolStripMenuItem1.Size = new System.Drawing.Size(172, 6);
+            // contextMenuTabStrip
+            // 
+            this.contextMenuTabStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.closeToolStripMenuItem});
+            this.contextMenuTabStrip.Name = "contextMenuTabStrip";
+            this.contextMenuTabStrip.Size = new System.Drawing.Size(153, 48);
+            // 
+            // closeToolStripMenuItem
+            // 
+            this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
+            this.closeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.closeToolStripMenuItem.Text = "&Close";
+            this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
             // 
             // MainWindow
             // 
@@ -366,6 +384,7 @@
             this.splitContainer2.ResumeLayout(false);
             this.statusStrip1.ResumeLayout(false);
             this.statusStrip1.PerformLayout();
+            this.contextMenuTabStrip.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -404,6 +423,8 @@
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
         private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
+        private System.Windows.Forms.ContextMenuStrip contextMenuTabStrip;
+        private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
 
     }
 }

Modified: trunk/tools/reactosdbg/RosDBG/MainWindow.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/MainWindow.cs?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/MainWindow.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/MainWindow.cs [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -18,6 +18,7 @@
 
     public partial class MainWindow : Form, IShell
     {
+        Point mMousePosition;
         bool mRunning;
         DebugConnection.Mode mConnectionMode;
         ulong mCurrentEip;
@@ -50,18 +51,22 @@
         void TryToDisplaySource()
         {
             if (mCurrentFile == null || mCurrentFile == "unknown") return;
-            string finalFileName = Path.Combine(mSourceRoot, mCurrentFile);
+            OpenSourceFile(Path.Combine(mSourceRoot, mCurrentFile));
+        }
+
+        private void OpenSourceFile(string FileName)
+        {
             SourceView theSourceView;
-            if (File.Exists(finalFileName))
-            {
-                if (mSourceFiles.TryGetValue(finalFileName, out theSourceView))
+            if (File.Exists(FileName))
+            {
+                if (mSourceFiles.TryGetValue(FileName, out theSourceView))
                     Rehighlight(theSourceView);
                 else
                 {
-                    theSourceView = new SourceView();
-                    mSourceFiles[finalFileName] = theSourceView;
+                    theSourceView = new SourceView(Path.GetFileName(FileName));
+                    mSourceFiles[FileName] = theSourceView;
                     AddTab(theSourceView);
-                    theSourceView.SourceFile = finalFileName;
+                    theSourceView.SourceFile = FileName;
                     Rehighlight(theSourceView);
                 }
             }
@@ -268,10 +273,44 @@
             OpenFileDialog fileDialog = new OpenFileDialog();
             fileDialog.Filter = "Sourcefiles (*.c;*.cpp)|*.c;*.cpp";
             if (fileDialog.ShowDialog() == DialogResult.OK)
-            {
-                Console.WriteLine("open sourcefile"); 
-            }
-        }
+                OpenSourceFile(fileDialog.FileName);  
+        }
+
+        private void WorkTabs_MouseClick(object sender, MouseEventArgs e)
+        {
+            switch (e.Button) 
+            {
+                case MouseButtons.Right:
+                    contextMenuTabStrip.Show(WorkTabs.PointToScreen(e.Location));
+                    mMousePosition = e.Location;
+                    break;
+                case MouseButtons.Middle:
+                    SelectTabFromPosition(e.Location);
+                    closeCurrentTabToolStripMenuItem_Click(this, null);
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void SelectTabFromPosition(Point Position)
+        {
+            for (int i = 0; i < WorkTabs.TabCount; i++)
+            {
+                if (WorkTabs.GetTabRect(i).Contains(Position))
+                {
+                    if (WorkTabs.SelectedIndex != i)
+                        WorkTabs.SelectTab(i);
+                    break;
+                }
+            }
+        }
+
+        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            SelectTabFromPosition(mMousePosition);
+            closeCurrentTabToolStripMenuItem_Click(this, null);
+    }
    
     }
 

Modified: trunk/tools/reactosdbg/RosDBG/MainWindow.resx
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/MainWindow.resx?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/MainWindow.resx [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/MainWindow.resx [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -123,4 +123,7 @@
   <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>132, 17</value>
   </metadata>
+  <metadata name="contextMenuTabStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>248, 17</value>
+  </metadata>
 </root>

Modified: trunk/tools/reactosdbg/RosDBG/SourceView.Designer.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/SourceView.Designer.cs?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/SourceView.Designer.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/SourceView.Designer.cs [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -28,8 +28,36 @@
         /// </summary>
         private void InitializeComponent()
         {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SourceView));
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
             this.SourceCode = new System.Windows.Forms.RichTextBox();
+            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
+            this.btnCopy = new System.Windows.Forms.ToolStripButton();
+            this.btnBreakpoint = new System.Windows.Forms.ToolStripButton();
+            this.splitContainer1.Panel1.SuspendLayout();
+            this.splitContainer1.Panel2.SuspendLayout();
+            this.splitContainer1.SuspendLayout();
+            this.toolStrip1.SuspendLayout();
             this.SuspendLayout();
+            // 
+            // splitContainer1
+            // 
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
+            this.splitContainer1.Name = "splitContainer1";
+            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
+            // 
+            // splitContainer1.Panel1
+            // 
+            this.splitContainer1.Panel1.Controls.Add(this.toolStrip1);
+            // 
+            // splitContainer1.Panel2
+            // 
+            this.splitContainer1.Panel2.Controls.Add(this.SourceCode);
+            this.splitContainer1.Size = new System.Drawing.Size(497, 308);
+            this.splitContainer1.SplitterDistance = 25;
+            this.splitContainer1.TabIndex = 2;
             // 
             // SourceCode
             // 
@@ -37,23 +65,67 @@
             this.SourceCode.Location = new System.Drawing.Point(0, 0);
             this.SourceCode.Name = "SourceCode";
             this.SourceCode.ReadOnly = true;
-            this.SourceCode.Size = new System.Drawing.Size(497, 308);
-            this.SourceCode.TabIndex = 0;
+            this.SourceCode.Size = new System.Drawing.Size(497, 279);
+            this.SourceCode.TabIndex = 3;
             this.SourceCode.Text = "";
+            this.SourceCode.SelectionChanged += new System.EventHandler(this.SourceCode_SelectionChanged);
+            // 
+            // toolStrip1
+            // 
+            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.btnCopy,
+            this.btnBreakpoint});
+            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
+            this.toolStrip1.Name = "toolStrip1";
+            this.toolStrip1.Size = new System.Drawing.Size(497, 25);
+            this.toolStrip1.TabIndex = 0;
+            this.toolStrip1.Text = "toolStrip1";
+            // 
+            // btnCopy
+            // 
+            this.btnCopy.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+            this.btnCopy.Enabled = false;
+            this.btnCopy.Image = ((System.Drawing.Image)(resources.GetObject("btnCopy.Image")));
+            this.btnCopy.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnCopy.Name = "btnCopy";
+            this.btnCopy.Size = new System.Drawing.Size(23, 22);
+            this.btnCopy.ToolTipText = "Copy";
+            this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click);
+            // 
+            // btnBreakpoint
+            // 
+            this.btnBreakpoint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
+            this.btnBreakpoint.Enabled = false;
+            this.btnBreakpoint.Image = ((System.Drawing.Image)(resources.GetObject("btnBreakpoint.Image")));
+            this.btnBreakpoint.ImageTransparentColor = System.Drawing.Color.Magenta;
+            this.btnBreakpoint.Name = "btnBreakpoint";
+            this.btnBreakpoint.Size = new System.Drawing.Size(23, 22);
+            this.btnBreakpoint.ToolTipText = "Set Breakpoint";
             // 
             // SourceView
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.Controls.Add(this.SourceCode);
+            this.Controls.Add(this.splitContainer1);
             this.Name = "SourceView";
             this.Size = new System.Drawing.Size(497, 308);
+            this.splitContainer1.Panel1.ResumeLayout(false);
+            this.splitContainer1.Panel1.PerformLayout();
+            this.splitContainer1.Panel2.ResumeLayout(false);
+            this.splitContainer1.ResumeLayout(false);
+            this.toolStrip1.ResumeLayout(false);
+            this.toolStrip1.PerformLayout();
             this.ResumeLayout(false);
 
         }
 
         #endregion
 
+        private System.Windows.Forms.SplitContainer splitContainer1;
+        private System.Windows.Forms.ToolStrip toolStrip1;
         private System.Windows.Forms.RichTextBox SourceCode;
+        private System.Windows.Forms.ToolStripButton btnCopy;
+        private System.Windows.Forms.ToolStripButton btnBreakpoint;
+
     }
 }

Modified: trunk/tools/reactosdbg/RosDBG/SourceView.cs
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/SourceView.cs?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/SourceView.cs [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/SourceView.cs [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -59,6 +59,12 @@
             InitializeComponent();
         }
 
+        public SourceView(string FileName)
+        {
+            InitializeComponent();
+            this.Tag = FileName;
+        }
+
         public void UpdateSourceCode()
         {
             SourceCode.Clear();
@@ -74,5 +80,15 @@
                 SourceCode.Text = "Could not load " + mSourceFile + ": " + ex.Message + "\n";
             }
         }
+
+        private void SourceCode_SelectionChanged(object sender, EventArgs e)
+        {
+            btnCopy.Enabled = (SourceCode.SelectionLength > 0);
+         }
+
+        private void btnCopy_Click(object sender, EventArgs e)
+        {
+            Clipboard.SetText(SourceCode.SelectedText);   
+        }
     }
 }

Modified: trunk/tools/reactosdbg/RosDBG/SourceView.resx
URL: http://svn.reactos.org/svn/reactos/trunk/tools/reactosdbg/RosDBG/SourceView.resx?rev=35237&r1=35236&r2=35237&view=diff
==============================================================================
--- trunk/tools/reactosdbg/RosDBG/SourceView.resx [iso-8859-1] (original)
+++ trunk/tools/reactosdbg/RosDBG/SourceView.resx [iso-8859-1] Sat Aug  9 10:36:24 2008
@@ -117,4 +117,40 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="btnCopy.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAehJREFUOE+t099L
+        U3EYx3H/lFKGZDdB7K6biDKlwCDxooJAk652oVddRYZBJjMWOJ0La5ayzc70RKSLlKlraTJzrl+TlkFu
+        MJUdnc7pZu92viPXFm1BPfC5+z6v7/N8D6ek5F9LnviIGmncL2Id8dInv+ZOt1z1V7banF+WYQ+NLY/R
+        VjccKYo4xvw5/am973T2v8Dp9nOhqaM4Yh2dE4AzANJb8AUV7lmeI00p2Cei2FxRHoxGMQytiVxqXz6W
+        M1Wf7NmfYGc3hbKRIBSJCSC/WgdW0F5xc7RxMouY7S5xrte9i35E4Ya0TPPDIP0vV38DmkwR5GmFw3XD
+        VNTKGcSY3lfdeyueZCUaZym0zvvgKuZnYQG0SSkR3+I6l/VhKuqecuj8IOU1jxCAuu92Irl/s84c4Krx
+        HXdtSzkTKJtJFr9t417YwCTNojl7PwsosQQfvkSY+xTC4/vK+JvPtPRmPu/1gRg6Y5iL7QHO3ZwXMUkz
+        aKq7soC2qp78NBvmBZBMrxeJJlkIbjHmVXBMrtE96KGs0pAB/lQNrdMC+PXmnxN02V9RelJfGKi95iK+
+        s4d5yEuPYxbTkxlxs9pstE5x8MTtwkClzpl+bZtIeY0FzZkeyk53UnqqI93cxoHjtwoDRf+B/3XgB/HZ
+        2qt308hsAAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="btnBreakpoint.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
+        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAlNJREFUOE+10l9I
+        U1EcB3Bfe/MhCHzqoYeKIpD+WJi0kolUuAos2EgykjGa5eya0839uc47zf2rrc1tbW5NclKsQRIKKj4E
+        abFypW1amKvG1Mq5TMnyfrvXIJBs2kMHzsOPc36f3+F3fhkZ/2sNPuraccuhEfgcWkglF7f2BQKZ667V
+        rCGO+N0Ubtspem5cTbdayHF/K4Vgu0O6LsTb0kDPT5Bgq2PKCI+NxMKEZjkODfYcWBNxmZVz9KSBSaB+
+        ARY12Nhra4BNJ4PHri9KizhNdUyCHl6rCpg0wmWSg2Ygt0WFr29JWHXSnrSAUS1erui6LgWdMMLWdAVL
+        DGhtJLAY06K+6lx0BeA2K+Uuswrsfhj0XKOIEiZRD7uhAovvmnBTI8Ti+0Y011zA/EQ9JKXHR34Dfp1u
+        g9emQfI1yRyS6HApIRPy8CPehO72y0hF5ei/K8aXNwq03yhDKlILEZ8bXvECn51SS/iHMD2ixOyYDFYl
+        DwsxCjNjaiRHZZiJSPE5QiAZlSIeEuH8idwnf/Sgzd5ILCPhSkw9K8fMKyVSo2rMRhT4OFyLxNBVJEKX
+        EO06DcHRff2rNtFhkt9hkQ8DQsQHyzHFJH0arsH0i2rEHpfh+b0C9Dnz6DOFu3tXBQIBQ2ZVCZdkkaEH
+        pxAK8OiXnSfp8P1jeOo/jAFfLrTi3G+Ss1zrX7+xrVmxkWmigkU6dPl0dwuH7nflodOcs1Rdmv298OB2
+        EKX5WWnnQCHibqkrL64UFO0P5uzMWtizbRM4ezeP8AuynRXFnF1rjvK/XPgJ7YdwWhzybo4AAAAASUVO
+        RK5CYII=
+</value>
+  </data>
 </root>



More information about the Ros-diffs mailing list