Skip to content

Instantly share code, notes, and snippets.

@branflake2267
Last active August 2, 2018 02:54
Show Gist options
  • Save branflake2267/18dd8030595f67c0c43ea192353aff3d to your computer and use it in GitHub Desktop.
Save branflake2267/18dd8030595f67c0c43ea192353aff3d to your computer and use it in GitHub Desktop.
GXT 4.0.x (4.0.2, 4.0.3+) Button or ButtonCell appearance override. Extending an Appearance. (ButtonCellAppearance)
@def BACKGROUND_COLOR rgba(102,51,153, 0.8);
@def GRADIENT rgba(102,51,153, 0.8);
/*
Override super css classes here
*/
.button {
background: BACKGROUND_COLOR;
/* @alternate */ background: -webkit-linear-gradient(top, GRADIENT);
/* @alternate */ background: -ms-linear-gradient(top, GRADIENT);
/* @alternate */ background: linear-gradient(to bottom, GRADIENT);
}
import com.google.gwt.core.client.GWT;
import com.sencha.gxt.theme.triton.client.base.button.Css3ButtonCellAppearance;
/**
* Note: Import the Css3ButtonCellAppearance from the Theme you want to override In this case its:
* Example: import com.sencha.gxt.theme.triton.client.base.button.Css3ButtonCellAppearance;
*/
public class PurpleButtonCellAppearance<M> extends Css3ButtonCellAppearance<M> {
/**
* Extend the super class style
*/
public interface PurpleCss3ButtonStyle extends Css3ButtonStyle {
}
/**
* Note: replace path to the extencded theme GSS if need be.
* If it's Triton, no need to change.
* Triton path: com/sencha/gxt/theme/triton/client/base/button/
*/
public interface PurpleCss3ButtonResources extends Css3ButtonResources {
@Override
@Source({ "com/sencha/gxt/theme/triton/client/base/button/Css3ButtonCell.gss",
"com/sencha/gxt/theme/triton/client/base/button/Css3ButtonCellToolBar.gss",
"PurpleButton.gss"})
PurpleCss3ButtonStyle style();
}
public PurpleButtonCellAppearance() {
super(GWT.<Css3ButtonCellAppearance.Css3ButtonResources>create(PurpleCss3ButtonResources.class));
}
}
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.sencha.gxt.cell.core.client.form.ToggleButtonCell;
import com.sencha.gxt.widget.core.client.button.ToggleButton;
public class PurpleButtonExample implements EntryPoint {
@Override
public void onModuleLoad() {
/**
* Provide a custom appearance which colors the button purple
*/
PurpleButtonCellAppearance<Boolean> purpleAppearance = new PurpleButtonCellAppearance<Boolean>();
/**
* Provide custom appearance to the Cell
*/
ToggleButtonCell buttonCell = new ToggleButtonCell(purpleAppearance);
buttonCell.setText("Toggle Button");
ToggleButton button = new ToggleButton(buttonCell);
RootPanel.get().add(button);
}
}
@branflake2267
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment