61 #include <wx/dcclient.h>
62 #include <wx/dcbuffer.h>
63 #include <wx/settings.h>
66 #include <wx/sstream.h>
67 #include <wx/txtstrm.h>
68 #include <wx/clipbrd.h>
69 #include <wx/dataobj.h>
94 m_Panel->PushEventHandler(
this);
100 wxFont font = wnd.GetFont();
123 if ((*it)->GetAssosiatedObject() != obj)
124 newSelection.
insert(newSelection.
end(), *it);
133 std::pair <CTextItemPanel::TObjectToItem::iterator, CTextItemPanel::TObjectToItem::iterator> ret =
161 if (
object && objSet.
find(
object.GetPointer()) == objSet.
end()) {
162 objSet.
insert(
object.GetPointer());
173 if (
object && objSet.
find(
object.GetPointer()) == objSet.
end()) {
174 objSet.
insert(
object.GetPointer());
176 scopes_object.
object = object;
177 objects::CScope* scope = (*it)->GetAssosiatedScope();
181 objects.push_back(scopes_object);
228 objects.push_back(scoped_object);
260 objSet.
insert(it->GetPointer());
268 std::pair <CTextItemPanel::TObjectToItem::iterator, CTextItemPanel::TObjectToItem::iterator> ret =
296 : m_Selecting(
false), m_Timer(this), m_TooltipWindow(0), m_MousePos(-1,-1),
297 m_TrackSelection(
false), m_Host()
299 Create(parent,
id, pos,
size, style);
311 SetBackgroundStyle(wxBG_STYLE_PAINT);
315 SetScrollRate(dc.GetCharWidth(),dc.GetCharHeight());
317 #ifndef __WXOSX_COCOA__
318 wxCaret *caret =
new wxCaret(
this, 1, dc.GetCharHeight());
372 if (FindFocus() !=
this)
return;
382 SetVirtualSize(wxSize(0,0));
388 bool retVal = wxScrolledWindow::SetFont(font);
393 SetScrollRate(dc.GetCharWidth(),dc.GetCharHeight());
395 wxCaret* caret = GetCaret();
397 caret->SetSize(1, dc.GetCharHeight());
408 virtual bool ProcessItem(
CTextItem& textItem)
501 textItem->
AddLine(
"Loading...");
528 dc.SetDeviceOrigin(0, 0);
530 if (IsDoubleBuffered()) {
535 wxSize clientSize = GetClientRect().GetSize();
536 int w = clientSize.GetWidth(), h = clientSize.GetHeight();
548 memDC.SetDeviceOrigin(0, 0);
549 dc.Blit(0, 0, w, h, &memDC, 0, 0);
557 wxRect updateRect = GetUpdateRegion().GetBox();
558 dc.DrawRectangle(updateRect);
566 CalcUnscrolledPosition(updateRect.x,updateRect.y,&updateRect.x, &updateRect.y);
571 catch (
const exception&) {
577 wxColor bkgdColor = GetBackgroundColour();
579 bkgdColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
581 dc.SetBrush(wxBrush(bkgdColor));
582 dc.SetPen(wxPen(bkgdColor,1));
583 dc.SetTextBackground(bkgdColor);
584 dc.SetFont(GetFont());
589 if (event.LeftDown() && FindFocus() !=
this)
600 wxMouseEvent ev(event);
601 CalcUnscrolledPosition(event.m_x, event.m_y, &ev.m_x, &ev.m_y);
614 if (!event.LeftDown())
621 wxMouseEvent ev(wxEVT_LEFT_UP);
622 ev.SetEventObject(
this);
631 wxCaret* caret = GetCaret();
634 CalcScrolledPosition(x, y, &x, &y);
640 wxCaret* caret = GetCaret();
657 dc.GetCharHeight(),
m_Context->GetIndentWidth(),
664 CalcScrolledPosition(x + itemPos.x, y + itemPos.y, &x, &y);
678 wxCaret* caret = GetCaret();
679 if (caret) caret->Show();
680 if (m_Host) m_Host->OnTextGotFocus();
685 wxCaret* caret = GetCaret();
686 if (caret) caret->Hide();
692 wxPoint point =
event.GetPosition();
694 if (point.x == -1 && point.y == -1) {
695 wxSize
size = GetSize();
696 point.x =
size.x / 2;
697 point.y =
size.y / 2;
700 point = ScreenToClient(point);
704 wxMenu* menu = cmd_reg.
CreateMenu(kPopupMenu);
708 unique_ptr<wxMenu> contextMenu(
m_Context->CreateMenu());
709 if (contextMenu.get()) {
710 Merge(*menu, *contextMenu);
712 m_Context->GetActiveObjects(sel_objects);
715 vector<wxEvtHandler*> handlers;
726 for(
size_t i = 0;
i < handlers.size();
i++ ) {
727 PushEventHandler(handlers[
i]);
731 PopupMenu(menu, point);
735 for(
size_t i = 0;
i < handlers.size();
i++ ) {
736 wxEvtHandler* h = PopEventHandler();
749 if (wxTheClipboard->Open()) {
750 wxStringOutputStream stream;
751 wxTextOutputStream os(stream);
753 wxTheClipboard->SetData(
new wxTextDataObject(stream.GetString()));
754 wxTheClipboard->Close();
772 GetClientSize(&cw, &ch);
773 GetVirtualSize(&w, &h);
777 GetScrollPixelsPerUnit(&xUnit, &yUnit);
778 Scroll(0, (h - ch)/yUnit);
790 bool found =
false, searchCanceled =
false;
804 if (line.length() >=
str.length()) {
806 if (pos != string::npos) {
807 foundPos = it.GetPosition();
817 wxT(
"Searching for \"") + searchStr +
wxT(
"\"..."));
827 end.
ShiftCol((
int)searchStr.length());
853 item =
dynamic_cast<ITextItem*
>(container);
857 GetClientSize(&cw, &ch);
858 GetVirtualSize(&w, &h);
867 dc.GetCharHeight(),
m_Context->GetIndentWidth(),
873 int yN = y + itemPos.y;
874 CalcScrolledPosition(x + itemPos.x, y + itemPos.y, &x, &y);
877 GetScrollPixelsPerUnit(&xUnit, &yUnit);
883 else if (y + yUnit > ch)
884 Scroll(0, (yN + 2*yUnit - 1 - ch)/yUnit);
892 it->GetContainer(container, index);
896 it =
dynamic_cast<ITextItem*
>(container);
900 GetClientSize(&cw, &ch);
901 GetVirtualSize(&w, &h);
905 wxSize itemSize = item->
GetSize();
908 CalcScrolledPosition(0, itemPos.y, &x, &y);
911 GetScrollPixelsPerUnit(&xUnit, &yUnit);
916 Scroll(0, itemPos.y/yUnit);
917 else if (y + itemSize.GetY() > ch) {
918 if (itemSize.GetY() >= ch)
919 Scroll(0, itemPos.y/yUnit);
921 Scroll(0, (itemPos.y + itemSize.GetY() - ch + yUnit - 1)/yUnit);
927 std::pair <TObjectToItem::iterator, TObjectToItem::iterator> ret =
930 if (ret.first != ret.second) {
946 m_Timer.Start(500, wxTIMER_ONE_SHOT);
960 wxSize clientSize = GetClientSize();
964 if (pos.y + tooltipSize.GetHeight() > clientSize.GetHeight() &&
965 pos.y - tooltipSize.GetHeight() >= 0) {
966 pos.y -= tooltipSize.GetHeight();
969 if (pos.x + tooltipSize.GetWidth() > clientSize.GetWidth()) {
970 pos.x =
max(0, clientSize.GetWidth() - tooltipSize.GetWidth());
std::invoke_result< _Fty, ICanceled & >::type GUI_AsyncExec(_Fty &&_Fnarg, const wxString &msg=wxT("Accessing network..."))
void GetCaretPos(int &caretPosX, int &caretPosY) const
virtual void CalcSize(wxDC &dc, CTextPanelContext *context)
void AddItem(ITextItem *item, bool updatePositions=true)
virtual void Toggle(CTextPanelContext *context, bool update)
virtual bool IsExpanded() const
virtual const CConstRef< CObject > GetAssosiatedObject() const
void SetStyle(const CTextStyle &style)
void AddLine(const string &line)
CTextPosition GetEnd() const
CTextPosition GetStart() const
CTextBlock Normalized() const
TObjectToItem & GetObjectToItem()
void OnContextMenu(wxContextMenuEvent &event)
void OnCopy(wxCommandEvent &event)
bool MakeObjectVisible(const CObject &object)
void SetMainItem(ITextItem *item, CTextPanelContext *context)
void MakePosVisible(const CTextPosition &pos)
void MakeItemVisible(ITextItem *item)
void OnSetFocus(wxFocusEvent &event)
void OnMouseEvent(wxMouseEvent &event)
void SelStart(int row, int col, bool shift)
void ObjectSelectionChanged()
void OnSelectAll(wxCommandEvent &event)
void SetCaretPos(int x, int y)
void OnUpdateCopy(wxUpdateUIEvent &event)
bool GetTrackSelection() const
void ReportError(const string &report)
bool FindText(const wxString &text, bool matchCase, bool forward)
CTextBlock GetTextSelection() const
TObjectToItem m_ObjectToItem
shared_ptr< CTextPanelContext > m_Context
bool IsTextSelected() const
shared_ptr< ITextItem > m_RootItem
void SetSelection(const CTextBlock &selection)
bool FindSequence(const wxString &text)
wxWindow * m_TooltipWindow
void SelMove(int row, int col)
void SelEnd(int row, int col)
void OnTimer(wxTimerEvent &event)
CTextBlock m_TextSelection
virtual bool SetFont(const wxFont &font)
void OnKillFocus(wxFocusEvent &event)
void OnCaptureLost(wxMouseCaptureLostEvent &event)
virtual void OnDraw(wxDC &dc)
virtual wxPoint GetPosition() const
virtual int GetStartLine() const
virtual void TextPosToCollapsed(CTextPosition &WXUNUSED(pos), CTextPanelContext *WXUNUSED(context)) const
void RenderText(CStyledTextOStream &ostream, CTextPanelContext *context) const
virtual void GetVisibleObjects(TConstScopedObjects &)
ITextItem * m_MouseOverItem
void SetSelectedObjects(const TConstObjects &objs)
virtual void GetMainObjects(TConstScopedObjects &objects)
void GetSelectedObjects(TConstObjects &objs)
virtual void EditItem(ITextItem *item, bool controlDown, bool shiftDown)
void SetFontDesc(wxWindow &wnd)
void GetActiveObjects(TConstScopedObjects &objects)
void AddHier(ITextItem *item)
CRef< objects::CScope > m_Scope
bool IsItemSelected(ITextItem *item)
vector< ITextItem * > m_Hier
void MouseOverItem(ITextItem *item)
void SelectItem(ITextItem *item, bool controlDown, bool shiftDown)
virtual void SetPanel(CTextItemPanel *panel)
CConstRef< CSerialObject > m_SO
set< ITextItem * > m_SelectedItems
CUICommandRegistry is a centralized registry where all application commands should be registered.
static CUICommandRegistry & GetInstance()
the main instance associated with the application
wxMenu * CreateMenu(const SwxMenuItemRec *items)
create a menu from a static definition (see WX_*_MENU macros)
Interface for testing cancellation request in a long lasting operation.
virtual wxSize GetSize() const =0
virtual void GetContainer(IContainer *&container, int &index)=0
virtual wxPoint GetPosition() const =0
virtual const CConstRef< CObject > GetAssosiatedObject() const
virtual void OnTextLostFocus()=0
virtual void WidgetSelectionChanged()=0
virtual void OnTextPositionChanged(int row, int col)=0
const_iterator_pair equal_range(const key_type &key) const
container_type::iterator iterator
iterator_bool insert(const value_type &val)
const_iterator begin() const
const_iterator find(const key_type &key) const
const_iterator end() const
static const char * str(char *buf, int n)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
CRef< objects::CScope > scope
vector< CConstRef< CObject > > TConstObjects
CConstRef< CObject > object
vector< SConstScopedObject > TConstScopedObjects
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
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
static string & ToUpper(string &str)
Convert string to upper case – string& version.
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size
#define EXT_POINT__SCOPED_OBJECTS__CMD_CONTRIBUTOR
This Extension Point allows external components to add commands that can be applied to scoped CObject...
void AddCommandsForScopedObjects(wxMenu &aMenu, vector< wxEvtHandler * > &handlers, const string &anExtPointId, TConstScopedObjects &objects, CUICommandRegistry *aCmdReg=NULL)
Helper function for adding commands provided by contributors to the menu.
static const GLdouble origin[]
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
#define row(bind, expected)
#define WX_DEFINE_MENU(name)
New macros for defining menus for use with CUICommandRegistry.
#define WX_MENU_SEPARATOR_L(label)
#define WX_MENU_ITEM(cmd)
void SetFocus(CRef< objects::CSeq_entry > entry)
static CS_CONTEXT * context
void Merge(wxMenu &menu_1, const wxMenu &menu_2)
merges all items form menu_2 into menu_1, preserving the structure if possible
string ToStdString(const wxString &s)
void CleanupSeparators(wxMenu &menu)
Removes extra separators (in the begining or at the end of the menu, ot those that precede other sepa...