📄 cdd_book_ref_dialog.cpp
字号:
Close(false); return; } else if (event.GetId() == ID_B_LAUNCH) { if (selDescr) { wxString url; url.Printf("http://www.ncbi.nlm.nih.gov/books/bv.fcgi?rid=%s", MakeRID((*selDescr)->GetBook_ref()).c_str()); LaunchWebPage(url.c_str()); } } else if (event.GetId() == ID_B_UP || event.GetId() == ID_B_DOWN) { CRef < CCdd_descr > *switchWith = NULL; if (event.GetId() == ID_B_UP && selectedItem > 0) { switchWith = reinterpret_cast<CRef<CCdd_descr>*>(listbox->GetClientData(selectedItem - 1)); --selectedItem; } else if (event.GetId() == ID_B_DOWN && selectedItem < listbox->GetCount() - 1){ switchWith = reinterpret_cast<CRef<CCdd_descr>*>(listbox->GetClientData(selectedItem + 1)); ++selectedItem; } else { WARNINGMSG("CDDBookRefDialog::OnClick() - invalid up/down request"); return; } CRef < CCdd_descr > tmp = *switchWith; *switchWith = *selDescr; *selDescr = tmp; sSet->SetDataChanged(StructureSet::eCDDData); } else if (event.GetId() == ID_B_EDIT) { editOn = true; } else if (event.GetId() == ID_B_SAVE) { DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tName, ID_T_NAME, wxTextCtrl) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(cType, ID_C_TYPE, wxChoice) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tAddress, ID_T_ADDRESS, wxTextCtrl) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tSubaddress, ID_T_SUBADDRESS, wxTextCtrl) long address, subaddress; if (!tAddress->GetValue().ToLong(&address) || (tSubaddress->GetValue().size() > 0 && !tSubaddress->GetValue().ToLong(&subaddress))) { ERRORMSG("Address (required) and sub-address (optional) must be integers"); return; } CCdd_descr *descr; if (selDescr) { // editing existing item descr = selDescr->GetPointer(); } else { // create new item CRef < CCdd_descr > newDescr(new CCdd_descr); descrSet->Set().push_back(newDescr); descr = newDescr.GetPointer(); } descr->SetBook_ref().SetBookname(tName->GetValue().c_str()); descr->SetBook_ref().SetTextelement(*(enum2str.Find(string(cType->GetStringSelection().c_str())))); descr->SetBook_ref().SetElementid((int) address); if (tSubaddress->GetValue().size() > 0) descr->SetBook_ref().SetSubelementid((int) subaddress); else descr->SetBook_ref().ResetSubelementid(); sSet->SetDataChanged(StructureSet::eCDDData); editOn = false; } else if (event.GetId() == ID_B_NEW) { selectedItem = listbox->GetCount(); editOn = true; } else if (event.GetId() == ID_B_PASTE) { if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_TEXT)) { wxTextDataObject data; wxTheClipboard->GetData(data); wxStringTokenizer tkz(data.GetText(), ".#", wxTOKEN_STRTOK); if (tkz.CountTokens() == 3 || tkz.CountTokens() == 4) { bool haveSubaddr = (tkz.CountTokens() == 4); CRef < CCdd_descr > descr(new CCdd_descr); descr->SetBook_ref().SetBookname(tkz.GetNextToken().c_str()); const CCdd_book_ref::ETextelement *type = enum2str.Find(string(tkz.GetNextToken().c_str())); long address, subaddress; bool gotAddr = tkz.GetNextToken().ToLong(&address), gotSubaddr = haveSubaddr ? tkz.GetNextToken().ToLong(&subaddress) : false; if (type && gotAddr && (!haveSubaddr || gotSubaddr)) { descr->SetBook_ref().SetTextelement(*type); descr->SetBook_ref().SetElementid((int) address); if (haveSubaddr) descr->SetBook_ref().SetSubelementid((int) subaddress); else descr->SetBook_ref().ResetSubelementid(); descrSet->Set().push_back(descr); sSet->SetDataChanged(StructureSet::eCDDData); selectedItem = listbox->GetCount(); } } } wxTheClipboard->Close(); } } else if (event.GetId() == ID_B_DELETE) { if (selDescr) { CCdd_descr_set::Tdata::iterator d, de = descrSet->Set().end(); for (d=descrSet->Set().begin(); d!=de; ++d) { if (&(*d) == selDescr) { descrSet->Set().erase(d); sSet->SetDataChanged(StructureSet::eCDDData); if (selectedItem == listbox->GetCount() - 1) --selectedItem; break; } } } else --selectedItem; editOn = false; } else if (event.GetId() == ID_LISTBOX) { selectedItem = listbox->GetSelection(); } SetWidgetStates();}END_SCOPE(Cn3D)//////////////////////////////////////////////////////////////////////////////////////////////////// The following is taken *without* modification from wxDesigner C++ code generated from// cdd_book_ref_dialog.wdr.//////////////////////////////////////////////////////////////////////////////////////////////////wxSizer *SetupBookRefDialog( wxWindow *parent, bool call_fit, bool set_sizer ){ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); wxStaticBox *item2 = new wxStaticBox( parent, -1, wxT("Book References") ); wxStaticBoxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL ); wxString *strs3 = (wxString*) NULL; wxListBox *item3 = new wxListBox( parent, ID_LISTBOX, wxDefaultPosition, wxSize(80,100), 0, strs3, wxLB_SINGLE ); item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxGridSizer *item4 = new wxGridSizer( 2, 0, 0, 0 ); wxButton *item5 = new wxButton( parent, ID_B_UP, wxT("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item6 = new wxButton( parent, ID_B_LAUNCH, wxT("Launch"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item7 = new wxButton( parent, ID_B_NEW, wxT("New"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item8 = new wxButton( parent, ID_B_SAVE, wxT("Save"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item9 = new wxButton( parent, ID_B_DOWN, wxT("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item10 = new wxButton( parent, ID_B_EDIT, wxT("Edit"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item11 = new wxButton( parent, ID_B_PASTE, wxT("Paste"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item12 = new wxButton( parent, ID_B_DELETE, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 ); item4->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 ); item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxStaticLine *item13 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL ); item1->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxFlexGridSizer *item14 = new wxFlexGridSizer( 1, 0, 0, 0 ); item14->AddGrowableCol( 1 ); wxStaticText *item15 = new wxStaticText( parent, ID_TEXT, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 ); item14->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 ); wxTextCtrl *item16 = new wxTextCtrl( parent, ID_T_NAME, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 ); item14->Add( item16, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxStaticText *item17 = new wxStaticText( parent, ID_TEXT, wxT("Type:"), wxDefaultPosition, wxDefaultSize, 0 ); item14->Add( item17, 0, wxALIGN_CENTRE|wxALL, 5 ); wxString strs18[] = { wxT("unassigned"), wxT("section"), wxT("figgrp"), wxT("table"), wxT("chapter"), wxT("biblist"), wxT("box"), wxT("glossary"), wxT("appendix"), wxT("other") }; wxChoice *item18 = new wxChoice( parent, ID_C_TYPE, wxDefaultPosition, wxSize(100,-1), 10, strs18, 0 ); item14->Add( item18, 0, wxALIGN_CENTRE|wxALL, 5 ); item1->Add( item14, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxFlexGridSizer *item19 = new wxFlexGridSizer( 1, 0, 0, 0 ); wxStaticText *item20 = new wxStaticText( parent, ID_TEXT, wxT("Address:"), wxDefaultPosition, wxDefaultSize, 0 ); item19->Add( item20, 0, wxALIGN_CENTRE|wxALL, 5 ); wxTextCtrl *item21 = new wxTextCtrl( parent, ID_T_ADDRESS, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 ); item19->Add( item21, 0, wxALIGN_CENTRE|wxALL, 5 ); wxStaticText *item22 = new wxStaticText( parent, ID_TEXT, wxT("Sub-address:"), wxDefaultPosition, wxDefaultSize, 0 ); item19->Add( item22, 0, wxALIGN_CENTRE|wxALL, 5 ); wxTextCtrl *item23 = new wxTextCtrl( parent, ID_T_SUBADDRESS, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 ); item19->Add( item23, 0, wxALIGN_CENTRE|wxALL, 5 ); item1->Add( item19, 0, wxALIGN_CENTRE|wxALL, 5 ); item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxButton *item24 = new wxButton( parent, ID_B_DONE, wxT("Done"), wxDefaultPosition, wxDefaultSize, 0 ); item24->SetDefault(); item0->Add( item24, 0, wxALIGN_CENTRE|wxALL, 5 ); if (set_sizer) { parent->SetAutoLayout( TRUE ); parent->SetSizer( item0 ); if (call_fit) { item0->Fit( parent ); item0->SetSizeHints( parent ); } } return item0;}/** ---------------------------------------------------------------------------* $Log: cdd_book_ref_dialog.cpp,v $* Revision 1000.2 2004/06/01 18:27:57 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7** Revision 1.7 2004/05/28 21:01:45 thiessen* namespace/typename fixes for GCC 3.4** Revision 1.6 2004/05/21 21:41:38 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.5 2004/03/15 17:27:02 thiessen* prefer prefix vs. postfix ++/-- operators** Revision 1.4 2004/02/19 17:04:45 thiessen* remove cn3d/ from include paths; add pragma to disable annoying msvc warning** Revision 1.3 2003/09/29 23:34:05 thiessen* add launch, paste buttons** Revision 1.2 2003/09/26 17:39:14 thiessen* fixes for button states** Revision 1.1 2003/09/26 17:12:46 thiessen* add book reference dialog**/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -