obj_menu.cpp
来自「ncbi源码」· C++ 代码 · 共 166 行
CPP
166 行
/* * =========================================================================== * PRODUCTION $Log: obj_menu.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/02 20:24:01 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * PRODUCTION * =========================================================================== *//* $Id: obj_menu.cpp,v 1000.1 2004/06/02 20:24:01 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_menu.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_SCOPEUSING_SCOPE(objects);CObjChoice::CObjChoice(int x, int y, int w, int h, const string& type_info, const char* label) : Fl_Choice(x, y, w, h, label) , m_TypeInfo(type_info){ m_EventHandler.StandardConfig(); labelsize(12);}void CObjChoice::Add(const IDocument& doc, const CObject& obj){ CObjectConverter::TObjList objs; CObjectConverter::Convert(doc.GetScope(), obj, m_TypeInfo, objs); ITERATE (CObjectConverter::TObjList, iter, objs) { Add(doc.GetScope(), **iter); }}void CObjChoice::Add(CScope& scope, const CObject& obj){ SConstScopedObject scoped_obj(obj, scope); string label = CPluginUtils::GetLabel(obj, &scope); add(label.c_str()); m_Objects.push_back(scoped_obj);}const SConstScopedObject& CObjChoice::GetSelection() const{ int idx = value(); _ASSERT(idx >= 0 && idx < m_Objects.size()); return m_Objects[idx];}int CObjChoice::handle(int event){ m_EventHandler.OnFLTKEvent(event); switch (m_EventHandler.GetGUIState()) { case CGUIEvent::eCopyState: {{ CObjClipboard::Clear(); int idx = value(); if (idx >= 0 && idx < m_Objects.size()) { CObjClipboard::Add(*m_Objects[idx].scope, *m_Objects[idx].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: break; default: break; } return Fl_Choice::handle(event);}END_NCBI_SCOPE/* * =========================================================================== * $Log: obj_menu.cpp,v $ * Revision 1000.1 2004/06/02 20:24:01 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.2 * * Revision 1.2 2004/06/01 21:47:36 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 + -
显示快捷键?