📄 splitter.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: splitter.hpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 19:52:22 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== */#ifndef GUI_WIDGETS_FL___SPLITTER__HPP#define GUI_WIDGETS_FL___SPLITTER__HPP/* $Id: splitter.hpp,v 1000.1 2004/06/01 19:52:22 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/ncbistd.hpp>#include <gui/utils/fltk_utils.hpp>#include <FL/Fl_Group.H>/** @addtogroup GUI_FltkWidgets * * @{ */BEGIN_NCBI_SCOPE// by default it has a single cell////////////////////////////////////////////////////////////////////////////////// CSplitter - container with resizable separators.////// CSplitter is divided into a number of Cells, each cell can contain one child/// widget. Any child widget can belong to a single cell.class NCBI_GUIWIDGETS_FL_EXPORT CSplitter : public Fl_Group{public: typedef vector<int> TPosVector; typedef vector<int> TSizeVector; /// EMode - splitter orientation enum EMode { eHorizontal, /// cells are separated with horizontal split lines eVertical, /// cells are separated with vertical split lines eGrid /// cells are separated with in both directions }; CSplitter(int x, int y, int w, int h, const char* label = 0); virtual ~CSplitter(); EMode GetMode() const; /// Creates a splitter with a single cell virtual void Create(EMode mode); /// Creates a splitter with cells defined by "sizes". If mode == eGrid then /// size will be used as both width and heights virtual void Create(EMode mode, const TPosVector& sizes); /// Creates a splitter with cells defined by "sizes". If mode == eGrid then /// ar_sizes will be used as both width and heights. "ar_sizes" is -1 terminated /// array. virtual void Create(EMode mode, const int ar_size[]); /// Creates splitter, "widths" and "height" define number and sizes of cells. virtual void Create(EMode mode, const TPosVector& widths, const TPosVector& heights); /// Creates splitter, "ar_w" and "ar_h" are arrays terminated by -1. virtual void Create(EMode mode, const int ar_w[], const int ar_h[]); virtual void Create(int n_horz_panes, int n_vert_panes); int GetColumnsCount() const; int GetRowsCount() const; /// returns "true" if cell specified by (i_x, i_y) exists in splitter bool IsValidCell(int i_x, int i_y) const; int GetColumnWidth(int i_x) const { return x_GetWidth(i_x); } int GetRowHeight(int i_y) const { return x_GetHeight(i_y); } /// If cell [ix, i_y] exists and vacant - adds widget to the container. /// Returns "true" if widget has been added. bool InsertToCell(Fl_Widget* w, int i_x, int i_y); /// Removes a widget from the cell specified by [i_x, i_y]. Returns pointer /// to removed widget. Fl_Widget* RemoveFromCell(int i_x, int i_y); bool Remove(Fl_Widget* w); void RemoveAll(); bool Find(Fl_Widget* w, int& i_x, int& i_y) const;public: /// @name Fl_Group functions /// @{ /// Adds widgets to the next available cell void add(Fl_Widget *w); void add(Fl_Widget& w); void remove(Fl_Widget &w); //virtual void clear(); virtual void draw(); virtual void resize(int new_x, int new_y, int new_w, int new_h); virtual int handle(int); /// @}protected: /// @name deprecated Fl_Group overridable /// @{ void init_sizes(); void insert(Fl_Widget &w, int n); void begin(); void end(); const Fl_Widget** array() const; Fl_Widget* child(int n) const; int children() const; int find(const Fl_Widget *w) const; int find(const Fl_Widget &w) const; void resizable(Fl_Widget *box); void resizable(Fl_Widget &box); Fl_Widget* resizable() const; Fl_Group& add_resizable(Fl_Widget &box); /// @}protected: void x_Create(EMode mode, const TPosVector& widths, const TPosVector& heights); Fl_Widget* x_GetCell(int i_x, int i_y); int x_GetCellIndex(int i_x, int i_y); int x_GetColumn(int i_cell) const; int x_GetRow(int i_cell) const; int x_GetLeft(int i_x) const; int x_GetRight(int i_x) const; int x_GetWidth(int i_x) const; int x_GetTop(int i_y) const; int x_GetBottom(int i_y) const; int x_GetHeight(int i_y) const; void x_Clear(); void x_ResizeToCell(int i_cell); void x_ResizeToCell(int i_x, int i_y); int x_HandleKeyEvent(); int x_HandleMouseMove(); int x_HandleMousePush(); int x_HandleMouseDrag(); int x_HandleMouseRelease(); virtual void x_OnShowPopupMenu(); void x_DoDragSeparator(bool b_final); /// returns Separator index if hit or -1 int x_HitTestSeparator(int z, TPosVector& vpos); void x_HitTest(int z, TPosVector& vpos, int& i_cell, int& i_sep); bool x_IsDragging() { return m_iDragSepX != -1 || m_iDragSepY != -1; } void x_DistributeEvenly(bool b_x, bool b_y); void x_DoDistributeEvenly(TPosVector& vSplitPos, int size); void x_DoResize(TPosVector& v_split_pos, TSizeVector& v_norm_sizes, int size, int new_size); void x_MoveSeparator(int i_sep, int new_pos, TPosVector& vSplitPos, int size, int& start, int& stop); // updates cells belonging to [start_x, stop_x] or to [start_y, stop_y] void x_UpdateRegion(int start_x, int stop_x, int start_y, int stop_y); void x_NewSplit(TPosVector& v_split_pos, TSizeVector& v_norm_size, int size); void x_Deprecated() const { _ASSERT(false); }protected: typedef vector<Fl_Widget*> TCells; EMode m_Mode; TPosVector m_vSplitPosX; // first pixels of separator TPosVector m_vSplitPosY; // first pixels of separator int m_SepSize; TSizeVector m_vNormSizeX; // normal (not "shrinked") sizes of cells TSizeVector m_vNormSizeY; // normal (not "shrinked") sizes of cells TCells m_vCells; int m_MouseDownX, m_MouseDownY; // window coordinate of last Mouse-Down int m_StartPosX, m_StartPosY; // start position of separators being dragged (local) int m_iDragSepX, m_iDragSepY; // index of separtor being dragged or -1 CGUIEvent m_Event;};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: splitter.hpp,v $ * Revision 1000.1 2004/06/01 19:52:22 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6 2004/05/11 18:55:14 dicuccio * Added doxygen modules info * * Revision 1.5 2004/02/04 20:02:32 yazhuk * Added Remove(), RemoveAll(), Find() and new overload for Create() * * Revision 1.4 2004/01/28 16:45:26 tereshko * Added NCBI_GUIWIDGETS_FL_EXPORT * * Revision 1.3 2004/01/28 16:38:55 yazhuk * Refactored and extended API, added Fl_Group functions * * Revision 1.2 2004/01/23 03:14:45 ucko * Properly capitalize FL directory for headers, and fix another typo nearby. * * Revision 1.1 2004/01/22 16:27:19 yazhuk * Initial revision * * =========================================================================== */#endif // GUI_WIDGETS_FL___SPLITTER__HPP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -