Home | Trees | Indices | Help |
|
---|
|
1 """ Control Widgets. Presently comprises a Vertical Slider and derivatives. 2 3 HorizontalSlider and HorizontalSlider2 added by Bill Winder 4 AreaSlider and AreaSlider2 added by Bill Winder 5 6 Copyright (C) 2008, 2009, 2010 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 7 Copyright (C) 2010 - Cedric Gestes <gestes@aldebaran-robotics.com> 8 Copyright (C) 2009, 2010 - Bill Winder <wgwinder@gmail.com> 9 10 11 To do: All controls with draggable=True do not fire the OnFocus methon on single click. 12 the control does not activate the OnFocus method. Clicking the handle does fire OnFocus, however. 13 14 """ 15 16 from pyjamas import Factory 17 from pyjamas import DOM 18 from pyjamas.ui import MouseListener 19 from pyjamas.ui.InputControl import InputControl 20 212367 68 Factory.registerClass('pyjamas.ui.MouseInputControl', 'InputControl', InputControl) 6926 27 if not kwargs.has_key("StyleName"): 28 kwargs['StyleName'] = "gwt-MouseInputControl" 29 InputControl.__init__(self, min_value, max_value, start_value, 30 step, **kwargs) 31 32 self.addMouseListener(self) 33 self.setDragable(True)3436 self.addStyleName("gwt-MouseInputControl-focussed")3739 self.removeStyleName("gwt-MouseInputControl-focussed") 40 self.dragging = False 41 DOM.releaseCapture(self.getElement())4244 height_range = 100.0 45 val_diff = self.max_value - self.min_value 46 if first_move: 47 # back-calculate value to offset so that control doesn't jump 48 value = self.value 49 self.height_offset = mouse_y - height_range + \ 50 (height_range * (value - self.min_value)) / val_diff 51 52 relative_y = mouse_y - self.height_offset 53 #widget_height = self.getOffsetHeight() 54 #relative_y = mouse_y - (widget_height / 2) - self.height_offset 55 if relative_y < 0: 56 relative_y = 0 57 if relative_y >= height_range: 58 relative_y = height_range 59 60 relative_y = height_range - relative_y # turn round (bottom to top) 61 62 new_value = ((val_diff * relative_y) / height_range) + self.min_value 63 new_value = self.processValue(new_value) 64 65 self.setControlPos(new_value) 66 self.setValue(new_value)
Home | Trees | Indices | Help |
|
---|
http://epydoc.sourceforge.net |