manager.cpp
来自「A*算法 A*算法 A*算法 A*算法A*算法A*算法」· C++ 代码 · 共 2,037 行 · 第 1/5 页
CPP
2,037 行
const wxDockInfoArray& src_docks, const wxPaneInfoArray& src_panes){ dest_docks = src_docks; dest_panes = src_panes; int i, j, k, dock_count, pc1, pc2; for (i = 0, dock_count = dest_docks.GetCount(); i < dock_count; ++i) { wxDockInfo& dock = dest_docks.Item(i); for (j = 0, pc1 = dock.panes.GetCount(); j < pc1; ++j) for (k = 0, pc2 = src_panes.GetCount(); k < pc2; ++k) if (dock.panes.Item(j) == &src_panes.Item(k)) dock.panes.Item(j) = &dest_panes.Item(k); }}// GetMaxLayer() is an internal function which returns// the highest layer inside the specified dockstatic int GetMaxLayer(const wxDockInfoArray& docks, int dock_direction){ int i, dock_count, max_layer = 0; for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) { wxDockInfo& dock = docks.Item(i); if (dock.dock_direction == dock_direction && dock.dock_layer > max_layer && !dock.fixed) max_layer = dock.dock_layer; } return max_layer;}// GetMaxRow() is an internal function which returns// the highest layer inside the specified dockstatic int GetMaxRow(const wxPaneInfoArray& panes, int direction, int layer){ int i, pane_count, max_row = 0; for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& pane = panes.Item(i); if (pane.dock_direction == direction && pane.dock_layer == layer && pane.dock_row > max_row) max_row = pane.dock_row; } return max_row;}// DoInsertDockLayer() is an internal function that inserts a new dock// layer by incrementing all existing dock layer values by onestatic void DoInsertDockLayer(wxPaneInfoArray& panes, int dock_direction, int dock_layer){ int i, pane_count; for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& pane = panes.Item(i); if (!pane.IsFloating() && pane.dock_direction == dock_direction && pane.dock_layer >= dock_layer) pane.dock_layer++; }}// DoInsertDockLayer() is an internal function that inserts a new dock// row by incrementing all existing dock row values by onestatic void DoInsertDockRow(wxPaneInfoArray& panes, int dock_direction, int dock_layer, int dock_row){ int i, pane_count; for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& pane = panes.Item(i); if (!pane.IsFloating() && pane.dock_direction == dock_direction && pane.dock_layer == dock_layer && pane.dock_row >= dock_row) pane.dock_row++; }}// DoInsertDockLayer() is an internal function that inserts a space for // another dock pane by incrementing all existing dock row values by onestatic void DoInsertPane(wxPaneInfoArray& panes, int dock_direction, int dock_layer, int dock_row, int dock_pos){ int i, pane_count; for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& pane = panes.Item(i); if (!pane.IsFloating() && pane.dock_direction == dock_direction && pane.dock_layer == dock_layer && pane.dock_row == dock_row && pane.dock_pos >= dock_pos) pane.dock_pos++; }}// FindDocks() is an internal function that returns a list of docks which meet// the specified conditions in the parameters and returns a sorted array// (sorted by layer and then row)static void FindDocks(wxDockInfoArray& docks, int dock_direction, int dock_layer, int dock_row, wxDockInfoPtrArray& arr){ int begin_layer = dock_layer; int end_layer = dock_layer; int begin_row = dock_row; int end_row = dock_row; int dock_count = docks.GetCount(); int layer, row, i, max_row = 0, max_layer = 0; // discover the maximum dock layer and the max row for (i = 0; i < dock_count; ++i) { max_row = wxMax(max_row, docks.Item(i).dock_row); max_layer = wxMax(max_layer, docks.Item(i).dock_layer); } // if no dock layer was specified, search all dock layers if (dock_layer == -1) { begin_layer = 0; end_layer = max_layer; } // if no dock row was specified, search all dock row if (dock_row == -1) { begin_row = 0; end_row = max_row; } arr.Clear(); for (layer = begin_layer; layer <= end_layer; ++layer) for (row = begin_row; row <= end_row; ++row) for (i = 0; i < dock_count; ++i) { wxDockInfo& d = docks.Item(i); if (dock_direction == -1 || dock_direction == d.dock_direction) { if (d.dock_layer == layer && d.dock_row == row) arr.Add(&d); } }}// FindPaneInDock() looks up a specified window pointer inside a dock.// If found, the corresponding wxPaneInfo pointer is returned, otherwise NULL.static wxPaneInfo* FindPaneInDock(const wxDockInfo& dock, wxWindow* window){ int i, count = dock.panes.GetCount(); for (i = 0; i < count; ++i) { wxPaneInfo* p = dock.panes.Item(i); if (p->window == window) return p; } return NULL;}// RemovePaneFromDocks() removes a pane window from all docks// with a possible exception specified by parameter "except"static void RemovePaneFromDocks(wxDockInfoArray& docks, wxPaneInfo& pane, wxDockInfo* except = NULL){ int i, dock_count; for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) { wxDockInfo& d = docks.Item(i); if (&d == except) continue; wxPaneInfo* pi = FindPaneInDock(d, pane.window); if (pi) d.panes.Remove(pi); }}// RenumberDockRows() takes a dock and assigns sequential numbers// to existing rows. Basically it takes out the gaps; so if a// dock has rows with numbers 0,2,5, they will become 0,1,2static void RenumberDockRows(wxDockInfoPtrArray& docks){ int i, dock_count, j, pane_count; for (i = 0, dock_count = docks.GetCount(); i < dock_count; ++i) { wxDockInfo& dock = *docks.Item(i); dock.dock_row = i; for (j = 0, pane_count = dock.panes.GetCount(); j < pane_count; ++j) dock.panes.Item(j)->dock_row = i; }}static void SetActivePane(wxPaneInfoArray& panes, wxWindow* active_pane){ int i, pane_count; for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& pane = panes.Item(i); pane.state &= ~wxPaneInfo::optionActive; if (pane.window == active_pane) pane.state |= wxPaneInfo::optionActive; }}// this function is used to sort panes by dock positionstatic int PaneSortFunc(wxPaneInfo** p1, wxPaneInfo** p2){ return ((*p1)->dock_pos < (*p2)->dock_pos) ? -1 : 1;}// -- wxFrameManager class implementation --BEGIN_EVENT_TABLE(wxFrameManager, wxEvtHandler) EVT_AUI_PANEBUTTON(wxFrameManager::OnPaneButton) EVT_PAINT(wxFrameManager::OnPaint) EVT_ERASE_BACKGROUND(wxFrameManager::OnEraseBackground) EVT_SIZE(wxFrameManager::OnSize) EVT_SET_CURSOR(wxFrameManager::OnSetCursor) EVT_LEFT_DOWN(wxFrameManager::OnLeftDown) EVT_LEFT_UP(wxFrameManager::OnLeftUp) EVT_MOTION(wxFrameManager::OnMotion) EVT_LEAVE_WINDOW(wxFrameManager::OnLeaveWindow) EVT_CHILD_FOCUS(wxFrameManager::OnChildFocus) EVT_TIMER(101, wxFrameManager::OnHintFadeTimer)END_EVENT_TABLE()wxFrameManager::wxFrameManager(wxFrame* frame, unsigned int flags){ m_action = actionNone; m_last_mouse_move = wxPoint(); m_hover_button = NULL; m_art = new wxDefaultDockArt; m_hint_wnd = NULL; m_flags = flags; if (frame) { SetFrame(frame); }}wxFrameManager::~wxFrameManager(){ delete m_art;}// GetPane() looks up a wxPaneInfo structure based// on the supplied window pointer. Upon failure, GetPane()// returns an empty wxPaneInfo, a condition which can be checked// by calling wxPaneInfo::IsOk().//// The pane info's structure may then be modified. Once a pane's// info is modified, wxFrameManager::Update() must be called to// realize the changes in the UI.wxPaneInfo& wxFrameManager::GetPane(wxWindow* window){ int i, pane_count; for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& p = m_panes.Item(i); if (p.window == window) return p; } return wxNullPaneInfo;}// this version of GetPane() looks up a pane based on a// 'pane name', see above comment for more infowxPaneInfo& wxFrameManager::GetPane(const wxString& name){ int i, pane_count; for (i = 0, pane_count = m_panes.GetCount(); i < pane_count; ++i) { wxPaneInfo& p = m_panes.Item(i); if (p.name == name) return p; } return wxNullPaneInfo;}// GetAllPanes() returns a reference to all the pane info structureswxPaneInfoArray& wxFrameManager::GetAllPanes(){ return m_panes;}// HitTest() is an internal function which determines// which UI item the specified coordinates are over// (x,y) specify a position in client coordinateswxDockUIPart* wxFrameManager::HitTest(int x, int y){ wxDockUIPart* result = NULL; int i, part_count; for (i = 0, part_count = m_uiparts.GetCount(); i < part_count; ++i) { wxDockUIPart* item = &m_uiparts.Item(i); // we are not interested in typeDock, because this space // isn't used to draw anything, just for measurements; // besides, the entire dock area is covered with other // rectangles, which we are interested in. if (item->type == wxDockUIPart::typeDock) continue; // if we already have a hit on a more specific item, we are not // interested in a pane hit. If, however, we don't already have // a hit, returning a pane hit is necessary for some operations if ((item->type == wxDockUIPart::typePane || item->type == wxDockUIPart::typePaneBorder) && result) continue; // if the point is inside the rectangle, we have a hit if (item->rect.Inside(x,y)) result = item; } return result;}// SetFlags() and GetFlags() allow the owner to set various// options which are global to wxFrameManagervoid wxFrameManager::SetFlags(unsigned int flags){ m_flags = flags;}unsigned int wxFrameManager::GetFlags() const{ return m_flags;}// SetFrame() is usually called once when the frame// manager class is being initialized. "frame" specifies// the frame which should be managed by the frame manangervoid wxFrameManager::SetFrame(wxFrame* frame){ wxASSERT_MSG(frame, wxT("specified frame must be non-NULL")); m_frame = frame; m_frame->PushEventHandler(this);#if wxUSE_MDI // if the owner is going to manage an MDI parent frame, // we need to add the MDI client window as the default // center pane if (frame->IsKindOf(CLASSINFO(wxMDIParentFrame))) { wxMDIParentFrame* mdi_frame = (wxMDIParentFrame*)frame; wxMDIClientWindow* client_window = mdi_frame->GetClientWindow(); wxASSERT_MSG(client_window, wxT("Client window is NULL!")); AddPane(client_window, wxPaneInfo().Name(wxT("mdiclient")). CenterPane().PaneBorder(false)); }#endif}// UnInit() must be called, usually in the destructor// of the frame class. If it is not called, usually this// will result in a crash upon program exitvoid wxFrameManager::UnInit(){ m_frame->RemoveEventHandler(this);}// GetFrame() returns the frame pointer being managed by wxFrameManagerwxFrame* wxFrameManager::GetFrame() const{ return m_frame;}wxDockArt* wxFrameManager::GetArtProvider() const{ return m_art;}void wxFrameManager::ProcessMgrEvent(wxFrameManagerEvent& event){ // first, give the owner frame a chance to override if (m_frame)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?