33 #include <wx/imaglist.h>
39 #include <wx/dcmemory.h>
45 #define EVT_SET_VISIBILITY(id, fn) \
46 DECLARE_EVENT_TABLE_ENTRY( \
47 wxEVT_SET_VISIBILITY, id, wxID_ANY, \
48 wxCommandEventHandler(fn), \
63 return wxBitmap(w, h);
66 strings.emplace_back(
" c None");
67 strings.emplace_back(
"X c Gray25");
69 for (
int i = 0;
i < h; ++
i) {
71 int ii =
i - (h - 4) / 2;
72 if (ii >= 0 && ii < 4) {
74 strings.back().replace(0, w,
string(bits[ii] + (7 - w) / 2, w));
80 vector<const char*> xpm;
82 xpm.push_back(s.c_str());
84 return wxBitmap(&xpm[0]);
88 : m_ImageList(), m_SortColumn(0)
90 wxListCtrl::Create(parent,
id, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_VIRTUAL);
95 static const char *
up_xpm[] = {
101 static const char * dn_xpm[] = {
112 InsertColumn(0,
wxT(
"Track Name"), wxLIST_FORMAT_LEFT, 250);
113 InsertColumn(1,
wxT(
"Accession"), wxLIST_FORMAT_LEFT);
114 InsertColumn(2,
wxT(
"Category"), wxLIST_FORMAT_LEFT);
115 InsertColumn(3,
wxT(
"Description"), wxLIST_FORMAT_LEFT);
132 SetColumnWidth(1, wxLIST_AUTOSIZE);
140 long item = HitTest(evt.GetPosition(),
flags);
143 wxCommandEvent eventCustom(wxEVT_SET_VISIBILITY);
144 eventCustom.SetInt(track->
GetVisible() ? 0 : 1);
145 wxPostEvent(
this, eventCustom);
146 if (!GetItemState(item, wxLIST_STATE_SELECTED))
156 int col = evt.GetColumn();
175 for (
int i = 0;
i < GetColumnCount(); ++
i) {
177 item.SetAlign(wxLIST_FORMAT_LEFT);
182 item.SetMask(wxLIST_MASK_IMAGE | wxLIST_MASK_FORMAT);
197 ->
bool { return NStr::CompareNocase(t1->GetDisplayName(), t2->GetDisplayName()) < 0; });
201 ->
bool { string s1 = t1->GetAccession(); if (!NStr::StartsWith(s1,
"NA")) s1 = NcbiEmptyString;
202 string s2 = t2->GetAccession(); if (!NStr::StartsWith(s2,
"NA")) s2 = NcbiEmptyString;
203 return NStr::CompareNocase(s1, s2) < 0; });
207 ->
bool { return NStr::CompareNocase(t1->GetCategory(), t2->GetCategory()) < 0; });
211 ->
bool { return NStr::CompareNocase(t1->GetComments(), t2->GetComments()) < 0; });
221 bool visible = evt.IsChecked();
223 for (
long item = -1;;) {
224 item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
225 if (item == -1)
break;
235 return wxEmptyString;
241 return wxString::FromUTF8(trackName.c_str());
247 return wxString::FromUTF8(accession.c_str());
249 return wxEmptyString;
254 return wxString::FromUTF8(category.c_str());
259 return wxString::FromUTF8(description.c_str());
262 return wxEmptyString;
276 if (filter.empty()) {
282 string trackName =
i->GetDisplayName();
283 string accession =
i->GetAccession();
302 if ((
int)widths.size() == GetColumnCount()) {
303 for (
int i = 0;
i < GetColumnCount(); ++
i) {
305 if (w > 0) SetColumnWidth(
i, w);
313 for (
int i = 0;
i < GetColumnCount(); ++
i)
314 widths.push_back(GetColumnWidth(
i));
316 if (widths.size() > 0)
class CRegistryReadView provides a nested hierarchical view at a particular key.
void GetIntVec(const string &key, vector< int > &val) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
virtual void SetVisible(bool visible)=0
virtual bool GetVisible() const =0
virtual string GetComments() const =0
virtual string GetAccession() const =0
virtual string GetDisplayName() const =0
virtual string GetCategory() const =0
vector< ITrackInfo * > TTracks
void FilterValues(const string &filter)
wxImageList * m_ImageList
void OnColumnClick(wxListEvent &evt)
void LoadSettings(const CRegistryReadView &view)
void OnSetVisibility(wxCommandEvent &evt)
void SetTracks(const TTracks &tracks)
void SaveSettings(CRegistryWriteView view) const
virtual wxString OnGetItemText(long item, long column) const
CTrackListCtrl(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxLC_REPORT|wxLC_VIRTUAL|wxLC_SINGLE_SEL, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxListCtrlNameStr)
void OnLeftDown(wxMouseEvent &evt)
virtual int OnGetItemImage(long item) const
static const char * up_xpm[]
static const char * column
static const char *const strings[]
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
static wxBitmap s_BitmapFrom7x4(int w, int h, const char *const *bits)
static const char * kWidths
#define EVT_SET_VISIBILITY(id, fn)
wxDEFINE_EVENT(wxEVT_SET_VISIBILITY, wxCommandEvent)
wxImageList * CreateCheckboxImages(wxWindow *wnd)