47 #include <wx/tokenzr.h>
54 #include <wx/statline.h>
55 #include <wx/spinbutt.h>
56 #include <wx/spinctrl.h>
57 #include <wx/splitter.h>
58 #include <wx/listctrl.h>
59 #include <wx/treectrl.h>
60 #include <wx/notebook.h>
65 #define ID_L_REFS 10000
66 #define ID_B_LAUNCH 10001
68 #define ID_B_EDIT 10003
69 #define ID_B_DOWN 10004
70 #define ID_B_ADD 10005
71 #define ID_B_DELETE 10006
72 #define ID_B_DONE 10007
83 #define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type) \
85 var = wxDynamicCast(FindWindow(id), type); \
87 ERRORMSG("Can't find window with id " << id); \
97 wxWindow* parent, wxWindowID
id,
const wxString& title,
const wxPoint& pos) :
98 wxDialog(parent,
id, title, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
99 sSet(structureSet), dialogHandle(handle), selectItem(0)
101 if (!structureSet || !(descrSet = structureSet->GetCDDDescrSet())) {
102 ERRORMSG(
"CDDRefDialog::CDDRefDialog() - error getting descr set data");
120 bAdd->Enable(!readOnly);
121 bEdit->Enable(!readOnly);
122 bDelete->Enable(!readOnly);
123 bUp->Enable(!readOnly);
124 bDown->Enable(!readOnly);
128 topSizer->SetSizeHints(
this);
135 TRACEMSG(
"CDD references dialog destroyed");
149 wxArrayInt selections;
150 int nSelected = listbox->GetSelections(selections);
151 selectItem = (nSelected > 0) ? selections.Item(selections.GetCount() - 1) : -1;
156 if (event.GetId() ==
ID_B_LAUNCH && nSelected > 0) {
157 string url(
"https://www.ncbi.nlm.nih.gov/pubmed/");
158 for (
int i=0;
i<nSelected; ++
i) {
159 descr =
dynamic_cast<CCdd_descr*
>(
reinterpret_cast<CObject*
>(listbox->GetClientData(selections.Item(
i))));
168 else if (event.GetId() ==
ID_B_ADD) {
169 wxString ids = wxGetTextFromUser(
"Enter a list of PubMed IDs:",
"Input PMIDs",
"",
this);
170 wxStringTokenizer tkz(ids,
" ,;\t\r\n", wxTOKEN_STRTOK);
172 while (tkz.HasMoreTokens()) {
173 wxString
id = tkz.GetNextToken();
174 if (
id.
size() > 0 &&
id.ToLong(&pmidVal) && pmidVal > 0) {
176 ref->SetReference().SetPmid().Set((
int) pmidVal);
177 CCdd_descr_set::Tdata::iterator d, de =
descrSet->Set().end();
178 for (d=
descrSet->Set().begin(); d!=de; ++d) {
179 if (d->GetPointer() == descr) {
189 ERRORMSG(
"Invalid PMID: '" <<
id.c_str() <<
"'");
194 else if (event.GetId() ==
ID_B_EDIT && nSelected == 1) {
197 wxString pmidStr = wxGetTextFromUser(
"Enter/edit the PubMed ID:",
"Edit PMID",
init,
this);
198 unsigned long pmidVal;
199 if (pmidStr.size() > 0 && pmidStr.ToULong(&pmidVal)) {
207 else if (event.GetId() ==
ID_B_DELETE && nSelected > 0) {
209 CCdd_descr_set::Tdata::iterator d, de =
descrSet->Set().end();
210 for (d=
descrSet->Set().begin(); d!=de; ++d) {
212 for (
i=0;
i<nSelected; ++
i)
213 if (d->GetPointer() ==
214 dynamic_cast<CCdd_descr*
>(
reinterpret_cast<CObject*
>(listbox->GetClientData(selections.Item(
i)))))
217 keepDescrs.
Set().push_back(*d);
219 if (keepDescrs.
Get().size() !=
descrSet->Get().size()) {
226 else if ((event.GetId() ==
ID_B_UP || event.GetId() ==
ID_B_DOWN) && nSelected == 1) {
227 CCdd_descr_set::Tdata::iterator d, de =
descrSet->Set().end(), p =
descrSet->Set().end(),
n;
228 for (d=
descrSet->Set().begin(); d!=de; ++d) {
229 if (d->GetPointer() == descr) {
234 }
while (
n !=
descrSet->Set().end() && !((*n)->IsReference() && (*n)->GetReference().IsPmid()));
249 if ((*d)->IsReference() && (*d)->GetReference().IsPmid())
264 CCdd_descr_set::Tdata::iterator d, de =
descrSet->Set().end();
265 for (d=
descrSet->Set().begin(); d!=de; ++d) {
266 if ((*d)->IsReference() && (*d)->GetReference().IsPmid()) {
268 title.Printf(
"%i", (*d)->GetReference().GetPmid().Get());
270 listbox->Append(title, d->GetPointer());
286 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
288 wxStaticBox *item2 =
new wxStaticBox( parent, -1,
wxT(
"PubMed IDs") );
289 wxStaticBoxSizer *item1 =
new wxStaticBoxSizer( item2, wxVERTICAL );
291 wxFlexGridSizer *item3 =
new wxFlexGridSizer( 1, 0, 0 );
293 wxString *strs4 = (wxString*)
NULL;
294 wxListBox *item4 =
new wxListBox( parent,
ID_L_REFS, wxDefaultPosition, wxSize(80,100), 0, strs4, wxLB_EXTENDED|wxLB_NEEDED_SB );
295 item3->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
297 wxGridSizer *item5 =
new wxGridSizer( 2, 0, 0 );
299 wxButton *item6 =
new wxButton( parent,
ID_B_LAUNCH,
wxT(
"Launch"), wxDefaultPosition, wxDefaultSize, 0 );
300 item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
302 wxButton *item7 =
new wxButton( parent,
ID_B_UP,
wxT(
"Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
303 item5->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 );
305 wxButton *item8 =
new wxButton( parent,
ID_B_EDIT,
wxT(
"Edit"), wxDefaultPosition, wxDefaultSize, 0 );
306 item5->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 );
308 wxButton *item9 =
new wxButton( parent,
ID_B_DOWN,
wxT(
"Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
309 item5->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
311 wxButton *item10 =
new wxButton( parent,
ID_B_ADD,
wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0 );
312 item5->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 );
314 wxButton *item11 =
new wxButton( parent,
ID_B_DELETE,
wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
315 item5->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
317 item3->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
319 item1->Add( item3, 0, wxALIGN_CENTRE, 5 );
321 item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
323 wxBoxSizer *item12 =
new wxBoxSizer( wxHORIZONTAL );
325 wxButton *item13 =
new wxButton( parent,
ID_B_DONE,
wxT(
"Done"), wxDefaultPosition, wxDefaultSize, 0 );
326 item12->Add( item13, 0, wxALIGN_CENTRE|wxALL, 5 );
328 item0->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
332 parent->SetAutoLayout(
TRUE );
333 parent->SetSizer( item0 );
336 item0->Fit( parent );
337 item0->SetSizeHints( parent );
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type)
wxSizer * SetupReferencesDialog(wxWindow *parent, bool call_fit=TRUE, bool set_sizer=TRUE)
void OnCloseWindow(wxCloseEvent &event)
CDDRefDialog ** dialogHandle
ncbi::objects::CCdd_descr_set * descrSet
void OnButton(wxCommandEvent &event)
static const unsigned int eCDDData
void SetDataChanged(unsigned int what) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
const TPrim & Get(void) const
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_SCOPE(ns)
Define a new scope.
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.
const Tdata & Get(void) const
Get the member data.
TReference & SetReference(void)
Select the variant.
Tdata & Set(void)
Assign a value to data member.
const TReference & GetReference(void) const
Get the variant data.
TPmid & SetPmid(void)
Select the variant.
const TPmid & GetPmid(void) const
Get the variant data.
const struct ncbi::grid::netcache::search::fields::SIZE size
#define TRUE
bool replacment for C indicating true.