1. #1
    Ext User haplo's Avatar
    Join Date
    Jul 2008
    Location
    Paderborn - Germany
    Posts
    11
    Vote Rating
    0
    haplo is on a distinguished road

      0  

    Default ImageBundleButton

    ImageBundleButton


    Hi everyone,

    i extended the GXT Button to support ImageBundels.

    Code:
    public class ImageBundleButton extends Button {
    
        private AbstractImagePrototype imagePrototype;
    
        /**
         * used for image width calculation  
         */
        private int additionalImageWidth = 0;
    
        public ImageBundleButton() {
    
        }
    
        public ImageBundleButton(AbstractImagePrototype imagePrototype) {
            this.imagePrototype = imagePrototype;
        }
    
    
        public ImageBundleButton(String text, AbstractImagePrototype imagePrototype) {
            super(text);
            this.imagePrototype = imagePrototype;
        }
    
        public void setImagePrototype(AbstractImagePrototype imagePrototype) {
            this.imagePrototype = imagePrototype;
        }
    
        /**
         * if margins are added to the icon style, use this method to correct the autowidth calculation in ie
         */
        public void setAdditionalImageWidth(int additionalImageWidth) {
            this.additionalImageWidth = additionalImageWidth;
        }
    
        protected void autoWidth() {
          if (rendered) {
            el().setWidth("auto");
            if (GXT.isIE) {
              if (buttonEl != null && buttonEl.getWidth() > 20) {
                buttonEl.clip();
                TextMetrics.get().bind(buttonEl.dom);
                int adj = getIconStyle() != null ? 8 : 0;
                adj += (imagePrototype!=null) ? imagePrototype.createImage().getWidth() + additionalImageWidth + 6: 0;
                int w = TextMetrics.get().getWidth(text) + buttonEl.getFrameWidth("lr") + adj;
                buttonEl.setWidth(w);
              }
            }
            if (getMinWidth() != Style.DEFAULT) {
              if (el().getWidth() < getMinWidth()) {
                el().setWidth(getMinWidth());
              }
            }
          }
        }
    
        protected void setElement(Element elem, Element parent, int index) {
            super.setElement(template.create((text != null && !text.equals("")) ? text : "&nbsp;", getType(), baseStyle, (imagePrototype !=null) ? imagePrototype.getHTML() : ""), parent, index);
        }
    
        protected void onRender(Element target, int index) {
            if(buttonTemplate == null){
                buttonTemplate = new Template(this.getTemplateString());
            }
            super.onRender(target, index);
        }
    
        private String getTemplateString(){
            StringBuffer sb = new StringBuffer();
            sb.append("<table border=0 cellpadding=0 cellspacing=0 class='{2}-wrap'><tbody><tr>");
            sb.append("<td class={2}-left><i>&#160;</i></td><td class='{2}-center'><em unselectable=on><button class={2}-text type={1}><span class={2}-image>{3}</span> {0}</button></em></td><td class={2}-right><i>&#160;</i></td>");
            sb.append("</tr></tbody></table>");
            return sb.toString();
        }
    }

  2. #2
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    365
    Vote Rating
    5
    DavidHoffer is on a distinguished road

      0  

    Question


    How could I do something similar for SplitButton?

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi