parasietje
parasietje

Reputation: 1539

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?

Upvotes: 3

Views: 120

Answers (1)

Martti Käärik
Martti Käärik

Reputation: 3621

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.

Upvotes: 1

Related Questions