示例#1
0
 def NewGroup(self, group=None, layout=False):
     if group is None:
         while "%s %s" % (self.L["GROUP_NEW"],
                          self.newGroupIndex) in self.Groups:
             self.newGroupIndex += 1
         group = "%s %s" % (self.L["GROUP_NEW"], self.newGroupIndex)
     else:
         if group in self.Groups:
             return group
     panel = UI.BaseControl(self.Inner)
     title = GroupTitle(self.Inner, group)
     groupSizer = wx.WrapSizer()
     btnAdd = UI.Button(panel,
                        size=wx.Size(36, 36),
                        pic=self.R["MANAGE_ADD"],
                        func=None,
                        edge=None,
                        res="L")
     groupSizer.Add(btnAdd, SF_ITEM)
     btnDel = UI.Button(panel,
                        size=wx.Size(36, 36),
                        pic=self.R["MANAGE_DEL"],
                        func=(self.DelGroup, title),
                        edge=None,
                        res="L")
     groupSizer.Add(btnDel, SF_ITEM)
     panel.SetSizer(groupSizer)
     self.Inner.GetSizer().AddMany(((title, SF_TITLE), (panel, SF_PANEL)))
     self.Groups[group] = {
         "TITLE": title,
         "PANEL": panel,
         "ADD": btnAdd,
         "DEL": btnDel
     }
     if self["NEW"]:
         self.Inner.GetSizer().Detach(self["NEW"])
         self.Inner.GetSizer().Add(self["NEW"], SF_NEW)
     if layout:
         self.OnArrangement()
     return group
示例#2
0
    def __init__(self, r, s, l, m):
        super().__init__(parent=None,
                         title=l["TITLE"],
                         pos=s["LAST_POS"],
                         size=s["LAST_SIZE"],
                         style=wx.DEFAULT_FRAME_STYLE
                         | wx.FULL_REPAINT_ON_RESIZE)
        self.R = r
        self.S = s
        self.L = l
        self.M = m
        self.D = {}
        self.T = {
            "LAST_FILE": "",
        }

        self.SetStatus = UI.DoNothing
        self.SetDoubleBuffered(True)
        self.SetMinSize(wx.Size(800, 600))
        self.SetIcon(self.R["__LabPype__"])
        self.SetFont(self.R["FONT_N"])
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        if self.S["MAXIMIZED"]:
            self.Maximize()

        self.Tool = UI.Tool(self, edge=("", "B"))
        self.Info = UI.Info(self, edge=("T", ""))
        self.Gadget = Gadget(self, size=wx.Size(self.S["WIDTH_GADGET"], -1))
        self.Canvas = Canvas(self)
        self.Harbor = Harbor(self, size=wx.Size(self.S["WIDTH_HARBOR"], -1))
        self.Manage = None

        self.Center = UI.BaseControl(self,
                                     size=wx.Size(-1, self.S["HEIGHT_CENTER"]),
                                     edge=("LR", ""))
        self.Record = Record(self.Center)

        self.SashC = UI.Sash(self,
                             target=self.Center,
                             direction="B",
                             vRange=(0, 250),
                             edge=("LR", "T"))
        self.SashL = UI.Sash(self,
                             target=self.Gadget,
                             direction="L",
                             vRange=(0, 384),
                             edge=("T", "RB"))
        self.SashR = UI.Sash(self,
                             target=self.Harbor,
                             direction="R",
                             vRange=(0, 600),
                             edge=("T", "LB"))
        self.HiderC = UI.Hider(self,
                               targets=(self.Center, self.SashC),
                               orientation="H",
                               edge=("LR", "B"))
        self.HiderL = UI.Hider(self,
                               targets=(self.Gadget, self.SashL),
                               edge="H")
        self.HiderR = UI.Hider(self,
                               targets=(self.Harbor, self.SashR),
                               edge="H")
        self.HiderC.SetTip(self.SetStatus, self.L["HIDER_CENTER"])
        self.HiderL.SetTip(self.SetStatus, self.L["HIDER_GADGET"])
        self.HiderR.SetTip(self.SetStatus, self.L["HIDER_HARBOR"])

        self.AcceleratorEntries = []
        for flags, keyCode, func in (
            (wx.ACCEL_NORMAL, wx.WXK_F3, self.HiderL.Click),
            (wx.ACCEL_NORMAL, wx.WXK_F4, self.HiderC.Click),
            (wx.ACCEL_NORMAL, wx.WXK_F5, self.HiderR.Click),
            (wx.ACCEL_CTRL, ord("F"),
             lambda evt: self.Gadget.Tool["GADGET_SEARCH"].SetFocus()),
            (wx.ACCEL_CTRL, ord("D"), self.Gadget.Tool["GADGET_CANCEL"].Click),
            (wx.ACCEL_CTRL, ord("E"), self.Gadget.Tool["TOOL_T_SHOW"].Click),
            (wx.ACCEL_CTRL, ord("R"), self.Gadget.Tool["TOOL_T_TEXT"].Click),
            (wx.ACCEL_CTRL, ord("W"), self.Gadget.Tool["TOOL_MANAGE"].Click),
            (wx.ACCEL_CTRL, ord("A"), lambda evt: self.Canvas.SelectAll()),
        ):
            cmd = wx.NewId()
            self.Bind(wx.EVT_MENU, func, id=cmd)
            self.AcceleratorEntries.append(
                wx.AcceleratorEntry(flags=flags, keyCode=keyCode, cmd=cmd))

        self.Tool.AddItemsWithHotKey(
            ("N", "TOOL_OPTION", self.OnOption, wx.ACCEL_CTRL | wx.ACCEL_ALT,
             ord("S")),
            "|",
            ("N", "TOOL_FILE_N", self.OnNew, wx.ACCEL_CTRL, ord("N")),
            ("N", "TOOL_FILE_O",
             (self.OnMakeDialog, "DIALOG_HEAD_LOAD", LoadDialog, {
                 "buttons": False
             }), wx.ACCEL_CTRL, ord("O")),
            ("N", "TOOL_FILE_S",
             (self.OnMakeDialog, "DIALOG_HEAD_SAVE", SaveDialog, {
                 "buttons": False
             }), wx.ACCEL_CTRL, ord("S")),
            "|",
            ("T", "TOOL_T_ANCR",
             (self.OnToggle, "TOGGLE_ANCR"), wx.ACCEL_NORMAL, wx.WXK_F6, {
                 "toggle": self.S["TOGGLE_ANCR"]
             }),
            ("T", "TOOL_T_NAME",
             (self.OnToggle, "TOGGLE_NAME"), wx.ACCEL_NORMAL, wx.WXK_F7, {
                 "toggle": self.S["TOGGLE_NAME"]
             }),
            ("T", "TOOL_T_SNAP",
             (self.OnToggle, "TOGGLE_SNAP"), wx.ACCEL_NORMAL, wx.WXK_F8, {
                 "toggle": self.S["TOGGLE_SNAP"]
             }),
            ("T", "TOOL_T_CURV", self.Canvas.ToggleLinkType, wx.ACCEL_NORMAL,
             wx.WXK_F9, {
                 "toggle": self.S["TOGGLE_CURV"]
             }),
            ("T", "TOOL_T_DIAG", self.OnToggleDialogSize, wx.ACCEL_NORMAL,
             wx.WXK_F10, {
                 "toggle": 0
             }),
            ("T", "TOOL_T_FSCN", self.OnToggleFullScreen, wx.ACCEL_NORMAL,
             wx.WXK_F11, {
                 "toggle": 0
             }),
            "|",
            ("N", "TOOL_ALGN_L",
             (self.Canvas.Align, Ut.AlignL), wx.ACCEL_CTRL, wx.WXK_NUMPAD4),
            ("N", "TOOL_ALGN_V",
             (self.Canvas.Align, Ut.AlignV), wx.ACCEL_CTRL, wx.WXK_NUMPAD5),
            ("N", "TOOL_ALGN_R",
             (self.Canvas.Align, Ut.AlignR), wx.ACCEL_CTRL, wx.WXK_NUMPAD6),
            ("N", "TOOL_ALGN_T",
             (self.Canvas.Align, Ut.AlignT), wx.ACCEL_CTRL, wx.WXK_NUMPAD8),
            ("N", "TOOL_ALGN_H",
             (self.Canvas.Align, Ut.AlignH), wx.ACCEL_CTRL, wx.WXK_NUMPAD0),
            ("N", "TOOL_ALGN_B",
             (self.Canvas.Align, Ut.AlignB), wx.ACCEL_CTRL, wx.WXK_NUMPAD2),
            "|",
            ("N", "TOOL_DIST_H", (self.Canvas.Distribute, Ut.DistributeH),
             wx.ACCEL_CTRL, ord("H")),
            ("N", "TOOL_DIST_V", (self.Canvas.Distribute, Ut.DistributeV),
             wx.ACCEL_CTRL, ord("V")),
            "|",
            ("N", "TOOL_MOVE_T",
             (self.Canvas.AlterLayer, "T"), wx.ACCEL_CTRL, wx.WXK_NUMPAD9),
            ("N", "TOOL_MOVE_U",
             (self.Canvas.AlterLayer, "U"), wx.ACCEL_CTRL, wx.WXK_NUMPAD7),
            ("N", "TOOL_MOVE_D",
             (self.Canvas.AlterLayer, "D"), wx.ACCEL_CTRL, wx.WXK_NUMPAD1),
            ("N", "TOOL_MOVE_B",
             (self.Canvas.AlterLayer, "B"), wx.ACCEL_CTRL, wx.WXK_NUMPAD3),
            "|",
            ("N", "TOOL_CANCEL", self.OnDismissAllDialog, wx.ACCEL_CTRL,
             wx.WXK_DELETE, {
                 "res": "R"
             }),
            ("N", "TOOL_DELETE", self.Canvas.DeleteSelected, wx.ACCEL_NORMAL,
             wx.WXK_DELETE, {
                 "res": "R"
             }),
        )
        self.Info.AddItems((wx.StaticText(self.Info, size=(268, 16)), 0),
                           (wx.StaticText(self.Info, size=(-1, 16)), 1),
                           (wx.StaticText(self.Info, size=(268, 16)), 0))

        self.SetAcceleratorTable(wx.AcceleratorTable(self.AcceleratorEntries))

        CenterSizer = wx.BoxSizer(wx.HORIZONTAL)
        CenterSizer.Add(self.Record, 1, wx.EXPAND | wx.ALL, 1)
        self.Center.SetSizer(CenterSizer)

        MiddleSizer = wx.BoxSizer(wx.VERTICAL)
        MiddleSizer.AddMany((
            (self.Canvas, 1, wx.EXPAND),
            (self.SashC, 0, wx.EXPAND),
            (self.Center, 0, wx.EXPAND),
            (self.HiderC, 0, wx.EXPAND),
        ))
        MainSizer = wx.BoxSizer(wx.HORIZONTAL)
        MainSizer.AddMany((
            (self.HiderL, 0, wx.EXPAND),
            (self.Gadget, 0, wx.EXPAND),
            (self.SashL, 0, wx.EXPAND),
            (MiddleSizer, 1, wx.EXPAND),
            (self.SashR, 0, wx.EXPAND),
            (self.Harbor, 0, wx.EXPAND),
            (self.HiderR, 0, wx.EXPAND),
        ))
        FrameSizer = wx.BoxSizer(wx.VERTICAL)
        FrameSizer.AddMany((
            (self.Tool, 0, wx.EXPAND),
            (MainSizer, 1, wx.EXPAND),
            (self.Info, 0, wx.EXPAND),
        ))
        self.SetSizer(FrameSizer)
        self.Layout()
        if not self.S["SHOW_GADGET"]:
            self.HiderL.OnHider()
        if not self.S["SHOW_HARBOR"]:
            self.HiderR.OnHider()
        if not self.S["SHOW_CENTER"]:
            self.HiderC.OnHider()

        self.M.Init(self)