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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_OBJECT_LIST_WIDGET___OBJECT_LIST_WIDGET__HPP
2 #define GUI_WIDGETS_OBJECT_LIST_WIDGET___OBJECT_LIST_WIDGET__HPP
3 
4 /* $Id: object_list_widget.hpp 39666 2017-10-25 16:01:13Z katargir $
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, Yury voronov
30  *
31  * File Description:
32  *
33  */
34 
35 #include <gui/gui_export.h>
36 
38 
40 
42 
44 
45 
47 
48 ///////////////////////////////////////////////////////////////////////////////
49 /// CObjectListTableModel
50 
52  : public CwxAbstractTableModel
53 {
54 public:
55  CObjectListTableModel() : m_ObjectList( new CObjectList() ) {}
56  CObjectListTableModel( CObjectList& list ) : m_ObjectList( &list ) {}
57 
58  virtual ~CObjectListTableModel();
59 
60  CObjectList* GetObjectList() { return m_ObjectList.GetPointer(); }
61  void SetObjectList( CObjectList& list );
62  void SetObjects( TConstScopedObjects& objects );
63 
64  CObject* GetObject( int row ){ return m_ObjectList->GetObject( row ); }
65  objects::CScope* GetScope( int row ){ return m_ObjectList->GetScope( row ); }
66 
67  void Clear();
68 
69  /// @name IwxTableModel virtual functions implementation
70  /// @{
71  virtual int GetNumRows() const;
72 
73  virtual int GetNumColumns() const;
74  virtual wxString GetColumnType( int col ) const;
75  virtual wxString GetColumnName( int col ) const;
76 
77  virtual wxVariant GetValueAt( int row, int col ) const;
78  /// @}
79 
80  /// @name Table model decorations from IwxDecoratedTableModel
81  /// @{
82  virtual CIRef<IwxStringFormat> GetColumnFormat( int col ) const;
83  virtual wxString GetImageAliasAt( int row, int col ) const;
84  /// @}
85 
86  virtual wxString GetImageAlias( int row ) const;
87 
88  virtual int GetNumExtraColumns() const;
89  virtual wxString GetExtraColumnType( int col ) const;
90  virtual wxString GetExtraColumnName( int col ) const;
91  virtual wxVariant GetExtraValueAt( int row, int col ) const;
92 
93  virtual CIRef<IwxStringFormat> GetExtraColumnFormat( int col ) const;
94 
95 protected:
96  void x_Clear();
97 
98  inline void x_AssertRowValid( int row ) const;
99  bool x_ColIsLabel( int col ) const;
100  int x_AdjustColToData( int col ) const;
101 
102 protected:
104 
105  struct CachedCell
106  {
107  CachedCell() : m_Initialized(false) {}
108  CachedCell(const string& value) : m_Initialized(true), m_Value(value) {}
109 
111  string m_Value;
112  };
113 
114  bool x_GetCachedLabel(int row, int col, string& value) const;
115  void x_SetCachedLabel(int row, int col, const string& value) const;
116  mutable vector<vector<CachedCell> > m_Cache;
117 };
118 
119 
120 ///////////////////////////////////////////////////////////////////////////////
121 /// CObjectListWidget - mediator widget
123  : public CwxTableListCtrl
124 {
125  // DECLARE_EVENT_TABLE()
126 public:
128 
130  wxWindow* parent,
131  wxWindowID id = wxID_ANY,
132  const wxPoint& pos = wxDefaultPosition,
133  const wxSize& size = wxDefaultSize,
134  long style = 0
135  );
136 
137  //virtual ~CObjectListWidget();
138 
139  //NCBI_DEPRECATED void SetHandler( IObjectColumnHandler* handler );
140  //NCBI_DEPRECATED void SetDefaultHandler();
141 
143  return ((CObjectListTableModel*)GetModel())->GetObjectList();
144  }
145  void SetObjectList( CObjectList& list );
146  void SetObjects( TConstScopedObjects& objects );
147 
148  //NCBI_DEPRECATED void InitModel( TConstScopedObjects& objects, IObjectColumnHandler* handler );
149  //NCBI_DEPRECATED void InitModel( CObjectList& list, IObjectColumnHandler* handler );
150 
151  /// Inits widget with object list and optional model. If model is omitted,
152  /// default implementation is used. If model explicitly stated as NULL,
153  /// model is not replaced.
154  void Init( CObjectList& list, CObjectListTableModel* model = new CObjectListTableModel() );
155 
156  void Clear();
157 
158  /// ISelection-style API
159  void GetSelection( TConstScopedObjects& objects );
160  void DisableMultipleSelection(bool disabled = true);
161 
162  void SaveSettings(CRegistryWriteView& view);
163  void LoadSettings(CRegistryReadView& view);
164 
165  virtual void AppendMenuItems( wxMenu& aMenu );
166 
167 protected:
168  virtual void x_OnCopy();
169 
170  /// Debug & testing methods right now
171  void OnSelected( wxListEvent& anEvt );
172  void OnDeselected( wxListEvent& anEvt );
173 
174  inline CObjectListTableModel* GetOLTModel() const;
175 };
176 
178 {
179  return (CObjectListTableModel*)GetModel();
180 }
181 
183 
184 #endif // GUI_WIDGETS_OBJECT_LIST_WIDGET___OBJECT_LIST_WIDGET__HPP
CObjectListTableModel.
CRef< CObjectList > m_ObjectList
vector< vector< CachedCell > > m_Cache
CObjectListTableModel(CObjectList &list)
objects::CScope * GetScope(int row)
CObject * GetObject(int row)
CObjectList * GetObjectList()
CObjectListWidget - mediator widget.
CObjectList * GetObjectList()
CObjectListTableModel * GetOLTModel() const
CObjectList Data structure representing a list of CObjects with associated Scopes and other optional ...
Definition: object_list.hpp:63
CObject –.
Definition: ncbiobj.hpp:180
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
CwxAbstractTableModel - simple TableModel implementation.
virtual wxVariant GetValueAt(int row, int col) const =0
virtual wxString GetColumnType(int col_idx) const
Tries to extract actual type from row 0 value if it exists.
Definition: table_model.cpp:92
virtual wxString GetColumnName(int col_idx) const
Returns a default name for the column using spreadsheet conventions: A, B, C, ...
Definition: table_model.cpp:82
virtual int GetNumColumns() const =0
Returns the number of columns in the model.
virtual int GetNumRows() const =0
Returns the number of rows in the model.
CwxTableListCtrl - generic wxListCtrl-based Table Control.
IwxTableModel * GetModel() const
virtual CIRef< IwxStringFormat > GetColumnFormat(int) const
virtual wxString GetImageAliasAt(int, int) const
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static void Init(void)
Definition: cursor6.c:76
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#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_OBJECT_LIST_EXPORT
Definition: gui_export.h:531
Defines to provide correct exporting from DLLs in Windows.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static static static wxID_ANY
#define row(bind, expected)
Definition: string_bind.c:73
Modified on Wed Jun 19 17:01:19 2024 by modify_doxy.py rev. 669887