Exemplo n.º 1
0
Arquivo: candy.py Projeto: rtfb/candy
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, -1, title)

        self.splitter = wx.SplitterWindow(self, ID_SPLITTER,
                                          style=wx.SP_BORDER)
        self.splitter.SetMinimumPaneSize(50)

        width, height = wx.DisplaySize()
        self.SetSize((width / 2, height / 2))

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.splitter, 1, wx.EXPAND)
        self.status_line = StatusLine(self, ID_STATUS_LINE, width / 2,
                                      general_config, color_scheme)
        self.sizer.AddSpacer(2)
        sizer_flags = wx.BOTTOM | wx.ALIGN_BOTTOM | wx.EXPAND
        self.sizer.Add(self.status_line, 0, sizer_flags)
        self.SetSizer(self.sizer)

        self.p1 = PanelController(Panel(self.splitter), 'm1.', 'c1.')
        self.p2 = PanelController(Panel(self.splitter), 'm2.', 'c2.')
        self.splitter.SplitVertically(self.p1.view, self.p2.view)

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_SPLITTER_DCLICK, self.on_double_click, id=ID_SPLITTER)
        self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash_pos_changed,
                  id=ID_SPLITTER)

        self.status_bar = self.CreateStatusBar()
        self.status_bar.SetStatusText(os.getcwdu())
        self.Center()
        self.set_active_pane(self.p1)
Exemplo n.º 2
0
Arquivo: candy.py Projeto: rtfb/candy
class Candy(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, -1, title)

        self.splitter = wx.SplitterWindow(self, ID_SPLITTER,
                                          style=wx.SP_BORDER)
        self.splitter.SetMinimumPaneSize(50)

        width, height = wx.DisplaySize()
        self.SetSize((width / 2, height / 2))

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.splitter, 1, wx.EXPAND)
        self.status_line = StatusLine(self, ID_STATUS_LINE, width / 2,
                                      general_config, color_scheme)
        self.sizer.AddSpacer(2)
        sizer_flags = wx.BOTTOM | wx.ALIGN_BOTTOM | wx.EXPAND
        self.sizer.Add(self.status_line, 0, sizer_flags)
        self.SetSizer(self.sizer)

        self.p1 = PanelController(Panel(self.splitter), 'm1.', 'c1.')
        self.p2 = PanelController(Panel(self.splitter), 'm2.', 'c2.')
        self.splitter.SplitVertically(self.p1.view, self.p2.view)

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_SPLITTER_DCLICK, self.on_double_click, id=ID_SPLITTER)
        self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.on_sash_pos_changed,
                  id=ID_SPLITTER)

        self.status_bar = self.CreateStatusBar()
        self.status_bar.SetStatusText(os.getcwdu())
        self.Center()
        self.set_active_pane(self.p1)

    def set_active_pane(self, pane):
        self.active_pane = pane
        pane.view.SetFocus()
        self.status_line.set_message_prefix(pane.controller_signature)

    def setup_and_show(self):
        self.p2.initialize_and_show_initial_view()
        self.p1.initialize_and_show_initial_view()
        self.set_active_pane(self.p1)

    # XXX: is it ever used?
    def OnExit(self, e):
        self.Close(True)

    def update_panes_on_size(self):
        num_columns = 3

        if self.splitter.GetSplitMode() == wx.SPLIT_HORIZONTAL:
            num_columns = 5

        self.p1.initialize_view_settings(num_columns)
        self.p2.initialize_view_settings(num_columns)

    def split_equal(self):
        size = self.GetSize()

        split_mode = self.splitter.GetSplitMode()
        sash_dimension = size.x

        if split_mode == wx.SPLIT_HORIZONTAL:
            sash_dimension = size.y

        # compensate for the five pixels of sash itself (dammit!)
        sash_dimension -= 5
        self.splitter.SetSashPosition(sash_dimension / 2)
        self.update_panes_on_size()

    def on_size(self, event):
        self.split_equal()
        event.Skip()

    def on_double_click(self, event):
        self.split_equal()

    def on_sash_pos_changed(self, event):
        self.splitter.UpdateSize()
        self.update_panes_on_size()
        event.Skip()

    def switch_pane(self):
        if self.active_pane == self.p1:
            self.set_active_pane(self.p2)
        else:
            self.set_active_pane(self.p1)

    def switch_splitting_mode(self):
        curr_split_mode = self.splitter.GetSplitMode()
        new_split_mode = wx.SPLIT_VERTICAL
        num_columns = 3

        if curr_split_mode == wx.SPLIT_VERTICAL:
            new_split_mode = wx.SPLIT_HORIZONTAL
            num_columns = 5

        self.splitter.SetSplitMode(new_split_mode)
        self.split_equal()
        self.p1.initialize_view_settings(num_columns)
        self.p2.initialize_view_settings(num_columns)