464 if plugin is not None: |
469 if plugin is not None: |
465 old_window = self.PluginTree.GetItemWindow(root) |
470 old_window = self.PluginTree.GetItemWindow(root) |
466 if old_window is not None: |
471 if old_window is not None: |
467 old_window.GetSizer().Clear(True) |
472 old_window.GetSizer().Clear(True) |
468 old_window.Destroy() |
473 old_window.Destroy() |
469 |
|
470 window = wx.Panel(self.PluginTree, -1, size=wx.Size(-1, -1)) |
|
471 window.SetBackgroundColour(wx.WHITE) |
|
472 tcsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
473 |
474 |
|
475 outside = wx.Panel(self.PluginTree, -1, size=wx.Size(-1, -1)) |
|
476 outside.SetBackgroundColour(wx.WHITE) |
|
477 |
|
478 insidesizer = wx.FlexGridSizer(cols=1,rows=1) |
|
479 insidesizer.AddGrowableCol(0) |
|
480 |
|
481 outside.SetSizer(insidesizer) |
|
482 |
|
483 window = wx.Panel(outside, -1, size=wx.Size(-1, -1)) |
|
484 window.SetBackgroundColour(wx.Colour(250,250,255)) |
|
485 insidesizer.AddWindow(window, border=1, flag=wx.GROW|wx.ALL) |
|
486 |
|
487 tcsizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0) |
|
488 |
474 if "channel" in infos: |
489 if "channel" in infos: |
475 sc = wx.SpinCtrl(window, -1, size=wx.Size(50, 25)) |
490 sc = wx.SpinCtrl(window, -1, size=wx.Size(50, 25)) |
476 sc.SetValue(infos["channel"]) |
491 sc.SetValue(infos["channel"]) |
477 sc.Bind(wx.EVT_SPINCTRL, self.GetItemChannelChangedFunction(root)) |
492 sc.Bind(wx.EVT_SPINCTRL, self.GetItemChannelChangedFunction(root)) |
478 tcsizer.AddWindow(sc, 0, border=5, flag=wx.LEFT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
493 tcsizer.AddWindow(sc, 0, border=5, flag=wx.LEFT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
|
494 |
|
495 bsizer = wx.BoxSizer(wx.HORIZONTAL) |
479 |
496 |
480 if "parent" in infos or plugin == self.PluginRoot: |
497 if "parent" in infos or plugin == self.PluginRoot: |
481 addbutton_id = wx.NewId() |
498 addbutton_id = wx.NewId() |
482 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add24x24.png')), |
499 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Add24x24.png')), |
483 name='AddBusButton', parent=window, pos=wx.Point(0, 0), |
500 name='AddBusButton', parent=window, pos=wx.Point(0, 0), |
484 size=wx.Size(24, 24), style=wx.NO_BORDER) |
501 size=wx.Size(24, 24), style=wx.NO_BORDER) |
485 addbutton.SetToolTipString("Add a plugin to this one") |
502 addbutton.SetToolTipString("Add a plugin to this one") |
486 addbutton.Bind(wx.EVT_BUTTON, self.GetAddButtonFunction(root, window), id=addbutton_id) |
503 addbutton.Bind(wx.EVT_BUTTON, self.GetAddButtonFunction(root, window), id=addbutton_id) |
487 tcsizer.AddWindow(addbutton, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
504 bsizer.AddWindow(addbutton, 0, border=5, flag=wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
488 |
505 |
489 if plugin != self.PluginRoot: |
506 if plugin != self.PluginRoot: |
490 deletebutton_id = wx.NewId() |
507 deletebutton_id = wx.NewId() |
491 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete24x24.png')), |
508 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(os.path.join(CWD, 'images', 'Delete24x24.png')), |
492 name='DeleteBusButton', parent=window, pos=wx.Point(0, 0), |
509 name='DeleteBusButton', parent=window, pos=wx.Point(0, 0), |
493 size=wx.Size(24, 24), style=wx.NO_BORDER) |
510 size=wx.Size(24, 24), style=wx.NO_BORDER) |
494 deletebutton.SetToolTipString("Delete this plugin") |
511 deletebutton.SetToolTipString("Delete this plugin") |
495 deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(root), id=deletebutton_id) |
512 deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(root), id=deletebutton_id) |
496 tcsizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
513 bsizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.TOP|wx.BOTTOM|wx.ALIGN_CENTER) |
497 |
514 |
|
515 plugin_infos = plugin.GetParamsAttributes() |
|
516 |
498 psizer = wx.BoxSizer(wx.HORIZONTAL) |
517 psizer = wx.BoxSizer(wx.HORIZONTAL) |
499 plugin_infos = plugin.GetParamsAttributes() |
518 self.RefreshSizerElement(window, psizer, plugin_infos, None, True, root) |
500 |
519 |
501 sizer = wx.BoxSizer(wx.HORIZONTAL) |
520 msizer = wx.BoxSizer(wx.VERTICAL) |
502 self.RefreshSizerElement(window, sizer, plugin_infos, None, True, root) |
521 msizer.AddSizer(bsizer, 0, border=0, flag=wx.GROW) |
503 if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0: |
522 if plugin != self.PluginRoot and len(plugin.PluginMethods) > 0: |
504 for plugin_method in plugin.PluginMethods: |
523 for plugin_method in plugin.PluginMethods: |
505 if "method" in plugin_method: |
524 if "method" in plugin_method: |
506 id = wx.NewId() |
525 id = wx.NewId() |
507 if "bitmap" in plugin_method: |
526 button = wx.lib.buttons.GenBitmapTextButton(id=id, parent=window, |
508 button = wx.lib.buttons.GenBitmapTextButton(id=id, parent=window, |
527 bitmap=wx.Bitmap(os.path.join(CWD, "%s24x24.png"%plugin_method.get("bitmap", os.path.join("images", "RunMethod")))), label=plugin_method["name"], |
509 bitmap=wx.Bitmap(os.path.join(CWD, "%s24x24.png"%plugin_method["bitmap"])), label=plugin_method["name"], |
528 name=plugin_method["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
510 name=plugin_method["name"], pos=wx.Point(0, 0), style=wx.BU_EXACTFIT|wx.NO_BORDER) |
|
511 else: |
|
512 button = wx.Button(id=id, label=plugin_method["name"], |
|
513 name=plugin_method["name"], parent=window, |
|
514 pos=wx.Point(0, 0), style=wx.BU_EXACTFIT) |
|
515 button.SetToolTipString(plugin_method["tooltip"]) |
529 button.SetToolTipString(plugin_method["tooltip"]) |
516 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id) |
530 button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id) |
517 sizer.AddWindow(button, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
531 msizer.AddWindow(button, 0, border=5, flag=wx.RIGHT) |
518 tcsizer.AddSizer(sizer, 0, border=0, flag=wx.GROW) |
532 tcsizer.AddSizer(msizer, 0, border=0, flag=wx.ALIGN_CENTER_VERTICAL) |
|
533 tcsizer.AddSizer(psizer, 0, border=0, flag=wx.GROW) |
|
534 if plugin == self.PluginRoot: |
|
535 tcsizer.AddGrowableCol(0) |
|
536 else: |
|
537 tcsizer.AddGrowableCol(1) |
|
538 |
519 window.SetSizer(tcsizer) |
539 window.SetSizer(tcsizer) |
520 tcsizer.Fit(window) |
540 insidesizer.Fit(outside) |
521 self.PluginTree.SetItemWindow(root, window) |
541 self.PluginTree.SetItemWindow(root, outside) |
522 if "enabled" in infos: |
542 if "enabled" in infos: |
523 self.PluginTree.CheckItem(root, infos["enabled"]) |
543 self.PluginTree.CheckItem(root, infos["enabled"]) |
524 self.PluginTree.SetItemWindowEnabled(root, infos["enabled"]) |
544 self.PluginTree.SetItemWindowEnabled(root, infos["enabled"]) |
525 |
545 |
526 item, root_cookie = self.PluginTree.GetFirstChild(root) |
546 item, root_cookie = self.PluginTree.GetFirstChild(root) |
527 for values in infos["values"]: |
547 for values in infos["values"]: |
528 if item is None or not item.IsOk(): |
548 if item is None or not item.IsOk(): |
529 if wx.VERSION >= (2, 8, 0): |
549 item = self.PluginTree.AppendItem(root, "") |
530 item = self.PluginTree.AppendItem(root, "", ct_type=1) |
550 # 2.6.x returns bad item on gtk |
531 else: |
|
532 item = self.PluginTree.AppendItem(root, "") |
|
533 |
|
534 if wx.Platform != '__WXMSW__' or wx.VERSION >= (2, 8, 0): |
551 if wx.Platform != '__WXMSW__' or wx.VERSION >= (2, 8, 0): |
535 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
552 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
536 self.GenerateTreeBranch(item, values) |
553 self.GenerateTreeBranch(item, values) |
537 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
554 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
538 while item is not None and item.IsOk(): |
555 while item is not None and item.IsOk(): |
539 to_delete.append(item) |
556 to_delete.append(item) |
540 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
557 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
541 for item in to_delete: |
558 for item in to_delete: |
542 self.PluginTree.Delete(item) |
559 self.PluginTree.Delete(item) |
|
560 |
|
561 MustRecalTreeSizes = False |
|
562 def OnPluginTreeResize(self,event): |
|
563 self.ResizePluginTreeWindow() |
|
564 event.Skip() |
|
565 |
|
566 def OnPluginTreeIdle(self,event): |
|
567 if self.MustRecalTreeSizes: |
|
568 event.RequestMore() |
|
569 self.ResizePluginTreeWindow() |
|
570 event.Skip() |
|
571 |
|
572 def ResizePluginTreeWindow(self): |
|
573 if getattr(self, "PluginRoot", None): |
|
574 root = self.PluginTree.GetRootItem() |
|
575 if root is not None and root.IsOk(): |
|
576 self.ResizePluginTreeWindow_r(root) |
|
577 self.MustRecalTreeSizes = False |
|
578 |
|
579 def ResizePluginTreeWindow_r(self, root): |
|
580 window = self.PluginTree.GetItemWindow(root) |
|
581 pos = window.GetPosition() |
|
582 sz = self.PluginTree.GetClientSize() |
|
583 window.SetSize(wx.Size(sz.width - pos.x, -1)) |
|
584 item, root_cookie = self.PluginTree.GetFirstChild(root) |
|
585 while item is not None and item.IsOk(): |
|
586 self.ResizePluginTreeWindow_r(item) |
|
587 item, root_cookie = self.PluginTree.GetNextChild(root, root_cookie) |
|
588 |
|
589 |
543 |
590 |
544 def GetSelectedPluginName(self, selected = None): |
591 def GetSelectedPluginName(self, selected = None): |
545 if selected is None: |
592 if selected is None: |
546 selected = self.PluginTree.GetSelection() |
593 selected = self.PluginTree.GetSelection() |
547 if selected is None or not selected.IsOk(): |
594 if selected is None or not selected.IsOk(): |