22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 from __future__ import absolute_import |
26 from __future__ import absolute_import |
|
27 from __future__ import division |
27 from datetime import datetime |
28 from datetime import datetime |
28 from time import time as gettime |
29 from time import time as gettime |
29 from weakref import proxy |
30 from weakref import proxy |
30 |
31 |
31 import numpy |
32 import numpy |
32 import wx |
33 import wx |
|
34 from six.moves import xrange |
33 |
35 |
34 from controls.CustomToolTip import CustomToolTip, TOOLTIP_WAIT_PERIOD |
36 from controls.CustomToolTip import CustomToolTip, TOOLTIP_WAIT_PERIOD |
35 from editors.DebugViewer import DebugViewer, REFRESH_PERIOD |
37 from editors.DebugViewer import DebugViewer, REFRESH_PERIOD |
36 from runtime.loglevels import LogLevelsCount, LogLevels |
38 from runtime.loglevels import LogLevelsCount, LogLevels |
37 from util.BitmapLibrary import GetBitmap |
39 from util.BitmapLibrary import GetBitmap |
41 |
43 |
42 |
44 |
43 def ArrowPoints(direction, width, height, xoffset, yoffset): |
45 def ArrowPoints(direction, width, height, xoffset, yoffset): |
44 if direction == wx.TOP: |
46 if direction == wx.TOP: |
45 return [wx.Point(xoffset + 1, yoffset + height - 2), |
47 return [wx.Point(xoffset + 1, yoffset + height - 2), |
46 wx.Point(xoffset + width / 2, yoffset + 1), |
48 wx.Point(xoffset + width // 2, yoffset + 1), |
47 wx.Point(xoffset + width - 1, yoffset + height - 2)] |
49 wx.Point(xoffset + width - 1, yoffset + height - 2)] |
48 else: |
50 else: |
49 return [wx.Point(xoffset + 1, yoffset - height + 1), |
51 return [wx.Point(xoffset + 1, yoffset - height + 1), |
50 wx.Point(xoffset + width / 2, yoffset - 2), |
52 wx.Point(xoffset + width // 2, yoffset - 2), |
51 wx.Point(xoffset + width - 1, yoffset - height + 1)] |
53 wx.Point(xoffset + width - 1, yoffset - height + 1)] |
52 |
54 |
53 |
55 |
54 class LogScrollBar(wx.Panel): |
56 class LogScrollBar(wx.Panel): |
55 |
57 |
122 _posx, posy = event.GetPosition() |
124 _posx, posy = event.GetPosition() |
123 range_rect = self.GetRangeRect() |
125 range_rect = self.GetRangeRect() |
124 thumb_size = range_rect.height * THUMB_SIZE_RATIO |
126 thumb_size = range_rect.height * THUMB_SIZE_RATIO |
125 thumb_range = range_rect.height - thumb_size |
127 thumb_range = range_rect.height - thumb_size |
126 self.RefreshThumbPosition( |
128 self.RefreshThumbPosition( |
127 max(-1., min((posy - self.ThumbScrollingStartPos.y) * 2. / thumb_range, 1.))) |
129 max(-1., min((posy - self.ThumbScrollingStartPos.y) * 2. // thumb_range, 1.))) |
128 event.Skip() |
130 event.Skip() |
129 |
131 |
130 def OnResize(self, event): |
132 def OnResize(self, event): |
131 self.Refresh() |
133 self.Refresh() |
132 event.Skip() |
134 event.Skip() |
144 width, height = self.GetClientSize() |
146 width, height = self.GetClientSize() |
145 |
147 |
146 gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3)) |
148 gc.SetPen(wx.Pen(wx.NamedColour("GREY"), 3)) |
147 gc.SetBrush(wx.GREY_BRUSH) |
149 gc.SetBrush(wx.GREY_BRUSH) |
148 |
150 |
149 gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 - 3)) |
151 gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 - 3)) |
150 gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) / 4 + 3)) |
152 gc.DrawLines(ArrowPoints(wx.TOP, width * 0.75, width * 0.5, 2, (width + height) // 4 + 3)) |
151 |
153 |
152 gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 + 3)) |
154 gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 + 3)) |
153 gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) / 4 - 3)) |
155 gc.DrawLines(ArrowPoints(wx.BOTTOM, width * 0.75, width * 0.5, 2, (height * 3 - width) // 4 - 3)) |
154 |
156 |
155 thumb_rect = self.GetThumbRect() |
157 thumb_rect = self.GetThumbRect() |
156 exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y, |
158 exclusion_rect = wx.Rect(thumb_rect.x, thumb_rect.y, |
157 thumb_rect.width, thumb_rect.height) |
159 thumb_rect.width, thumb_rect.height) |
158 if self.Parent.IsMessagePanelTop(): |
160 if self.Parent.IsMessagePanelTop(): |
220 dc.DrawRectangle(self.Position.x, self.Position.y, |
222 dc.DrawRectangle(self.Position.x, self.Position.y, |
221 self.Size.width, self.Size.height) |
223 self.Size.width, self.Size.height) |
222 |
224 |
223 w, h = dc.GetTextExtent(self.Label) |
225 w, h = dc.GetTextExtent(self.Label) |
224 dc.DrawText(self.Label, |
226 dc.DrawText(self.Label, |
225 self.Position.x + (self.Size.width - w) / 2, |
227 self.Position.x + (self.Size.width - w) // 2, |
226 self.Position.y + (self.Size.height - h) / 2) |
228 self.Position.y + (self.Size.height - h) // 2) |
227 |
229 |
228 |
230 |
229 DATE_INFO_SIZE = 10 |
231 DATE_INFO_SIZE = 10 |
230 MESSAGE_INFO_SIZE = 18 |
232 MESSAGE_INFO_SIZE = 18 |
231 |
233 |
257 |
259 |
258 def Draw(self, dc, offset, width, draw_date): |
260 def Draw(self, dc, offset, width, draw_date): |
259 if draw_date: |
261 if draw_date: |
260 datetime_text = self.Date.strftime("%d/%m/%y %H:%M") |
262 datetime_text = self.Date.strftime("%d/%m/%y %H:%M") |
261 dw, dh = dc.GetTextExtent(datetime_text) |
263 dw, dh = dc.GetTextExtent(datetime_text) |
262 dc.DrawText(datetime_text, (width - dw) / 2, offset + (DATE_INFO_SIZE - dh) / 2) |
264 dc.DrawText(datetime_text, (width - dw) // 2, offset + (DATE_INFO_SIZE - dh) // 2) |
263 offset += DATE_INFO_SIZE |
265 offset += DATE_INFO_SIZE |
264 |
266 |
265 seconds_text = "%12.9f" % self.Seconds |
267 seconds_text = "%12.9f" % self.Seconds |
266 sw, sh = dc.GetTextExtent(seconds_text) |
268 sw, sh = dc.GetTextExtent(seconds_text) |
267 dc.DrawText(seconds_text, 5, offset + (MESSAGE_INFO_SIZE - sh) / 2) |
269 dc.DrawText(seconds_text, 5, offset + (MESSAGE_INFO_SIZE - sh) // 2) |
268 |
270 |
269 bw, bh = self.LevelBitmap.GetWidth(), self.LevelBitmap.GetHeight() |
271 bw, bh = self.LevelBitmap.GetWidth(), self.LevelBitmap.GetHeight() |
270 dc.DrawBitmap(self.LevelBitmap, 10 + sw, offset + (MESSAGE_INFO_SIZE - bh) / 2) |
272 dc.DrawBitmap(self.LevelBitmap, 10 + sw, offset + (MESSAGE_INFO_SIZE - bh) // 2) |
271 |
273 |
272 text = self.Message.replace("\n", " ") |
274 text = self.Message.replace("\n", " ") |
273 _mw, mh = dc.GetTextExtent(text) |
275 _mw, mh = dc.GetTextExtent(text) |
274 dc.DrawText(text, 15 + sw + bw, offset + (MESSAGE_INFO_SIZE - mh) / 2) |
276 dc.DrawText(text, 15 + sw + bw, offset + (MESSAGE_INFO_SIZE - mh) // 2) |
275 |
277 |
276 def GetHeight(self, draw_date): |
278 def GetHeight(self, draw_date): |
277 if draw_date: |
279 if draw_date: |
278 return DATE_INFO_SIZE + MESSAGE_INFO_SIZE |
280 return DATE_INFO_SIZE + MESSAGE_INFO_SIZE |
279 return MESSAGE_INFO_SIZE |
281 return MESSAGE_INFO_SIZE |
609 self.RefreshView() |
611 self.RefreshView() |
610 |
612 |
611 def ScrollMessagePanelByPage(self, page): |
613 def ScrollMessagePanelByPage(self, page): |
612 if self.CurrentMessage is not None: |
614 if self.CurrentMessage is not None: |
613 _width, height = self.MessagePanel.GetClientSize() |
615 _width, height = self.MessagePanel.GetClientSize() |
614 message_per_page = max(1, (height - DATE_INFO_SIZE) / MESSAGE_INFO_SIZE - 1) |
616 message_per_page = max(1, (height - DATE_INFO_SIZE) // MESSAGE_INFO_SIZE - 1) |
615 self.ScrollMessagePanel(page * message_per_page) |
617 self.ScrollMessagePanel(page * message_per_page) |
616 |
618 |
617 def ScrollMessagePanelByTimestamp(self, seconds): |
619 def ScrollMessagePanelByTimestamp(self, seconds): |
618 if self.CurrentMessage is not None: |
620 if self.CurrentMessage is not None: |
619 current_message = self.LogMessages[self.CurrentMessage] |
621 current_message = self.LogMessages[self.CurrentMessage] |
754 self.LastMousePos = None |
756 self.LastMousePos = None |
755 self.MessageToolTipTimer.Stop() |
757 self.MessageToolTipTimer.Stop() |
756 event.Skip() |
758 event.Skip() |
757 |
759 |
758 def OnMessagePanelMouseWheel(self, event): |
760 def OnMessagePanelMouseWheel(self, event): |
759 self.ScrollMessagePanel(event.GetWheelRotation() / event.GetWheelDelta()) |
761 self.ScrollMessagePanel(event.GetWheelRotation() // event.GetWheelDelta()) |
760 event.Skip() |
762 event.Skip() |
761 |
763 |
762 def OnMessagePanelEraseBackground(self, event): |
764 def OnMessagePanelEraseBackground(self, event): |
763 pass |
765 pass |
764 |
766 |