MContainer

Description

MContainer is a container for other Monoi components. It aims to be a parent for these components and is usually a child of another container, except for the first MContainer in the hierarchy that can be embedded in a raw SWT composite. MContainer's main role is to manage the component layout, based on a grid mechanism that can be in row or in column mode (default). To add components to a container, a reference to this container must be given to the component constructor. Every component added to the container will then be positioned in a new fictitious area in the grid.

Note that MContainer can be used in conjunction with Eclipse Forms plugin which provides an alternate look and feel.

A simple example

 1        //Creates the first level's container with its composite's parent
 2        MContainer container = new MContainer(parent);
 3        container.setHAlign(Alignment.FILL);
 4        container.setBorder(true);
 5
 6        //Create a new container as a child of the main container
 7        MContainer container1 = new MContainer(container);
 8        container1.setBorder(true);
 9
10        //Starts with a new column
11        container.newColumn();
12
13        //Create another new container as a child of the main container
14        MContainer container2 = new MContainer(container);
15        container2.setBorder(true);

Layout example

 1        //A MContainer
 2        MContainer container = new MContainer(parent, MContainer.COLUMN_MODE);
 3
 4        //Three MLabels in column
 5        new MLabel(container, "========== 1A ==========",true);
 6        new MLabel(container, "========== 1B ==========",true);
 7        new MLabel(container, "========== 1C ==========",true);
 8
 9        // A new column
10        container.newColumn();
11        new MLabel(container, "========== 2A ==========",true);
12
13        // A new column
14        container.newColumn();
15
16        // A MLabel with span who takes two cells
17        MLabel label = new MLabel(container, "========== 3A ==========",true);
18        label.setVSpan(2);
19        new MLabel(container, "========== 3B ==========",true);

API

  • Constructors
MContainer(Composite parent) Constructs a new instance of this class given its composite parent
MContainer(Composite parent, FormToolkit toolkit) Constructs a new instance of this class given its composite parent (form's body) and form's toolkit
MContainer(Composite parent, FormToolkit toolkit, int mode) Constructs a new instance of this class given its composite parent (form's body), form's toolkit and mode(ColumnMode or RowMode, ColumnMode by default)
MContainer(Composite parent, int mode) Constructs a new instance of this class given its composite parent and mode(ColumnMode or RowMode, ColumnMode by default)
MContainer(Form form, FormToolkit toolkit) Constructs a new instance of this class given its form parent and form's toolkit
MContainer(Form form, FormToolkit toolkit, int mode) Constructs a new instance of this class given its form parent , form's toolkit and mode(ColumnMode or RowMode, ColumnMode by default)
MContainer(MonoiContainer parent) Constructs a new instance of this class given its MonoiContainer parent
MContainer(MonoiContainer parent, int mode) Constructs a new instance of this class given its form parent and mode(ColumnMode or RowMode, ColumnMode by default)
  • Methods
Collection<MonoiComponent> getComponents() Gets all the MonoiComponents in the current MContainer
Integer getLabelWidthForFields() Gets the label's width
int getMode() Gets the mode(Column or Row)
Composite getParent() Gets the parent
boolean isBorder() True if MContainer has a border
boolean isFirstLevel() True if MContainer is the firstLevel
void newColumn() Create a new column and starts with it
void newRow() Create a new row and starts with it
void setBorder(boolean border) Sets the Mcontainer's border
void setFirstLevel(boolean firstLevel) Sets the first level for MContainer
void setLabelWidthForFields(Integer labelWidthForFields) Sets a label's width
String toString() Gets the Component's value of String
  • See also superclasses :
    • MonoiContainer, MonoiComponent and MonoiDataComponent

MContainer1.jpg (13 kB) Frédéric ESNAULT, 02/24/2012 03:43 pm

MContainer2.jpg (15.6 kB) Frédéric ESNAULT, 02/24/2012 03:43 pm