graphics/SFC_Objects.py
changeset 1338 c1e6c712cc35
parent 1258 441f31474b50
child 1339 6adf05c4508d
equal deleted inserted replaced
1337:204ef2daa33c 1338:c1e6c712cc35
  1892     def SetActions(self, actions):
  1892     def SetActions(self, actions):
  1893         self.Actions = actions
  1893         self.Actions = actions
  1894         self.ColSize = [0, 0, 0]
  1894         self.ColSize = [0, 0, 0]
  1895         min_height = 0
  1895         min_height = 0
  1896         for action in self.Actions:
  1896         for action in self.Actions:
  1897             width, height = self.Parent.GetTextExtent(action["qualifier"])
  1897             width, height = self.Parent.GetTextExtent(action.qualifier)
  1898             self.ColSize[0] = max(self.ColSize[0], width + 10)
  1898             self.ColSize[0] = max(self.ColSize[0], width + 10)
  1899             row_height = height
  1899             row_height = height
  1900             if action.has_key("duration"):
  1900             if action.duration is not None:
  1901                 width, height = self.Parent.GetTextExtent(action["duration"])
  1901                 width, height = self.Parent.GetTextExtent(action.duration)
  1902                 row_height = max(row_height, height)
  1902                 row_height = max(row_height, height)
  1903                 self.ColSize[0] = max(self.ColSize[0], width + 10)
  1903                 self.ColSize[0] = max(self.ColSize[0], width + 10)
  1904             width, height = self.Parent.GetTextExtent(action["value"])
  1904             width, height = self.Parent.GetTextExtent(action.value)
  1905             row_height = max(row_height, height)
  1905             row_height = max(row_height, height)
  1906             self.ColSize[1] = max(self.ColSize[1], width + 10)
  1906             self.ColSize[1] = max(self.ColSize[1], width + 10)
  1907             if action.get("indicator", "") != "":
  1907             if action.indicator is not None:
  1908                 width, height = self.Parent.GetTextExtent(action["indicator"])
  1908                 width, height = self.Parent.GetTextExtent(action.indicator)
  1909                 row_height = max(row_height, height)
  1909                 row_height = max(row_height, height)
  1910                 self.ColSize[2] = max(self.ColSize[2], width + 10)
  1910                 self.ColSize[2] = max(self.ColSize[2], width + 10)
  1911             min_height += row_height + 5
  1911             min_height += row_height + 5
  1912         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
  1912         if self.Parent.GetDrawingMode() == FREEDRAWING_MODE:
  1913             self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], max(min_height, SFC_ACTION_MIN_SIZE[1], self.Size[1]))
  1913             self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], max(min_height, SFC_ACTION_MIN_SIZE[1], self.Size[1]))
  2020         line_size = self.GetLineSize()
  2020         line_size = self.GetLineSize()
  2021         for i, action in enumerate(self.Actions):
  2021         for i, action in enumerate(self.Actions):
  2022             if i != 0:
  2022             if i != 0:
  2023                 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, 
  2023                 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, 
  2024                     self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
  2024                     self.Pos.x + self.Size[0], self.Pos.y + i * line_size)
  2025             qualifier_size = dc.GetTextExtent(action["qualifier"])
  2025             qualifier_size = dc.GetTextExtent(action.qualifier)
  2026             if action.has_key("duration"):
  2026             if action.duration is not None:
  2027                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2027                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2028                                  self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1])
  2028                                  self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1])
  2029                 duration_size = dc.GetTextExtent(action["duration"])
  2029                 duration_size = dc.GetTextExtent(action.duration)
  2030                 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2,
  2030                 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2,
  2031                                 self.Pos.y + i * line_size + line_size / 2)
  2031                                 self.Pos.y + i * line_size + line_size / 2)
  2032                 dc.DrawText(action["duration"], duration_pos[0], duration_pos[1])
  2032                 dc.DrawText(action.duration, duration_pos[0], duration_pos[1])
  2033             else:
  2033             else:
  2034                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2034                 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2,
  2035                                  self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2)
  2035                                  self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2)
  2036             dc.DrawText(action["qualifier"], qualifier_pos[0], qualifier_pos[1])
  2036             dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1])
  2037             content_size = dc.GetTextExtent(action["value"])
  2037             content_size = dc.GetTextExtent(action.value)
  2038             content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2,
  2038             content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2,
  2039                            self.Pos.y + i * line_size + (line_size - content_size[1]) / 2)
  2039                            self.Pos.y + i * line_size + (line_size - content_size[1]) / 2)
  2040             dc.DrawText(action["value"], content_pos[0], content_pos[1])
  2040             dc.DrawText(action.value, content_pos[0], content_pos[1])
  2041             if action.has_key("indicator"):
  2041             if action.indicator is not None:
  2042                 indicator_size = dc.GetTextExtent(action["indicator"])
  2042                 indicator_size = dc.GetTextExtent(action.indicator)
  2043                 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
  2043                 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2,
  2044                                  self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
  2044                                  self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2)
  2045                 dc.DrawText(action["indicator"], indicator_pos[0], indicator_pos[1])
  2045                 dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1])
  2046             
  2046             
  2047             if not getattr(dc, "printing", False):
  2047             if not getattr(dc, "printing", False):
  2048                 action_highlights = self.Highlights.get(i, {})
  2048                 action_highlights = self.Highlights.get(i, {})
  2049                 for name, attribute_highlights in action_highlights.iteritems():
  2049                 for name, attribute_highlights in action_highlights.iteritems():
  2050                     if name == "qualifier":
  2050                     if name == "qualifier":
  2051                         DrawHighlightedText(dc, action["qualifier"], attribute_highlights, qualifier_pos[0], qualifier_pos[1])
  2051                         DrawHighlightedText(dc, action.qualifier, attribute_highlights, qualifier_pos[0], qualifier_pos[1])
  2052                     elif name == "duration":
  2052                     elif name == "duration":
  2053                         DrawHighlightedText(dc, action["duration"], attribute_highlights, duration_pos[0], duration_pos[1])
  2053                         DrawHighlightedText(dc, action.duration, attribute_highlights, duration_pos[0], duration_pos[1])
  2054                     elif name in ["reference", "inline"]:
  2054                     elif name in ["reference", "inline"]:
  2055                         DrawHighlightedText(dc, action["value"], attribute_highlights, content_pos[0], content_pos[1])
  2055                         DrawHighlightedText(dc, action.value, attribute_highlights, content_pos[0], content_pos[1])
  2056                     elif name == "indicator":
  2056                     elif name == "indicator":
  2057                         DrawHighlightedText(dc, action["indicator"], attribute_highlights, indicator_pos[0], indicator_pos[1])
  2057                         DrawHighlightedText(dc, action.indicator, attribute_highlights, indicator_pos[0], indicator_pos[1])
  2058         
  2058         
  2059         # Draw input connector
  2059         # Draw input connector
  2060         self.Input.Draw(dc)
  2060         self.Input.Draw(dc)
  2061         
  2061