Tabbed Container is a control that has tabs that can have text and / or images. It has an automatic scrool, that is, by clicking on a specific tab, the controler simulates the drag to the chosen tab.
Source Code
importtotalcross.io.IOException;importtotalcross.sample.util.Colors;importtotalcross.sys.Settings;importtotalcross.ui.Container;importtotalcross.ui.Label;importtotalcross.ui.ScrollContainer;importtotalcross.ui.TabbedContainer;importtotalcross.ui.dialog.MessageBox;importtotalcross.ui.gfx.Color;importtotalcross.ui.image.Image;importtotalcross.ui.image.ImageException;publicclassTabbedContainerSampleextendsScrollContainer {privatefinalint gap = (int)(Settings.screenDensity*30); @OverridepublicvoidinitUI() {try {setBackForeColors(Colors.BACKGROUND,Colors.ON_BACKGROUND);CreateImageAndTextTabbedContainer();CreateTextOnlyTabbedContainer();CreateBulletsTabbedContainer(); } catch (Exception ee) {MessageBox.showException(ee,true); } }privatevoidCreateImageAndTextTabbedContainer() throwsImageException,IOException {String[] caps = { "Social 1","Social 2","Social 3" };Image[] icons = { newImage("images/fb_icon_40.png"),newImage("images/gmail_icon_40.png"),newImage("images/insta_icon_40.png") };Label sampleTitle =newLabel("This is a icon and text Tabbed Container", CENTER);sampleTitle.autoSplit=true;add(sampleTitle, LEFT + gap, TOP + gap, FILL - gap, PREFERRED);Container spacing =newContainer();add(spacing, LEFT + gap*2, AFTER + gap/2, FILL - gap*2, (int) (Settings.screenHeight*0.3));finalTabbedContainer tc =newTabbedContainer(caps);tc.setBackColor(Color.DARK);tc.getContainer(0).setBackColor(Colors.P_300);tc.getContainer(1).setBackColor(Colors.P_400);tc.getContainer(2).setBackColor(Colors.P_500);tc.setIcons(icons);tc.pressedColor=Colors.P_800;tc.activeTabBackColor=Colors.P_800;tc.allSameWidth=true;tc.extraTabHeight= fmH *2;spacing.add(tc, LEFT, TOP, FILL, PARENTSIZE);for(int i =0; i <3; i++)tc.getContainer(i).add(newLabel("Container "+ (i+1)), CENTER, CENTER); }privatevoidCreateTextOnlyTabbedContainer() throwsImageException,IOException {String[] caps =newString[3]; caps[0] ="Home"; caps[1] ="Photos"; caps[2] ="Profile";Label sampleTitle =newLabel("This is a text only Tabbed Container", CENTER);sampleTitle.autoSplit=true;add(sampleTitle, LEFT + gap, AFTER + gap*2, FILL - gap, PREFERRED);Container spacing =newContainer();add(spacing, LEFT + gap*2, AFTER + gap/2, FILL - gap*2, (int) (Settings.screenHeight*0.3));finalTabbedContainer tc =newTabbedContainer(caps);tc.setType(TabbedContainer.TABS_BOTTOM);tc.setBackColor(Color.DARK);tc.getContainer(0).setBackColor(Colors.P_300);tc.getContainer(1).setBackColor(Colors.P_400);tc.getContainer(2).setBackColor(Colors.P_500);tc.useOnTabTheContainerColor=true;tc.allSameWidth=true;tc.extraTabHeight= fmH /2;spacing.add(tc, LEFT, TOP, FILL, PARENTSIZE);for(int i =0; i <3; i++)tc.getContainer(i).add(newLabel("Container "+ (i+1)), CENTER, CENTER); }privatevoidCreateBulletsTabbedContainer() throwsImageException,IOException {Image[] images =newImage[3];Image empty =newImage("images/bullet_empty.png").getSmoothScaledInstance(fmH, fmH);Image filled =newImage("images/bullet_full.png").getSmoothScaledInstance(fmH, fmH);filled.applyColor2(Color.ORANGE);for (int i =images.length; --i >=0;) { images[i] = empty; }Label sampleTitle =newLabel("This is a image-only Tabbed Container", CENTER);sampleTitle.autoSplit=true;add(sampleTitle, LEFT + gap, AFTER + gap*2, FILL - gap, PREFERRED);Container spacing =newContainer();add(spacing, LEFT + gap*2, AFTER + gap/2, FILL - gap*2, (int) (Settings.screenHeight*0.3));finalTabbedContainer tc =newTabbedContainer(images);tc.setActiveIcon(filled);tc.setType(TabbedContainer.TABS_BOTTOM);tc.setBackColor(Color.DARK);tc.getContainer(0).setBackColor(Colors.P_300);tc.getContainer(1).setBackColor(Colors.P_400);tc.getContainer(2).setBackColor(Colors.P_500);tc.allSameWidth=true;tc.extraTabHeight= fmH /2;tc.setBorderStyle(Container.BORDER_NONE);tc.transparentBackground=true;spacing.add(tc, LEFT, TOP, FILL, PARENTSIZE);for(int i =0; i <3; i++)tc.getContainer(i).add(newLabel("Container "+ (i+1)), CENTER, CENTER); }}
Methods
Tipo
Nome
Descrição
Construct
TabbedContainer(String[] strCaptions)
Uses a string array as capations for the tabs.
Construct
TabbedContainer(Image[] imgCaptions, int transparentColor)
Uses an image array to represent the flaps and set a color.