HTML titleText = new HTML(title);
headerId = "h_" + DOM.createUniqueId();
titleText.getElement().setId(headerId);
titleText.setStyleName("default-window-title");
FontIcon closeIcon = new FontIcon("icon-remove", FontIcon.Size.SMALL);
closeIcon.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent clickEvent) {
callback.hide();
}
});
FontIcon maximizeIcon = new FontIcon("icon-resize-full", FontIcon.Size.SMALL);
maximizeIcon.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent clickEvent) {
int width = origWidth;
int height = origHeight;
if(origWidth==-1)
{
origWidth = getOffsetWidth();
origHeight = (int) ( origWidth / 1.618 ) +50;// TODO: this fails "getOffsetHeight()";
origLeft = getAbsoluteLeft();
origTop = getAbsoluteTop();
width = Window.getClientWidth() - 50;
height = Window.getClientHeight() - 50;
callback.hide();
callback.setPopupPosition(25, 25);
callback.setWidth(width+"px");
callback.setHeight(height+"px");
callback.show();
}
else
{
// reset to previous size & position
// see above ...
callback.hide();
callback.setWidth(width+"px");
callback.setHeight(height+"px");
callback.center();
// clear
origWidth = -1;
origHeight = -1;
origLeft = -1;
origTop = -1;
}
}
});
header.add(titleText);
header.add(maximizeIcon);
header.add(closeIcon);
initWidget(header);
titleText.getElement().getParentElement().setAttribute("width", "100%");
maximizeIcon.getElement().getParentElement().setAttribute("width", "16px");
maximizeIcon.getElement().getParentElement().setAttribute("style", "padding-right:10px");
closeIcon.getElement().getParentElement().setAttribute("width", "16px");
closeIcon.getElement().getParentElement().setAttribute("style", "padding-right:10px");
}