Matthias Benkmann wrote:
On 9/22/05, Carsten Driesner <[EMAIL PROTECTED]> wrote:

wd.WindowAttributes = WindowAttribute.SHOW|VclWindowPeerAttribute .DROPDOWN;



That did the trick. Thanks for all your help so far. Now there's just
one little cosmetic thing: How do we specify the size of the ComboBox
so that it scales with the system font. Currently we're supplying
absolute pixel values.

Hi Matthias,

the OOo toolbar implementation scales all item windows automatically. Unluckily there is no API which gives you a notification when the user has changed the UI system font. The best solution I am aware of is, try to determine which system font is used for the combo box. Use the font metric information to set a generic width which is appropriate for your needs.

How to retrieve the needed font information?

1. Query your created combo box for com::sun::star::beans::XPropertySet
2. Use getPropertyValue() with property name = "FontDescriptor".
3. Retrieve the com::sun::star::awt::FontDescriptor from the provided com::sun::star::uno::Any.

Now I see two possible ways to find your generic width:
1. Get the width from the font descriptor (see com::sun::star::awt::FontDescriptor) and use it to calculate your control width.
2. - Query your combo box for com::sun::star::awt::XDevice.
- Use XDevice::getFont( [in] FontDescriptor ) to retrieve a font object for your font descriptor.
   - Query your font object for com::sun::star::awt::XFont
- Use XFont::getStringWidth( [in] string ) to determine the width of your largest possible string. Use it to calculate the size of your combo box.

Regards,
Carsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to