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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_WX___GROUP_MAP_WIDGET__HPP
2 #define GUI_WIDGETS_WX___GROUP_MAP_WIDGET__HPP
3 
4 /* $Id: group_map_widget.hpp 25493 2012-03-27 18:28:58Z kuznets $
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 
37 
38 //#include <gui/utils/event_handler.hpp>
39 
40 class wxDC;
41 
43 
44 class IMapItem;
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 /// CGroupMapWidget
49  public wxPanel
50 {
51  typedef wxPanel TParent;
52 public:
53  /// @name Definitions of data exchange elements
54  /// @{
55  struct SItemDescr {
56  string m_Label;
57  string m_IconAlias;
58  string m_Description;
60  };
61 
62  typedef vector<SItemDescr> TItemDescrVector;
63 
64  struct SGroupDescr {
65  string m_Label;
66  bool m_Expanded;
68 
69  SGroupDescr(const string& label) : m_Label(label), m_Expanded(true) {};
70  };
71 
72  typedef vector<SGroupDescr> TGroupDescrVector;
73  /// @}
74 
75  CGroupMapWidget(wxWindow* parent,
76  wxWindowID id = wxID_ANY,
77  const wxPoint& pos = wxDefaultPosition,
78  const wxSize& size = wxDefaultSize,
79  long style = wxTAB_TRAVERSAL,
80  const wxString& name = wxT("groupmapwidget"));
81  virtual ~CGroupMapWidget();
82 
83  virtual void Init(const TGroupDescrVector& groups);
84  virtual void Clear();
85 
86  virtual void AddGroup(const string& label, bool expand = true);
87  virtual void AddItem(const string& group_label, const string& label,
88  const string& icon_alias, const string& descr,
89  bool showDefault);
90 
91  virtual void GetGroupLabels(vector<string>& groups) const;
92  virtual bool IsExpanded(const string& group) const;
93 
94  string GetDefaultItem() const { return m_DefaultItem; }
95  void SetDefaultItem(const string& label) { m_DefaultItem = label; }
96 
97  virtual string GetSelectedItem() const;
98  string GetHotItem() const;
99  string GetItemLabel(int index) const;
100 
101  virtual void ExpandGroup(const string& label);
102 
103  virtual CMapControl* GetMapControl();
104 
105  void SetInputCategory(const string& category) { m_InputCategory = category; }
106  string GetInputCategory() const { return m_InputCategory; }
107 
108  /// CGroupItem ////////////////////////////////////////////////////////////
110  {
111  public:
115  eDefaultNo
116  };
117 
118  CGroupItem(const string& label, wxBitmap& icon, const string& descr,
119  EDefaultState def,
120  CGroupMapWidget& widget, bool group);
121 
122  bool IsExpanded() const;
123  void Expand(bool exp);
124 
125  /// @name IMapItem implementation
126  /// @{
127  virtual void Layout(wxDC& dc, SwxMapItemProperties& props);
128  virtual int PreferredHeight(wxDC& dc, SwxMapItemProperties& props, int width);
129  virtual void Draw(wxDC& dc, int state, SwxMapItemProperties& props);
130  virtual void OnDefaultAction();
131  virtual bool OnHotTrack(const wxPoint& ms_pos);
132  virtual void OnMouseDown(const wxPoint& ms_pos);
133  virtual void OnLeftDoubleClick(const wxPoint& ms_pos);
134  /// @}
135 
136  EDefaultState GetDefaultState() const { return m_DefaultState; }
137  void SetDefaultState(EDefaultState state) { m_DefaultState = state; }
138 
139  string GetFullDescr() const;
140 
141  protected:
142  virtual int x_GetItemShift() const;
143  virtual int x_PreferredSeparatorHeight(wxDC& dc) const;
144 
145  virtual void x_DrawBackground(wxDC& dc, const wxRect& rc, int state, SwxMapItemProperties& props);
146 
147  protected:
152  bool m_HotDef;
156  };
157 
158  // Current - Hot or Selected item
159  CConstRef<CGroupItem> GetCurrentItem() const;
160 
162 
164  typedef vector<TItemRef> TMapItems;
165 
166 protected:
167  struct SGroup {
170  };
171 
172  typedef vector<SGroup*> TGroups;
173 
174  int x_GetGroupIndex(const string& label) const;
175 
176  void x_OnToggleGroup(CGroupItem& item);
177  void x_OnSelectItem(CGroupItem& item);
178  void x_OnMakeDefaultItem(CGroupItem& item);
179 
181 
183 
184  wxBitmap m_OpenIcon;
185  wxBitmap m_ClosedIcon;
186 
189 };
190 
191 
193 
194 /* @} */
195 
196 #endif // GUI_WIDGETS_WX___GROUP_MAP_WIDGET__HPP
CConstRef –.
Definition: ncbiobj.hpp:1266
CGroupItem ////////////////////////////////////////////////////////////.
void SetDefaultState(EDefaultState state)
EDefaultState GetDefaultState() const
CGroupMapWidget.
vector< SGroupDescr > TGroupDescrVector
CMapControl::TItemRef TItemRef
vector< SItemDescr > TItemDescrVector
vector< SGroup * > TGroups
void SetInputCategory(const string &category)
vector< TItemRef > TMapItems
CMapControl * m_Control
string GetInputCategory() const
string GetDefaultItem() const
void SetDefaultItem(const string &label)
CMapControl owns all its items.
Definition: map_control.hpp:67
CMapItem This is a base class for IwxMapItem implementations.
Definition: map_item.hpp:53
#define true
Definition: bool.h:35
static void Init(void)
Definition: cursor6.c:76
#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
static const char label[]
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
SGroupDescr(const string &label)
CRef< CGroupMapWidget::CGroupItem > m_GroupItem
SwxMapItemProperties - properties of the IwxMapItem.
Definition: imap_item.hpp:82
Modified on Sat May 25 14:19:32 2024 by modify_doxy.py rev. 669887