Browse Source

Python forms designer now supports AutoScrollMinSize, AutoScrollMargin and MinimumSize properties.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3851 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
c016cdb91a
  1. 2
      src/AddIns/BackendBindings/Python/PythonBinding.sln
  2. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
  3. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
  4. 30
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs
  5. 63
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs
  6. 42
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
  7. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

2
src/AddIns/BackendBindings/Python/PythonBinding.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.0.0.3710
# SharpDevelop 3.0.0.3800
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}"

1
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj

@ -96,6 +96,7 @@ @@ -96,6 +96,7 @@
<Compile Include="Src\PythonControlImeModeProperty.cs" />
<Compile Include="Src\PythonControlProperty.cs" />
<Compile Include="Src\PythonControlRightToLeftProperty.cs" />
<Compile Include="Src\PythonControlSizeProperty.cs" />
<Compile Include="Src\PythonControlTextProperty.cs" />
<Compile Include="Src\PythonDesignerGenerator.cs" />
<Compile Include="Src\PythonDesignerLoader.cs" />

17
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs

@ -32,6 +32,9 @@ namespace ICSharpCode.PythonBinding @@ -32,6 +32,9 @@ namespace ICSharpCode.PythonBinding
defaultPropertyValues.Add("ImeMode", new PythonControlImeModeProperty());
defaultPropertyValues.Add("RightToLeft", new PythonControlRightToLeftProperty());
defaultPropertyValues.Add("Cursor", new PythonControlCursorProperty());
defaultPropertyValues.Add("MinimumSize", new PythonControlSizeProperty(0, 0));
defaultPropertyValues.Add("AutoScrollMinSize", new PythonControlSizeProperty(0, 0));
defaultPropertyValues.Add("AutoScrollMargin", new PythonControlSizeProperty(0, 0));
}
/// <summary>
@ -97,24 +100,10 @@ namespace ICSharpCode.PythonBinding @@ -97,24 +100,10 @@ namespace ICSharpCode.PythonBinding
} else if (propertyInfo.Name == "Icon") {
return true;
} else if (propertyInfo.Name == "Location") {
// 0, 0
return true;
} else if (propertyInfo.Name == "Margin") {
// Padding.DefaultMargin.
return true;
} else if (propertyInfo.Name == "MinimumSize") {
// 0, 0
return true;
} else if (propertyInfo.Name == "TransparencyKey") {
return true;
} else if (propertyInfo.Name == "AutoScrollMargin") {
return true;
} else if (propertyInfo.Name == "AutoScrollMinSize") {
return true;
} else if (propertyInfo.Name == "HorizontalScroll") {
return true;
} else if (propertyInfo.Name == "VerticalScroll") {
return true;
} else if (propertyInfo.Name == "Font") {
// Default is Control.DefaultFont
return true;

30
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
namespace ICSharpCode.PythonBinding
{
public class PythonControlSizeProperty : PythonControlProperty
{
Size defaultSize;
public PythonControlSizeProperty(int width, int height)
{
defaultSize = new Size(width, height);
}
public override bool IsDefaultValue(object propertyValue)
{
if (propertyValue is Size) {
return (Size)propertyValue == defaultSize;
}
return false;
}
}
}

63
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
/// <summary>
/// Tests that a form's MinimumSize, AutoScrollMinSize and AutoScrollMargin properties are generated
/// in the InitializeComponent method.
/// </summary>
[TestFixture]
public class GenerateMinSizeFormTestFixture
{
string generatedPythonCode;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
form.ClientSize = new Size(284, 264);
form.MinimumSize = new Size(100, 200);
form.AutoScrollMinSize = new Size(10, 20);
form.AutoScrollMargin = new Size(11, 22);
form.AutoScroll = false;
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.MinimumSize = System.Drawing.Size(100, 200)\r\n" +
" self.AutoScrollMargin = System.Drawing.Size(11, 22)\r\n" +
" self.AutoScrollMinSize = System.Drawing.Size(10, 20)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode);
}
}
}

42
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs

@ -140,6 +140,48 @@ namespace PythonBinding.Tests.Designer @@ -140,6 +140,48 @@ namespace PythonBinding.Tests.Designer
{
form.Visible = false;
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("Visible", form));
}
[Test]
public void MinFormSizeDefaultIsEmpty()
{
form.MinimumSize = new Size(0, 0);
Assert.IsTrue(defaultPropertyValues.IsDefaultValue("MinimumSize", form));
}
[Test]
public void NonDefaultMinFormSize()
{
form.MinimumSize = new Size(100, 100);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("MinimumSize", form));
}
[Test]
public void AutoScrollSizeDefaultIsEmpty()
{
form.AutoScrollMinSize = new Size(0, 0);
Assert.IsTrue(defaultPropertyValues.IsDefaultValue("AutoScrollMinSize", form));
}
[Test]
public void NonDefaultAutoScrollMinSize()
{
form.AutoScrollMinSize = new Size(100, 100);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("AutoScrollMinSize", form));
}
[Test]
public void AutoScrollMarginDefaultIsEmpty()
{
form.AutoScrollMargin = new Size(0, 0);
Assert.IsTrue(defaultPropertyValues.IsDefaultValue("AutoScrollMargin", form));
}
[Test]
public void NonDefaultAutoScrollMargin()
{
form.AutoScrollMargin = new Size(100, 100);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("AutoScrollMargin", form));
}
}
}

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -154,6 +154,7 @@ @@ -154,6 +154,7 @@
<Compile Include="Designer\GenerateCursorFormTestFixture.cs" />
<Compile Include="Designer\GenerateDoubleBufferedFormTestFixture.cs" />
<Compile Include="Designer\GenerateImeModeFormTestFixture.cs" />
<Compile Include="Designer\GenerateMinSizeFormTestFixture.cs" />
<Compile Include="Designer\GenerateRightToLeftFormTestFixture.cs" />
<Compile Include="Designer\GenerateSimpleFormTestFixture.cs" />
<Compile Include="Designer\GeneratorMergeFindsInitializeComponentsTestFixture.cs" />

Loading…
Cancel
Save