editors/Viewer.py
changeset 2737 38afed869ff6
parent 2704 4ba3bdc7d71f
child 2739 7278186a2083
equal deleted inserted replaced
2736:a81b72ef156c 2737:38afed869ff6
    65                    wx.StockCursor(wx.CURSOR_SIZENESW),
    65                    wx.StockCursor(wx.CURSOR_SIZENESW),
    66                    wx.StockCursor(wx.CURSOR_SIZEWE),
    66                    wx.StockCursor(wx.CURSOR_SIZEWE),
    67                    wx.StockCursor(wx.CURSOR_SIZENS)]
    67                    wx.StockCursor(wx.CURSOR_SIZENS)]
    68 
    68 
    69 
    69 
    70 def AppendMenu(parent, help, id, kind, text):
       
    71     parent.Append(help=help, id=id, kind=kind, text=text)
       
    72 
       
    73 
       
    74 if wx.Platform == '__WXMSW__':
    70 if wx.Platform == '__WXMSW__':
    75     faces = {
    71     faces = {
    76         'times': 'Times New Roman',
    72         'times': 'Times New Roman',
    77         'mono':  'Courier New',
    73         'mono':  'Courier New',
    78         'helv':  'Arial',
    74         'helv':  'Arial',
   234         return cmp(y1, y2)
   230         return cmp(y1, y2)
   235 
   231 
   236 # -------------------------------------------------------------------------------
   232 # -------------------------------------------------------------------------------
   237 #                       Graphic elements Viewer base class
   233 #                       Graphic elements Viewer base class
   238 # -------------------------------------------------------------------------------
   234 # -------------------------------------------------------------------------------
   239 
       
   240 
       
   241 # ID Constants for alignment menu items
       
   242 [
       
   243     ID_VIEWERALIGNMENTMENUITEMS0, ID_VIEWERALIGNMENTMENUITEMS1,
       
   244     ID_VIEWERALIGNMENTMENUITEMS2, ID_VIEWERALIGNMENTMENUITEMS4,
       
   245     ID_VIEWERALIGNMENTMENUITEMS5, ID_VIEWERALIGNMENTMENUITEMS6,
       
   246 ] = [wx.NewId() for _init_coll_AlignmentMenu_Items in range(6)]
       
   247 
       
   248 # ID Constants for contextual menu items
       
   249 [
       
   250     ID_VIEWERCONTEXTUALMENUITEMS0, ID_VIEWERCONTEXTUALMENUITEMS1,
       
   251     ID_VIEWERCONTEXTUALMENUITEMS2, ID_VIEWERCONTEXTUALMENUITEMS3,
       
   252     ID_VIEWERCONTEXTUALMENUITEMS5, ID_VIEWERCONTEXTUALMENUITEMS6,
       
   253     ID_VIEWERCONTEXTUALMENUITEMS8, ID_VIEWERCONTEXTUALMENUITEMS9,
       
   254     ID_VIEWERCONTEXTUALMENUITEMS11, ID_VIEWERCONTEXTUALMENUITEMS12,
       
   255     ID_VIEWERCONTEXTUALMENUITEMS14, ID_VIEWERCONTEXTUALMENUITEMS16,
       
   256     ID_VIEWERCONTEXTUALMENUITEMS17,
       
   257 ] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(13)]
       
   258 
   235 
   259 
   236 
   260 class ViewerDropTarget(wx.TextDropTarget):
   237 class ViewerDropTarget(wx.TextDropTarget):
   261 
   238 
   262     def __init__(self, parent):
   239     def __init__(self, parent):
   533     """
   510     """
   534     Class that implements a Viewer based on a wx.ScrolledWindow for drawing and
   511     Class that implements a Viewer based on a wx.ScrolledWindow for drawing and
   535     manipulating graphic elements
   512     manipulating graphic elements
   536     """
   513     """
   537 
   514 
   538     # Add list of menu items to the given menu
       
   539     def AddMenuItems(self, menu, items):
       
   540         for item in items:
       
   541             if item is None:
       
   542                 menu.AppendSeparator()
       
   543             else:
       
   544                 id, kind, text, help, callback = item
       
   545                 AppendMenu(menu, help=help, id=id, kind=kind, text=text)
       
   546                 # Link menu event to corresponding called functions
       
   547                 self.Bind(wx.EVT_MENU, callback, id=id)
       
   548 
       
   549     def AppendItem(self, menu, text, callback, *args, **kwargs):
   515     def AppendItem(self, menu, text, callback, *args, **kwargs):
   550         item = menu.Append(wx.ID_ANY, text, *args, **kwargs)
   516         item = menu.Append(wx.ID_ANY, text, *args, **kwargs)
   551         self.Bind(wx.EVT_MENU, callback, item)
   517         self.Bind(wx.EVT_MENU, callback, item)
   552         return item
   518         return item
   553 
   519