obj_browser.cpp
来自「ncbi源码」· C++ 代码 · 共 216 行
CPP
216 行
/* * =========================================================================== * PRODUCTION $Log: obj_browser.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/02 20:23:58 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * PRODUCTION * =========================================================================== *//* $Id: obj_browser.cpp,v 1000.1 2004/06/02 20:23:58 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: Mike DiCuccio * * File Description: * */#include <ncbi_pch.hpp>#include "obj_browser.hpp"#include "obj_browse_other.hpp"#include <gui/objutils/obj_clipboard.hpp>#include <gui/core/plugin_utils.hpp>#include <gui/core/doc_manager.hpp>BEGIN_NCBI_SCOPESBrowserObject::SBrowserObject(){}SBrowserObject::SBrowserObject(const IDocument& doc, const CObject& obj) : document(&doc), object(&obj){}CObjBrowser::CObjBrowser(int x, int y, int w, int h, const string& type_info, const string& col_header, const char* label) : CTablePanel<SBrowserObject>(x, y, w, h, label) , m_TypeInfo(type_info){ SetColumn(eObjLabel, col_header, eString, FL_ALIGN_LEFT, 1.0f); labelsize(12); m_EventHandler.StandardConfig();}void CObjBrowser::Add(const IDocument& doc, const CObject& obj){ CObjectConverter::TObjList objs; CObjectConverter::Convert(doc.GetScope(), obj, m_TypeInfo, objs); size_t idx = GetRows(); SetRows(GetRows() + objs.size()); ITERATE (CObjectConverter::TObjList, iter, objs) { SetData(idx) = SBrowserObject(doc, **iter); string& label = SetCell(idx, eObjLabel); label = CPluginUtils::GetLabel(**iter, &doc.GetScope()); ++idx; }}int CObjBrowser::handle(int event){ m_EventHandler.OnFLTKEvent(event); switch (m_EventHandler.GetGUIState()) { case CGUIEvent::eCutState: {{ CObjClipboard::Clear(); for (int i = GetRows() - 1; i >= 0; --i) { if (row_selected(i)) { const SBrowserObject& obj = GetData(i); CObjClipboard::Add(obj.document->GetScope(), *obj.object); RemoveRow(i); } } CObjClipboard::Copy(); if (parent()) { parent()->redraw(); } else { redraw(); } }} return 1; case CGUIEvent::eCopyState: {{ CObjClipboard::Clear(); for (size_t i = 0; i < GetRows(); ++i) { if ( !row_selected(i) ) { continue; } const SBrowserObject& obj = GetData(i); CObjClipboard::Add(obj.document->GetScope(), *obj.object); } CObjClipboard::Copy(); }} return 1; case CGUIEvent::ePasteState: {{ TConstScopedObjects objs; CObjClipboard::Paste(&objs, NULL); ITERATE (TConstScopedObjects, iter, objs) { const IDocument* doc = NULL; ITERATE(CDocManager::TDocList, doc_iter, CDocManager::GetDocuments()) { const objects::CScope* docscope = &(*doc_iter)->GetScope(); if (docscope == iter->scope) { doc = *doc_iter; break; } } if ( !doc ) { continue; } Add(*doc, *iter->object); } if (parent()) { parent()->redraw(); } else { redraw(); } }} return 1; case CGUIEvent::eDeleteState: {{ for (int i = GetRows() - 1; i >= 0; --i) { if (row_selected(i)) { RemoveRow(i); } } // clear all selections select_all_rows(0); if (parent()) { parent()->redraw(); } else { redraw(); } }} return 1; default: break; } return CTablePanel<SBrowserObject>::handle(event);}void CObjBrowser::ShowBrowseDlg(){ if ( !m_BrowseDlg.get() ) { m_BrowseDlg.reset(new CBrowseOtherDlg(this)); } m_BrowseDlg->Show();}END_NCBI_SCOPE/* * =========================================================================== * $Log: obj_browser.cpp,v $ * Revision 1000.1 2004/06/02 20:23:58 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * * Revision 1.2 2004/06/01 21:43:52 ucko * Tweak to fix compilation on WorkShop. * * Revision 1.1 2004/06/01 18:04:44 dicuccio * Initial revision. Lots of changes: added gui_project ASN.1 project, added new * plugin arg form (separate widget), added plugin selector dialog * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?