📄 wm_tab_control.cpp
字号:
/* * =========================================================================== * PRODUCTION $Log: wm_tab_control.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 21:14:53 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * PRODUCTION * =========================================================================== *//* $Id: wm_tab_control.cpp,v 1000.1 2004/06/01 21:14:53 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Andrey Yazhuk * * File Description: * */#include <ncbi_pch.hpp>#include <gui/widgets/workspace/wm_tab_control.hpp>#include <gui/widgets/fl/menu_window.hpp>BEGIN_NCBI_SCOPE////////////////////////////////////////////////////////////////////////////////// CWMTabPosCWMTabPos::CWMTabPos(): m_Pos(-1)// invaid position{}CWMTabPos::CWMTabPos(int pos): m_Pos(pos){}CWMTabPos::~CWMTabPos(){}bool CWMTabPos::IsValid() const{ return m_Pos >=0;}IWMPosition* CWMTabPos::Clone() const{ return new CWMTabPos(this->GetPos());}int CWMTabPos::GetPos() const{ return m_Pos;}void CWMTabPos::Set(int pos){ m_Pos = pos;}////////////////////////////////////////////////////////////////////////////////// CWMTabControlCWMTabControl::CWMTabControl(): CTabControl(), m_pManager(NULL){}CWMTabControl::CWMTabControl(int x, int y, int w, int h, const char* label): CTabControl(x, y, w, h, label), m_pManager(NULL){}CWMTabControl::~CWMTabControl(){}BEGIN_CMD_MAP(CWMTabControl, CCommandTarget)END_CMD_MAP()void CWMTabControl::SetManager(IWindowManager* manager){ m_pManager = manager;}bool CWMTabControl::IsVacant(const IWMPosition& pos){ const CWMTabPos* p_pos = dynamic_cast<const CWMTabPos*>(&pos); if(p_pos) { int ind = p_pos->GetPos(); return ind == x_GetTabsCount(); } return false;}CWMTabControl::TChild* CWMTabControl::GetChild(const IWMPosition& pos){ const CWMTabPos* p_pos = dynamic_cast<const CWMTabPos*>(&pos); if(p_pos) { return GetTab(p_pos->GetPos()); } return NULL;}bool CWMTabControl::Insert(TChild* child, const IWMPosition& pos){ const CWMTabPos* p_pos = dynamic_cast<const CWMTabPos*>(&pos); if(child && p_pos) { if(p_pos->IsValid() && IsVacant(pos)) { IWMClient* client = dynamic_cast<IWMClient*>(child); string tab_name = client ? client->GetLabel() : "Container"; return AddTab(child, tab_name.c_str()); } } return false;}void CWMTabControl::RemoveAll(){ RemoveAllTabs();}bool CWMTabControl::Remove(const IWMPosition& pos){ const CWMTabPos* p_pos = dynamic_cast<const CWMTabPos*>(&pos); if(p_pos) { return RemoveTab(p_pos->GetPos()); } return false;} bool CWMTabControl::Remove(TChild* child){ return RemoveTab(child);} void CWMTabControl::GetChildren(vector<TChild*>& children){ int n = x_GetTabsCount(); children.clear(); for( int i = 0; i < n; i++ ) { Fl_Widget* child = x_GetPane(i); children.push_back(child); }}void CWMTabControl::x_OnShowPopupMenu(){ int i_tab; EHitResult hit_res = x_HitTest(Fl::event_x(), Fl::event_y(), i_tab); CMenuItem* root = new CMenuItem("Root"); m_PopupPos.Set(hit_res == eTab ? i_tab : x_GetTabsCount()); if(m_pManager) { vector<CMenuItem*> items; m_pManager->GetPopupItems(this, m_PopupPos, items); ITERATE(vector<CMenuItem*>, it, items) { root->AddSubItem(*it); } } if(root->IsSubmenuEmpty()) { delete root; } else { CPopupMenu1 menu(Fl::event_x_root(), Fl::event_y_root(), root, this); menu.Popup(); }}bool CWMTabControl::OnCommand(const TCmdID cmd){ bool b_handled = CCommandTarget::OnCommand(cmd); if(! b_handled && m_pManager) { b_handled = m_pManager->OnContainerCommand(this, m_PopupPos, cmd); } return b_handled;}END_NCBI_SCOPE/* * =========================================================================== * $Log: wm_tab_control.cpp,v $ * Revision 1000.1 2004/06/01 21:14:53 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.3 * * Revision 1.3 2004/05/21 22:27:56 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.2 2004/05/07 14:27:33 yazhuk * Replaced CPopupMenu with CPopupMenu1 * * Revision 1.1 2004/02/04 19:41:35 yazhuk * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -