Skip to content

Commit

Permalink
Cleaned up some styles
Browse files Browse the repository at this point in the history
  • Loading branch information
bradseefeld committed Aug 2, 2011
1 parent e3beecd commit c4dc45a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/bradley/gwt/demo/user/client/TestApp.java
Expand Up @@ -10,6 +10,8 @@
import com.bradley.gwt.user.client.celltable.CellTableResources;
import com.bradley.gwt.user.client.celltable.PagingCellTablePanel;
import com.bradley.gwt.user.client.celltable.TextColumn;
import com.bradley.gwt.user.client.resource.AddButtonResources;
import com.bradley.gwt.user.client.resource.ButtonResources;
import com.bradley.gwt.user.client.ui.Button;
import com.bradley.gwt.user.client.ui.CancelButton;
import com.bradley.gwt.user.client.ui.ComboBox;
Expand Down Expand Up @@ -57,7 +59,7 @@ protected void demoToolBar() {
ToolBar toolbar = new ToolBar();
toolbar.add(new Button("test"));

MenuButton btn = new MenuButton("menu button");
MenuButton btn = new MenuButton("menu button", (ButtonResources) GWT.create(AddButtonResources.class));
btn.add(new Label("line 1"));
btn.add(new Label("line 2"));
toolbar.add(btn);
Expand Down
Expand Up @@ -5,7 +5,7 @@

public interface MenuButtonClientBundle extends ButtonResources {

public interface MenuButtonStyle extends Style {
public interface MenuButtonStyle extends Style {
String menuButton();

String menu();
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/com/bradley/gwt/user/client/ui/MenuButton.java
@@ -1,5 +1,6 @@
package com.bradley.gwt.user.client.ui;

import com.bradley.gwt.user.client.resource.ButtonResources;
import com.bradley.gwt.user.client.resource.MenuButtonClientBundle;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
Expand All @@ -8,6 +9,7 @@
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
Expand All @@ -18,23 +20,24 @@ public class MenuButton extends FlowPanel {
protected Panel menu;

protected Button button;

protected MenuButtonClientBundle resources;

private static final MenuButtonClientBundle _resources = GWT.create(MenuButtonClientBundle.class);

private static final MenuButtonClientBundle resources = GWT.create(MenuButtonClientBundle.class);

public MenuButton(String label) {
this(label, _resources);
this(label, (ButtonResources) resources);
}

public MenuButton(String label, MenuButtonClientBundle resources) {
this.resources = resources;

public MenuButton(String label, ButtonResources resources) {
MenuButton.resources.style().ensureInjected();
resources.style().ensureInjected();
addStyleName(resources.style().menuButton());

initButton(label);
addStyleName(MenuButton.resources.style().menuButton());

initButton(label, resources);
initMenu();

// Add a span for the down arrow.
button.getElement().appendChild(DOM.createSpan());
}

public void add(final Label item) {
Expand All @@ -56,7 +59,6 @@ public void onClick(ClickEvent event) {
public void onMouseOver(MouseOverEvent event) {
item.addStyleName(resources.style().activeItem());
}

});

item.addMouseOutHandler(new MouseOutHandler() {
Expand All @@ -65,7 +67,6 @@ public void onMouseOver(MouseOverEvent event) {
public void onMouseOut(MouseOutEvent event) {
item.removeStyleName(resources.style().activeItem());
}

});
}

Expand All @@ -81,7 +82,7 @@ public void onButtonClick() {
}
}

private void initButton(String label) {
private void initButton(String label, ButtonResources resources) {
button = new Button(label, resources) {

@Override
Expand Down
Expand Up @@ -4,13 +4,14 @@
font-size: 11px !important;
}
@external html-face, gwt-Label;
@sprite .button .html-face {
.menuButton .html-face {
display: inline-block;
}
@sprite .menuButton span {
gwt-image: "downArrow";
background-repeat: no-repeat;
background-position: right center;
padding-right: 15px;
width: auto;
height: auto;
display: inline-block;
}
@sprite .menu {
gwt-image: "menuBackground";
Expand All @@ -21,6 +22,16 @@
background-color: #F0F0F0;
border: 1px solid #718BB7;
padding: 2px;
z-index: 1500; /* appear above everything else */
}
@sprite .active {
gwt-image: "menuBackgroundActive";
width: auto;
height: auto;
background-repeat: repeat-x;
background-color: #EBF3FD;
background-position: top;
color:#233D6D;
}
.menu .gwt-Label {
font-size: 11px;
Expand All @@ -29,6 +40,7 @@
padding-left: 30px;
padding-right: 5px;
cursor: pointer;
border: 1px solid #F0F0F0;
}
@sprite .menu .gwt-Label.activeItem {
gwt-image: "menuItemBackgroundActive";
Expand All @@ -39,13 +51,6 @@
height: auto;
border:1px solid #AACCF6;
}

@sprite .active {
gwt-image: "menuBackgroundActive";
width: auto;
height: auto;
background-repeat: repeat-x;
}
@external .gwt-PushButton;
.gwt-PushButton {
display: inline-block;
Expand Down

0 comments on commit c4dc45a

Please sign in to comment.