762 |
762 |
763 self.ElementRefreshList = [] |
763 self.ElementRefreshList = [] |
764 self.ElementRefreshList_lock = Lock() |
764 self.ElementRefreshList_lock = Lock() |
765 |
765 |
766 dc = wx.ClientDC(self.Editor) |
766 dc = wx.ClientDC(self.Editor) |
767 font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) |
767 while True: |
768 dc.SetFont(font) |
|
769 width, _height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
|
770 while width > 260: |
|
771 faces["size"] -= 1 |
|
772 font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) |
768 font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["mono"]) |
773 dc.SetFont(font) |
769 dc.SetFont(font) |
774 width, _height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
770 width, _height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
775 self.SetFont(font) |
771 if width < 260: |
|
772 break |
|
773 faces["size"] -= 1 |
|
774 self.Editor.SetFont(font) |
776 self.MiniTextDC = wx.MemoryDC(wx.EmptyBitmap(1, 1)) |
775 self.MiniTextDC = wx.MemoryDC(wx.EmptyBitmap(1, 1)) |
777 self.MiniTextDC.SetFont(wx.Font(faces["size"] * 0.75, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["helv"])) |
776 self.MiniTextDC.SetFont(wx.Font(faces["size"] * 0.75, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName=faces["helv"])) |
778 |
777 |
779 self.CurrentScale = None |
778 self.CurrentScale = None |
780 self.SetScale(ZOOM_FACTORS.index(1.0), False) |
779 self.SetScale(ZOOM_FACTORS.index(1.0), False) |
2657 connection = FBD_Connector(self, values["type"], values["name"], id) |
2656 connection = FBD_Connector(self, values["type"], values["name"], id) |
2658 self.Controler.AddEditedElementConnection(self.TagName, id, values["type"]) |
2657 self.Controler.AddEditedElementConnection(self.TagName, id, values["type"]) |
2659 self.AddNewElement(connection, bbox, wire) |
2658 self.AddNewElement(connection, bbox, wire) |
2660 |
2659 |
2661 def AddNewComment(self, bbox): |
2660 def AddNewComment(self, bbox): |
2662 dialog = wx.TextEntryDialog(self.ParentWindow, |
2661 dialog = CommentEditDialog(self.ParentWindow, |
2663 _("Edit comment"), |
2662 self.GetFont()) |
2664 _("Please enter comment text"), |
|
2665 "", wx.OK | wx.CANCEL | wx.TE_MULTILINE) |
|
2666 dialog.SetClientSize(wx.Size(400, 200)) |
|
2667 if dialog.ShowModal() == wx.ID_OK: |
2663 if dialog.ShowModal() == wx.ID_OK: |
2668 value = dialog.GetValue() |
2664 value = dialog.GetValue() |
2669 id = self.GetNewId() |
2665 id = self.GetNewId() |
2670 comment = Comment(self, value, id) |
2666 comment = Comment(self, value, id) |
2671 comment.SetPosition(bbox.x, bbox.y) |
2667 comment.SetPosition(bbox.x, bbox.y) |
3099 self.RefreshVisibleElements() |
3095 self.RefreshVisibleElements() |
3100 actionblock.Refresh(rect) |
3096 actionblock.Refresh(rect) |
3101 dialog.Destroy() |
3097 dialog.Destroy() |
3102 |
3098 |
3103 def EditCommentContent(self, comment): |
3099 def EditCommentContent(self, comment): |
3104 dialog = wx.TextEntryDialog(self.ParentWindow, |
3100 dialog = CommentEditDialog(self.ParentWindow, |
3105 _("Edit comment"), |
3101 self.GetFont(), |
3106 _("Please enter comment text"), |
3102 comment.GetContent(), |
3107 comment.GetContent(), |
3103 comment.GetSize()) |
3108 wx.OK | wx.CANCEL | wx.TE_MULTILINE) |
|
3109 width, height = comment.GetSize() |
|
3110 dialogSize = wx.Size(max(width + 30, 400), max(height + 60, 200)) |
|
3111 dialog.SetClientSize(dialogSize) |
|
3112 if dialog.ShowModal() == wx.ID_OK: |
3104 if dialog.ShowModal() == wx.ID_OK: |
3113 value = dialog.GetValue() |
3105 value = dialog.GetValue() |
3114 rect = comment.GetRedrawRect(1, 1) |
3106 rect = comment.GetRedrawRect(1, 1) |
3115 comment.SetContent(value) |
3107 comment.SetContent(value) |
3116 comment.SetSize(*self.GetScaledSize(*comment.GetSize())) |
3108 comment.SetSize(*self.GetScaledSize(*comment.GetSize())) |
3563 |
3555 |
3564 self.SearchParams = search_params |
3556 self.SearchParams = search_params |
3565 self.SearchResults = [] |
3557 self.SearchResults = [] |
3566 blocks = [] |
3558 blocks = [] |
3567 for infos, start, end, _text in self.Controler.SearchInPou(self.TagName, search_params, self.Debug): |
3559 for infos, start, end, _text in self.Controler.SearchInPou(self.TagName, search_params, self.Debug): |
3568 if (infos[0] == self.TagName or self.TagName.split("::")[0] in ['A', 'T']) and infos[1] is not 'name': |
3560 if (infos[0] == self.TagName or self.TagName.split("::")[0] in ['A', 'T']) and infos[1] != 'name': |
3569 if infos[1] in ["var_local", "var_input", "var_output", "var_inout"]: |
3561 if infos[1] in ["var_local", "var_input", "var_output", "var_inout"]: |
3570 self.SearchResults.append((infos[1:], start, end, SEARCH_RESULT_HIGHLIGHT)) |
3562 self.SearchResults.append((infos[1:], start, end, SEARCH_RESULT_HIGHLIGHT)) |
3571 else: |
3563 else: |
3572 block = self.Blocks.get(infos[2]) |
3564 block = self.Blocks.get(infos[2]) |
3573 if block is not None: |
3565 if block is not None: |
3715 dc.DrawRectangle(1, 1, width, height) |
3707 dc.DrawRectangle(1, 1, width, height) |
3716 if self.PageSize is not None and not printing: |
3708 if self.PageSize is not None and not printing: |
3717 dc.SetPen(self.PagePen) |
3709 dc.SetPen(self.PagePen) |
3718 xstart, ystart = self.GetViewStart() |
3710 xstart, ystart = self.GetViewStart() |
3719 window_size = self.Editor.GetClientSize() |
3711 window_size = self.Editor.GetClientSize() |
3720 for x in xrange(self.PageSize[0] - (xstart * SCROLLBAR_UNIT) % self.PageSize[0], int(window_size[0] / self.ViewScale[0]), self.PageSize[0]): |
3712 if self.PageSize[0] != 0: |
3721 dc.DrawLine(xstart * SCROLLBAR_UNIT + x + 1, int(ystart * SCROLLBAR_UNIT / self.ViewScale[0]), |
3713 for x in xrange(self.PageSize[0] - (xstart * SCROLLBAR_UNIT) % self.PageSize[0], int(window_size[0] / self.ViewScale[0]), self.PageSize[0]): |
3722 xstart * SCROLLBAR_UNIT + x + 1, int((ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[0])) |
3714 dc.DrawLine(xstart * SCROLLBAR_UNIT + x + 1, int(ystart * SCROLLBAR_UNIT / self.ViewScale[0]), |
3723 for y in xrange(self.PageSize[1] - (ystart * SCROLLBAR_UNIT) % self.PageSize[1], int(window_size[1] / self.ViewScale[1]), self.PageSize[1]): |
3715 xstart * SCROLLBAR_UNIT + x + 1, int((ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[0])) |
3724 dc.DrawLine(int(xstart * SCROLLBAR_UNIT / self.ViewScale[0]), ystart * SCROLLBAR_UNIT + y + 1, |
3716 if self.PageSize[1] != 0: |
3725 int((xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[1]), ystart * SCROLLBAR_UNIT + y + 1) |
3717 for y in xrange(self.PageSize[1] - (ystart * SCROLLBAR_UNIT) % self.PageSize[1], int(window_size[1] / self.ViewScale[1]), self.PageSize[1]): |
|
3718 dc.DrawLine(int(xstart * SCROLLBAR_UNIT / self.ViewScale[0]), ystart * SCROLLBAR_UNIT + y + 1, |
|
3719 int((xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[1]), ystart * SCROLLBAR_UNIT + y + 1) |
3726 |
3720 |
3727 # Draw all elements |
3721 # Draw all elements |
3728 for comment in self.Comments.itervalues(): |
3722 for comment in self.Comments.itervalues(): |
3729 if comment != self.SelectedElement and (comment.IsVisible() or printing): |
3723 if comment != self.SelectedElement and (comment.IsVisible() or printing): |
3730 comment.Draw(dc) |
3724 comment.Draw(dc) |