view.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:12k
- /*
- * ===========================================================================
- * PRODUCTION $Log: view.hpp,v $
- * PRODUCTION Revision 1000.5 2004/06/01 19:47:05 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.29
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_CORE___VIEW__HPP
- #define GUI_CORE___VIEW__HPP
- /* $Id: view.hpp,v 1000.5 2004/06/01 19:47:05 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 <gui/core/iview.hpp>
- #include <gui/objutils/iselection.hpp>
- #include <gui/utils/view_event.hpp>
- #include <util/ievent_receiver.hpp>
- #include <util/ievent_transmitter.hpp>
- #include <gui/plugin/PluginArgSet.hpp>
- #include <gui/print/print_options.hpp>
- #include <objmgr/bioseq_handle.hpp>
- #include <memory>
- BEGIN_NCBI_SCOPE
- class CSelectionBuffer;
- /////////////////////////////////////////////////////////////////////////////
- // CView -- base class for all views
- //
- class NCBI_GUICORE_EXPORT CView : public IView,
- public IEventTransmitter,
- public IEventReceiver,
- public ISelection
- {
- friend class CDocWorkspace;
- public:
- // default ctor
- CView();
- // virtual dtor
- virtual ~CView(void);
- // Show the current window
- virtual void Show(void);
- // Hide the current window
- virtual void Hide(void);
- // callback for exiting a given window
- virtual void OnExit(void);
- // Print the contents of the current window. This is made virtual to allow
- // overrides by derived classes.
- virtual void OnPrint(void);
- // set the size of the window for this view.
- virtual void SetSize(int width, int height);
- // get the size of the window for this view.
- virtual void GetSize(int& width, int& height) const;
- // set the position of the window for this view.
- virtual void SetPosition(int pos_x, int pos_y);
- // set the position of the window for this view.
- virtual void GetPosition(int& pos_x, int& pos_y) const;
- // resize this window.
- virtual void Resize(int pos_x, int pos_y, int width, int height);
- // Access the document associated with this view
- IDocument* GetDocument(void);
- // set the view's title
- void SetTitle(const string& title);
- // Access the event mask. The event mask is a bitmap of flags, each bit of
- // which corresponds to a distinct event. These events define the scope of
- // communication between views and from document to view.
- void SetEventMask(TUpdateFlags flags);
- TUpdateFlags GetEventMask(void) const;
- // Access the selection buffer. The selection buffer is a hierarchical
- // data structure holding lists of items for a number of documents.
- const CSelectionBuffer& GetSelBuffer(void) const;
- CSelectionBuffer& SetSelBuffer(void);
- // ISelection interface requirements.
- void GetSelections(TConstScopedObjects& objs) const;
- void SetSelections(const TConstScopedObjects& objs);
- // Access the visible range. This is provided as a global mechanism to
- // permit other views to maneuver the visible range of their sibling views.
- // This is provided as a virtual function such that sibling views can
- // choose to ignore this message.
- virtual void SetVisibleRange(const objects::CSeq_loc& range);
- // Access the current visible range
- const objects::CSeq_loc& GetVisibleRange(void) const;
- //
- // IWMClient interface
- //
- string GetLabel() const;
- const CMenuItem* GetMenu() const;
- //
- // messaging API
- //
- // Message even handler for inter-view messaging
- void MessageEventHandler(TUpdateFlags flags, const void *user_data);
- // message event triggers. These functions start the messaging cascade.
- void PostDocumentChanged(void);
- void PostVisibleRangeChanged(const objects::CSeq_loc& loc);
- void PostSelectionChanged(const CSelectionBuffer& buf);
- // Message events callbacks
- virtual void OnSelectionChanged(const CSelectionBuffer& sels);
- virtual void OnDocumentChanged(void);
- virtual void OnViewReleased(IView& view);
- virtual void OnViewCreated(IView& view);
- virtual void OnVisibleRangeChanged(const objects::CSeq_loc& loc);
- // Default events handler - reports unhandled event
- void OnAllEvents(CViewEvent::TEventObject evt);
- // Events map - all events to default handler
- EVENT_MAP_RX_BEGIN_INT
- EVENT_ACCEPT_ALL(OnAllEvents)
- EVENT_MAP_RX_END
- // IEventTransmitter
- EVENT_MAP_TX_BEGIN
- EVENT_FIRE_ALL()
- EVENT_MAP_TX_END
- // Transmitter/reciever QI for registering events with document
- virtual IEventTransmitter * QueryInterfaceTransmitter(void);
- virtual IEventReceiver * QueryInterfaceReceiver(void);
- protected:
- // The core chunk of the FLTK GUI that we represent: a child window for the
- // genome workbench framework
- auto_ptr<Fl_Window> m_Window;
- // Each view holds a CRef<> of a single document
- CRef<IDocument> m_Document;
- // Each view manages its own selection buffer.
- CRef<CSelectionBuffer> m_SelBuffer;
- // The bitmask of events this view has chosen to receive.
- TUpdateFlags m_EventMask;
- // The current visible range
- CRef<objects::CSeq_loc> m_VisibleRange;
- // our title (FLTK stores only the pointer, not the contents)
- string m_TitleStr;
- // internal document set function (this hides a const cast)
- void x_SetDocument(const IDocument& doc);
- // internal overridable hook for printing
- virtual void x_Print(const CPrintOptions& opts);
- // create a title string for this view, given a bioseq-handle
- string x_GetTitle(const objects::CBioseq_Handle& handle) const;
- private:
- // Prohibit copying!
- CView(const CView&);
- CView& operator= (const CView&);
- };
- ////////////////////////////////////////////////////////////////////////
- /// Inline Methods
- ////////////////////////////////////////////////////////////////////////
- inline
- void CView::SetEventMask(TUpdateFlags flags)
- {
- m_EventMask = flags;
- }
- inline
- TUpdateFlags CView::GetEventMask(void) const
- {
- return m_EventMask;
- }
- inline
- const CSelectionBuffer& CView::GetSelBuffer(void) const
- {
- return *m_SelBuffer;
- }
- inline
- CSelectionBuffer& CView::SetSelBuffer(void)
- {
- return *m_SelBuffer;
- }
- inline
- IDocument* CView::GetDocument(void)
- {
- return m_Document;
- }
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: view.hpp,v $
- * Revision 1000.5 2004/06/01 19:47:05 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.29
- *
- * Revision 1.29 2004/05/20 12:23:26 dicuccio
- * Removed include for child.hpp
- *
- * Revision 1.28 2004/05/17 13:18:51 dicuccio
- * Removed old document workspace. Inherit views from IWMClient to support new
- * workspace integration. Removed references to CChild.
- *
- * Revision 1.27 2004/05/03 12:42:17 dicuccio
- * Split gui_utils into gui_utils and gui_objutils
- *
- * Revision 1.26 2004/04/16 14:31:57 dicuccio
- * Inherit CView from ISelection. Provide base class support for marshalling
- * selections
- *
- * Revision 1.25 2004/04/07 12:37:35 dicuccio
- * Dropped unnneeded conversion ctor
- *
- * Revision 1.24 2004/03/30 17:09:56 tereshko
- * Added support for events broadcasting
- *
- * Revision 1.23 2004/01/20 18:14:21 dicuccio
- * Added default ctor. Removed dead code
- *
- * Revision 1.22 2003/12/22 19:12:11 dicuccio
- * Modified mechanism for view-view messaging: provide more explicit function
- * signatures; added helper functions to make posting messages easier.
- *
- * Revision 1.21 2003/11/06 19:59:29 dicuccio
- * Removed USING_SCOPE(objects)
- *
- * Revision 1.20 2003/11/04 17:13:37 dicuccio
- * Added APIs for querying GUI position/size
- *
- * Revision 1.19 2003/11/04 13:08:24 dicuccio
- * Formatting changes
- *
- * Revision 1.18 2003/11/04 12:36:50 friedman
- * Added event message handling and callback for the document message pool.
- *
- * Revision 1.17 2003/10/16 15:47:41 dicuccio
- * Added standard interface for retrieving a view's title given a bioseq-handle
- *
- * Revision 1.16 2003/10/10 17:10:57 dicuccio
- * Added callback for OnExit() - called at view release time
- *
- * Revision 1.15 2003/09/04 14:00:26 dicuccio
- * Introduce IDocument and IView as abstract base classes. Use IDocument instead
- * of CDocument.
- *
- * Revision 1.14 2003/08/15 19:33:22 dicuccio
- * Changed location of print code
- *
- * Revision 1.13 2003/06/25 16:59:41 dicuccio
- * Changed CPluginHandle into a pointer-to-implementation (the previous
- * implementation is now the pointer held). Lots of #include file clean-ups.
- *
- * Revision 1.12 2003/06/20 14:42:18 dicuccio
- * Added initial print capabilities
- *
- * Revision 1.11 2003/06/16 15:55:57 dicuccio
- * Work-in-progress: everything compiles, still much reorganization to be done.
- * Moved generic functionality out of opengl/print/ and into gui/utils (print
- * options, print dialogs, etc.). Removed interactive state from CGlCanvas.
- * Added hook in CView for opening standard print dialog, and for generic print
- * handling.
- *
- * Revision 1.10 2003/05/19 13:32:43 dicuccio
- * Moved gui/core/plugin --> gui/plugin/
- *
- * Revision 1.9 2003/04/24 16:14:02 dicuccio
- * Added new interface functions for retrieving / setting the document associated
- * with a view
- *
- * Revision 1.8 2003/03/17 14:58:01 dicuccio
- * Added member variable for the FLTK gui component (stored as auto_ptr<>).
- * Changed Show()/Hide() from pure virtual to virtual; provided default
- * implementation.
- *
- * Revision 1.7 2003/03/03 14:20:32 dicuccio
- * Added visible range as a base class quantity
- *
- * Revision 1.6 2003/01/13 13:11:42 dicuccio
- * Namespace clean-up. Retired namespace gui -> converted to namespace ncbi.
- * Moved all FLUID-generated code into namespace ncbi.
- *
- * Revision 1.5 2002/12/19 18:13:02 dicuccio
- * Added export specifiers for Win32.
- *
- * Revision 1.4 2002/12/12 15:18:57 dicuccio
- * Changed SetSelBuffer to non-const GetSelBuffer. Added copious function
- * description comments.
- *
- * Revision 1.3 2002/11/19 16:56:46 dicuccio
- * Added non-const accessor to a view's selection buffer.
- *
- * Revision 1.2 2002/11/07 18:20:14 dicuccio
- * Moved #ifdef to top of file.
- *
- * Revision 1.1 2002/11/05 19:42:54 dicuccio
- * Initial revision
- *
- * ===========================================================================
- */
- #endif // GUI_CORE___VIEW__HPP