def __init__(self, min_value, max_value, start_value=None, step=None, **kwargs): if not kwargs.has_key("StyleName"): kwargs['StyleName'] = "gwt-VerticalSlider" if kwargs.has_key('Element'): # XXX FIXME: Focus.createFocusable is here for a reason... element = kwargs.pop('Element') else: element = Focus.createFocusable() DOM.setStyleAttribute(element, "position", "relative") DOM.setStyleAttribute(element, "overflow", "hidden") self.handle = DOM.createDiv() DOM.appendChild(element, self.handle) DOM.setStyleAttribute(self.handle, "border", "1px") DOM.setStyleAttribute(self.handle, "width", "100%") DOM.setStyleAttribute(self.handle, "height", "10px") DOM.setStyleAttribute(self.handle, "backgroundColor", "#808080") Control.__init__(self, element, min_value, max_value, start_value, step, **kwargs) self.addClickListener(self) self.addFocusListener(self) self.addMouseListener(self)
def __init__(self, **ka): ka['StyleName'] = ka.get('StyleName', "gwt-Tree") self.root = None self.childWidgets = Set() self.curSelection = None self.focusable = None self.focusListeners = [] self.mouseListeners = [] self.imageBase = pygwt.getModuleBaseURL() self.keyboardListeners = [] self.listeners = [] self.lastEventType = "" element = ka.pop('Element', None) or DOM.createDiv() self.setElement(element) DOM.setStyleAttribute(self.getElement(), "position", "relative") self.focusable = Focus.createFocusable() # Hide focus outline in Mozilla/Webkit/Opera DOM.setStyleAttribute(self.focusable, "outline", "0px") # Hide focus outline in IE 6/7 DOM.setElemAttribute(self.focusable, "hideFocus", "true") DOM.setStyleAttribute(self.focusable, "fontSize", "0") DOM.setStyleAttribute(self.focusable, "position", "absolute") DOM.setIntStyleAttribute(self.focusable, "zIndex", -1) DOM.appendChild(self.getElement(), self.focusable) self.root = RootTreeItem() self.root.setTree(self) Widget.__init__(self, **ka) self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS) DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
def __init__(self, min_value, max_value, start_value=None, step=None, **kwargs): if not kwargs.has_key("StyleName"): kwargs['StyleName'] = "gwt-VerticalSlider" if kwargs.has_key('Element'): # XXX FIXME: Focus.createFocusable is here for a reason... element = kwargs.pop('Element') else: element = Focus.createFocusable() DOM.setStyleAttribute(element, "position", "relative") DOM.setStyleAttribute(element, "overflow", "hidden") self.handle = DOM.createDiv() DOM.appendChild(element, self.handle) self.setHandleStyle("1px", "100%", "10px", "#808080") # must use DoubleControl; otherwise, this init is = Vertical init, # plus a change in the handle style # this should be refactored, so that the AreaSlider # can be built on VerticalSlider DoubleControl.__init__(self, element, min_value, max_value, start_value, step, **kwargs) self.addClickListener(self) self.addFocusListener(self) self.addMouseListener(self) #Redefine VDS's styles for handle self.setHandleStyle("1px", "10px", "10px", "#808080")
def __init__(self, min_value, max_value, start_value=None, step=None, **ka): ka["StyleName"] = ka.get('StyleName', "gwt-VerticalSlider") # XXX FIXME: Focus.createFocusable is here for a reason... element = ka.pop('Element', None) or Focus.createFocusable() DOM.setStyleAttribute(element, "position", "relative") DOM.setStyleAttribute(element, "overflow", "hidden") self.handle = DOM.createDiv() DOM.appendChild(element, self.handle) self.setHandleStyle("1px", "100%", "10px", "#808080") Control.__init__(self, element, min_value, max_value, start_value, step, **ka) self.addClickListener(self) self.addFocusListener(self) self.addMouseListener(self)
def __init__(self, **ka): ka['StyleName'] = ka.get('StyleName', "gwt-Tree") self.root = None self.childWidgets = Set() self.curSelection = None self.focusable = None self.focusListeners = [] self.mouseListeners = [] self.imageBase = pygwt.getModuleBaseURL() self.keyboardListeners = [] self.listeners = [] self.lastEventType = "" element = ka.pop('Element', None) or DOM.createDiv() self.setElement(element) DOM.setStyleAttribute(self.getElement(), "position", "relative") self.focusable = Focus.createFocusable() # Hide focus outline in Mozilla/Webkit/Opera DOM.setStyleAttribute(self.focusable, "outline", "0px") # Hide focus outline in IE 6/7 DOM.setElemAttribute(self.focusable, "hideFocus", "true"); DOM.setStyleAttribute(self.focusable, "fontSize", "0") DOM.setStyleAttribute(self.focusable, "position", "absolute") DOM.setIntStyleAttribute(self.focusable, "zIndex", -1) DOM.appendChild(self.getElement(), self.focusable) self.root = RootTreeItem() self.root.setTree(self) Widget.__init__(self, **ka) self.sinkEvents(Event.ONMOUSEDOWN | Event.ONCLICK | Event.KEYEVENTS) DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS)
def __init__(self, width=0, height=0): Widget.__init__(self) self.context = None self.setElement(DOM.createDiv()) canvas = DOM.createElement("canvas") self.setWidth(width) self.setHeight(height) canvas.width=width canvas.height=height DOM.appendChild(self.getElement(), canvas) self.setStyleName("gwt-Canvas") self.init() self.context.fillStyle = "black" self.context.strokeStyle = "black" self.focusable = None self.focusable = Focus.createFocusable() self.focusListeners = [] self.clickListeners = [] self.mouseListeners = [] self.keyboardListeners = [] DOM.appendChild(self.getElement(), self.focusable) DOM.sinkEvents(canvas, Event.ONCLICK | Event.MOUSEEVENTS | DOM.getEventsSunk(canvas)) DOM.sinkEvents(self.focusable, Event.FOCUSEVENTS | Event.KEYEVENTS)
def __init__(self, **kwargs): """ pass in Widget={the widget} so that Applier will call setWidget. """ SimplePanel.__init__(self, Focus.createFocusable(), **kwargs) FocusHandler.__init__(self) KeyboardHandler.__init__(self) ClickHandler.__init__(self) MouseHandler.__init__(self)
def __init__(self, child=None): SimplePanel.__init__(self, Focus.createFocusable()) FocusHandler.__init__(self) KeyboardHandler.__init__(self) ClickHandler.__init__(self) MouseHandler.__init__(self) if child: self.setWidget(child)
def __init__(self, coordX=None, coordY=None, pixelX=None, pixelY=None, **kwargs): """ Creates an SVGCanvas element. Element type is 'svg' @param coordX the size of the coordinate space in the x direction @param coordY the size of the coordinate space in the y direction @param pixelX the CSS width in pixels of the canvas element @param pixelY the CSS height in pixels of the canvas element """ # init default coordinates/size self.pixelHeight = 150 self.pixelWidth = 300 self.coordHeight = self.pixelHeight self.coordWidth = self.pixelWidth focusable = Focus.createFocusable() self.canvas = self._createElementSVG("svg") # create an empty defs element self.defs = self._createElementSVG("defs") # and add it to the canvas DOM.appendChild(self.canvas, self.defs) # now add canvas to container DOM.appendChild(focusable, self.canvas) # init base widget (invokes settables) FocusWidget.__init__(self, focusable, **kwargs) # since the Applier class provides settable access, # we only override the dimensions if user actually # provided them as keyword args if pixelX is not None: self.setPixelWidth(pixelX) if pixelY is not None: self.setPixelHeight(pixelY) if coordX is not None: self.setCoordWidth(coordX) if coordY is not None: self.setCoordHeight(coordY) # init styles context stack self.ctx_stack = [] # init current context self._init_context() # insure we clear/init the canvas self.clear()
def __init__(self, Width=0, Height=0, **kwargs): if not kwargs.has_key('StyleName'): kwargs['StyleName'] = 'gwt-Canvas' kwargs['Width'] = Width kwargs['Height'] = Height self.context = None focusable = Focus.createFocusable() self.canvas = DOM.createElement("canvas") DOM.appendChild(focusable, self.canvas) FocusWidget.__init__(self, focusable, **kwargs) self.init() self.context.fillStyle = "black" self.context.strokeStyle = "black"
def __init__(self, coordX=300, coordY=150, pixelX=300, pixelY=150, **kwargs): """ * Impl Instance. Compiler should statify all the methods, so we * do not end up with duplicate code for each canvas instance. """ self.impl = self.getCanvasImpl() self.coordHeight = 0 self.coordWidth = 0 focusable = Focus.createFocusable() self.canvas = self.impl.createElement() DOM.appendChild(focusable, self.canvas) FocusWidget.__init__(self, focusable, **kwargs) self.setPixelWidth(pixelX) self.setPixelHeight(pixelY) self.setCoordSize(coordX, coordY)
def __init__(self, p, child, cDelegate, kDelegate) : Composite.__init__(self) self.clickDelegate = cDelegate self.keyDelegate = kDelegate self.focusablePanel = SimplePanel(Focus.createFocusable()) self.focusablePanel.setWidget(child) wrapperWidget = p.createTabTextWrapper() if wrapperWidget is None: self.initWidget(self.focusablePanel) else : wrapperWidget.setWidget(self.focusablePanel) self.initWidget(wrapperWidget) if hasattr(child, "addKeyboardListener"): child.addKeyboardListener(kDelegate) self.sinkEvents(Event.ONCLICK | Event.ONKEYDOWN)
def __init__(self, upImageText=None, downImageText=None, listener=None, **kwargs): """Constructor for CustomButton.""" if not kwargs.has_key('StyleName'): kwargs['StyleName']=self.STYLENAME_DEFAULT if kwargs.has_key('Element'): # XXX FIXME: createFocusable is used for a reason... element = kwargs.pop('Element') else: element = Focus.createFocusable() ButtonBase.__init__(self, element, **kwargs) self.curFace = None # The button's current face. self.curFaceElement = None # No "undefined" anymore self.up = None # Face for up. self.down = None # Face for down. self.downHovering = None # Face for downHover. self.upHovering = None # Face for upHover. self.upDisabled = None # Face for upDisabled. self.downDisabled = None # Face for downDisabled. self.isCapturing = False # If True, this widget is capturing with # the mouse held down. self.isFocusing = False # If True, widget has focus with space down. self.allowClick = False # Used to decide whether to allow clicks to # propagate up to the superclass or container # elements. self.setUpFace(self.createFace(None, "up", self.UP)) #self.getUpFace().setText("Not initialized yet:)") #self.setCurrentFace(self.getUpFace()) # Add a11y role "button" # XXX: TODO Accessibility # TODO: pyjslib.isinstance if downImageText is None and listener is None: listener = upImageText upImageText = None if upImageText and isinstance(upImageText, basestring): upText = upImageText upImage = None else: upImage = upImageText upText = None if downImageText and isinstance(downImageText, basestring): downText = downImageText downImage = None else: downImage = downImageText downText = None #self.getUpFace().setText("Just a test") if upImage is not None: self.getUpFace().setImage(upImage) if upText is not None: self.getUpFace().setText(upText) if downImage is not None: self.getDownFace().setImage(downImage) if downText is not None: self.getDownFace().setText(downText) # set the face DOWN #self.setCurrentFace(self.getDownFace()) # set the face UP #self.setCurrentFace(self.getUpFace()) self.sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS | Event.KEYEVENTS) if listener is not None: self.addClickListener(listener)