view.cpp

来自「ncbi源码」· C++ 代码 · 共 419 行

CPP
419
字号
/* * =========================================================================== * PRODUCTION $Log: view.cpp,v $ * PRODUCTION Revision 1000.5  2004/06/01 20:44:47  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.26 * PRODUCTION * =========================================================================== *//*  $Id: view.cpp,v 1000.5 2004/06/01 20:44:47 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: *    CView -- abstract base class for GBENCH views */#include <ncbi_pch.hpp>#include <gui/core/view.hpp>#include <gui/core/idocument.hpp>#include <gui/core/selection_buffer.hpp>#include <gui/print/print_dlg.hpp>#include <objmgr/util/sequence.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(ncbi::objects);CView::CView()    : m_SelBuffer(new CSelectionBuffer()),      m_EventMask(fAllEvents),      m_VisibleRange(new CSeq_loc()){}CView::~CView(void){}void CView::Show(){    if (m_Window.get()) {        m_Window->show();    }}void CView::Hide(){    if (m_Window.get()) {        m_Window->hide();    }}void CView::OnExit(void){    if (m_Document) {        CRef<CView> view(this);        m_Document->DetachView(this);    }}void CView::OnPrint(void){    CPrintDlg dlg;    if (dlg.ShowModal() == eCancel) {        return;    }    x_Print(dlg.GetOptions());}void CView::GetSelections(TConstScopedObjects& objs) const{    objs = GetSelBuffer().DecomposeToPairs();}void CView::SetSelections(const TConstScopedObjects& objs){    /// FIXME: stub}void CView::x_Print(const CPrintOptions& opts){}void CView::SetSize(int width, int height){    if (m_Window.get()) {        m_Window->size(width, height);    }}void CView::GetSize(int& width, int& height) const{    width  = 0;    height = 0;    if (m_Window.get()) {        width  = m_Window->w();        height = m_Window->h();    }}void CView::SetPosition(int pos_x, int pos_y){    if (m_Window.get()) {        m_Window->position(pos_x, pos_y);    }}void CView::GetPosition(int& pos_x, int& pos_y) const{    pos_x  = 0;    pos_y = 0;    if (m_Window.get()) {        pos_x = m_Window->x();        pos_y = m_Window->y();    }}void CView::Resize(int pos_x, int pos_y, int width, int height){    if (m_Window.get()) {        m_Window->resize(pos_x, pos_y, width, height);    }}void CView::SetTitle(const string& title){    m_TitleStr = title;    if (m_Window.get()) {        m_Window->label(m_TitleStr.c_str());    }}void CView::SetVisibleRange(const CSeq_loc& loc){    m_VisibleRange.Reset(const_cast<CSeq_loc*>(&loc));//    Update(fVisibleRangeChanged);}const CSeq_loc& CView::GetVisibleRange(void) const{    return *m_VisibleRange;}void CView::x_SetDocument(const IDocument& doc){    m_Document.Reset(const_cast<IDocument*> (&doc));}void CView::MessageEventHandler(TUpdateFlags flags, const void *user_data){    switch (flags) {    case fSelectionChanged:        OnSelectionChanged(*reinterpret_cast<const CSelectionBuffer*>(user_data));        break;    case fDocumentChanged:        OnDocumentChanged();        break;    case fViewReleased:        OnViewReleased(*const_cast<IView*>(reinterpret_cast<const IView*>(user_data)));        break;    case fViewCreated:        OnViewCreated(*const_cast<IView*>(reinterpret_cast<const IView*>(user_data)));        break;    case fVisibleRangeChanged:        OnVisibleRangeChanged(*reinterpret_cast<const CSeq_loc*>(user_data));        break;    default:        LOG_POST(Warning << "unhandled message: " << flags);        break;    }}// message event triggers.  These functions start the messaging cascade.void CView::PostVisibleRangeChanged(const CSeq_loc& loc){    GetDocument()->PostGroupMessage(this, fVisibleRangeChanged, &loc);}void CView::PostSelectionChanged(const CSelectionBuffer& buf){    GetDocument()->PostGroupMessage(this, fSelectionChanged, &buf);}void CView::PostDocumentChanged(void){    GetDocument()->PostGroupMessage(this, fDocumentChanged, NULL);}//// default message handlers//void CView::OnSelectionChanged(const CSelectionBuffer&){    _TRACE("unhandled message: OnSelectionChanged()");}void CView::OnDocumentChanged(void){    _TRACE("unhandled message: OnDocumentChanged()");}void CView::OnViewReleased(IView&){    _TRACE("unhandled message: OnViewReleased()");}void CView::OnViewCreated(IView&){    _TRACE("unhandled message: OnViewCreated()");}void CView::OnVisibleRangeChanged(const CSeq_loc&){    _TRACE("unhandled message: OnVisibleRangeChanged()");}// dummy event handlervoid CView::OnAllEvents(CViewEvent::TEventObject evt){    _TRACE("unhandled event: OnViewEvent()");}// Transmitter/reciever QIIEventTransmitter * CView::QueryInterfaceTransmitter(void){    return dynamic_cast<IEventTransmitter*>(this);}IEventReceiver    * CView::QueryInterfaceReceiver(void){    return dynamic_cast<IEventReceiver*>(this);}//// utilities//string CView::x_GetTitle(const CBioseq_Handle& handle) const{    const CSeq_id& best_id = sequence::GetId(handle, sequence::eGetId_Best);    string str("{");    str += NStr::IntToString(m_Document->GetDocID()) + "}: ";    str += GetTitle() + ": ";    best_id.GetLabel(&str);    str += ": ";    str += sequence::GetTitle(handle);    return str;}string CView::GetLabel() const{    return GetTitle();}const CMenuItem* CView::GetMenu() const{    return NULL;}END_NCBI_SCOPE/* * =========================================================================== * $Log: view.cpp,v $ * Revision 1000.5  2004/06/01 20:44:47  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.26 * * Revision 1.26  2004/05/21 22:27:40  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.25  2004/05/17 13:20:15  dicuccio * Added default implementations of GetLabel() and GetMenu() from IWMClient * interface * * Revision 1.24  2004/04/16 14:38:46  dicuccio * Added standard selection marshalling interface * * Revision 1.23  2004/04/07 12:48:48  dicuccio * Dropped unnnecessary conversion ctor.  Initialize m_pHost in base class * * Revision 1.22  2004/03/30 17:09:32  tereshko * Added support for events broadcasting * * Revision 1.21  2004/03/05 17:29:59  dicuccio * Use sequence::GetId() instead of CSeq_id::GetStringDescr() * * Revision 1.20  2004/01/20 18:14:31  dicuccio * Added default ctor * * Revision 1.19  2003/12/22 19:19:24  dicuccio * Clarified process of posting messages to other views.  Removed CView::Update(). * * Revision 1.18  2003/11/19 20:40:41  friedman * Added grouping views into group message pools * * Revision 1.17  2003/11/04 17:20:37  dicuccio * Implemented window position/size functions * * Revision 1.16  2003/11/04 12:48:04  friedman * Added event message handling and callback for the document all-view * message pool. * * Revision 1.15  2003/10/16 15:49:22  dicuccio * Added function to retrieve a formatted title for a view given a bioseq-handle * * Revision 1.14  2003/10/10 17:16:29  dicuccio * Implemented OnExit() - detach view, return from call forces destruction * * Revision 1.13  2003/09/29 15:29:31  dicuccio * CPrintDlg (CDialog) uses ShowModal(), not Show() * * Revision 1.12  2003/09/04 14:01:51  dicuccio * Introduce IDocument and IView as abstract base classes for CDocument and CView * * Revision 1.11  2003/08/15 19:34:47  dicuccio * Moved print code from gui/utils to gui/print * * Revision 1.10  2003/06/20 14:46:20  dicuccio * Initial changes to implement print functionality * * Revision 1.9  2003/06/16 15:56:55  dicuccio * Added hook for printing, popup of standard print dialog * * Revision 1.8  2003/04/24 16:35:01  dicuccio * Added explicit document set function.  Removed requirement for hard-coded * argument name * * Revision 1.7  2003/03/17 14:50:52  dicuccio * Changed Show()/Hide() from pure virtual to virtual - provided default * implementation * * Revision 1.6  2003/03/10 23:06:13  kuznets * iterate -> ITERATE * * Revision 1.5  2003/03/03 15:19:10  dicuccio * Added logic to handle slaved views * * Revision 1.4  2003/03/03 14:52:24  dicuccio * Added visible range as a base class entity.  Changed initialization to take * plugin arguments instead of IDocument * * Revision 1.3  2003/01/13 13:10:07  dicuccio * Namespace clean-up.  Retired namespace gui -> converted all to namespace * ncbi.  Moved all FLUID-generated code into namespace ncbi. * * Revision 1.2  2002/11/08 02:14:41  dicuccio * Minor code clean-ups (reformat text, eliminate dead variables, favor NCBI * macros) * * Revision 1.1  2002/11/06 17:46:19  dicuccio * Initial revision * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?