/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.types.Alignment; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.IconButton; import com.smartgwt.client.widgets.menu.IconMenuButton; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.toolbar.RibbonBar; import com.smartgwt.client.widgets.toolbar.RibbonGroup; import com.google.gwt.core.client.EntryPoint; public class RibbonBarSample implements EntryPoint { public void onModuleLoad() { RibbonBar ribbonBar = new RibbonBar(); ribbonBar.setLeft(0); ribbonBar.setTop(75); Menu menu = new Menu(); menu.addItem(new MenuItem("Document", "icons/16/document_plain_new.png", "Ctrl+D")); menu.addItem(new MenuItem("Picture", "icons/16/folder_out.png", "Ctrl+P")); menu.addItem(new MenuItem("Email", "icons/16/disk_blue.png", "Ctrl+E")); RibbonGroup fileGroup = new RibbonGroup(); fileGroup.setTitle("File"); fileGroup.setTitleAlign(Alignment.LEFT); fileGroup.setNumRows(3); fileGroup.addControl(getIconMenuButton("New", "piece_blue", menu, true)); fileGroup.addControl(getIconButton("Open", "star_yellow", true)); fileGroup.addControl(getIconButton("Save", "pawn_red", true)); fileGroup.addControl(getIconMenuButton("Save As", "cube_green", menu, true)); RibbonGroup editGroup = new RibbonGroup(); editGroup.setTitle("Edit"); editGroup.setNumRows(3); editGroup.addControl(getIconButton("Edit", "piece_blue", false)); editGroup.addControl(getIconButton("Copy", "pawn_green", false)); editGroup.addControl(getIconButton("Paste", "cube_yellow", false)); editGroup.addControl(getIconMenuButton("Undo", null, menu, false)); editGroup.addControl(getIconMenuButton("Redo", null, menu, false)); RibbonGroup insertGroup = new RibbonGroup(); insertGroup.setTitle("Insert"); insertGroup.setNumRows(3); insertGroup.addControl(getIconMenuButton("Picture", null, menu, true)); insertGroup.addControl(getIconButton("Link", "pawn_white", false)); insertGroup.addControl(getIconButton("Document", "star_yellow", false)); insertGroup.addControl(getIconButton("Video", "piece_red", false)); ribbonBar.addMember(fileGroup); ribbonBar.addMember(editGroup); ribbonBar.addMember(insertGroup); ribbonBar.draw(); } private IconButton getIconButton(String title, String iconName, boolean vertical) { IconButton button = new IconButton(title); button.setTitle(title); if (iconName == null) iconName = "cube_blue"; button.setIcon("pieces/16/" + iconName + ".png"); button.setLargeIcon("pieces/48/" + iconName + ".png"); if (vertical == true) button.setOrientation("vertical"); return button; } private IconMenuButton getIconMenuButton(String title, String iconName, Menu menu, boolean vertical) { IconMenuButton button = new IconMenuButton(); button.setTitle(title); if (iconName == null) iconName = "cube_blue"; button.setIcon("pieces/16/" + iconName + ".png"); button.setLargeIcon("pieces/48/" + iconName + ".png"); if (vertical == true) button.setOrientation("vertical"); if (menu != null) button.setMenu(menu); button.setShowMenuIcon(true); return button; } public boolean isTopIntro() { return true; } }