42 if wx.Platform == '__WXMSW__': |
42 if wx.Platform == '__WXMSW__': |
43 faces = { 'times': 'Times New Roman', |
43 faces = { 'times': 'Times New Roman', |
44 'mono' : 'Courier New', |
44 'mono' : 'Courier New', |
45 'helv' : 'Arial', |
45 'helv' : 'Arial', |
46 'other': 'Comic Sans MS', |
46 'other': 'Comic Sans MS', |
47 'size' : 10, |
47 'size' : 20, |
48 } |
48 } |
49 else: |
49 else: |
50 faces = { 'times': 'Times', |
50 faces = { 'times': 'Times', |
51 'mono' : 'Courier', |
51 'mono' : 'Courier', |
52 'helv' : 'Helvetica', |
52 'helv' : 'Helvetica', |
53 'other': 'new century schoolbook', |
53 'other': 'new century schoolbook', |
54 'size' : 12, |
54 'size' : 20, |
55 } |
55 } |
56 |
56 |
57 #------------------------------------------------------------------------------- |
57 #------------------------------------------------------------------------------- |
58 # Graphic elements Viewer base class |
58 # Graphic elements Viewer base class |
59 #------------------------------------------------------------------------------- |
59 #------------------------------------------------------------------------------- |
315 self.SetDropTarget(ViewerDropTarget(self)) |
315 self.SetDropTarget(ViewerDropTarget(self)) |
316 |
316 |
317 dc = wx.ClientDC(self) |
317 dc = wx.ClientDC(self) |
318 self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
318 self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
319 dc.SetFont(self.Font) |
319 dc.SetFont(self.Font) |
320 width, height = dc.GetTextExtent("A") |
320 width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
321 while height > 17: |
321 while width > 260: |
322 faces["size"] -= 1 |
322 faces["size"] -= 1 |
323 self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
323 self.Font = wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
324 dc.SetFont(self.Font) |
324 dc.SetFont(self.Font) |
325 width, height = dc.GetTextExtent("A") |
325 width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
326 |
326 |
327 # Link Viewer event to corresponding methods |
327 # Link Viewer event to corresponding methods |
328 self.Bind(wx.EVT_PAINT, self.OnPaint) |
328 self.Bind(wx.EVT_PAINT, self.OnPaint) |
329 self.Bind(wx.EVT_LEFT_DOWN, self.OnViewerLeftDown) |
329 self.Bind(wx.EVT_LEFT_DOWN, self.OnViewerLeftDown) |
330 self.Bind(wx.EVT_LEFT_UP, self.OnViewerLeftUp) |
330 self.Bind(wx.EVT_LEFT_UP, self.OnViewerLeftUp) |