def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, text=""): """ Constructor. Non-wxpython related parameters: @param text (str) the text to write in the pane. """ wx.Window.__init__(self, parent, id, pos, size, STYLE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetDoubleBuffered(True) # Members, Initializations self._text = text self.SetToolTip(wx.ToolTip(self.__tooltip())) self.Reset(size) # Bind the events related to our control wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, lambda event: None) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents)
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, audio=None): """ Constructor. Non-wxPython related parameter: - audio (sppasAudioPCM): the audio instance. """ spControl.__init__(self, parent, id, pos, size) # Preferences self._preferences = WavePreferences() # Disable Pane (because each channel has its own pane) self._infopanep = wx.ALIGN_CENTRE # Members self._selectarea = SelectArea() self._m_dragging = False # Wave self.__set(audio) # Handling mouse moving. wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents)
def _bindMouseEvents(self): """Binds wx mouse events and custom mouse events""" wx.EVT_MOUSE_EVENTS(self, self._mouseActions) wx.EVT_MOTION(self, self._mouseMotion) self.Bind(EVT_MOTION, self.OnMotion) self.Bind(EVT_MOUSE_EVENTS, self.MouseActions) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu)
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.NO_BORDER, validator=wx.DefaultValidator, name="Separator"): """ Constructor. """ wx.Control.__init__(self, parent, id, pos, size, style, validator, name) # Initialize the pen colour, for faster drawing later self.InitializeColours() self.InitialSize(size) self.InitializeCursor() # Allows to move the separator self._motional = False self._m_dragging = None # Bind the events related to our control: first of all, we use a # combination of wx.BufferedPaintDC and an empty handler for # wx.EVT_ERASE_BACKGROUND (see later) to reduce flicker self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) # Handling mouse moving. wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents)
def __init__(self, parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, label=None): """LabelCtrl constructor. Notice that each change of the object implies a refresh. Non-wxpython related parameter: - label (Label) the Label of an annotation. It is never modified. """ wx.Window.__init__(self, parent, id, pos, size, STYLE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetDoubleBuffered(True) # Members, Initializations self.Reset(size) self._label = label self._underlined = False # self.SetValue(label) # Bind the events related to our control wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, lambda event: None) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents)
def __init__(self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BORDER, name="ShapeCanvas"): wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name) self.diagram = None self._dragState = NoDragging self._draggedShape = None self._oldDragX = 0 self._oldDragY = 0 self._firstDragX = 0 self._firstDragY = 0 self._checkTolerance = True # this MAY actually be private... self.mouseTolerance = DEFAULT_MOUSE_TOLERANCE self.avoidRefreshes = False self.snapToGrid = False self.gridSpacing = 25.0 wx.EVT_PAINT(self, self.OnPaint) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent)
def __init__(self, parent, id=-1, size=wx.wxDefaultSize): # parent 1 ctor wx.wxScrolledWindow.__init__(self, parent, id, wx.wxPoint(0, 0), size, wx.wxSUNKEN_BORDER) # parent 2 ctor canvasSubject.__init__(self) self._cobjects = [] self._previousRealCoords = None self._mouseDelta = (0, 0) self._potentiallyDraggedObject = None self._draggedObject = None self._observers = {'drag': [], 'buttonDown': [], 'buttonUp': []} self.SetBackgroundColour("WHITE") wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent) wx.EVT_PAINT(self, self.OnPaint) self.virtualWidth = 2048 self.virtualHeight = 2048 self._buffer = None self._buffer = wx.wxEmptyBitmap(self.virtualWidth, self.virtualHeight) # we're only going to draw into the buffer, so no real client DC dc = wx.wxBufferedDC(None, self._buffer) dc.SetBackground(wx.wxBrush(self.GetBackgroundColour())) dc.Clear() self.doDrawing(dc) self.SetVirtualSize((self.virtualWidth, self.virtualHeight)) self.SetScrollRate(20, 20)
def __init__(self, parent, size=wx.DefaultSize): MyCanvasBase.__init__(self, parent, size=size) self.m_log = True # 20070724 - default log-scale self.fitYtoSeen = True # 20080731 self.mouse_last_x, self.mouse_last_y = 0,0 # in case mouseIsDown happens without preceeding mouseDown self.dragCenter = False # in case mouseIsDown happens without preceeding mouseDown self.dragLeft = True # in case mouseIsDown happens without preceeding mouseDown self.keepZoomedToBraces = True # 20080806 wx.EVT_MOUSE_EVENTS(self, self.OnMouse) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_CLOSE(self, self.OnClose) self.MakePopupMenu() self.m_histPlotArray = None self.leftBrace = 0. self.rightBrace= 100. self.bandTobeGenerated = True self.m_imgChanged = 1 self.m_histScaleChanged = 1 self.colMap = None self.m_texture_list = None self.m_histGlRGB=(1.0, 1.0, 1.0) #20080707 doOnXXXX event handler are now lists of functions self.doOnBrace = [] # (self) # use self.leftBrace, self.rightBrace to get current brace positions self.doOnMouse = [] # (xEff, ev)
def __init__(self, parent, id, txtCtrl, rect, font, mainControl, searchInit=None): # Frame title is invisible but is helpful for workarounds with # third-party tools wx.Frame.__init__(self, parent, id, u"WikidPad i-search", rect.GetPosition(), rect.GetSize(), wx.NO_BORDER | wx.FRAME_FLOAT_ON_PARENT) self.txtCtrl = txtCtrl self.mainControl = mainControl self.tfInput = wx.TextCtrl( self, GUI_ID.INC_SEARCH_TEXT_FIELD, _(u"Incremental search (ENTER/ESC to finish)"), style=wx.TE_PROCESS_ENTER | wx.TE_RICH) self.tfInput.SetFont(font) self.tfInput.SetBackgroundColour(IncrementalSearchDialog.COLOR_YELLOW) mainsizer = wx.BoxSizer(wx.HORIZONTAL) mainsizer.Add(self.tfInput, 1, wx.ALL | wx.EXPAND, 0) self.SetSizer(mainsizer) self.Layout() self.tfInput.SelectAll() #added for Mac compatibility self.tfInput.SetFocus() config = self.mainControl.getConfig() self.closeDelay = 1000 * config.getint( "main", "incSearch_autoOffDelay", 0) # Milliseconds to close or 0 to deactivate wx.EVT_TEXT(self, GUI_ID.INC_SEARCH_TEXT_FIELD, self.OnText) wx.EVT_KEY_DOWN(self.tfInput, self.OnKeyDownInput) wx.EVT_KILL_FOCUS(self.tfInput, self.OnKillFocus) wx.EVT_TIMER(self, GUI_ID.TIMER_INC_SEARCH_CLOSE, self.OnTimerIncSearchClose) wx.EVT_MOUSE_EVENTS(self.tfInput, self.OnMouseAnyInput) if searchInit: self.tfInput.SetValue(searchInit) self.tfInput.SetSelection(-1, -1) if self.closeDelay: self.closeTimer = wx.Timer(self, GUI_ID.TIMER_INC_SEARCH_CLOSE) self.closeTimer.Start(self.closeDelay, True)
def __bind_events(self): """Bind events.""" # Only refresh drawing when resizing is finished wx.EVT_PAINT(self, self.onPaint) wx.EVT_SIZE(self, self.onSize) wx.EVT_CLOSE(self, self.onClose) wx.EVT_IDLE(self, self.onIdle) wx.EVT_ERASE_BACKGROUND(self, lambda event: None) # Handling mouse moving. wx.EVT_MOUSE_EVENTS(self, self.onMouseEvents) # Mouse selection self.Bind(spEVT_CTRL_SELECTED, self.onSelectedObject) self.Bind(wx.EVT_TOOL_RANGE, self.onSelectionRange)
def __init__(self, parent=None, attrpanel=None, frame=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BORDER, name="ShapeCanvas"): wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name) self.attrpanel = attrpanel self.frame = frame wx.EVT_PAINT(self, self.OnPaint) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent) self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.curselshapelist = [] self.curselshape = None self.hotshape = None self.cureditshape = None self.isdragging = False self.startdragpos = [0, 0] self.dragseltype = SEL_NONE self.cmdhdr = None self.SetBackgroundColour("LIGHT BLUE") self.oneMoveKeyTrunkStart = False self.oneMoveKeyTrunkCmdObj = None self.cmdhdr = CommandHandler(self) self.copiedshapes = [] self.delayUpdateAttrTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnDelayUpdateAttrTimer, self.delayUpdateAttrTimer) acceltbl = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('Z'), 20001), #MENU_UNDO (wx.ACCEL_CTRL, ord('Y'), 20002), #MENU_REDO (wx.ACCEL_CTRL, ord('C'), 20017), #MENU_COPY (wx.ACCEL_CTRL, ord('V'), 20018) #MENU_PASTE ]) self.SetAcceleratorTable(acceltbl) global g_shapetree g_shapetree = self.frame.GetShapeTree()
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, ann=None): """ Constructor. Non-wxpython related parameters: @param ann (Annotation) the annotation to be represented. The size is representing the available area to draw the annotation. The member _pxsec must be fixed for the annotation to draw inside this area. It represents the number of pixels required for 1 second. """ self._pointctrl1 = None self._pointctrl2 = None self._labelctrl = None self._pxsec = 0 # the number of pixels to represent 1 second of time wx.Window.__init__(self, parent, id, pos, size, STYLE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetDoubleBuffered(True) # Members, Initializations self._ann = None if ann is not None: self.SetAnn(ann) self.Reset(size) # Bind the events related to our control wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, lambda event: None) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents) #spEVT_POINT_LEFT(self, self.OnPointEdit) #spEVT_RESIZING(self, self.OnPointResizing) #spEVT_RESIZED(self, self.OnPointResized) spEVT_MOVING(self, self.OnPointMoving)
def __init__(self, parent, ipu): wx.Panel.__init__(self, parent) self.SetBackgroundColour(ipu.color) self._ipu = ipu self._selected = False # create the information panel self._infopanel = wx.Panel(self) self._infopanel.SetBackgroundColour(self._ipu.color) self._title = wx.StaticText(self._infopanel) self._title.SetForegroundColour(self.GetForegroundColour()) self._startend = wx.StaticText(self._infopanel) self._startend.SetForegroundColour(self.GetForegroundColour()) self._length = wx.StaticText(self._infopanel) self._length.SetForegroundColour( co.LightenColor(self.GetForegroundColour(), 80)) info_sizer = wx.BoxSizer(wx.VERTICAL) info_sizer.Add(self._title, 1, wx.ALL | wx.CENTER, 2) info_sizer.Add(self._startend, 0, wx.ALL | wx.CENTER, 2) info_sizer.Add(self._length, 0, wx.ALL | wx.CENTER, 2) self._infopanel.SetSizer(info_sizer) self.refresh_title() # create the text control self._text = wx.TextCtrl(self, size=wx.Size(0, 50), style=wx.TE_MULTILINE | wx.TE_RICH2) self._text.SetBackgroundColour(wx.WHITE) self._text.AppendText(self._ipu.get_label()) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self._infopanel, 0, wx.EXPAND | wx.ALL, 2) sizer.Add(self._text, 1, wx.EXPAND | wx.ALL, 2) self.SetSizer(sizer) # Handling events. wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents) wx.EVT_MOUSE_EVENTS(self._infopanel, self.OnMouseEvents) wx.EVT_MOUSE_EVENTS(self._text, self.OnMouseEvents) wx.EVT_MOUSE_EVENTS(self._title, self.OnMouseEvents) wx.EVT_MOUSE_EVENTS(self._startend, self.OnMouseEvents) wx.EVT_MOUSE_EVENTS(self._length, self.OnMouseEvents) self._text.Bind(wx.EVT_TEXT, self.OnTextChanged) self._text.Bind(wx.EVT_SET_FOCUS, self.OnFocus)
def __init__(self, parent=None, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.BORDER, name="ShapeCanvas"): wx.ScrolledWindow.__init__(self, parent, id, pos, size, style, name) self._shapeDiagram = None self._dragState = NoDragging self._draggedShape = None self._oldDragX = 0 self._oldDragY = 0 self._firstDragX = 0 self._firstDragY = 0 self._checkTolerance = True wx.EVT_PAINT(self, self.OnPaint) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvent)
def __init__(self, parent, emdata=None, id=-1, size=wx.Size(200, 200)): wx.Window.__init__(self, parent, id, (0, 0), size=size) self.size = self.GetSize() tmp_scale1 = float(self.GetSize()[0]) / emdata.get_xsize() tmp_scale2 = float(self.GetSize()[1]) / emdata.get_ysize() if tmp_scale1 < tmp_scale2: self.default_scale = tmp_scale1 else: self.default_scale = tmp_scale2 self.emdatasize = [emdata.get_xsize(), emdata.get_ysize()] self.x_per = 0.5 self.y_per = 0.5 self.origin = [self.GetSize()[0] / 2, self.GetSize()[1] / 2 ] # origin in the image being displayed self.scale = self.default_scale # display scale self.mingrayval = 0.0 # value in EMData corresponding to min gray level self.maxgrayval = 1.0 # value in EMData corresponding to max gray level self.initial_gray_set = 0 self.data = None # pointer to the displayed EMData object self.Show() self.bm = None self.control = None self.dofft = 0 if emdata: self.setdata(emdata) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_SIZE(self, self.OnResize) wx.EVT_MOUSE_EVENTS(self, self.OnMouse) EMImageFrame.allim[self] = 0 del self # decrement the reference count so allim doesn't prevent deletion
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, point=None): """PointCtrl constructor. Notice that each change of the object implies a refresh. Non-wxpython related parameters: @param point (TimePoint) the TimePoint to be represented, indicating the midpoint value and the radius value. point will only be used to display the time values in the tooltip. It is never modified. """ wx.Window.__init__(self, parent, id, pos, size, STYLE) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetDoubleBuffered(True) # Members, Initializations self._point = point self.SetToolTip(wx.ToolTip(self.__tooltip())) self.Reset(size) # Allows to move/resize the PointCtrl self._ml_dragging = None # left button + mouse moving self._shift_ml_dragging = None # shift key + left button + mouse moving self._starting = None # Bind the events related to our control wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, lambda event: None) wx.EVT_MOUSE_EVENTS(self, self.OnMouseEvents)
def __init__(self, parent, axes = (1, 2), dataDoc = None, viewManager = None, style = 0, size = wx.DefaultSize): wx.glcanvas.GLCanvas.__init__(self, parent, style = style, size = size) ## DataDoc instance holding the data we show. self.dataDoc = dataDoc ## Controlling super-parent. self.viewManager = viewManager ## List of Image instances self.imgList = [] ## Set of Images that need to have their refresh() method called # next time OnPaint runs. self.imagesToRefresh = set() ## Cursor to default to when not displaying any special cursor. self.defaultCursor = self.GetCursor() ## Dimensions we are displaying; corresponds to dimensions in # the dataDoc instance (T/W/Z/Y/X). self.axes = axes ## Scaling factors in X and Y self.scaleX = 1.0 self.scaleY = 1.0 ## Whether or not the mouse is dragging something self.isMouseDragging = False ## Position of the mouse in the previous update cycle. self.mousePrevPos = [] ## If true, then dragging is modifying the slice lines. self.amDraggingSlicelines = False ## Indices of sliceline dimension(s) being dragged. self.dragIndices = [] ## If true, then dragging is modifying the cropbox. self.amDraggingCropbox = False ## Whether a given dimension's cropbox is having its min or max # modified. self.cropMinMax = [] ## Whether or not the current cursor is our default cursor. Sadly wx # doesn't allow you to compare cursors in any meaningful way. self.isCurrentCursorDefault = True ## Whether or not we've done some one-time initialization work. self.haveInitedGL = False ## Context instance, needed as of WX 2.9. self.context = wx.glcanvas.GLContext(self) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_MOUSE_EVENTS(self, self.OnMouse) self.Bind(wx.EVT_KEY_DOWN, self.OnKey)
def __init__(self, parent, size=wx.DefaultSize, originLeftBottom=None): wxgl.GLCanvas.__init__(self, parent, -1, size=size, style=wx.WANTS_CHARS) # wxWANTS_CHARS to get arrow keys on Windows self.error = None self.m_doViewportChange = True # NEW 20080701: in new coord system, integer pixel coord go through the center of pixel self.x00 = -.5 # 0 self.y00 = -.5 # 0 self.m_x0 = None #20070921 - call center() in OnPaint -- self.x00 self.m_y0 = None #20070921 - call center() in OnPaint -- self.y00 self.m_scale = 1 self.m_aspectRatio = 1. self.m_rot = 0. self.m_zoomChanged = True # // trigger a first placing of image self.m_sizeChanged = True self.keepCentered = True #20080722 self.m_pixelGrid_Idx = None self.m_pixelGrid_state = 0 # 0-off, 1-everyPixel, 2- every 10 pixels self.m_init = False self.m_moreGlLists = [] self.m_moreGlLists_enabled = [] self.m_moreMaster_enabled = True self.m_moreGlLists_dict = { } # map 'name' to list of idx in m_moreGlLists # a given idx can be part of multiple 'name' entries # a given name entry can contain a given idx only once # a name that is a tuple, has a special meaning: if name == zSecTuple - # auto en-/dis-able gfxs in splitNDcommon::OnZZSlider (ref. zlast) # UNLESS gfx idx is in self.m_moreGlLists_nameBlacklist self.m_moreGlLists_nameBlacklist = set() self.m_moreGlLists_NamedIdx = { } # map str to int or None -- this is helpful for reusing Idx for "changing" gllists # if name (type str) wasn't used before, it defaults to None (20080722) self.m_moreGlListReuseIdx = None self.m_wheelFactor = 2**(1 / 3. ) #1.189207115002721 # >>> 2 ** (1./4) # 2 self.mouse_last_x, self.mouse_last_y = 0, 0 # in case mouseIsDown happens without preceeding mouseDown #20080707 doOnXXXX event handler are now lists of functions # x,y are (corrected, float value) pixel position # ev is the wx onMouseEvent obj -- use ev.GetEventObject() to get to the viewer object #20080707-unused self.doOnFrameChange = [] # no args self.doOnMouse = [] # (x,y, ev) self.doOnLDClick = [] # (x,y, ev) self.doOnLDown = [] # (x,y, ev) wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground) #20080707-unused wx.EVT_MOVE(parent, self.OnMove) # CHECK wx.EVT_SIZE(self, self.OnSize) wx.EVT_MOUSEWHEEL(self, self.OnWheel) wx.EVT_MOUSE_EVENTS(self, self.OnMouse)
def __init__(self, parent=None, ID=-1, *args, **kw): # First do special handling of some keywords: # stereo, position, size, width, height, style stereo = 0 self._last_mouse_pos = None self.__is_frozen = False if 'stereo' in kw: if kw['stereo']: stereo = 1 del kw['stereo'] position = wx.DefaultPosition if 'position' in kw: position = kw['position'] del kw['position'] size = wx.DefaultSize if 'size' in kw: size = kw['size'] if not isinstance(size, wx.Size): size = wx.Size(*size) del kw['size'] if 'width' in kw and 'height' in kw: size = wx.Size(kw['width'], kw['height']) del kw['width'] del kw['height'] # wx.WANTS_CHARS says to give us e.g. TAB # wx.NO_FULL_REPAINT_ON_RESIZE cuts down resize flicker under GTK style = wx.WANTS_CHARS | wx.NO_FULL_REPAINT_ON_RESIZE if 'style' in kw: style = style | kw['style'] del kw['style'] # if there is no parent, make a frame window if parent is None: parent = wx.Frame(None, -1, "wxRenderWindow", position, size) parent.Show(1) self._wxFrame = parent # initialize the wxWindow -- take care here to ensure double-buffering is # enabled under Linux if wx.Platform != '__WXMSW__': attribList = [ wx.glcanvas.WX_GL_RGBA, wx.glcanvas.WX_GL_DOUBLEBUFFER, wx.glcanvas.WX_GL_DEPTH_SIZE, 16 ] baseClass.__init__(self, parent, id=ID, pos=position, size=size, style=style, attribList=attribList) else: baseClass.__init__(self, parent, ID, position, size, style) # create the RenderWindow and initialize it self._RenderWindow = vtk.vtkRenderWindow() self.__Created = 0 # create the RenderWindow and initialize it self._RenderWindowInteractor = vtk.vtkGenericRenderWindowInteractor() self._RenderWindowInteractor.SetRenderWindow(self._RenderWindow) self._RenderWindowInteractor.GetRenderWindow().AddObserver( 'CursorChangedEvent', self.CursorChangedEvent) try: self._RenderWindowInteractor.GetRenderWindow().SetSize( size.width, size.height) except AttributeError: self._RenderWindowInteractor.GetRenderWindow().SetSize( size[0], size[1]) if stereo: self._RenderWindowInteractor.GetRenderWindow( ).StereoCapableWindowOn() self._RenderWindowInteractor.GetRenderWindow( ).SetStereoTypeToCrystalEyes() # The superclass can't be initialized until _RenderWindow # has been declared. PaneFrame.PaneFrame.__init__(self) self.__handle = None self.__has_painted = False self.__is_mapped = False self._own_mouse = False self._mouse_capture_button = 0 self._cursor_map = { 0: wx.CURSOR_ARROW, # VTK_CURSOR_DEFAULT 1: wx.CURSOR_ARROW, # VTK_CURSOR_ARROW 2: wx.CURSOR_SIZENESW, # VTK_CURSOR_SIZENE 3: wx.CURSOR_SIZENWSE, # VTK_CURSOR_SIZENWSE 4: wx.CURSOR_SIZENESW, # VTK_CURSOR_SIZESW 5: wx.CURSOR_SIZENWSE, # VTK_CURSOR_SIZESE 6: wx.CURSOR_SIZENS, # VTK_CURSOR_SIZENS 7: wx.CURSOR_SIZEWE, # VTK_CURSOR_SIZEWE 8: wx.CURSOR_SIZING, # VTK_CURSOR_SIZEALL 9: wx.CURSOR_HAND, # VTK_CURSOR_HAND 10: wx.CURSOR_CROSS, # VTK_CURSOR_CROSSHAIR } # private variable for better Enter/Leave handling self.__ActiveButton = 0 self.__SaveState = 0 self._Inside = 0 # refresh window by doing a Render self.Bind(wx.EVT_PAINT, self.OnPaint) # turn off background erase to reduce flicker self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) # Bind the events to the event converters self.Bind(wx.EVT_RIGHT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_LEFT_DOWN, self.OnButtonDown) self.Bind(wx.EVT_MIDDLE_DOWN, self.OnButtonDown) self.Bind(wx.EVT_RIGHT_UP, self.OnButtonUp) self.Bind(wx.EVT_LEFT_UP, self.OnButtonUp) self.Bind(wx.EVT_MIDDLE_UP, self.OnButtonUp) # double click events self.Bind(wx.EVT_RIGHT_DCLICK, self.OnButtonDClick) self.Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDClick) self.Bind(wx.EVT_MIDDLE_DCLICK, self.OnButtonDClick) self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) # If we use EVT_KEY_DOWN instead of EVT_CHAR, capital versions # of all characters are always returned. EVT_CHAR also performs # other necessary keyboard-dependent translations. self.Bind(wx.EVT_CHAR, self.OnKeyDown) self.Bind(wx.EVT_KEY_UP, self.OnKeyUp) self.Bind(wx.EVT_SIZE, self.OnSize) # the wx 2.8.7.1 documentation states that you HAVE to handle # this event if you make use of CaptureMouse, which we do. if _useCapture and hasattr(wx, 'EVT_MOUSE_CAPTURE_LOST'): self.Bind(wx.EVT_MOUSE_CAPTURE_LOST, self.OnMouseCaptureLost) # pretend that we're a base window - let atamai help us out self._BindInteractor() # debug debug debug return # Bind the events to the event converters wx.EVT_MOUSE_EVENTS(self, self.ConvertMouseEvent) wx.EVT_KEY_DOWN(self, self.ConvertKeyEvent) wx.EVT_KEY_UP(self, self.ConvertKeyEvent) wx.EVT_SIZE(self, self.ConvertSizeEvent) # wx.EVT_MOVE(self, self.ConvertMoveEvent) wx.EVT_SET_FOCUS(self, self.ConvertFocusEvent) wx.EVT_KILL_FOCUS(self, self.ConvertFocusEvent)
def __init__(self, parent, size, keyTargetWin=None): wxgl.GLCanvas.__init__(self, parent, -1, size=size) self.error = None self.m_imgArrL = [] self.m_imgPosArr = [] self.m_imgSizeArr = [] self.m_imgRotArr = [] self.m_imgScaleMM = [] self.m_nImgs = 0 self.m_loadImgsToGfxCard = [] self.m_imgL_changed = True ## trigger initTex (also for wmpty imgList !!!) #False self.m_doViewportChange = True self.m_zoomChanged = True # // trigger a first placing of image self.m_sizeChanged = True self.m_originLeftBottom = True self.m_positionsChanged = True self.m_hideTheseImages = [] # 20051208 #20040308 lb = self.m_imgPosArr[0] self.x00 = 0#20040308 - lb[0] +10 self.y00 = 0#20040308 - lb[1] +10 #007 print self.x00, self.y00 self.m_x0=self.x00 self.m_y0=self.y00 self.m_scale=1 self.m_aspectRatio = 1. self.m_rot = 0 self.colMap = None self.m_minHistScale = 0 self.m_maxHistScale = 100 self.m_init = False self.m_gllist = None self.m_texture_list = [] self.m_moreGlLists = [] self.m_moreGlLists_enabled = [] self.m_moreMaster_enabled = True self.m_gllist_Changed = False # call defGlList() from OnPaint self.m_wheelFactor = 2 self.m_zoomDragFactor = 1.05 #//note:"ToolTip just annoys" SetToolTip(wx.String::Format("cam %d", camId)) #20041118 self.SetCursor(wx.CROSS_CURSOR) #20041202(just use defaultArrow) self.SetCursor( wx.StockCursor(wx.CURSOR_BULLSEYE) ) wx.EVT_PAINT(self, self.OnPaint) wx.EVT_ERASE_BACKGROUND(self, lambda evt: evt) # Do nothing, to avoid flashing #wx.EVT_SIZE(parent, self.OnSize) wx.EVT_SIZE(self, self.OnSize) #wx.EVT_MOVE(parent, self.OnMove) # CHECK #EVT_MIDDLE_DOWN(self, self.OnMiddleDown) wx.EVT_MOUSE_EVENTS(self, self.OnMouse) wx.EVT_MOUSEWHEEL(self, self.OnWheel) self.MakePopupMenu() ### wx.Yield() # setImage has gl-calls - so lets make the window first... ### self.setImage(imgArr) if keyTargetWin is not None: self.keyTargetWin = keyTargetWin # m_pMenuPopup = new wx.Menu wx.EVT_KEY_DOWN(self, self.OnKey)