Until now you could not use padding values with a negative value. Anything under 0 was treated as being defaulted. Now negative values are actually applied and are surprisingly useful.

This change is in response to a question on the forum. A user wants to create a rounded button. The problem is that the rounding causes the size of the button is increase dramatically in size making it impossible to actually use.

The following picture shows three button instances.

Left most is a default button with an image as the content and a square border. In the middle is the same button but with the border rounding defined as 20 pixels. At the end is the same 20 pixel border button with with a content padding value of -4 for all edges.

Here is the property window showing how to set the content padding property.

The middle button is doing the correct thing by getting bigger as the rounding increases. It is ensuring that the entire contents are placed within the border edges and so as the rounding gets bigger it needs to move the content further inwards to avoid overlapping any part of the rounding.

In order to offset this insetting from the rounding you can use the content padding to reduce the padding around the content. As the default padding for the Office 2003 palette is around 3 pixels you can therefore set this to something less. But once the rounding gets large your stuck becaues you cannot set a negative padding value, anything less than 0 is treated as meaning a default value and so it just tries to inherit the value instead.

The code is now changed so that only the value of -1 for a padding edge is treated as meaning a defaulted value that causes inheritance. More negative numbers are just used and applied as can be seen with the right most button in the first picture.

The change always works when use with KryptonHeader.

Or any other control such as a KryptonHeaderGroup.

Leave a Reply