📄 linear_sel_handler.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: linear_sel_handler.hpp,v $ * PRODUCTION Revision 1000.1 2004/04/12 18:16:31 gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.3 * PRODUCTION * =========================================================================== */#ifndef __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP#define __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP/* $Id: linear_sel_handler.hpp,v 1000.1 2004/04/12 18:16:31 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: Andrey Yazhuk * * File Description: * */#include <corelib/ncbistl.hpp>#include <gui/opengl/glbitmapfont.hpp>#include <gui/opengl/glpane.hpp>#include <gui/widgets/gl/ievent_handler.hpp>#include <util/range_coll.hpp>BEGIN_NCBI_SCOPE/////////////////////////////////////////////////////////////////////////////////// class ISelHandlerHostclass NCBI_GUIWIDGETS_GL_EXPORT ISelHandlerHost{public: virtual ~ISelHandlerHost(); virtual void SHH_Redraw() = 0; virtual TModelUnit SHH_GetModelByWindow(int z, EOrientation orient) = 0; virtual TVPUnit SHH_GetWindowByModel(TModelUnit z, EOrientation orient) = 0;};/////////////////////////////////////////////////////////////////////////////////// Class CLinearSelHandler represents in GUI a one-dimnesional multi-segment/// selection. CLinearSelHandler renders the selection in a given CGlPane and/// allows to interactively modify the selection.////// CLinearSelHandler implements IEventHandler what makes it compatible with/// IEventHandler-supproting widgets./// CLinearSelHandler provides API for programmatical manipulation of the // selection.class NCBI_GUIWIDGETS_GL_EXPORT CLinearSelHandler : public IEventHandler{public: typedef CRangeCollection<TSeqPos> TRangeColl; enum ERenderingOption { eActiveState, ePassiveState }; enum EColorType { eSelection, ePasssiveSelection, eSymbol };public: CLinearSelHandler(EOrientation orient = eHorz); virtual ~CLinearSelHandler(); void SetHost(ISelHandlerHost* pHost); void Render(CGlPane& Pane, ERenderingOption option = eActiveState); /// IEventHandler implementation. virtual int handle(CGUIEvent& event, CGlPane& Pane); // colors void SetColor(EColorType type, const CGlColor& color); // commands TSeqRange GetSelectionLimits() const; const TRangeColl& GetSelection() const; void SetSelection(const TRangeColl& C, bool bRedraw); void ResetSelection(bool bRedraw); protected: // user event handlers - translate event to signals int x_OnMousePush(CGUIEvent& event, CGlPane& Pane); int x_OnMouseDrag(CGUIEvent& event, CGlPane& Pane); int x_OnMouseRelease(CGUIEvent& event, CGlPane& Pane); int x_OnMouseMove(CGUIEvent& event, CGlPane& Pane); int x_OnKeyDown(CGUIEvent& event); int x_OnKeyUp(CGUIEvent& event); // signal handlers - invoked by event handlers void x_OnStartSel(CGUIEvent& event); void x_OnChangeSelRange(); void x_OnEndSelRange(); void x_OnResetAll(); void x_OnOpChange(CGUIEvent& event); void x_OnSelectCursor(); void x_SetCursor();protected: enum EExtState { eNoExt, eExtRangeStart, eExtRangeEnd }; enum EOpType { eNoOp, eAdd, eRemove, eChange }; EOpType x_GetOpTypeByEvent(CGUIEvent& event) const; TModelUnit x_MouseToSeqPos(); TSeqPos x_ClipPosByRange(TSeqPos Pos); void x_HitTest(TSeqRange& Range, bool& bHitStart); void x_AddToSelection(const TSeqRange& Range); void x_RemoveFromSelection(const TSeqRange& Range);private: EOrientation m_Orientation; TRangeColl m_Selection; TSeqRange m_CurrRange; // range being modified EExtState m_ExtState; // current range extension state EOpType m_OpType; // operation type bool m_bResizeCursor; ISelHandlerHost* m_pHost; CGlColor m_SelColor; CGlColor m_PassiveSelColor; CGlColor m_SymbolColor; CGlBitmapFont m_Font; CGlPane* m_pPane;};END_NCBI_SCOPE/* * =========================================================================== * $Log: linear_sel_handler.hpp,v $ * Revision 1000.1 2004/04/12 18:16:31 gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.3 * * Revision 1.3 2004/03/11 17:23:04 dicuccio * Use TSeqRange instead of TRange * * Revision 1.2 2004/02/09 13:48:51 lebedev * Added methods for customizing selection colors * * Revision 1.1 2003/12/01 16:33:00 yazhuk * Former alnmulti_sel_handler.hpp moved to gui/widgets/gl * * Revision 1.7 2003/11/17 21:15:39 yazhuk * Updated include for ievent_handler.hpp * * Revision 1.6 2003/10/20 15:45:44 yazhuk * Inherited from IEventHandler * * Revision 1.5 2003/10/08 14:12:58 dicuccio * Moved CGlPane into opengl * * Revision 1.4 2003/09/23 21:07:56 yazhuk * Added #include <corelib/ncbistl.hpp>, removed x_ModifiersOk() * and x_ClipPosByRange() declarations * * Revision 1.3 2003/09/10 20:48:45 yazhuk * Introduced data members for colors and font. Added SHH_GetSeqPosByX() function * * Revision 1.2 2003/09/08 20:43:14 yazhuk * Changed interface for working with Selection * * Revision 1.1 2003/09/08 16:34:21 yazhuk * Initial revision * * * =========================================================================== */#endif // __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -