diff --git a/Container.py b/Container.py index 2e8e25a7..908d0eda 100644 --- a/Container.py +++ b/Container.py @@ -76,6 +76,11 @@ import WizardGUI import LabelGUI + RED = '#d91e1e' + GREEN = '#90ee90' + BLACK = '#000000' + BLUE = '#add8e6' + import Components if builtins.__dict__.get('GUI_FLAG',True): @@ -1184,7 +1189,7 @@ class Shape(ShapeEvtHandler): """ Shape class """ - FILL = ['#add8e6'] + FILL = [BLUE] def __init__(self, x=[], y=[]): """ Constructor @@ -2814,7 +2819,7 @@ def __init__(self, line): """ Shape.__init__(self) - self.fill = ['#d91e1e'] + self.fill = [RED] self.x = array.array('d', line.x) self.y = array.array('d', line.y) @@ -3847,7 +3852,7 @@ class ContainerBlock(Block, Diagram): """ ContainerBlock(label, inputs, outputs) """ - FILL = ['#90ee90'] + FILL = [GREEN] ### def __init__(self, label = 'ContainerBlock', nb_inputs = 1, nb_outputs = 1): @@ -4114,7 +4119,7 @@ def draw(self, dc): x,y = self.item.getPortXY('input', self.index) self.moveto(x, y) - self.fill = ['#00b400'] #GREEN + self.fill = [GREEN] dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) @@ -4185,7 +4190,7 @@ def draw(self, dc): """ x,y = self.item.getPortXY('output', self.index) self.moveto(x, y) - self.fill = ['#ff0000'] + self.fill = [RED] dc.SetFont(wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL)) #dc.SetPen(wx.Pen(wx.NamedColour('black'), 20)) @@ -4225,7 +4230,7 @@ def __init__(self, item, index, cf, t = 'rect'): """ Node.__init__(self, item, index, cf, t) - self.fill = ['#000000'] #BLACK + self.fill = [BLACK] def draw(self, dc): """ Drawing method. @@ -4325,7 +4330,7 @@ def draw(self, dc): """ CircleShape.draw(self, dc) - w,h = dc.GetTextExtent(self.label) + w,h = dc.GetTextExtent(self.label) ### label position manager if self.label_pos == 'bottom': @@ -4342,8 +4347,8 @@ def draw(self, dc): dc.DrawText(self.label, mx, my) if self.lock_flag: - img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY) - dc.DrawBitmap( img, self.x[0]+w/3, self.y[0]) + img = wx.Bitmap(os.path.join(ICON_PATH_16_16, 'lock.png'),wx.BITMAP_TYPE_ANY) + dc.DrawBitmap(img, self.x[0]+w/3, self.y[0]) def leftUp(self, event): """ Left up event has been invoked. @@ -4403,15 +4408,15 @@ def __repr__(self): #------------------------------------------------------------------ class iPort(Port): - """ IPort(label) + """ IPort(label) for ContainerBlock (coupled model) """ def __init__(self, label = 'iPort'): - """ Constructor + """ Constructor. """ Port.__init__(self, 50, 60, 100, 120, label) - self.fill= ['#add8e6'] # fill color + self.fill= [GREEN] #self.AddAttribute('id') self.label_pos = 'bottom' self.input = 0 @@ -4430,7 +4435,7 @@ def __repr__(self): #---------------------------------------------------------------- class oPort(Port): - """ OPort(label) + """ OPort(label) for ContainerBlock (coupled model) """ def __init__(self, label = 'oPort'): @@ -4438,7 +4443,7 @@ def __init__(self, label = 'oPort'): """ Port.__init__(self, 50, 60, 100, 120, label) - self.fill = ['#90ee90'] + self.fill = [RED] #self.AddAttribute('id') self.label_pos = 'bottom' self.input = 1 diff --git a/DetachedFrame.py b/DetachedFrame.py index 6f39236d..e8e4d399 100644 --- a/DetachedFrame.py +++ b/DetachedFrame.py @@ -29,8 +29,12 @@ wx.ST_SIZEGRIP = wx.STB_SIZEGRIP if __name__ == '__main__': - builtins.__dict__['DEVS_DIR_PATH_DICT'] = {'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS')} - builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = 'PyPDEVS' + builtins.__dict__['GUI_FLAG'] = True + builtins.__dict__['HOME_PATH'] = os.path.abspath(os.path.dirname(sys.argv[0])) + builtins.__dict__['DEFAULT_DEVS_DIRNAME'] = "PyDEVS" + builtins.__dict__['DEVS_DIR_PATH_DICT'] = {\ + 'PyDEVS':os.path.join(os.pardir,'DEVSKernel','PyDEVS'),\ + 'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS', 'old')} import Container import Menu @@ -61,11 +65,14 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" name=name, style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN) + self.default_style = self.GetWindowStyle() + ### local Copy self.title = title self.parent = parent self.diagram = diagram + ### current abstract level #======================================================================= if hasattr(diagram, 'layers') and hasattr(diagram, 'current_level'): @@ -100,7 +107,7 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" self.toggle_list = wx.GetApp().GetTopWindow().toggle_list else: sys.stdout.write(_('Alone mode for DetachedFrame: Connector buttons are not binded\n')) - self.toggle_list = [wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef(), wx.NewIdRef()] + self.toggle_list = [wx.NewIdRef() for i in range(6)] if wx.VERSION_STRING < '2.9': self.tools = [ toolbar.AddTool(Menu.ID_SAVE, wx.Bitmap(os.path.join(ICON_PATH,'save.png')), shortHelpString=_('Save File') ,longHelpString=_('Save the current diagram'), clientData=self.canvas), @@ -155,7 +162,6 @@ def __init__(self, parent=None, ID=wx.NewIdRef(), title="", diagram=None, name=" ID_DOWNWARD = self.toggle_list[5] if wx.VERSION_STRING < '2.9': - self.tools.append(toolbar.AddTool(ID_DOWNWARD, wx.Bitmap(os.path.join(ICON_PATH,'downward.png')), shortHelpString=_('Downward rules'), longHelpString=_('Define Downward rules atomic model'))) self.tools.append(toolbar.AddTool(ID_UPWARD, wx.Bitmap(os.path.join(ICON_PATH,'upward.png')), shortHelpString=_('Upward rules'), longHelpString=_('Define Upward rules atomic model'))) else: @@ -213,10 +219,18 @@ def __binding(self): self.Bind(wx.EVT_TOOL, self.OnSaveAsFile, id=Menu.ID_SAVEAS) self.Bind(wx.EVT_CLOSE, self.OnClose) + def OnStayOnTop(self, event): + """ + """ + + if self.GetWindowStyle()==self.default_style: + self.SetWindowStyle(wx.CLIP_CHILDREN | wx.STAY_ON_TOP) + else: + self.SetWindowStyle(self.default_style) + def OnSaveFile(self, event): """ Save button has been clicked """ - ### OnSaveFile of the mainW is activated mainW = wx.GetApp().GetTopWindow() mainW.OnSaveFile(event) @@ -283,7 +297,6 @@ def OnInit(self): import gettext - #builtins.__dict__['PYDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy1', 'bag-based':'SimStrategy2', 'direct-coupling':'SimStrategy3'} #builtins.__dict__['PYPDEVS_SIM_STRATEGY_DICT'] = {'original':'SimStrategy4', 'distributed':'SimStrategy5', 'parallel':'SimStrategy6'} @@ -302,6 +315,5 @@ def OnQuit(self, event): self.Close() if __name__ == '__main__': - app = TestApp(0) app.MainLoop() \ No newline at end of file diff --git a/Menu.py b/Menu.py index bf9c5341..702bd3a1 100644 --- a/Menu.py +++ b/Menu.py @@ -140,6 +140,9 @@ # Experiment ID_GEN_EXPERIMENT = wx.NewIdRef() +# Stay on top +ID_STAY_ON_TOP = wx.NewIdRef() + # Library popup menu identifiers ID_NEW_LIB = wx.NewIdRef() ID_IMPORT_LIB = wx.NewIdRef() @@ -825,7 +828,7 @@ def __init__(self, parent): add_constants.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'properties.png'))) preview_dia.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'print-preview.png'))) generate_experiment.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'generation.png'))) - + AppendItem = self.AppendItem if wx.VERSION_STRING < '4.0' else self.Append ### append items @@ -836,7 +839,19 @@ def __init__(self, parent): AppendItem(preview_dia) AppendItem(generate_experiment) - self.Enable(ID_PASTE_SHAPE, not Container.clipboard == []) + ### Stay on top always for the detached frame (not for diagram into devsimpy as tab of notebook) + if isinstance(self.parent.parent, wx.Frame): + if self.parent.parent.GetWindowStyle() == self.parent.parent.default_style: + stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Enable stay on top'), _('Coupled model frame stay on top')) + stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_out.png'))) + else: + stay_on_top = wx.MenuItem(self, ID_STAY_ON_TOP, _('Disable stay on top'), _('Coupled model frame not stay on top')) + stay_on_top.SetBitmap(wx.Bitmap(os.path.join(ICON_PATH_16_16,'pin_in.png'))) + + AppendItem(stay_on_top) + parent.Bind(wx.EVT_MENU, parent.parent.OnStayOnTop, id=ID_STAY_ON_TOP) + + self.Enable(ID_PASTE_SHAPE, Container.clipboard != []) ### binding parent.Bind(wx.EVT_MENU, parent.OnNewModel, id=ID_NEW_SHAPE) @@ -845,7 +860,6 @@ def __init__(self, parent): parent.Bind(wx.EVT_MENU, parent.diagram.OnAddConstants, id=ID_ADD_CONSTANTS) parent.Bind(wx.EVT_MENU, parent.parent.PrintPreview, id=ID_PREVIEW_PRINT) parent.Bind(wx.EVT_MENU, ExperimentGenerator(os.path.join(HOME_PATH,'out')).OnExperiment, id=ID_GEN_EXPERIMENT) - class ShapePopupMenu(wx.Menu): """ Shape menu class """ diff --git a/icons/16x16/pin_in.png b/icons/16x16/pin_in.png new file mode 100644 index 00000000..d5c4f390 Binary files /dev/null and b/icons/16x16/pin_in.png differ diff --git a/icons/16x16/pin_out.png b/icons/16x16/pin_out.png new file mode 100644 index 00000000..ec2a0f26 Binary files /dev/null and b/icons/16x16/pin_out.png differ diff --git a/icons/pin_in.png b/icons/pin_in.png new file mode 100644 index 00000000..14cb32be Binary files /dev/null and b/icons/pin_in.png differ diff --git a/icons/pin_out.png b/icons/pin_out.png new file mode 100644 index 00000000..7b0f8935 Binary files /dev/null and b/icons/pin_out.png differ