editors/Viewer.py
changeset 1203 4399ddd024e5
parent 1201 3907f10efcf4
child 1204 8a620b460b49
equal deleted inserted replaced
1202:3d8c87ab2b5d 1203:4399ddd024e5
  1971                     self.Scroll(scrollx, scrolly)
  1971                     self.Scroll(scrollx, scrolly)
  1972                 else:
  1972                 else:
  1973                     self.Scroll(scrollx, scrolly)
  1973                     self.Scroll(scrollx, scrolly)
  1974                     self.RefreshScrollBars()
  1974                     self.RefreshScrollBars()
  1975                 self.RefreshVisibleElements()
  1975                 self.RefreshVisibleElements()
       
  1976                 if self.Debug:
       
  1977                     self.Refresh()
  1976         else:
  1978         else:
  1977             if not event.Dragging():
  1979             if not event.Dragging():
  1978                 highlighted = self.FindElement(event, connectors=False) 
  1980                 highlighted = self.FindElement(event, connectors=False) 
  1979                 if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
  1981                 if self.HighlightedElement is not None and self.HighlightedElement != highlighted:
  1980                     self.HighlightedElement.SetHighlighted(False)
  1982                     self.HighlightedElement.SetHighlighted(False)
  3315             wx.CallAfter(self.RefreshVisibleElements)
  3317             wx.CallAfter(self.RefreshVisibleElements)
  3316         elif event.GetOrientation() == wx.HORIZONTAL:
  3318         elif event.GetOrientation() == wx.HORIZONTAL:
  3317             self.RefreshVisibleElements(xp = event.GetPosition())
  3319             self.RefreshVisibleElements(xp = event.GetPosition())
  3318         else:
  3320         else:
  3319             self.RefreshVisibleElements(yp = event.GetPosition())
  3321             self.RefreshVisibleElements(yp = event.GetPosition())
  3320         event.Skip()
  3322         
       
  3323         # Handle scroll in debug to fully redraw area and ensuring
       
  3324         # instance path is fully draw without flickering
       
  3325         if self.Debug:
       
  3326             x, y = self.GetViewStart()
       
  3327             if event.GetOrientation() == wx.HORIZONTAL:
       
  3328                 self.Scroll(event.GetPosition(), y)
       
  3329             else:
       
  3330                 self.Scroll(x, event.GetPosition())
       
  3331             self.Refresh()
       
  3332         else:
       
  3333             event.Skip()
  3321 
  3334 
  3322     def OnScrollStop(self, event):
  3335     def OnScrollStop(self, event):
  3323         self.RefreshScrollBars()
  3336         self.RefreshScrollBars()
  3324         event.Skip()
  3337         event.Skip()
  3325 
  3338 
  3329             if event.ShiftDown():
  3342             if event.ShiftDown():
  3330                 x, y = self.GetViewStart()
  3343                 x, y = self.GetViewStart()
  3331                 xp = max(0, min(x - rotation * 3, self.Editor.GetVirtualSize()[0] / self.Editor.GetScrollPixelsPerUnit()[0]))
  3344                 xp = max(0, min(x - rotation * 3, self.Editor.GetVirtualSize()[0] / self.Editor.GetScrollPixelsPerUnit()[0]))
  3332                 self.RefreshVisibleElements(xp = xp)
  3345                 self.RefreshVisibleElements(xp = xp)
  3333                 self.Scroll(xp, y)
  3346                 self.Scroll(xp, y)
       
  3347                 if self.Debug:
       
  3348                     self.Refresh()
  3334             elif event.ControlDown():
  3349             elif event.ControlDown():
  3335                 dc = self.GetLogicalDC()
  3350                 dc = self.GetLogicalDC()
  3336                 self.SetScale(self.CurrentScale + rotation, mouse_event = event)
  3351                 self.SetScale(self.CurrentScale + rotation, mouse_event = event)
  3337                 self.ParentWindow.RefreshDisplayMenu()
  3352                 self.ParentWindow.RefreshDisplayMenu()
  3338             else:
  3353             else:
  3339                 x, y = self.GetViewStart()
  3354                 x, y = self.GetViewStart()
  3340                 yp = max(0, min(y - rotation * 3, self.Editor.GetVirtualSize()[1] / self.Editor.GetScrollPixelsPerUnit()[1]))
  3355                 yp = max(0, min(y - rotation * 3, self.Editor.GetVirtualSize()[1] / self.Editor.GetScrollPixelsPerUnit()[1]))
  3341                 self.RefreshVisibleElements(yp = yp)
  3356                 self.RefreshVisibleElements(yp = yp)
  3342                 self.Scroll(x, yp)
  3357                 self.Scroll(x, yp)
       
  3358                 if self.Debug:
       
  3359                     self.Refresh()
  3343         
  3360         
  3344     def OnMoveWindow(self, event):
  3361     def OnMoveWindow(self, event):
  3345         self.RefreshScrollBars()
  3362         self.RefreshScrollBars()
  3346         self.RefreshVisibleElements()
  3363         self.RefreshVisibleElements()
  3347         event.Skip()
  3364         event.Skip()
  3396         if self.SelectedElement is not None and (self.SelectedElement.IsVisible() or printing):
  3413         if self.SelectedElement is not None and (self.SelectedElement.IsVisible() or printing):
  3397             self.SelectedElement.Draw(dc)
  3414             self.SelectedElement.Draw(dc)
  3398         
  3415         
  3399         if not printing:
  3416         if not printing:
  3400             if self.Debug:
  3417             if self.Debug:
       
  3418                 scalex, scaley = dc.GetUserScale()
       
  3419                 dc.SetUserScale(1, 1)
       
  3420                 
  3401                 is_action = self.TagName.split("::")[0] == "A"
  3421                 is_action = self.TagName.split("::")[0] == "A"
  3402                 text = _("Debug: %s") % self.InstancePath
  3422                 text = _("Debug: %s") % self.InstancePath
  3403                 if is_action and self.Value is not None:
  3423                 if is_action and self.Value is not None:
  3404                     text += " ("
  3424                     text += " ("
  3405                 text_offset_x, text_offset_y = self.CalcUnscrolledPosition(2, 2)
  3425                 text_offset_x, text_offset_y = self.CalcUnscrolledPosition(2, 2)
  3406                 dc.DrawText(text, 2, 2)
  3426                 dc.DrawText(text, text_offset_x, text_offset_y)
  3407                 if is_action and self.Value is not None:
  3427                 if is_action and self.Value is not None:
  3408                     value_text = self.VALUE_TRANSLATION[self.Value]
  3428                     value_text = self.VALUE_TRANSLATION[self.Value]
  3409                     tw, th = dc.GetTextExtent(text)
  3429                     tw, th = dc.GetTextExtent(text)
  3410                     if self.Value:
  3430                     if self.Value:
  3411                         dc.SetTextForeground(wx.GREEN)
  3431                         dc.SetTextForeground(wx.GREEN)
  3412                     dc.DrawText(value_text, tw + 2, 2)
  3432                     dc.DrawText(value_text, text_offset_x + tw, text_offset_y)
  3413                     if self.Value:
  3433                     if self.Value:
  3414                         dc.SetTextForeground(wx.BLACK)
  3434                         dc.SetTextForeground(wx.BLACK)
  3415                     vw, vh = dc.GetTextExtent(value_text)
  3435                     vw, vh = dc.GetTextExtent(value_text)
  3416                     dc.DrawText(")", tw + vw + 4, 2)
  3436                     dc.DrawText(")", text_offset_x + tw + vw + 2, text_offset_y)
       
  3437                 
       
  3438                 dc.SetUserScale(scalex, scaley)
       
  3439                 
  3417             if self.rubberBand.IsShown():
  3440             if self.rubberBand.IsShown():
  3418                 self.rubberBand.Draw(dc)
  3441                 self.rubberBand.Draw(dc)
  3419             dc.EndDrawing()
  3442             dc.EndDrawing()
  3420 
  3443 
  3421     def OnPaint(self, event):
  3444     def OnPaint(self, event):