[Mono-dev] Questions about Mono's TableLayout implementation
Steven Boswell II
ulatekh at yahoo.com
Sat Jul 7 17:33:19 UTC 2012
Recently I encountered a situation where TableLayoutPanel behaves differently under Mono and .NET -- one of my columns didn't contain a non-column-spanning control. Under Mono, that led to the column having zero width, and one of my controls ended up with an unusably small size. So I started digging around the relevant code, and ended up in mcs/class/Managed.Windows.Forms/System.Windows.Forms.Layout/TableLayout.cs . I have some questions about how it's implemented...hopefully someone has some answers, otherwise I'm just going to charge ahead and fix things the way I want. :-)
Note that when I say "column" below, I mean the equivalent situation with rows -- I just didn't want to keep typing "column/row". Also, the line numbers are relative to the latest version in git, as of this writing.
1) http://msdn.microsoft.com/en-us/library/ms171690.aspx says that, when the panel's AutoSize property is set to true, that Percent-style columns get treated like AutoSize-style columns with regard to the widest child control in the column. Mono doesn't do that. Line 284 would have to gain "|| (panel.AutoSize && cs.SizeType == SizeType.Percent)" inside the conditional, and the code around line 335 would have to gain logic that only added to the column width if the percentage-based calculation indicated that it needed to be wider. Does that sound right?
2) Line 344 takes any remaining undistributed width, and just stuffs it in the last column. That would seem to be broken, if the last column's style is SizeType.Absolute . Why is it done this way?
3) The code from lines 129-133 seem to be broken -- they extend dummy controls along the top edge of a column-spanning control, and along the left edge of a row-spanning control, but not in the rest of the control's extent, i.e. it should be filling in a rectangular region with dummy controls. Am I right?
Source-code comments would have been really helpful when inferring the intent of this code. ;-)
I've been pondering solutions for the problem I ran into, so that Mono's behavior matches .NET's. I think I can avoid any sort of backtracking/retrying solution, since I highly doubt .NET does anything that complex. Rather, I'm thinking of an extension to the current solution, one that simply proceeds from left to right. But in the block of code at lines 281-313, I would have N passes, where N is the highest column-span value of any contained control. The first pass would deal only with 1-column controls, the second pass only with 2-column controls, and so on In each column, it would look at controls that end in that column, and increase the width of that column, taking into account the width of the other columns spanned by the controls that end in that column, but not modifying the width of those previous columns. How does that sound?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list