36 #include <wx/dcbuffer.h>
37 #include <wx/settings.h>
70 m_SepLineVertOffset(2),
73 m_SeparateGroups(
true),
74 m_SingleColumn(
false),
75 m_SizePolicy(eAdjustVertSize)
81 const wxSize&
size,
long style,
const wxString& name)
91 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
93 SetScrollRate( 16, 16 );
97 wxColour cl_back = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
98 SetBackgroundColour(cl_back);
163 for(
size_t i = 0;
i < indexes.size();
i++ ) {
177 m_Items[i_focused]->GetRect(rc_foc);
180 TIndex col_start_index = -1, to_index = -1;
185 if(rc.GetLeft() >= rc_foc.GetRight()) {
193 for(
TIndex i = i_focused;
i >= 0;
i-- ) {
195 if(rc.GetRight() < rc_foc.GetLeft() && rc.GetTop() <= rc_foc.GetTop()) {
202 if(col_start_index >= 0) {
205 to_index = col_start_index;
208 m_Items[to_index]->GetRect(rc);
209 if(! (rc.GetTop() > rc_foc.GetBottom() || rc.GetBottom() < rc_foc.GetTop())) {
213 if(to_index == (
int)
m_Items.size()) {
228 wxAutoBufferedPaintDC dc(
this);
231 wxRect rc = GetClientSize();
232 wxBrush brush(GetBackgroundColour());
234 dc.SetPen(*wxTRANSPARENT_PEN);
235 dc.DrawRectangle(rc.x, rc.y, rc.width, rc.height);
245 dc.SetDeviceOrigin(0, 0);
251 bool focused = (wxWindow::FindFocus() ==
this);
253 wxSystemColour
type = focused ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT;
257 type = focused ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_BTNFACE;
270 int origin_x = 0, origin_y = 0, size_x, size_y;
271 GetViewStart(&origin_x, &origin_y);
272 GetVirtualSize(&size_x, &size_y);
275 int start = step * (
int) (floor(
double(origin_x + step) / step));
276 int end = step * (
int) (floor(
double(origin_x + size_x - 1) / step));
281 wxRect rc = GetClientRect();
283 int y1 = rc.y + off_y;
284 int line_h = rc.height - 2 * off_y;
289 dc.SetPen(*wxTRANSPARENT_PEN);
291 for(
int xx = start; xx <= end; xx += step ) {
292 dc.DrawRectangle(xx, y1, sep_w, line_h);
344 bool valid = (index >=0 && index <= (
TIndex)
m_Items.size());
365 SetCursor(wxCursor(wxCURSOR_DEFAULT));
393 SetCursor(wxCursor(wxCURSOR_DEFAULT));
406 for(
size_t i = 0;
i <
m_Items.size();
i++ ) {
443 int focused = (wxWindow::FindFocus() ==
this) ?
446 int origin_x, origin_y;
447 GetViewStart(&origin_x, &origin_y);
461 wxSize old_virt_size = GetVirtualSize();
462 wxSize sz = GetClientSize();
465 if(new_virt_sz != old_virt_size) {
466 SetVirtualSize(new_virt_sz);
478 int max_y = height - 1;
488 for(
size_t i = 0;
i <
m_Items.size();
i++ ) {
494 bool column_full = (item_y + real_h > max_y) && (item_y > 0);
509 rc.SetSize(wxSize(item_w, real_h));
515 sz.y =
max(sz.y, item_y + real_h);
525 wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED,
GetId());
526 event.SetEventObject(
this);
529 (void)GetEventHandler()->ProcessEvent(event);
552 wxPoint pos = GetPosition();
553 int origin_x, origin_y;
554 GetViewStart(&origin_x, &origin_y);
556 rc_draw.Offset(pos.x - origin_x, pos.y - origin_x );
558 if( ! rc_draw.IsEmpty()) {
566 CalcUnscrolledPosition(x, y, &x, &y);
571 if( rc.Contains( x, y ) ){
586 wxSize sz = GetSize();
587 int origin_x, origin_y;
588 GetViewStart(&origin_x, &origin_y);
590 if(rc.GetLeft() < origin_x) {
591 origin_x = rc.GetLeft();
592 }
else if(rc.GetRight() >= origin_x + sz.x) {
593 origin_y = rc.GetRight() - sz.x + 1;
595 if(rc.GetTop() < origin_y) {
596 origin_y = rc.GetTop();
597 }
else if(rc.GetBottom() >= origin_y + sz.y) {
598 origin_y = rc.GetBottom() - sz.y + 1;
600 Scroll(origin_x, origin_y);
630 LOG_POST(
"CMapControl::OnContextMenu()");
639 wxPoint ms_pos =
event.GetPosition();
641 CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
654 wxPoint ms_pos =
event.GetPosition();
658 CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
676 int shift =
event.GetWheelRotation() /
event.GetWheelDelta();
678 int origin_x, origin_y;
679 GetViewStart(&origin_x, &origin_y);
681 int old_origin_x = origin_x;
682 int old_origin_y = origin_y;
691 for(
size_t i = 0;
i <
m_Items.size();
i++ ) {
693 if(rc.GetBottom() > y) {
698 origin_y += rc_next.GetTop();
705 for(
size_t i =
m_Items.size();
i > 0; ) {
708 if(rc.GetTop() < y) {
709 origin_y = rc.GetTop();
732 if(origin_x != old_origin_x || origin_y != old_origin_y) {
733 Scroll(origin_x, origin_y);
751 CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
763 SetCursor(wxCursor(wxCURSOR_HAND));
774 SetCursor(wxCursor(wxCURSOR_DEFAULT));
791 int key =
event.GetKeyCode();
801 case WXK_NUMPAD_ENTER:
806 if (!event.ShiftDown())
808 if (event.ControlDown())
809 flags |= wxNavigationKeyEvent::WinChange ;
bool IsForward(ENa_strand s)
static EGUIState wxGetSelectState(const wxMouseEvent &event)
CMapControl owns all its items.
void OnPaint(wxPaintEvent &event)
virtual void AddItem(IwxMapItem *item)
void OnSize(wxSizeEvent &event)
SwxMapItemProperties m_ItemProps
virtual void SetColumnWidth(int w, bool update=true)
virtual void x_InitItemProperties()
virtual void DeleteAllItems()
@ eAdjustVertSize
widget adjusts its model space so that its vertical size fits into available viewport
@ eAdjustHorzSize
widget adjusts its model space so that its horizontal size fits into available viewport
virtual int x_GetIndexByWindowPos(int win_x, int win_y, bool clip=false)
virtual void x_DoDefaultActionOnSelected()
virtual wxSize x_CalculateLayout(int width, int height)
void OnContextMenu(wxContextMenuEvent &event)
virtual void x_DrawSeparationLines(wxDC &dc)
CIRef< IwxMapItem > TItemRef
void OnMouseWheel(wxMouseEvent &event)
virtual void x_UpdateItems(TIndexVector &indexes)
CMapControl(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL|wxTAB_TRAVERSAL|wxWANTS_CHARS|wxFULL_REPAINT_ON_RESIZE, const wxString &name=wxT("mapcontrol"))
void OnMouseLeave(wxMouseEvent &event)
virtual void InsertItem(TIndex index, IwxMapItem *item)
virtual void SetMaxItemHeight(int h, bool update=true)
void OnMouseMove(wxMouseEvent &event)
virtual void x_DrawItemsRange(wxDC &dc, TIndex from, TIndex to)
bool x_IsUpdatesLocked() const
virtual void LockUpdates(bool lock=true)
block layout and repainting until control is unlocked
void OnKeyDown(wxKeyEvent &event)
void x_HorzMoveSelectionBy(int shift, CGUIEvent::EGUIState state)
void OnMouseDown(wxMouseEvent &evt)
void x_UpdateHotItem(wxPoint ms_pos)
virtual void x_SendSelectionEvent(TIndex index)
void OnLeftDoubleClick(wxMouseEvent &evt)
virtual TIndex GetSelectedIndex() const
virtual void x_MakeVisible(TIndex index)
virtual TItemRef GetItem(TIndex index)
virtual TIndex GetItemsCount() const
TItemRef x_GetItem(TIndex index)
void OnMouseUp(wxMouseEvent &evt)
virtual SwxMapItemProperties & GetMapItemProperties()
virtual void x_UpdateItemsRange(TIndex start, TIndex end)
virtual TIndex GetItemIndex(IwxMapItem &item) const
virtual void DeleteItem(TIndex index)
void OnFocusChanged(wxFocusEvent &event)
virtual TIndex GetFocusedIndex() const
virtual void GetSelectedIndexes(TIndexVector &indexes) const
virtual TIndex GetSelectedIndex() const
bool x_InsertItem(TIndex index, const TItemHandle &item, bool update)
virtual void x_SelectTo(TIndex index)
virtual int GetItemState(TIndex index) const
Items state and selection.
void MoveSelectionBy(int shift, CGUIEvent::EGUIState state)
void OnMouseDown(wxMouseEvent &event)
Event handling.
bool x_DeleteItem(TIndex index, bool update=true)
vector< TIndex > TIndexVector
bool x_AssertIndexValid(TIndex index) const
Protected API -.
void OnKeyDown(wxKeyEvent &event)
IwxMapItem Abstarct item of the Map Control.
virtual void OnMouseDown(const wxPoint &ms_pos)=0
virtual void Layout(wxDC &dc, SwxMapItemProperties &props)=0
virtual bool IsGroupSeparator() const =0
virtual int PreferredHeight(wxDC &dc, SwxMapItemProperties &props, int width)=0
virtual void SetRect(const wxRect &rc)=0
virtual void OnLeftDoubleClick(const wxPoint &ms_pos)=0
virtual void OnDefaultAction()=0
a callback to perform a default action associated with the item
virtual bool OnHotTrack(const wxPoint &ms_pos)=0
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int
A callback function used to compare two keys in a database.
static const int kMaxItemH
default column width
static const int kDefaultColumnW
CMapControl.
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
int m_ItemOffsetY
horz space between an item and separation line or border
int m_ItemOffsetX
vertical space between separation lines and the borders
bool m_SeparateGroups
vert space around an item
int m_SepLineWidth
max item height
int m_SepLineVertOffset
width of the separation line between the columns
SwxMapItemProperties - properties of the IwxMapItem.
void SetFocus(CRef< objects::CSeq_entry > entry)
wxColour GetAverage(const wxColor &c1, const wxColor &c2, double ratio)