obj_clipboard.cpp
来自「ncbi源码」· C++ 代码 · 共 183 行
CPP
183 行
/* * =========================================================================== * PRODUCTION $Log: obj_clipboard.cpp,v $ * PRODUCTION Revision 1000.0 2004/06/01 21:21:01 gouriano * PRODUCTION PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.2 * PRODUCTION * =========================================================================== *//* $Id: obj_clipboard.cpp,v 1000.0 2004/06/01 21:21: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 <gui/objutils/obj_clipboard.hpp>#include <gui/objutils/label.hpp>#include <FL/Fl.H>#include <connect/ncbi_conn_stream.hpp>#include <serial/objostr.hpp>#include <corelib/ncbimtx.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);// our current objectsTConstScopedObjects CObjClipboard::sm_Objects;// the mode of text copyCObjClipboard::ECopyMode CObjClipboard::sm_Mode = CObjClipboard::eCopy_ASN;void CObjClipboard::Add(CScope& scope, const CObject& obj){ CMutexGuard LOCK(sm_ClipboardMutex); SConstScopedObject clip_object(obj, scope); sm_Objects.push_back(clip_object); string str; x_GetText(scope, obj, &str); CClipboard::Add(str);}void CObjClipboard::Add(CScope& scope, const CObject& obj, const string& text){ CMutexGuard LOCK(sm_ClipboardMutex); SConstScopedObject clip_object(obj, scope); sm_Objects.push_back(clip_object); CClipboard::Add(text);}void CObjClipboard::Add(const string& text){ CMutexGuard LOCK(sm_ClipboardMutex); CClipboard::Add(text);}void CObjClipboard::Clear(){ CMutexGuard LOCK(sm_ClipboardMutex); sm_Objects.clear(); CClipboard::Clear();}void CObjClipboard::Copy(){ CMutexGuard LOCK(sm_ClipboardMutex); CClipboard::Copy();}void CObjClipboard::Paste(TConstScopedObjects* objects, string* text){ CMutexGuard LOCK(sm_ClipboardMutex); if (objects) { *objects = sm_Objects; } CClipboard::Paste(text);}void CObjClipboard::x_GetText(CScope& scope, const CObject& object, string* text){ if ( !text ) { return; } switch (sm_Mode) { case eCopy_Label: CLabel::GetLabel(object, text, CLabel::eDefault, &scope); break; case eCopy_ASN: case eCopy_XML: {{ const CSerialObject* obj = dynamic_cast<const CSerialObject*>(&object); if (obj) { CConn_MemoryStream ostr; {{ auto_ptr<CObjectOStream> os (CObjectOStream::Open(eSerial_AsnText, ostr)); os->Write(obj, obj->GetThisTypeInfo()); }} string str; str.resize(ostr.tellp() - CT_POS_TYPE(0)); ostr.read(const_cast<char*>(str.data()), str.size()); *text += str; } }} break; }}END_NCBI_SCOPE/* * =========================================================================== * $Log: obj_clipboard.cpp,v $ * Revision 1000.0 2004/06/01 21:21:01 gouriano * PRODUCTION: IMPORTED [GCC34_MSVC7] Dev-tree R1.2 * * Revision 1.2 2004/05/21 22:27:44 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.1 2004/05/07 15:39:54 dicuccio * Rearranged clipboard classes - renamed CClipboard -> CObjClipboard to reflect * its specialized function * * Revision 1.1 2004/04/30 11:48:15 dicuccio * Initial commit - split out from src/gui/utils * * Revision 1.4 2004/04/07 13:05:46 dicuccio * Reworked to use TConstScopedObjects * * Revision 1.3 2004/02/20 20:03:27 ucko * Fix to compile with stricter implementations of CT_POS_TYPE * * Revision 1.2 2004/01/30 21:08:36 dicuccio * Added default text interpretation of copied items * * Revision 1.1 2004/01/30 17:13:56 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?