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( |
|
1898 action.qualifier if action.qualifier != "" else "N") |
1898 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1899 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1899 row_height = height |
1900 row_height = height |
1900 if action.has_key("duration"): |
1901 if action.duration != "": |
1901 width, height = self.Parent.GetTextExtent(action["duration"]) |
1902 width, height = self.Parent.GetTextExtent(action.duration) |
1902 row_height = max(row_height, height) |
1903 row_height = max(row_height, height) |
1903 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1904 self.ColSize[0] = max(self.ColSize[0], width + 10) |
1904 width, height = self.Parent.GetTextExtent(action["value"]) |
1905 width, height = self.Parent.GetTextExtent(action.value) |
1905 row_height = max(row_height, height) |
1906 row_height = max(row_height, height) |
1906 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1907 self.ColSize[1] = max(self.ColSize[1], width + 10) |
1907 if action.get("indicator", "") != "": |
1908 if action.indicator != "": |
1908 width, height = self.Parent.GetTextExtent(action["indicator"]) |
1909 width, height = self.Parent.GetTextExtent(action.indicator) |
1909 row_height = max(row_height, height) |
1910 row_height = max(row_height, height) |
1910 self.ColSize[2] = max(self.ColSize[2], width + 10) |
1911 self.ColSize[2] = max(self.ColSize[2], width + 10) |
1911 min_height += row_height + 5 |
1912 min_height += row_height + 5 |
1912 if self.Parent.GetDrawingMode() == FREEDRAWING_MODE: |
1913 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])) |
1914 self.Size = wx.Size(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], max(min_height, SFC_ACTION_MIN_SIZE[1], self.Size[1])) |
1918 self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1919 self.Size = wx.Size(max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1919 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]) |
1920 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1]) |
1920 self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1921 self.MinSize = max(self.ColSize[0] + self.ColSize[1] + self.ColSize[2], |
1921 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1] |
1922 SFC_ACTION_MIN_SIZE[0]), len(self.Actions) * SFC_ACTION_MIN_SIZE[1] |
1922 self.RefreshBoundingBox() |
1923 self.RefreshBoundingBox() |
1923 if self.Input: |
1924 if self.Input is not None: |
1924 wires = self.Input.GetWires() |
1925 wires = self.Input.GetWires() |
1925 if len(wires) == 1: |
1926 if len(wires) == 1: |
1926 input_block = wires[0][0].GetOtherConnected(self.Input).GetParentBlock() |
1927 input_block = wires[0][0].GetOtherConnected(self.Input).GetParentBlock() |
1927 input_block.RefreshOutputPosition() |
1928 input_block.RefreshOutputPosition() |
1928 input_block.RefreshOutputModel(True) |
1929 input_block.RefreshOutputModel(True) |
2020 line_size = self.GetLineSize() |
2021 line_size = self.GetLineSize() |
2021 for i, action in enumerate(self.Actions): |
2022 for i, action in enumerate(self.Actions): |
2022 if i != 0: |
2023 if i != 0: |
2023 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, |
2024 dc.DrawLine(self.Pos.x, self.Pos.y + i * line_size, |
2024 self.Pos.x + self.Size[0], self.Pos.y + i * line_size) |
2025 self.Pos.x + self.Size[0], self.Pos.y + i * line_size) |
2025 qualifier_size = dc.GetTextExtent(action["qualifier"]) |
2026 qualifier_size = dc.GetTextExtent(action.qualifier) |
2026 if action.has_key("duration"): |
2027 if action.duration != "": |
2027 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
2028 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
2028 self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1]) |
2029 self.Pos.y + i * line_size + line_size / 2 - qualifier_size[1]) |
2029 duration_size = dc.GetTextExtent(action["duration"]) |
2030 duration_size = dc.GetTextExtent(action.duration) |
2030 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2, |
2031 duration_pos = (self.Pos.x + (colsize[0] - duration_size[0]) / 2, |
2031 self.Pos.y + i * line_size + line_size / 2) |
2032 self.Pos.y + i * line_size + line_size / 2) |
2032 dc.DrawText(action["duration"], duration_pos[0], duration_pos[1]) |
2033 dc.DrawText(action.duration, duration_pos[0], duration_pos[1]) |
2033 else: |
2034 else: |
2034 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
2035 qualifier_pos = (self.Pos.x + (colsize[0] - qualifier_size[0]) / 2, |
2035 self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2) |
2036 self.Pos.y + i * line_size + (line_size - qualifier_size[1]) / 2) |
2036 dc.DrawText(action["qualifier"], qualifier_pos[0], qualifier_pos[1]) |
2037 dc.DrawText(action.qualifier, qualifier_pos[0], qualifier_pos[1]) |
2037 content_size = dc.GetTextExtent(action["value"]) |
2038 content_size = dc.GetTextExtent(action.value) |
2038 content_pos = (self.Pos.x + colsize[0] + (colsize[1] - content_size[0]) / 2, |
2039 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) |
2040 self.Pos.y + i * line_size + (line_size - content_size[1]) / 2) |
2040 dc.DrawText(action["value"], content_pos[0], content_pos[1]) |
2041 dc.DrawText(action.value, content_pos[0], content_pos[1]) |
2041 if action.has_key("indicator"): |
2042 if action.indicator != "": |
2042 indicator_size = dc.GetTextExtent(action["indicator"]) |
2043 indicator_size = dc.GetTextExtent(action.indicator) |
2043 indicator_pos = (self.Pos.x + colsize[0] + colsize[1] + (colsize[2] - indicator_size[0]) / 2, |
2044 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) |
2045 self.Pos.y + i * line_size + (line_size - indicator_size[1]) / 2) |
2045 dc.DrawText(action["indicator"], indicator_pos[0], indicator_pos[1]) |
2046 dc.DrawText(action.indicator, indicator_pos[0], indicator_pos[1]) |
2046 |
2047 |
2047 if not getattr(dc, "printing", False): |
2048 if not getattr(dc, "printing", False): |
2048 action_highlights = self.Highlights.get(i, {}) |
2049 action_highlights = self.Highlights.get(i, {}) |
2049 for name, attribute_highlights in action_highlights.iteritems(): |
2050 for name, attribute_highlights in action_highlights.iteritems(): |
2050 if name == "qualifier": |
2051 if name == "qualifier": |
2051 DrawHighlightedText(dc, action["qualifier"], attribute_highlights, qualifier_pos[0], qualifier_pos[1]) |
2052 DrawHighlightedText(dc, action.qualifier, attribute_highlights, qualifier_pos[0], qualifier_pos[1]) |
2052 elif name == "duration": |
2053 elif name == "duration": |
2053 DrawHighlightedText(dc, action["duration"], attribute_highlights, duration_pos[0], duration_pos[1]) |
2054 DrawHighlightedText(dc, action.duration, attribute_highlights, duration_pos[0], duration_pos[1]) |
2054 elif name in ["reference", "inline"]: |
2055 elif name in ["reference", "inline"]: |
2055 DrawHighlightedText(dc, action["value"], attribute_highlights, content_pos[0], content_pos[1]) |
2056 DrawHighlightedText(dc, action.value, attribute_highlights, content_pos[0], content_pos[1]) |
2056 elif name == "indicator": |
2057 elif name == "indicator": |
2057 DrawHighlightedText(dc, action["indicator"], attribute_highlights, indicator_pos[0], indicator_pos[1]) |
2058 DrawHighlightedText(dc, action.indicator, attribute_highlights, indicator_pos[0], indicator_pos[1]) |
2058 |
2059 |
2059 # Draw input connector |
2060 # Draw input connector |
2060 self.Input.Draw(dc) |
2061 self.Input.Draw(dc) |
2061 |
2062 |