--- a/PLCOpenEditor.py Thu Jul 10 18:52:03 2008 +0200
+++ b/PLCOpenEditor.py Fri Jul 11 17:16:08 2008 +0200
@@ -234,24 +234,33 @@
parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_PROPERTIES,
kind=wx.ITEM_NORMAL, text=u'Properties')
+ parent.AppendSeparator()
if self.ModeSolo:
- parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_EXIT,
kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q')
-
- self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
- self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
+ else:
+ AppendMenu(parent, help='', id=wx.ID_CLOSE_ALL,
+ kind=wx.ITEM_NORMAL, text=u'Close\tCTRL+Q')
+
+ if self.ModeSolo:
+ self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW)
+ self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN)
self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
- self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
+ if self.ModeSolo:
+ self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL)
self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
- self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS)
- self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu,
- id=ID_PLCOPENEDITORFILEMENUGENERATE)
+ if self.ModeSolo:
+ self.Bind(wx.EVT_MENU, self.OnSaveProjectAsMenu, id=wx.ID_SAVEAS)
+ self.Bind(wx.EVT_MENU, self.OnGenerateProgramMenu,
+ id=ID_PLCOPENEDITORFILEMENUGENERATE)
self.Bind(wx.EVT_MENU, self.OnPageSetupMenu, id=wx.ID_PAGE_SETUP)
self.Bind(wx.EVT_MENU, self.OnPreviewMenu, id=wx.ID_PREVIEW)
self.Bind(wx.EVT_MENU, self.OnPrintMenu, id=wx.ID_PRINT)
self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES)
- self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
+ if self.ModeSolo:
+ self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT)
+ else:
+ self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_CLOSE_ALL)
def _init_coll_EditMenu_Items(self, parent):
AppendMenu(parent, help='', id=wx.ID_REFRESH,
@@ -339,12 +348,6 @@
self.SetClientSize(wx.Size(1000, 600))
self.SetMenuBar(self.MenuBar)
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
- if not self.ModeSolo:
- self.Bind(wx.EVT_MENU, self.OnCloseTabMenu, id=wx.ID_CLOSE)
- self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE)
- accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 119, wx.ID_CLOSE),
- wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, wx.ID_SAVE)])
- self.SetAcceleratorTable(accel)
if wx.VERSION >= (2, 8, 0):
self.AUIManager = wx.aui.AuiManager(self)
@@ -669,41 +672,42 @@
#-------------------------------------------------------------------------------
def RefreshFileMenu(self):
- if self.ModeSolo:
- if self.Controler.HasOpenedProject():
- selected = self.GetPageSelection()
- if selected >= 0:
- graphic_viewer = isinstance(self.GetPage(selected), Viewer)
+ if self.Controler.HasOpenedProject():
+ selected = self.GetPageSelection()
+ if selected >= 0:
+ graphic_viewer = isinstance(self.GetPage(selected), Viewer)
+ else:
+ graphic_viewer = False
+ if self.GetPageCount() > 0:
+ self.FileMenu.Enable(wx.ID_CLOSE, True)
+ if graphic_viewer:
+ self.FileMenu.Enable(wx.ID_PREVIEW, True)
+ self.FileMenu.Enable(wx.ID_PRINT, True)
else:
- graphic_viewer = False
- if self.GetPageCount() > 0:
- self.FileMenu.Enable(wx.ID_CLOSE, True)
- if graphic_viewer:
- self.FileMenu.Enable(wx.ID_PREVIEW, True)
- self.FileMenu.Enable(wx.ID_PRINT, True)
- else:
- self.FileMenu.Enable(wx.ID_PREVIEW, False)
- self.FileMenu.Enable(wx.ID_PRINT, False)
- else:
- self.FileMenu.Enable(wx.ID_CLOSE, False)
self.FileMenu.Enable(wx.ID_PREVIEW, False)
self.FileMenu.Enable(wx.ID_PRINT, False)
+ else:
+ self.FileMenu.Enable(wx.ID_CLOSE, False)
+ self.FileMenu.Enable(wx.ID_PREVIEW, False)
+ self.FileMenu.Enable(wx.ID_PRINT, False)
+ self.FileMenu.Enable(wx.ID_SAVE, True)
+ self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
+ self.FileMenu.Enable(wx.ID_PROPERTIES, True)
+ if self.ModeSolo:
self.FileMenu.Enable(wx.ID_CLOSE_ALL, True)
- self.FileMenu.Enable(wx.ID_SAVE, True)
self.FileMenu.Enable(wx.ID_SAVEAS, True)
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, True)
- self.FileMenu.Enable(wx.ID_PAGE_SETUP, True)
- self.FileMenu.Enable(wx.ID_PROPERTIES, True)
- else:
- self.FileMenu.Enable(wx.ID_CLOSE, False)
+ else:
+ self.FileMenu.Enable(wx.ID_CLOSE, False)
+ self.FileMenu.Enable(wx.ID_SAVE, False)
+ self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
+ self.FileMenu.Enable(wx.ID_PREVIEW, False)
+ self.FileMenu.Enable(wx.ID_PRINT, False)
+ self.FileMenu.Enable(wx.ID_PROPERTIES, False)
+ if self.ModeSolo:
self.FileMenu.Enable(wx.ID_CLOSE_ALL, False)
- self.FileMenu.Enable(wx.ID_SAVE, False)
self.FileMenu.Enable(wx.ID_SAVEAS, False)
self.FileMenu.Enable(ID_PLCOPENEDITORFILEMENUGENERATE, False)
- self.FileMenu.Enable(wx.ID_PAGE_SETUP, False)
- self.FileMenu.Enable(wx.ID_PREVIEW, False)
- self.FileMenu.Enable(wx.ID_PRINT, False)
- self.FileMenu.Enable(wx.ID_PROPERTIES, False)
def OnNewProjectMenu(self, event):
dialog = ProjectDialog(self)
@@ -3897,13 +3901,16 @@
wx.Printout.__init__(self)
self.Viewer = viewer
self.PageSize = page_size
+ if self.PageSize[0] == 0 or self.PageSize[1] == 0:
+ self.PageSize = (1050, 1485)
self.Preview = preview
self.Margins = margins
- self.FontSize = 14
- self.TextMargin = 5
+ self.FontSize = 5
+ self.TextMargin = 3
maxx, maxy = viewer.GetMaxSize()
- self.PageGrid = (UPPER_DIV(maxx, page_size[0]), UPPER_DIV(maxy, page_size[1]))
+ self.PageGrid = (UPPER_DIV(maxx, self.PageSize[0]),
+ UPPER_DIV(maxy, self.PageSize[1]))
def GetPageNumber(self):
return self.PageGrid[0] * self.PageGrid[1]
@@ -3919,12 +3926,12 @@
dc = self.GetDC()
if not self.Preview and isinstance(dc, wx.PostScriptDC):
dc.SetResolution(720)
- self.FontSize = 140
- self.TextMargin = 50
super(GraphicPrintout, self).OnBeginDocument(startPage, endPage)
def OnPrintPage(self, page):
dc = self.GetDC()
+ dc.SetUserScale(1.0, 1.0)
+ dc.SetDeviceOrigin(0, 0)
dc.printing = not self.Preview
# Get the size of the DC in pixels
@@ -3935,6 +3942,9 @@
Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4)
Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4)
+ fontsize = self.FontSize * Yscale
+ text_margin = self.TextMargin * Yscale
+
margin_left = self.Margins[0].x * Xscale
margin_top = self.Margins[0].y * Yscale
area_width = dw - self.Margins[1].x * Xscale - margin_left
@@ -3944,7 +3954,7 @@
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.DrawRectangle(margin_left, margin_top, area_width, area_height)
- dc.SetFont(wx.Font(self.FontSize, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
+ dc.SetFont(wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
dc.SetTextForeground(wx.BLACK)
block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:])
text_width, text_height = dc.GetTextExtent(block_name)
@@ -3961,8 +3971,8 @@
# Set the scale and origin
dc.SetDeviceOrigin(-posX + margin_left, -posY + margin_top)
+ dc.SetClippingRegion(posX, posY, self.PageSize[0] * scale, self.PageSize[1] * scale)
dc.SetUserScale(scale, scale)
- dc.SetClippingRegion(posX, posY, self.PageSize[0], self.PageSize[1])
#-------------------------------------------