manager.cpp

来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C++ 代码 · 共 2,037 行 · 第 1/5 页

CPP
2,037
字号
        pane.buttons = p.buttons;        p = pane;    }        if (update)        Update();    return true;}void wxFrameManager::GetPanePositionsAndSizes(wxDockInfo& dock,                                              wxArrayInt& positions,                                              wxArrayInt& sizes){    int caption_size = m_art->GetMetric(wxAUI_ART_CAPTION_SIZE);    int pane_border_size = m_art->GetMetric(wxAUI_ART_PANE_BORDER_SIZE);    int gripper_size = m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);    positions.Empty();    sizes.Empty();    int offset, action_pane = -1;    int pane_i, pane_count = dock.panes.GetCount();    // find the pane marked as our action pane    for (pane_i = 0; pane_i < pane_count; ++pane_i)    {        wxPaneInfo& pane = *(dock.panes.Item(pane_i));        if (pane.state & wxPaneInfo::actionPane)        {            wxASSERT_MSG(action_pane==-1, wxT("Too many fixed action panes"));            action_pane = pane_i;        }    }        // set up each panes default position, and    // determine the size (width or height, depending    // on the dock's orientation) of each pane    for (pane_i = 0; pane_i < pane_count; ++pane_i)    {        wxPaneInfo& pane = *(dock.panes.Item(pane_i));        positions.Add(pane.dock_pos);        int size = 0;                if (pane.HasBorder())            size += (pane_border_size*2);        if (pane.HasGripper())            size += gripper_size;                        if (dock.IsHorizontal())        {            size += pane.best_size.x;        }         else        {            if (pane.HasCaption())                size += caption_size;             size += pane.best_size.y;        }           sizes.Add(size);    }    // if there is no action pane, just return the default    // positions (as specified in pane.pane_pos)    if (action_pane == -1)        return;    offset = 0;    for (pane_i = action_pane-1; pane_i >= 0; --pane_i)    {        int amount = positions[pane_i+1] - (positions[pane_i] + sizes[pane_i]);        if (amount >= 0)            offset += amount;             else            positions[pane_i] -= -amount;        offset += sizes[pane_i];    }        // if the dock mode is fixed, make sure none of the panes    // overlap; we will bump panes that overlap    offset = 0;    for (pane_i = action_pane; pane_i < pane_count; ++pane_i)    {        int amount = positions[pane_i] - offset;        if (amount >= 0)            offset += amount;             else            positions[pane_i] += -amount;        offset += sizes[pane_i];    }}void wxFrameManager::LayoutAddPane(wxSizer* cont,                                   wxDockInfo& dock,                                   wxPaneInfo& pane,                                   wxDockUIPartArray& uiparts,                                   bool spacer_only){            wxDockUIPart part;    wxSizerItem* sizer_item;    int caption_size = m_art->GetMetric(wxAUI_ART_CAPTION_SIZE);    int gripper_size = m_art->GetMetric(wxAUI_ART_GRIPPER_SIZE);    int pane_border_size = m_art->GetMetric(wxAUI_ART_PANE_BORDER_SIZE);    int pane_button_size = m_art->GetMetric(wxAUI_ART_PANE_BUTTON_SIZE);    // find out the orientation of the item (orientation for panes    // is the same as the dock's orientation)    int orientation;    if (dock.IsHorizontal())        orientation = wxHORIZONTAL;         else        orientation = wxVERTICAL;    // this variable will store the proportion    // value that the pane will receive    int pane_proportion = pane.dock_proportion;    wxBoxSizer* horz_pane_sizer = new wxBoxSizer(wxHORIZONTAL);    wxBoxSizer* vert_pane_sizer = new wxBoxSizer(wxVERTICAL);    if (pane.HasGripper())    {        sizer_item = horz_pane_sizer->Add(gripper_size, 1, 0, wxEXPAND);        part.type = wxDockUIPart::typeGripper;        part.dock = &dock;        part.pane = &pane;        part.button = NULL;        part.orientation = orientation;        part.cont_sizer = horz_pane_sizer;        part.sizer_item = sizer_item;        uiparts.Add(part);    }    if (pane.HasCaption())    {        // create the caption sizer        wxBoxSizer* caption_sizer = new wxBoxSizer(wxHORIZONTAL);        sizer_item = caption_sizer->Add(1, caption_size, 1, wxEXPAND);        part.type = wxDockUIPart::typeCaption;        part.dock = &dock;        part.pane = &pane;        part.button = NULL;        part.orientation = orientation;        part.cont_sizer = vert_pane_sizer;        part.sizer_item = sizer_item;        int caption_part_idx = uiparts.GetCount();        uiparts.Add(part);        // add pane buttons to the caption        int i, button_count;        for (i = 0, button_count = pane.buttons.GetCount();             i < button_count; ++i)        {            wxPaneButton& button = pane.buttons.Item(i);            sizer_item = caption_sizer->Add(pane_button_size,                                            caption_size,                                            0, wxEXPAND);            part.type = wxDockUIPart::typePaneButton;            part.dock = &dock;            part.pane = &pane;            part.button = &button;            part.orientation = orientation;            part.cont_sizer = caption_sizer;            part.sizer_item = sizer_item;            uiparts.Add(part);        }        // add the caption sizer        sizer_item = vert_pane_sizer->Add(caption_sizer, 0, wxEXPAND);        uiparts.Item(caption_part_idx).sizer_item = sizer_item;    }    // add the pane window itself    if (spacer_only)    {        sizer_item = vert_pane_sizer->Add(1, 1, 1, wxEXPAND);    }     else    {        sizer_item = vert_pane_sizer->Add(pane.window, 1, wxEXPAND);        vert_pane_sizer->SetItemMinSize(pane.window, 1, 1);    }    part.type = wxDockUIPart::typePane;    part.dock = &dock;    part.pane = &pane;    part.button = NULL;    part.orientation = orientation;    part.cont_sizer = vert_pane_sizer;    part.sizer_item = sizer_item;    uiparts.Add(part);    // determine if the pane should have a minimum size; if the pane is    // non-resizable (fixed) then we must set a minimum size. Alternitavely,    // if the pane.min_size is set, we must use that value as well        wxSize min_size = pane.min_size;    if (pane.IsFixed())    {        if (min_size == wxDefaultSize)        {            min_size = pane.best_size;            pane_proportion = 0;        }    }        if (min_size != wxDefaultSize)    {        vert_pane_sizer->SetItemMinSize(                        vert_pane_sizer->GetChildren().GetCount()-1,                        min_size.x, min_size.y);    }    // add the verticle sizer (caption, pane window) to the    // horizontal sizer (gripper, verticle sizer)    horz_pane_sizer->Add(vert_pane_sizer, 1, wxEXPAND);    // finally, add the pane sizer to the dock sizer    if (pane.HasBorder())    {        // allowing space for the pane's border        sizer_item = cont->Add(horz_pane_sizer, pane_proportion,                               wxEXPAND | wxALL, pane_border_size);        part.type = wxDockUIPart::typePaneBorder;        part.dock = &dock;        part.pane = &pane;        part.button = NULL;        part.orientation = orientation;        part.cont_sizer = cont;        part.sizer_item = sizer_item;        uiparts.Add(part);    }     else    {        sizer_item = cont->Add(horz_pane_sizer, pane_proportion, wxEXPAND);    }}void wxFrameManager::LayoutAddDock(wxSizer* cont,                                   wxDockInfo& dock,                                   wxDockUIPartArray& uiparts,                                   bool spacer_only){    wxSizerItem* sizer_item;    wxDockUIPart part;    int sash_size = m_art->GetMetric(wxAUI_ART_SASH_SIZE);    int orientation = dock.IsHorizontal() ? wxHORIZONTAL : wxVERTICAL;    // resizable bottom and right docks have a sash before them    if (!dock.fixed && (dock.dock_direction == wxAUI_DOCK_BOTTOM ||                        dock.dock_direction == wxAUI_DOCK_RIGHT))    {        sizer_item = cont->Add(sash_size, sash_size, 0, wxEXPAND);        part.type = wxDockUIPart::typeDockSizer;        part.orientation = orientation;        part.dock = &dock;        part.pane = NULL;        part.button = NULL;        part.cont_sizer = cont;        part.sizer_item = sizer_item;        uiparts.Add(part);    }    // create the sizer for the dock    wxSizer* dock_sizer = new wxBoxSizer(orientation);    // add each pane to the dock    int pane_i, pane_count = dock.panes.GetCount();    if (dock.fixed)    {        wxArrayInt pane_positions, pane_sizes;                // figure out the real pane positions we will        // use, without modifying the each pane's pane_pos member        GetPanePositionsAndSizes(dock, pane_positions, pane_sizes);        int offset = 0;        for (pane_i = 0; pane_i < pane_count; ++pane_i)        {            wxPaneInfo& pane = *(dock.panes.Item(pane_i));            int pane_pos = pane_positions.Item(pane_i);            int amount = pane_pos - offset;            if (amount > 0)            {                if (dock.IsVertical())                    sizer_item = dock_sizer->Add(1, amount, 0, wxEXPAND);                     else                    sizer_item = dock_sizer->Add(amount, 1, 0, wxEXPAND);                part.type = wxDockUIPart::typeBackground;                part.dock = &dock;                part.pane = NULL;                part.button = NULL;                part.orientation = (orientation==wxHORIZONTAL) ? wxVERTICAL:wxHORIZONTAL;                part.cont_sizer = dock_sizer;                part.sizer_item = sizer_item;                uiparts.Add(part);                offset += amount;            }            LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only);            offset += pane_sizes.Item(pane_i);        }        // at the end add a very small stretchable background area        sizer_item = dock_sizer->Add(1,1, 1, wxEXPAND);        part.type = wxDockUIPart::typeBackground;        part.dock = &dock;        part.pane = NULL;        part.button = NULL;        part.orientation = orientation;        part.cont_sizer = dock_sizer;        part.sizer_item = sizer_item;        uiparts.Add(part);    }     else    {        for (pane_i = 0; pane_i < pane_count; ++pane_i)        {            wxPaneInfo& pane = *(dock.panes.Item(pane_i));            // if this is not the first pane being added,            // we need to add a pane sizer            if (pane_i > 0)            {                sizer_item = dock_sizer->Add(sash_size, sash_size, 0, wxEXPAND);                part.type = wxDockUIPart::typePaneSizer;                part.dock = &dock;                part.pane = dock.panes.Item(pane_i-1);                part.button = NULL;                part.orientation = (orientation==wxHORIZONTAL) ? wxVERTICAL:wxHORIZONTAL;                part.cont_sizer = dock_sizer;                part.sizer_item = sizer_item;                uiparts.Add(part);            }            LayoutAddPane(dock_sizer, dock, pane, uiparts, spacer_only);        }    }    if (dock.dock_direction == wxAUI_DOCK_CENTER)        sizer_item = cont->Add(dock_sizer, 1, wxEXPAND);         else        sizer_item = cont->Add(dock_sizer, 0, wxEXPAND);    part.type = wxDockUIPart::typeDock;    part.dock = &dock;    part.pane = NULL;    part.button = NULL;    part.orientation = orientation;    part.cont_sizer = cont;    part.sizer_item = sizer_item;    uiparts.Add(part);    if (dock.IsHorizontal())        cont->SetItemMinSize(dock_sizer, 0, dock.size);         else        cont->SetItemMinSize(dock_sizer, dock.size, 0);    //  top and left docks have a sash after them    if (!dock.fixed && (dock.dock_direction == wxAUI_DOCK_TOP ||                        dock.dock_direction == wxAUI_DOCK_LEFT))    {        sizer_item = cont->Add(sash_size, sash_size, 0, wxEXPAND);        part.type = wxDockUIPart::typeDockSizer;        part.dock = &dock;        part.pane = NULL;        part.button = NULL;        part.orientation = orientation;        part.cont_sizer = cont;        part.sizer_item = sizer_item;        uiparts.Add(part);    }}wxSizer* wxFrameManager::LayoutAll(wxPaneInfoArray& panes,                                   wxDockInfoArray& docks, 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?