33 #include <wx/choice.h>
34 #include <wx/stattext.h>
35 #include <wx/checkbox.h>
36 #include <wx/textctrl.h>
37 #include <wx/button.h>
38 #include <wx/bmpbuttn.h>
39 #include <wx/choice.h>
40 #include <wx/bitmap.h>
42 #include <wx/msgdlg.h>
43 #include <wx/filedlg.h>
44 #include <wx/dcclient.h>
45 #include <wx/settings.h>
101 IMPLEMENT_DYNAMIC_CLASS(
CTextPanel, wxPanel )
137 : m_bVector(bVector), m_Pos(0) {}
142 m_bVector.set(m_Pos, expandItem.
IsExpanded());
178 case 0: pointSize = 8;
break;
179 case 2: pointSize = 12;
break;
180 case 3: pointSize = 14;
break;
183 #ifdef __WXOSX_COCOA__
185 pointSize = (
int)(pointSize*mult + .5);
188 return wxFont(pointSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
214 Create(parent,
id, pos,
size, style);
295 SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
309 m_TextWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
331 static bool sImagesRegistered =
false;
332 if (!sImagesRegistered) {
336 sImagesRegistered =
true;
340 wxAuiToolBar* toolbar =
nullptr;
344 toolbar = (wxAuiToolBar*)pane.window;
347 if (ctrl) ctrl->Destroy();
358 if (ctrl) ctrl->Destroy();
361 toolbar->ClearTools();
364 toolbar =
new wxAuiToolBar(
this,
wxID_ANY, wxDefaultPosition,
365 wxDefaultSize, wxAUI_TB_HORIZONTAL | wxBORDER_NONE);
371 strings.Add(
_(
"Do not match case"));
375 if (m_FindMode < 0 || m_FindMode >= (
int)
m_FindModeCtrl->GetCount())
383 wxMenu* menu =
new wxMenu();
384 menu->Append(wxID_COPY,
_(
"&Copy"));
385 menu->Append(wxID_PASTE,
_(
"&Paste"));
392 toolbar->AddSeparator();
393 toolbar->AddTool(
ID_TB_Options,
wxT(
"Options"), wxArtProvider::GetBitmap(
wxT(
"text_panel::options")),
wxT(
"Options"));
396 toolbar->AddSeparator();
402 toolbar->AddStretchSpacer();
418 .RightDockable(
false)
419 .BottomDockable(
false)
424 .DestroyOnClose(
true)
427 pane.BestSize(toolbar->GetClientSize());
437 objs.push_back(scoped_object);
468 }
catch (
const exception& e) {
482 if (
data.IsEntrys()) {
514 else if (bioseq_set) {
561 if (
data.IsEntrys()) {
569 submitBlock = &seq_submit->
GetSub();
571 }
else if (!seq_feat) {
575 if (!seq_feat && !seh)
595 formatter->SetContext(*
ctx);
638 wxFont font(
context.GetFontDesc());
646 "&Expand All\tCtrl+E",
650 "Command expands(opens) all of a FlatFile view");
651 wxAcceleratorEntry accelerator(wxACCEL_CTRL,
'E',
kExpandAll);
656 vector<IEditorFactory*> factories;
659 ITERATE(vector<IEditorFactory*>, it, factories) {
660 (*it)->RegisterCommands(cmd_reg, provider);
668 vector<IEditorFactory*> factories;
671 ITERATE(vector<IEditorFactory*>, it, factories) {
768 root->SetDeleteChildren(
false);
773 for (
size_t i = 0;
i < root->GetItemCount(); ++
i) {
804 root->UpdatePositions();
849 .RightDockable(
false)
850 .BottomDockable(
false)
855 .DestroyOnClose(
true)
924 return seq_id || seq_loc || seq_feat || seq_entry || bioseq || bioseq_set;
1043 else if (seq_id || seq_loc || seq_entry || bioseq || bioseq_set)
1063 GetSizer()->Layout();
1074 const wxString caption =
wxT(
"Find Text");
1078 wxMessageBox(
wxT(
"Search string is empty."), caption, wxOK | wxICON_EXCLAMATION);
1093 wxMessageBox(
wxT(
"Search string not found."), caption, wxOK | wxICON_EXCLAMATION);
1111 if (dlg.ShowModal() == wxID_OK) {
1135 vector<pair<CBioseq_Handle, string> > handles(
m_FlatFileSeqs.size());
1139 vector<ITextItem*> items;
1145 errMsg =
"No nucleotide sequences.";
1160 errMsg =
"No sequences.";
1171 string selSeq = seqName;
1176 if (dlg.ShowModal() != wxID_OK)
1182 errMsg =
"Sequence '" + selSeq +
"' not found.";
1204 if (items.empty()) {
1224 if (seq_submit && seq_submit->
IsSetSub())
1225 submitBlock = &seq_submit->
GetSub();
1256 for (
size_t i = 0;
i < seqCount; ++
i) {
1271 for (
size_t i = (
size_t)listStart;
i <
min(seqCount, (
size_t)listStart +
kMaxSeqNumber); ++
i)
1278 size_t selection = 0;
1284 selection = seqIndex - listStart + 2;
1291 if (!pane.IsOk())
return;
1292 wxAuiToolBar* toolbar =
dynamic_cast<wxAuiToolBar*
>(pane.window);
1293 if (!toolbar)
return;
1297 item->SetMinSize(wxDefaultSize);
1300 pane.BestSize(toolbar->GetSize());
1312 if (s.m_Handle == h) {
1321 if (seq.empty())
return false;
1365 if (
objects.size() != 1)
return false;
1397 string str(
"failed to retrieve sequence for id ");
1407 wxString viewTypeString;
1412 if (seq_id || seq_loc || seq_feat || seq_entry || bioseq || bioseq_set) {
1419 if (seq_feat !=
NULL)
1455 TransferDataToWindow();
1468 if (!widget)
return;
1479 if (!widget)
return;
1511 if (!widget)
return;
1538 i.m_Item->Traverse(trv);
User-defined methods of the data storage class.
void InsertItems(size_t index, ITextItem *const *items, size_t count, bool updatePositions=true)
void SetDeleteChildren(bool val)
virtual void SetRegistryPath(const string &path)
virtual void Toggle(CTextPanelContext *context, bool update)
virtual bool IsExpanded() const
CTextItem * GetExpandedItem()
static void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
CRegistryWriteView GetWriteView(const string §ion)
get a read-write view at a particular level.
static CGuiRegistry & GetInstance()
access the application-wide singleton
CRegistryReadView GetReadView(const string §ion) const
get a read-only view at a particular level.
class CRegistryReadView provides a nested hierarchical view at a particular key.
int GetInt(const string &key, int default_val=0) const
access a named key at this level, with no recursion
bool GetBool(const string &key, bool default_val=false) const
string GetString(const string &key, const string &default_val=kEmptyStr) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
const bm::bvector & m_bVector
virtual bool ProcessItem(CTextItem &)
CRestoreTreeTraverser(CTextPanelContext &context, const bm::bvector<> &bVector)
virtual bool ProcessItem(CExpandItem &expandItem)
CTextPanelContext & m_Context
CRichTextCtrl - a wrapper for wxRichTextCtrl that handles additional keyboard events (such as Clipboa...
void SetContextMenu(wxMenu *contextMenu)
virtual bool ProcessItem(CExpandItem &expandItem)
virtual bool ProcessItem(CTextItem &)
CSaveTreeTraverser(bm::bvector<> &bVector)
string GetSequenceId() const
namespace ncbi::objects::
Base class for all serializable objects.
void LoadXml(CTextPanelContext *context, const CSerialObject &so, objects::CScope &scope)
void LoadFasta(CTextPanelContext *context, const vector< pair< objects::CBioseq_Handle, string > > &handles)
void GetFlatFileSeqs(objects::CSeq_entry_Handle &h, const objects::CSubmit_block *submitBlock, const objects::CSeq_loc *seq_loc, objects::CFlatFileConfig::EStyle style)
void LoadAsn(CTextPanelContext *context, const CSerialObject &so, objects::CScope &scope)
void LoadFlatFile(CTextPanelContext *context, const vector< pair< objects::CBioseq_Handle, string > > &handles, const SFlatFileParams ¶ms)
bool MakeObjectVisible(const CObject &object)
void SetMainItem(ITextItem *item, CTextPanelContext *context)
ITextItem * GetRootItem()
CTextPanelContext * GetContext()
void ReportError(const string &report)
bool FindText(const wxString &text, bool matchCase, bool forward)
bool FindSequence(const wxString &text)
virtual bool SetFont(const wxFont &font)
virtual void SetHost(IGuiWidgetHost *host)
IGuiWidgetHost implementation.
CTextPanelContext * x_CreateFastaContext()
CTextPanelContext * x_CreateAsnContext(const CSerialObject &so)
virtual bool SetPosition(const string &seq, const CObject *object)
CTextPanelContext * x_CreateFlatFileContext(bool createEditor=true)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
CTextItemPanel * m_TextWindow
void OnContextMenu(wxContextMenuEvent &event)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
virtual void SetSelectedObjects(const TConstObjects &objects)
bool m_ShowComponentFeats
CTextPanelContext * x_CreateXmlContext(const CSerialObject &so)
void SetInitialViewType(const string &type)
void CreateControls()
Creates the controls and sizers.
IGuiWidgetHost * m_WidgetHost
virtual void DataChanging()
void GetMainObjects(TConstScopedObjects &objs)
static void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
static bool ShowToolTips()
Should we show tooltips?
virtual void GetSelectedObjects(TConstObjects &objects) const
void OnFindModeSelected(wxCommandEvent &event)
void OnSequenceSelected(wxCommandEvent &event)
vector< CFlatFileSeq > m_FlatFileSeqs
void x_CreateMainToolbar()
static void SetTextBackground(const wxColor &color)
bool x_SelectFlatFileSequence(const string &seqName)
bool CanShowFlatFile() const
CRichTextCtrl * m_FindTextCtrl
CConstRef< CObject > m_PositionOnLoad
CRef< CTextDataSource > m_DataSource
ICommandProccessor * m_CmdProccessor
void OnFindNextClick(wxCommandEvent &event)
static wxWindow * CreateForm(wxWindow *parent)
void x_InitContext(CTextPanelContext &context)
wxAuiManager m_AuiManager
CConstRef< CSerialObject > m_SO
CTextItemPanel * GetWidget() const
void SetFontSize(int value)
CRef< objects::CScope > m_Scope
void OnOptionsClick(wxCommandEvent &event)
map< string, bm::bvector<> > m_TreeState
bool GetShowASNPathToRoot() const
wxChoice * m_FindModeCtrl
wxChoice * m_SequenceList
void AddExtensionToolbar(wxAuiToolBar &toolbar, const wxString &name)
void x_UpdateViewType(const wxString &type)
virtual void GetActiveObjects(vector< TConstScopedObjects > &objects)
bool GetShowASNTypes() const
virtual void SetUndoManager(ICommandProccessor *cmdProccessor)
CIRef< IBioseqEditor > x_CreateEditor()
void SequenceListLoaded(const vector< CFlatFileSeq > &sequenceList)
virtual bool InitWidget(TConstScopedObjects &objects)
friend class CAsnViewContext
bool CanShowFastA() const
CIRef< IMenuContributor > GetMenuContributor()
CTextPanel()
Constructors.
virtual void DataChanged()
virtual const CObject * GetOrigObject() const
void DataLoaded(shared_ptr< CRootTextItem > root, shared_ptr< CTextPanelContext > context)
void OnSearchTermCtrlEnter(wxCommandEvent &event)
bool ObjectIsFeature() const
static wxFont GetFont(int size)
CUICommandRegistry is a centralized registry where all application commands should be registered.
int RegisterCommand(CUICommand *cmd)
assumes ownership of the given object returns a command id (useful when registry is used for auto id ...
void AddAccelerator(const wxAcceleratorEntry &entry)
Undo/Redo interface for editing operations.
virtual bool Traverse(ICompositeTraverser &)=0
const_iterator end() const
const_iterator find(const key_type &key) const
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
int Main(int argc, const char *argv[])
const int kFastaTextOffset
static const char * str(char *buf, int n)
static const char *const strings[]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
TValue Get(void) const THROWS_NONE
Get atomic counter value.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
const string & GetMsg(void) const
Get message string.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
void Info(CExceptionArgs_Base &args)
CRef< objects::CScope > scope
void GetExtensionAsInterface(const string &ext_point_id, vector< CIRef< I > > &interfaces)
GetExtensionAsInterface() is a helper function that extracts all extensions implementing the specifie...
vector< CConstRef< CObject > > TConstObjects
CConstRef< CObject > object
vector< SConstScopedObject > TConstScopedObjects
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set &seqset, EMissing action=eMissing_Default)
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Return a handle for the top-level seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CConstRef< CSeq_entry > GetSeq_entryCore(void) const
Get const reference to the seq-entry.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
E_Choice Which(void) const
Which variant is currently selected.
const TData & GetData(void) const
Get the Data member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
list< CRef< CSeq_entry > > TEntrys
const TData & GetData(void) const
Get the Data member data.
const TSub & GetSub(void) const
Get the Sub member data.
bool IsSetSub(void) const
Check if a value has been assigned to Sub data member.
unsigned int
A callback function used to compare two keys in a database.
#define EXT_POINT__EDITOR_FACTORY
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
CConstRef< objects::CSeq_loc > m_SeqLoc
objects::CFlatFileConfig::EMode m_Mode
bool m_ShowComponentFeats
CConstRef< objects::CSubmit_block > m_SeqSubmit
objects::CFlatFileConfig::EStyle m_Style
CAtomicCounter_WithAutoInit gITextItemCount
static const wxChar * pszFlatFile
static const wxChar * pszMainToolbar
static wxColor m_BackgroundColor
static const char * kFeatureMode
static const char * kViewTypeSeq
static const char * kViewTypeFeat
static const char * kMoreSequences
static const char * kAllSequences
static const char * kFFHideSTS
static CSeq_entry_Handle GetSeqEntryHandle(CScope &scope, const CSerialObject &so)
static const char * kShowSequence
static const wxChar * pszASN
const size_t kMaxSeqNumber
static const char * kViewTypeGeneric
static const char * kFontSize
static const char * kFlatFileMode
static const wxChar * pszFastA
static const char * kASNShowPathToRoot
static CFlatFileConfig::EMode s_FFMode(int val)
static const wxChar * pszSequenceToolbar
static CFlatFileConfig::EStyle s_FFStyle(bool showSequence)
static const char * kFindMode
static const char * kOpenExpanded
static const char * kFFHideVariations
static const char * kTextViewPath
static const char * kAllNucleotides
static const char * kFlatFileSequence
static bool s_BackgroundColorSet
static const wxChar * pszXML
static const CSeq_entry * GetSeqEntryFromSeqSubmit(const CSerialObject *so)
static const char * kASNShowTypes
static CS_CONTEXT * context
static wxAcceleratorEntry entries[3]
wxFileArtProvider * GetDefaultFileArtProvider()
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)
wxSize GetDisplayPPI()
Mac always seems to return 72 for screen PPI so use wx function for non-mac and on mac divide the dis...