Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layouting custom buttons

I am trying to create buttons shaped as in the following picture: Powerpoint arrow buttons

This works pretty well by doing the following:

class ArrowButton extends Composite {
    ArrowButton(Composite parent, int style) {
        [...]
        setRegion(customRegion);
    }
}

addStuff(Composite parent) {
    ArrowButton b = new ArrowButton(parent, SWT.NONE);
    b.setBounds(x, y, width, height);
}

However, I want to use a layout manager to layout these buttons. Ideally, the buttons are layouted on a standard size, after which they can still paint outside of this region.

Is this at all possible? How can I do this?

like image 948
parasietje Avatar asked Mar 18 '26 18:03

parasietje


1 Answers

Layout managers have two functions: calculating the size of the composite that they are applied to and setting the bounds of the composite's children. Given the relative simplicity of your requirements (line up buttons horizontally) I'd say that you're better off doing the layout yourself (rather than trying to hack an existing implementation). You can always put your code into a delegate behind the Layout interface, if that feels better.

like image 139
Martti Käärik Avatar answered Mar 21 '26 06:03

Martti Käärik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!