53 #include <wx/toolbar.h>
54 #include <wx/statline.h>
84 void*
data = anEvent.GetClientData();
88 anEvent.SetClientData(
NULL );
97 m_Panel->GetCurrentCtrl()->PopupMenu( menu.get() );
101 #define ACTIVE_VIEW_TARGET_IX 0
102 #define ALL_VIEWS_TARGET_IX 1
104 #define ID_TABLE 10001
105 #define ID_TEXT 10002
106 #define ID_TOOLBAR 10003
107 #define ID_COMBOBOX 10004
119 , m_TargetChoice(
NULL)
120 , m_DisplayMode(eInvalidDisplayMode)
129 #ifdef __WXOSX_COCOA__
130 SetBackgroundStyle(wxBG_STYLE_COLOUR);
131 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_FRAMEBK));
134 wxPanel::Create( parent,
id, pos,
size );
143 PopEventHandler(
true );
144 PopEventHandler(
true );
146 return wxPanel::Destroy();
156 static bool s_RegisteredIcons =
false;
159 if( ! s_RegisteredIcons ){
166 s_RegisteredIcons =
true;
172 wxSizer* sizer =
new wxBoxSizer( wxVERTICAL );
176 wxToolBar* toolBar =
new wxToolBar(
177 this,
ID_TOOLBAR, wxDefaultPosition, wxDefaultSize,
178 wxTB_FLAT | wxTB_HORIZONTAL | wxTB_TEXT | wxTB_HORZ_LAYOUT
182 wxArtProvider::GetBitmap(
wxT(
"menu::insp_table_mode")),
183 wxNullBitmap,
wxT(
"Table mode"));
185 wxArtProvider::GetBitmap(
wxT(
"menu::insp_brief_text_mode")),
186 wxNullBitmap,
wxT(
"Brief Text mode"));
188 wxArtProvider::GetBitmap(
wxT(
"menu::insp_text_mode") ),
189 wxNullBitmap,
wxT(
"Full Text mode"));
190 toolBar->AddSeparator();
201 sizer->Add( toolBar, 0, wxEXPAND );
204 wxStaticLine* line =
new wxStaticLine(
205 this, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL
207 sizer->Add( line, 0, wxEXPAND );
218 m_TextWidget->
SetFont(wxFont(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
289 void*
data = anEvent.GetClientData();
290 menu =
data ? (wxMenu*)
data :
new wxMenu();
293 anEvent.SetClientData( menu );
298 anEvent.SetClientData(
NULL );
345 switch( update.
GetID() ){
399 if( target_ix == wxNOT_FOUND ){
408 string s_active =
"Active View";
414 if( current_client ){
430 if( clients.empty() ){
444 string s =
client->GetSelClientLabel();
447 if(
client == cur_target ){
466 if( !
m_Service || target_ix == wxNOT_FOUND ){
478 client->GetActiveObjects( tmp_sel_objs );
494 if (find(active_clients.begin(), active_clients.end(),
client) == active_clients.end()) {
500 client->GetActiveObjects( tmp_sel_objs );
506 auto loc = dynamic_cast<const objects::CSeq_loc*>(&*obj.object);
507 return loc && loc->GetTotalRange().GetLength() <= 0;
508 }), tmp_sel_objs.end());
510 bool matched =
false;
515 objs.
insert(iter->object.GetPointerOrNull());
519 if (objs.count(iter->object.GetPointerOrNull()) == 0) {
567 typedef tuple<unique_ptr<CCompositeTextItem>, unique_ptr<CTextPanelContext> > TResult;
571 fontDesc =
m_TextWidget->GetFont().GetNativeFontInfoDesc(),
576 auto rootItem = std::make_unique<CCompositeTextItem>();
577 auto context = std::make_unique<CTextPanelContext>(1, nullptr, nullptr);
579 context->SetFontDesc(fontDesc);
581 string logMsg(
"CTextJob: ");
584 NON_CONST_ITERATE(TConstScopedObjects, it, objects) {
585 if (canceled.IsCanceled())
588 if (rootItem->GetItemCount() > 0) {
589 CPlainTextItem* itemDiv = new CPlainTextItem();
590 itemDiv->AddLine(
" ");
591 rootItem->AddItem(itemDiv, false);
593 rootItem->AddItem(CObjectTextItem::CreateTextItem(*it, mode, &canceled), false);
600 catch (std::exception& e) {
608 CCancelGuard guard(&canceled, *
context);
610 wxFont font(
context->GetFontDesc());
613 rootItem->CalcSize(dc,
context.get());
618 std::get<0>(
result) = std::move(rootItem);
625 string errMsg =
"Unknown fatal error";
629 unique_ptr<CCompositeTextItem> rootItem(std::move(std::get<0>(
result)));
630 unique_ptr<CTextPanelContext>
context(std::move(std::get<1>(
result)));
633 textWidget->ReportError(
"No data");
636 textWidget->SetMainItem(rootItem.release(),
context.release());
637 textWidget->Layout();
638 textWidget->Refresh();
645 catch (
const std::exception& e) {
649 textWidget->ReportError(
"Failed: " + errMsg);
651 ,
"Generate Selection Text"));
void remove_if(Container &c, Predicate *__pred)
ICanceled * m_SaveCanceled
CCancelGuard(ICanceled *canceled, CTextPanelContext &context)
CTextPanelContext & m_Context
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.
virtual void LoadSettings()
static const int scm_ModeCmd
virtual void Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
virtual void SetRegistryPath(const string ®_path)
void SetSelectionService(CSelectionService *service)
void x_ResetObjectWidget()
void Init()
Initialises member variables.
ISelectionClient * m_SelView
void OnModeChanged(wxCommandEvent &event)
CTextItemPanel * m_TextWidget
EDisplayMode m_DisplayMode
wxWindow * GetCurrentCtrl()
virtual void SaveSettings() const
std::unique_ptr< async_job > m_Future
void x_ResetTargetChoice()
void OnContextMenu(wxContextMenuEvent &event)
wxChoice * m_TargetChoice
void OnSelServiceStateChange(CSelectionServiceEvent &update)
CSelectionService * m_Service
void OnTargetChanged(wxCommandEvent &event)
void GetSelection(TConstScopedObjects &buf) const
CObjectListWidget * m_ListWidget
CWeakIRef< ISelectionClient > m_CurrentClientWeakPtr
void x_InitCurrentWidget()
void CreateControls()
Creates the controls and sizers.
TConstScopedObjects m_SelObjects
CIRef< ISelectionClient > GetClient()
void GetClients(TClients &clients)
vector< ISelectionClient * > TClients
virtual bool IsAttached(ISelectionClient *client) const
CSelectionPanel * m_Panel
CSelectionViewEventHandler(CSelectionPanel *panel)
void OnContextMenu(wxContextMenuEvent &anEvent)
CTextPanelContext * GetContext()
virtual bool SetFont(const wxFont &font)
ICanceled * SetCanceled(ICanceled *canceled)
void SetContextMenuEventPropagation(bool flag)
void LoadTableSettings(const CRegistryReadView &view, bool byName=false)
void SaveTableSettings(CRegistryWriteView &view, bool saveSorting=true) const
Interface for testing cancellation request in a long lasting operation.
ISelectionClient - represents an object that support a notion of selection.
virtual string GetSelClientLabel()=0
returns a string identifying the client in UI
iterator_bool insert(const value_type &val)
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
void Error(CExceptionArgs_Base &args)
const string & GetMsg(void) const
Get message string.
#define NCBI_REPORT_EXCEPTION(title, ex)
Generate a report on the exception.
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
const TEventID GetID(void) const
Inline Implementation.
vector< SConstScopedObject > TConstScopedObjects
TRefType Lock(void) const
Lock the object and return reference to it.
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
virtual bool IsCanceled(void) const =0
job_function_traits< _Fty >::future job_async(const _Fty &_Fnarg, const string &descr)
const struct ncbi::grid::netcache::search::fields::SIZE size
wxMenu * CreateContextMenuBackbone()
#define ALL_VIEWS_TARGET_IX
#define ACTIVE_VIEW_TARGET_IX
static CNamedPipeClient * client
static CS_CONTEXT * context
wxFileArtProvider * GetDefaultFileArtProvider()
void Merge(wxMenu &menu_1, const wxMenu &menu_2)
merges all items form menu_2 into menu_1, preserving the structure if possible
wxString ToWxString(const string &s)
void CleanupSeparators(wxMenu &menu)
Removes extra separators (in the begining or at the end of the menu, ot those that precede other sepa...