changeset 146:5d9d4c75305f

Fixes #250: New panels don't work perfectly in Linux through Mono * Manually size the panel based on the contents
author IBBoard <dev@ibboard.co.uk>
date Sun, 18 Apr 2010 14:25:32 +0000
parents 51463bc1fb21
children 1bcd7ea857c4
files FrmMain.cs
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/FrmMain.cs	Sun Apr 18 14:22:10 2010 +0000
     1.2 +++ b/FrmMain.cs	Sun Apr 18 14:25:32 2010 +0000
     1.3 @@ -977,7 +977,6 @@
     1.4  			int catCount = cats.Length;
     1.5  			Category cat;
     1.6  			IBBToolStripButton[] categoryButtons = new IBBToolStripButton[catCount];
     1.7 -			int buttonWidths = 0;
     1.8  
     1.9  			for (int i = 0; i < catCount; i++)
    1.10  			{
    1.11 @@ -989,13 +988,25 @@
    1.12  				button.Enabled = false;
    1.13  				button.Click += new EventHandler(CreateUnitForCategoryButtonClick);
    1.14  				categoryButtons[i] = button;
    1.15 +			}
    1.16 +
    1.17 +			this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(AddCatToolStripButtons), new object[] { categoryButtons });
    1.18 +		}
    1.19 +
    1.20 +		private void AddCatToolStripButtons(IBBToolStripButton[] buttons)
    1.21 +		{
    1.22 +			log.Debug("Toolstrip width: " + catToolStrip.Width);
    1.23 +			catToolStrip.Items.AddRange(buttons);
    1.24 +			catToolStrip.Refresh();
    1.25 +			int buttonWidths = 0;
    1.26 +
    1.27 +			foreach (IBBToolStripButton button in buttons)
    1.28 +			{
    1.29  				buttonWidths += button.Width;
    1.30  			}
    1.31 -
    1.32 +			catToolStrip.Width = buttonWidths;
    1.33 +			log.Debug("Button widths: " + buttonWidths);
    1.34  			log.Debug("Toolstrip width: " + catToolStrip.Width);
    1.35 -			log.Debug("Button widths: " + buttonWidths);
    1.36 -
    1.37 -			this.Invoke(new ArrayMethodInvoker<IBBToolStripButton>(catToolStrip.Items.AddRange), new object[]{ categoryButtons });
    1.38  		}
    1.39  
    1.40  		private void CreateUnitForCategoryButtonClick(object sender, EventArgs e)