📄 glpane_widget.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: glpane_widget.hpp,v $ * PRODUCTION Revision 1000.2 2004/04/12 18:16:25 gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4 * PRODUCTION * =========================================================================== */#ifndef GUI_WIDGETS_GL___GLPANE_WIDGET__HPP#define GUI_WIDGETS_GL___GLPANE_WIDGET__HPP/* $Id: glpane_widget.hpp,v 1000.2 2004/04/12 18:16:25 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/ncbiobj.hpp>#include <gui/opengl/glcanvas2d.hpp>#include <gui/opengl/gldlist.hpp>#include <gui/opengl/glviewport.hpp>#include <gui/opengl/glpane.hpp>#include <gui/utils/command.hpp>#include <gui/utils/fltk_utils.hpp>#include <gui/widgets/gl/ievent_handler.hpp>#include <gui/utils/view_event.hpp>#include <util/ievent_receiver.hpp>#include <util/ievent_transmitter.hpp>#include <FL/Fl_Group.H>#include <FL/Fl_Scrollbar.H>BEGIN_NCBI_SCOPE/// CGlPaneWidgetChild represent a window component residing in CGlPaneWidget/// client area.class NCBI_GUIWIDGETS_GL_EXPORT CGlPaneWidgetChild : public CGlCanvas2d {public: CGlPaneWidgetChild(int x, int y, int w, int h, const char* label = NULL); virtual ~CGlPaneWidgetChild(); /// retruns size of the master pane in screen coordinates virtual TVPPoint GetPortSize(void) = 0; // FLTK overridables //virtual void resize(int x, int y, int w, int h); virtual int handle(int event); virtual void draw(); protected: virtual void x_Render(void) = 0; virtual int x_HandleKeyEvent(); virtual int x_HandleMouseMove(); virtual int x_HandleMousePush(); virtual int x_HandleMouseDrag(); virtual int x_HandleMouseRelease(); virtual int x_HandleMouseWheel(); virtual int x_GetAreaByMousePos(); virtual void x_OnShowPopup() = 0; /// IEventHandler management struct SHandlerRec { IEventHandler* m_pHandler; int m_Area; CGlPane* m_pPane; }; bool x_RegisterHandler(IEventHandler* handler, int area, CGlPane* pane); bool x_UnregisterHandler(IEventHandler* handler); void x_SetCurrHandler(SHandlerRec* rec); /// iterates through registered handlers until event is hdnaled (handler /// returned true) int x_Handlers_handle(CGUIEvent& event, int area, bool ignore_curr = true); protected: CGUIEvent m_Event; typedef list<SHandlerRec> THandlerRecList; /// list of records for registered handlers THandlerRecList m_lsHandlerRecs; /// pointer to record for last active handler SHandlerRec* m_pCurrHandlerRec; };/////////////////////////////////////////////////////////////////////////////////// class CGlPaneWidgetclass NCBI_GUIWIDGETS_GL_EXPORT CGlPaneWidget : public Fl_Group, public CCommandTarget, public IEventTransmitter, public IEventReceiver{public: CGlPaneWidget(int x, int y, int w, int h, const char* label = NULL); virtual ~CGlPaneWidget(); /// creates controls and performs basic initialization virtual void Create(void); // Fl_Widget overridables virtual void resize(int x, int y, int w, int h); // Zoom command handlers virtual void OnZoomIn(void); virtual void OnZoomInX(void); virtual void OnZoomInY(void); virtual void OnZoomOut(void); virtual void OnZoomOutX(void); virtual void OnZoomOutY(void); virtual void OnZoomAll(void); virtual void OnZoomAllX(void); virtual void OnZoomAllY(void); // add SetScale function virtual void ZoomRect(const TModelRect& rc); virtual void Scroll(TModelUnit d_x, TModelUnit d_y); // add Scroll functions virtual void OnShowPopup() = 0; // 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 // IViewEventTransmitter EVENT_MAP_TX_BEGIN EVENT_FIRE_ALL() EVENT_MAP_TX_END DECLARE_CMD_MAP();protected: /// creates Pane, Scrollbars and other child widgets, called from Create() virtual void x_CreateControls(void); /// factory method creating master pane, called form x_CreateControls() virtual void x_CreatePane(void) = 0; virtual CGlPaneWidgetChild* x_GetPane() = 0; /// return reference to the Master instance of CGlPane virtual const CGlPane& x_GetPort(void) const; virtual void x_RedrawControls(void); virtual void x_Update(); //### introduce Update levels /// updates model limits of the Master CGlPane virtual void x_SetPortLimits(void) = 0; /// Zoom functions void x_ZoomIn(int options); void x_ZoomOut(int options); void x_ZoomAll(int options); void x_UpdateOnZoom(void); //void x_UpdatePanes(); // ??? //void x_RedrawControls(); // ??? void x_OnResize(void); // ### rename to Update, merge with Update virtual void x_UpdateScrollbars(void) = 0; virtual void x_OnScrollX(void) = 0; virtual void x_OnScrollY(void) = 0; /// scrollbar callback static void x_OnScrollX(Fl_Widget*, void* pData); /// scrollbar callback static void x_OnScrollY(Fl_Widget*, void* pData); /* add various functions here void x_ZoomToRange(TSeqPos from, TSeqPos to); //make version that takes doubles, make vertical version (move to GLPane?) void x_MakeVisibleHorz(TSeqPos pos); void x_MakeVisibleHorz(TSeqPos from, TSeqPos to); */protected: CGlPane m_Port; Fl_Scrollbar *m_pScrollX; Fl_Scrollbar *m_pScrollY;};END_NCBI_SCOPE#endif // GUI_WIDGETS_GL___GLPANE_WIDGET__HPP/* * =========================================================================== * $Log: glpane_widget.hpp,v $ * Revision 1000.2 2004/04/12 18:16:25 gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.4 * * Revision 1.4 2004/03/30 17:10:21 tereshko * Added support for events broadcasting * * Revision 1.3 2004/02/12 20:59:38 yazhuk * Added OnShowPopup() to CGlPaneWidgetx_OnShowPopup(), x_HandleMouseRelease() * to CGlPaneWidgetChild. * * Revision 1.2 2003/12/01 16:38:49 yazhuk * Refactored event handling - introduced CGUIEvent * * Revision 1.1 2003/11/17 20:23:48 yazhuk * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -