NCBI C++ ToolKit
map_control.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_WX___MAP_CONTROL__HPP
2 #define GUI_WIDGETS_WX___MAP_CONTROL__HPP
3 
4 /* $Id: map_control.hpp 25849 2012-05-23 01:03:31Z voronov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
36 #include <gui/utils/menu_item.hpp>
37 
40 
41 #include <wx/scrolwin.h>
42 
44 
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 ///
48 enum EColorType {
57 };
58 
59 
60 ///////////////////////////////////////////////////////////////////////////////
61 ///
62 /// CMapControl owns all its items.
64  public wxScrolledCanvas,
65  public CSelectionControl//,
66  //public CEventHandler
67 {
68  typedef wxScrolledCanvas TParent;
70 
71 public:
74 
75  enum ESizePolicy {
76  eFixedSize, // model space does not depend on available viewport space
77 
78  /// widget adjusts its model space so that its horizontal size fits into
79  /// available viewport
81 
82  /// widget adjusts its model space so that its vertical size fits into
83  /// available viewport
84  eAdjustVertSize
85  };
86 
87  struct SProperties {
89  int m_MaxItemHeight; /// max item height
90  int m_SepLineWidth; /// width of the separation line between the columns
91  int m_SepLineVertOffset; /// vertical space between separation lines and the borders
92  int m_ItemOffsetX; /// horz space between an item and separation line or border
93  int m_ItemOffsetY; /// vert space around an item
94  bool m_SeparateGroups; // place each group in a separate column
97 
98  SProperties();
99  };
100 
101  CMapControl(wxWindow* parent,
102  wxWindowID id = wxID_ANY,
103  const wxPoint& pos = wxDefaultPosition,
104  const wxSize& size = wxDefaultSize,
105  long style = wxHSCROLL | wxVSCROLL | wxTAB_TRAVERSAL |
106  wxWANTS_CHARS | wxFULL_REPAINT_ON_RESIZE,
107  const wxString& name = wxT("mapcontrol"));
108  virtual ~CMapControl();
109 
110  virtual void SetColumnWidth(int w, bool update = true);
111  virtual void SetMaxItemHeight(int h, bool update = true);
112  SProperties& GetProperties() { return m_Properties; }
113 
114  virtual SwxMapItemProperties& GetMapItemProperties();
115 
116  /// block layout and repainting until control is unlocked
117  virtual void LockUpdates(bool lock = true);
118 
119  virtual TIndex GetItemsCount() const;
120 
121  virtual TItemRef GetItem(TIndex index);
122  virtual TCItemRef GetItem(TIndex index) const;
123 
124  virtual void AddItem(IwxMapItem* item);
125  virtual void InsertItem(TIndex index, IwxMapItem* item);
126  virtual void DeleteItem(TIndex index);
127  virtual void DeleteItem(IwxMapItem& item);
128  virtual void DeleteAllItems();
129 
130  virtual TIndex GetItemIndex(IwxMapItem& item) const;
131  virtual bool Layout();
132 
133 // override CSelectionControl member for hot tracking
134  virtual TIndex GetSelectedIndex() const;
135  TIndex GetHotIndex() const { return m_HotItem; }
136 
137  void OnPaint(wxPaintEvent& event);
138  void OnSize(wxSizeEvent& event);
139 
140  void UpdateSelection();
141 
142 protected:
143  void x_Init();
144 
145  TItemRef x_GetItem(TIndex index);
146  TCItemRef x_GetItem(TIndex index) const;
147 
148  bool x_IsUpdatesLocked() const;
149 
150  virtual void x_InitItemProperties();
151  virtual void x_DrawSeparationLines(wxDC& dc);
152  virtual void x_DrawItemsRange(wxDC& dc, TIndex from, TIndex to);
153 
154 
155  virtual wxSize x_CalculateLayout(int width, int height);
156 
157  virtual void x_DoDefaultActionOnSelected();
158 
159  /// @name CSelectionControl pure virtual functions
160  /// @{
161  virtual void x_SendSelectionEvent(TIndex index);
162  virtual void x_UpdateItems(TIndexVector& indexes);
163  virtual void x_UpdateItemsRange(TIndex start, TIndex end);
164 
165  virtual int x_GetIndexByWindowPos(int win_x, int win_y, bool clip = false);
166 
167  virtual void x_MakeVisible(TIndex index);
168  /// @}
169 
170  void OnContextMenu(wxContextMenuEvent& event);
171  void OnFocusChanged(wxFocusEvent& event);
172  void OnMouseDown(wxMouseEvent& evt);
173  void OnLeftDoubleClick(wxMouseEvent& evt);
174  void OnMouseUp(wxMouseEvent& evt);
175  void OnMouseWheel(wxMouseEvent& event);
176  void OnKeyDown(wxKeyEvent& event);
177  void OnMouseMove(wxMouseEvent& event);
178  void OnMouseLeave(wxMouseEvent& event);
179 
180  void x_HorzMoveSelectionBy(int shift, CGUIEvent::EGUIState state);
181 
182  void x_UpdateHotItem(wxPoint ms_pos);
183 
184  //virtual void x_OnShowPopupMenu();
185  //virtual CMenuItem* x_CreatePopupMenu();
186 protected:
188 
190 
191  /// this is kind of Model
192  typedef vector<TItemRef> TItems;
193 
195  int m_UpdateLockCounter; // when updates are locked the counter is incremented //TODO
196 
197  wxPoint m_PageInc;
199 };
200 
201 
203 
204 /* @} */
205 
206 #endif // GUI_WIDGETS_WX___MAP_CONTROL__HPP
CMapControl owns all its items.
Definition: map_control.hpp:67
SwxMapItemProperties m_ItemProps
@ eAdjustHorzSize
widget adjusts its model space so that its horizontal size fits into available viewport
Definition: map_control.hpp:80
TItems m_Items
SProperties & GetProperties()
CIRef< IwxMapItem > TItemRef
Definition: map_control.hpp:72
SProperties m_Properties
vector< TItemRef > TItems
this is kind of Model
wxScrolledCanvas TParent
Definition: map_control.hpp:68
wxPoint m_PageInc
CConstIRef< IwxMapItem > TCItemRef
Definition: map_control.hpp:73
TIndex GetHotIndex() const
int m_UpdateLockCounter
virtual TIndex GetSelectedIndex() const
virtual void x_UpdateItems(TIndexVector &indexes)=0
void OnMouseDown(wxMouseEvent &event)
Event handling.
virtual int x_GetIndexByWindowPos(int win_x, int win_y, bool clip=false)=0
virtual void x_MakeVisible(TIndex index)=0
virtual void x_UpdateItemsRange(TIndex start, TIndex end)=0
virtual void x_SendSelectionEvent(TIndex index)=0
void OnKeyDown(wxKeyEvent &event)
IwxMapItem Abstarct item of the Map Control.
Definition: imap_item.hpp:55
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_WX_EXPORT
Definition: gui_export.h:543
CMapControl::TIndex TIndex
EColorType
Definition: map_control.hpp:48
@ eReadOnlyText
Definition: map_control.hpp:52
@ eSelectedBack
Definition: map_control.hpp:53
@ eDisabledText
Definition: map_control.hpp:51
@ eBackground
Definition: map_control.hpp:49
@ eFocused
Definition: map_control.hpp:55
@ eSelectedText
Definition: map_control.hpp:54
@ eFocusedText
Definition: map_control.hpp:56
@ eText
Definition: map_control.hpp:50
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
int m_ItemOffsetY
horz space between an item and separation line or border
Definition: map_control.hpp:93
int m_ItemOffsetX
vertical space between separation lines and the borders
Definition: map_control.hpp:92
bool m_SeparateGroups
vert space around an item
Definition: map_control.hpp:94
int m_SepLineWidth
max item height
Definition: map_control.hpp:90
int m_SepLineVertOffset
width of the separation line between the columns
Definition: map_control.hpp:91
SwxMapItemProperties - properties of the IwxMapItem.
Definition: imap_item.hpp:82
Modified on Wed Sep 04 15:05:33 2024 by modify_doxy.py rev. 669887