List of usage examples for com.google.gwt.dom.client Element getOffsetLeft
@Override
public int getOffsetLeft()
From source file:com.ephesoft.gxt.core.client.ui.widget.DetailGrid.java
License:Open Source License
private void setEditing() { editingGrid = new GridInlineEditing<DetailsDTO>(this) { @SuppressWarnings("rawtypes") @Override//from w w w . jav a2s. c o m protected <N, O> void doStartEditing(final com.sencha.gxt.widget.core.client.grid.Grid.GridCell cell) { super.doStartEditing(cell); final ColumnModel<DetailsDTO> columnModel = cm; setEditorDimension(cell, columnModel); } private void setEditorDimension(final com.sencha.gxt.widget.core.client.grid.Grid.GridCell cell, final ColumnModel<DetailsDTO> columnModel) { if (null != columnModel) { final ColumnConfig<DetailsDTO, ?> columnConfig = columnModel.getColumn(cell.getCol()); if (null != columnConfig) { final IsField editor = getEditor(columnConfig); final Element cellElement = getView().getCell(cell.getRow(), cell.getCol()); if (editor instanceof Component) { final Component field = (Component) editor; final int client_y = cellElement.getOffsetTop(); final int client_x = cellElement.getOffsetLeft(); final int margin = Math.abs(cellElement.getAbsoluteLeft() - client_x) / 2; final int width = cellElement.getAbsoluteRight() - client_x - margin; field.setWidth(250); field.setPosition(client_x, client_y); } } } } }; }
From source file:com.ephesoft.gxt.core.client.ui.widget.Grid.java
License:Open Source License
private GridInlineEditing<T> getGridEditing() { return new GridInlineEditing<T>(this) { @Override/*from w w w .ja va 2s. c o m*/ protected <N, O> void doStartEditing(com.sencha.gxt.widget.core.client.grid.Grid.GridCell cell) { super.doStartEditing(cell); ColumnModel<T> columnModel = getColumnModel(); if (null != columnModel) { ColumnConfig<T, ?> columnConfig = columnModel.getColumn(cell.getCol()); if (null != columnConfig) { IsField<T> editor = getEditor(columnConfig); Element cellElement = Grid.this.getView().getCell(cell.getRow(), cell.getCol()); if (editor instanceof Field) { Field<T> field = (Field<T>) editor; Widget editorWidget = editor.asWidget(); int client_y = cellElement.getOffsetTop(); int client_x = cellElement.getOffsetLeft(); int width = cellElement.getAbsoluteRight() - cellElement.getAbsoluteLeft(); int height = cellElement.getAbsoluteBottom() - cellElement.getAbsoluteTop() + 3; field.setPixelSize(width, height); editorWidget.getElement().getStyle().setTop(client_y, Unit.PX); editorWidget.getElement().getStyle().setLeft(client_x, Unit.PX); } } } } }; }
From source file:com.ephesoft.gxt.rv.client.widget.DataTableGrid.java
License:Open Source License
private void setEditable() { editingGrid = new GridInlineEditing<Row>(this) { @Override/*from www .ja v a 2 s.co m*/ protected <N, O> void doStartEditing(final com.sencha.gxt.widget.core.client.grid.Grid.GridCell cell) { super.doStartEditing(cell); final ColumnModel<Row> columnModel = getColumnModel(); if (null != columnModel) { final ColumnConfig<Row, ?> columnConfig = columnModel.getColumn(cell.getCol()); if (null != columnConfig) { final IsField editor = getEditor(columnConfig); final Element cellElement = DataTableGrid.this.getView().getCell(cell.getRow(), cell.getCol()); if (editor instanceof Field) { final Field field = (Field) editor; final int client_y = cellElement.getOffsetTop(); final int client_x = cellElement.getOffsetLeft(); final int margin = Math.abs(cellElement.getAbsoluteLeft() - client_x) / 2; final int width = cellElement.getAbsoluteRight() - client_x - margin; field.setWidth(width); field.setPosition(client_x, client_y); if (field instanceof ColumnSuggestionBox) { ColumnSuggestionBox columnSuggestionBox = (ColumnSuggestionBox) field; addAlternateValue(columnSuggestionBox, cell); } } } } } }; this.setEditors(); }
From source file:com.extjs.gxt.ui.client.widget.grid.GridView.java
License:sencha.com license
/** * Ensured the current row and column is visible. * //from ww w . j a v a 2 s . co m * @param row the row index * @param col the column index * @param hscroll true to scroll horizontally if needed * @return the calculated point */ public Point ensureVisible(int row, int col, boolean hscroll) { if (grid == null || !grid.isViewReady() || row < 0 || row > ds.getCount()) { return null; } if (col == -1) { col = 0; } Element rowEl = getRow(row); Element cellEl = null; if (!(!hscroll && col == 0)) { while (cm.isHidden(col)) { col++; } cellEl = getCell(row, col); } if (rowEl == null) { return null; } Element c = scroller.dom; int ctop = 0; Element p = rowEl, stope = el.dom; while (p != null && p != stope) { ctop += p.getOffsetTop(); p = p.getOffsetParent().cast(); } ctop -= mainHd.dom.getOffsetHeight(); int cbot = ctop + rowEl.getOffsetHeight(); int ch = c.getOffsetHeight(); int stop = c.getScrollTop(); int sbot = stop + ch; if (ctop < stop) { c.setScrollTop(ctop); } else if (cbot > sbot) { if (hscroll && (cm.getTotalWidth() > scroller.getWidth() - scrollOffset)) { cbot += scrollOffset; } c.setScrollTop(cbot -= ch); } if (hscroll && cellEl != null) { int cleft = cellEl.getOffsetLeft(); int cright = cleft + cellEl.getOffsetWidth(); int sleft = c.getScrollLeft(); int sright = sleft + c.getOffsetWidth(); if (cleft < sleft) { c.setScrollLeft(cleft); } else if (cright > sright) { c.setScrollLeft(cright - scroller.getStyleWidth()); } } return cellEl != null ? fly(cellEl).getXY() : new Point(c.getScrollLeft(), fly(rowEl).getY()); }
From source file:com.fullmetalgalaxy.client.game.board.WgtBoardBase.java
License:Open Source License
@Override public void onTouchEnd(TouchEndEvent p_event) { if (!m_hasTouchMoved) { p_event.preventDefault();//from w w w. ja v a2s .c o m Touch touch = p_event.getChangedTouches().get(0); Element current = getElement(); Element parent = current.getParentElement(); int x = touch.getPageX() - current.getOffsetLeft() - parent.getOffsetLeft(); int y = touch.getPageY() - current.getOffsetTop() - parent.getOffsetTop(); onUp(UserAction.Touch, x, y); } }
From source file:com.preferanser.client.application.layout.PanelLayout.java
License:Open Source License
protected void positionWidget(CardWidget cardWidget, int x, int y, int z) { Element element = cardWidget.getElement(); int currentX = element.getOffsetLeft(); int currentY = element.getOffsetTop(); element.getStyle().setZIndex(z);//ww w. ja v a 2 s. co m if (currentX != x || currentY != y) { CardAnimation animation = new CardAnimation(element); animation.moveTo(x, y, ANIMATION_DURATION_MILLIS); } }
From source file:fr.putnami.pwt.core.widget.client.base.AbstractHover.java
License:Open Source License
private void resetPosition(Element toPositionedElement, Widget relativeTo, Placement placement) { Element relativeElement = relativeTo.getElement(); com.google.gwt.dom.client.Style elementStyle = toPositionedElement.getStyle(); int tooltipWidth = toPositionedElement.getOffsetWidth(); int tooltipHeight = toPositionedElement.getOffsetHeight(); int targetWidth = relativeElement.getOffsetWidth(); int targetHeight = relativeElement.getOffsetHeight(); int targetTop = relativeElement.getOffsetTop(); int targetLeft = relativeElement.getOffsetLeft(); elementStyle.setPosition(Position.ABSOLUTE); switch (placement) { case TOP:/*from w w w .j a v a 2 s.c o m*/ elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX); elementStyle.setTop(targetTop - tooltipHeight, Unit.PX); break; case BOTTOM: elementStyle.setLeft(targetLeft + targetWidth / 2 - tooltipWidth / 2, Unit.PX); elementStyle.setTop(targetTop + targetHeight, Unit.PX); break; case LEFT: elementStyle.setLeft(targetLeft - tooltipWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX); break; case RIGHT: elementStyle.setLeft(targetLeft + targetWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight / 2 - tooltipHeight / 2, Unit.PX); break; default: break; } }
From source file:fr.putnami.pwt.core.widget.client.InputSwitch.java
License:Open Source License
private void resetSlider(T value) { for (SwitchItem item : this.items.values()) { StyleUtils.removeStyle(item, InputSwitch.STYLE_ACTIVE); }/*from w ww . ja v a2 s. c o m*/ final SwitchItem item = this.items.get(value); if (item != null) { StyleUtils.addStyle(item, InputSwitch.STYLE_ACTIVE); Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { Element itemElement = item.getElement(); InputSwitch.this.slider.getElement().getStyle().setWidth(itemElement.getClientWidth(), Unit.PX); InputSwitch.this.slider.getElement().getStyle().setMarginLeft(itemElement.getOffsetLeft() - 5, Unit.PX); } }); } }
From source file:gwtquery.plugins.draggable.client.impl.DraggableHandlerImpl.java
License:Apache License
public Offset calculateRelativeHelperOffset(Element element, DraggableHandler draggableHandler) { Offset position = new Offset(element.getOffsetLeft(), element.getOffsetTop()); Element helperElement = draggableHandler.getHelper().get(0); Offset margin = draggableHandler.getMargin(); Offset helperCssPosition = getCssPosition(helperElement); int top = position.top - helperCssPosition.top - margin.top; int left = position.left - helperCssPosition.left - margin.left; return new Offset(left, top); }
From source file:jetbrains.jetpad.projectional.domUtil.DomUtil.java
License:Apache License
public static Rectangle visiblePart(Element ctx, Rectangle rect) { while (true) { if (ctx.getOffsetParent() == null) { Rectangle visibleArea = new Rectangle(Window.getScrollLeft(), Window.getScrollTop(), Window.getClientWidth(), Window.getClientHeight()); return visibleArea.intersect(rect); } else {/*from ww w. j a v a2s.c o m*/ Rectangle visible; if (hasScroller(ctx)) { visible = new Rectangle(0, 0, ctx.getClientWidth(), ctx.getClientHeight()); Vector scroll = new Vector(ctx.getScrollLeft(), ctx.getScrollTop()); rect = rect.sub(scroll); } else { visible = new Rectangle(0, 0, ctx.getScrollWidth(), ctx.getScrollHeight()); } Rectangle newRect = visible.intersect(rect); Vector offset = new Vector(ctx.getOffsetLeft(), ctx.getOffsetTop()); ctx = ctx.getOffsetParent(); rect = newRect.add(offset); } } }