def _setSplitPositionUsingPixels(self, px): """ Set the splitter's position in units of pixels. px represents the splitter's position as a distance of px pixels from the left edge of the container. This is true even in a bidi environment. Callers of this method must be aware of this constraint. """ splitElem = self.panel.getSplitElement() rootElemWidth = DOM.getOffsetWidth(self.panel.container) splitElemWidth = DOM.getOffsetWidth(splitElem) # This represents an invalid state where layout is incomplete. This # typically happens before DOM attachment, but I leave it here as a # precaution because negative width/height style attributes produce # errors on IE. if (rootElemWidth < splitElemWidth): return # Compute the new right side width. newRightWidth = rootElemWidth - px - splitElemWidth # Constrain the dragging to the physical size of the panel. if (px < 0): px = 0 newRightWidth = rootElemWidth - splitElemWidth elif (newRightWidth < 0): px = rootElemWidth - splitElemWidth newRightWidth = 0 rightElem = self.panel.getWidgetElement(1) # Set the width of the left side. self.panel.setElemWidth(self.panel.getWidgetElement(0), "%dpx" % px) # Move the splitter to the right edge of the left element. self.panel.setLeft(splitElem, "%dpx" % px) # Move the right element to the right of the splitter. self.panel.setLeft(rightElem, "%dpx" % (px + splitElemWidth)) self.updateRightWidth(rightElem, newRightWidth)
def _move_cursor(self, col): """ moves the css-styled cursor """ #old style (useful for insert mode - don't delete this line for now!) #self.cf.setStyleName(0, col, "inputbox-square-word-cursor", highlight) el = self.cf.getRawElement(0, col+1) w = self.getWidget() px = self.tp.getAbsoluteLeft() py = self.tp.getAbsoluteTop() width = DOM.getOffsetWidth(el) px = DOM.getAbsoluteLeft(el) - px py = DOM.getAbsoluteTop(el) - py w.setWidgetPosition(self.cursor, px, py)
def setSplitPosition(self, pos): leftElem = self.panel.getWidgetElement(0) self.panel.setElemWidth(leftElem, pos) self.setSplitPositionUsingPixels(DOM.getOffsetWidth(leftElem))
def onSplitterResizeStarted(self, x, y): self.initialThumbPos = x self.initialLeftWidth = DOM.getOffsetWidth(self.getWidgetElement(0))