NCBI C++ ToolKit
map_control.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: map_control.cpp 47473 2023-04-26 02:25:49Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 
35 
36 #include <wx/dcbuffer.h>
37 #include <wx/settings.h>
38 
39 #include <math.h>
40 
42 
43 ///////////////////////////////////////////////////////////////////////////////
44 /// CMapControl
45 
46 static const int kDefaultColumnW = 160; /// default column width
47 static const int kMaxItemH = 64;
48 
49 BEGIN_EVENT_TABLE(CMapControl, CMapControl::TParent)
50  EVT_PAINT(CMapControl::OnPaint)
51  EVT_SIZE(CMapControl::OnSize)
52  EVT_CONTEXT_MENU(CMapControl::OnContextMenu)
53  EVT_SET_FOCUS(CMapControl::OnFocusChanged)
54  EVT_KILL_FOCUS(CMapControl::OnFocusChanged)
55 
56  EVT_LEFT_DOWN(CMapControl::OnMouseDown)
57  EVT_RIGHT_DOWN(CMapControl::OnMouseDown)
58  EVT_LEFT_DCLICK(CMapControl::OnLeftDoubleClick)
59  EVT_KEY_DOWN(CMapControl::OnKeyDown)
60  EVT_MOUSEWHEEL(CMapControl::OnMouseWheel)
61  EVT_MOTION(CMapControl::OnMouseMove)
62  EVT_LEAVE_WINDOW(CMapControl::OnMouseLeave)
64 
65 
67 : m_ColumnWidth(kDefaultColumnW),
68  m_MaxItemHeight(kMaxItemH),
69  m_SepLineWidth(2),
70  m_SepLineVertOffset(2),
71  m_ItemOffsetX(2),
72  m_ItemOffsetY(2),
73  m_SeparateGroups(true),
74  m_SingleColumn(false),
75  m_SizePolicy(eAdjustVertSize)
76 {
77 }
78 
79 
80 CMapControl::CMapControl(wxWindow* parent, wxWindowID id, const wxPoint& pos,
81  const wxSize& size, long style, const wxString& name)
82 : TParent(parent, id, pos, size, style, name),
83  m_HotItem(-1)
84 {
85  x_Init();
86 }
87 
88 
90 {
91  SetBackgroundStyle(wxBG_STYLE_CUSTOM);
92 
93  SetScrollRate( 16, 16 );
94 
96 
97  wxColour cl_back = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
98  SetBackgroundColour(cl_back);
99 
100  // Setup item rendering properties
101  m_ItemProps.m_Font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
103  m_ItemProps.m_Font.SetWeight(wxFONTWEIGHT_BOLD);
104 
105  m_ItemProps.m_TextColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
107 }
108 
109 
111 {
112  LockUpdates(true);
113 
114  DeleteAllItems();
115 
116  LockUpdates(false);
117 }
118 
119 
120 void CMapControl::SetColumnWidth(int w, bool update)
121 {
122  _ASSERT(w >= 0);
124 
125  if(update) {
126  Layout();
127  }
128 }
129 
130 void CMapControl::SetMaxItemHeight(int h, bool update)
131 {
132  _ASSERT(h >= 0);
134 
135  if(update) {
136  Layout();
137  }
138 }
139 
140 
142 {
143  return m_ItemProps;
144 }
145 
146 
148 {
149  m_UpdateLockCounter += (lock ? 1 : -1);
150  if(m_UpdateLockCounter == 0) {
151  Layout();
152  }
153 }
154 
155 
156 // apply default action to all selected items
158 {
159  //LOG_POST("CMapControl::x_DoDefaultActionOnSelected()");
160  // assuming that single click was handled by CSelectionControl
161  TIndexVector indexes;
162  GetSelectedIndexes(indexes);
163  for( size_t i = 0; i < indexes.size(); i++ ) {
164  TIndex ind = indexes[i];
165  IwxMapItem* item = x_GetItem(ind);
166  if(item) {
167  item->OnDefaultAction();
168  }
169  }
170 }
171 
173 {
174  TIndex i_focused = GetFocusedIndex();
175  if(i_focused >= 0) {
176  wxRect rc_foc;
177  m_Items[i_focused]->GetRect(rc_foc);
178 
179  // find an element in the columnt to the right (left)
180  TIndex col_start_index = -1, to_index = -1;
181  if(shift > 0) {
182  wxRect rc;
183  for( TIndex i = i_focused; i < (TIndex) m_Items.size(); i++ ) {
184  m_Items[i]->GetRect(rc);
185  if(rc.GetLeft() >= rc_foc.GetRight()) {
186  col_start_index = i;
187  break;
188  }
189  }
190  } else {
191  // find item to the left that is not lower than focused one
192  wxRect rc;
193  for( TIndex i = i_focused; i >= 0; i-- ) {
194  m_Items[i]->GetRect(rc);
195  if(rc.GetRight() < rc_foc.GetLeft() && rc.GetTop() <= rc_foc.GetTop()) {
196  col_start_index = i;
197  break;
198  }
199  }
200  }
201 
202  if(col_start_index >= 0) {
203  // have found a column - now skip down to the element the intersects
204  // the focused element vertically
205  to_index = col_start_index;
206  wxRect rc;
207  for( ; to_index < (TIndex) m_Items.size(); to_index++ ) {
208  m_Items[to_index]->GetRect(rc);
209  if(! (rc.GetTop() > rc_foc.GetBottom() || rc.GetBottom() < rc_foc.GetTop())) {
210  break; // intersects rec vertically
211  }
212  }
213  if(to_index == (int)m_Items.size()) {
214  to_index = (int)(m_Items.size() - 1);
215  }
216  }
217 
218  if(to_index != -1) {
219  // we found appropriate item - select it (or the whole range)
220  x_SelectTo(to_index, state);
221  }
222  }
223 }
224 
225 
226 void CMapControl::OnPaint(wxPaintEvent& event)
227 {
228  wxAutoBufferedPaintDC dc(this);
229 
230  // fill background
231  wxRect rc = GetClientSize();
232  wxBrush brush(GetBackgroundColour());
233  dc.SetBrush(brush);
234  dc.SetPen(*wxTRANSPARENT_PEN);
235  dc.DrawRectangle(rc.x, rc.y, rc.width, rc.height);
236 
237  PrepareDC( dc );
238 
240 
242 
243  x_DrawItemsRange(dc, 0, (TIndex)(m_Items.size() - 1));
244 
245  dc.SetDeviceOrigin(0, 0);
246 }
247 
248 
250 {
251  bool focused = (wxWindow::FindFocus() == this);
252 
253  wxSystemColour type = focused ? wxSYS_COLOUR_HIGHLIGHTTEXT : wxSYS_COLOUR_WINDOWTEXT;
254  m_ItemProps.m_SelTextColor = wxSystemSettings::GetColour(type);
255 
256  //type = focused ? eSysColor_FocusedBack : eSysColor_SelectedBack;
257  type = focused ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_BTNFACE;
258  m_ItemProps.m_SelBackColor = wxSystemSettings::GetColour(type);
259 }
260 
261 
263 {
265  return; // do not need to draw
266  }
267 
268  int sep_w = m_Properties.m_SepLineWidth;
269  if(sep_w > 0) {
270  int origin_x = 0, origin_y = 0, size_x, size_y;
271  GetViewStart(&origin_x, &origin_y);
272  GetVirtualSize(&size_x, &size_y);
273 
274  int step = m_Properties.m_ColumnWidth;
275  int start = step * (int) (floor( double(origin_x + step) / step));
276  int end = step * (int) (floor( double(origin_x + size_x - 1) / step));
277 
278  start -= sep_w;
279  end -= sep_w;
280 
281  wxRect rc = GetClientRect();
282  int off_y = m_Properties.m_SepLineVertOffset;
283  int y1 = rc.y + off_y;
284  int line_h = rc.height - 2 * off_y;
285 
286  wxColour cl = GetAverage(GetBackgroundColour(), m_ItemProps.m_TextColor, 0.8f);
287  wxBrush brush(cl);
288  dc.SetBrush(brush);
289  dc.SetPen(*wxTRANSPARENT_PEN);
290 
291  for( int xx = start; xx <= end; xx += step ) {
292  dc.DrawRectangle(xx, y1, sep_w, line_h);
293  }
294  }
295 }
296 
297 
298 void CMapControl::OnSize(wxSizeEvent& event)
299 {
300  Layout();
301 }
302 
303 
305 {
306  return (CMapControl::TIndex)m_Items.size();
307 }
308 
309 
311 {
312  bool valid = x_AssertIndexValid(index);
313  return valid ? m_Items[index] : TItemRef();
314 }
315 
316 
318 {
319  TCItemRef ref;
320  if(x_AssertIndexValid(index)) {
321  ref = m_Items[index];
322  }
323  return ref;
324 }
325 
326 
328 {
329  if(item) {
330  m_Items.push_back(TItemRef(item));
331  TIndex index = (CMapControl::TIndex)(m_Items.size() - 1);
332  CSelectionControl::x_InsertItem(index, item, false);
333 
334  if(! x_IsUpdatesLocked()) {
335  Layout();
336  x_UpdateItemsRange(index, index);
337  }
338  }
339 }
340 
341 
343 {
344  bool valid = (index >=0 && index <= (TIndex) m_Items.size());
345  _VERIFY(valid);
346 
347  if(item) {
348  m_Items.insert(m_Items.begin() + index, TItemRef(item));
349  CSelectionControl::x_InsertItem(index, item, false);
350 
351  if(! x_IsUpdatesLocked()) {
352  Layout();
353  x_UpdateItemsRange(index, (CMapControl::TIndex)m_Items.size() - 1);
354  }
355  }
356 }
357 
358 
360 {
361  bool valid = x_AssertIndexValid(index);
362  if(valid) {
363  if(m_HotItem == index) {
364  m_HotItem = -1;
365  SetCursor(wxCursor(wxCURSOR_DEFAULT));
366  }
367  x_DeleteItem(index, false); // delete from CSelectionControl
368 
369  m_Items.erase(m_Items.begin() + index);
370 
371  if(! x_IsUpdatesLocked()) {
372  Layout();
373  x_UpdateItemsRange(index, (TIndex)m_Items.size() - 1);
374  }
375  }
376 }
377 
378 
380 {
381  TIndex index = GetItemIndex(item);
382  DeleteItem(index);
383 
384  if(! x_IsUpdatesLocked()) {
385  Layout();
386  }
387 }
388 
389 
391 {
392  m_HotItem = -1;
393  SetCursor(wxCursor(wxCURSOR_DEFAULT));
394 
395  m_Items.clear();
397 
398  if(! x_IsUpdatesLocked()) {
399  Layout();
400  }
401 }
402 
403 
405 {
406  for( size_t i = 0; i < m_Items.size(); i++ ) {
407  if(x_GetItem((TIndex)i).GetPointer() == &item) {
408  return (TIndex)i;
409  }
410  }
411  return -1;
412 }
413 
414 
416 {
417  TItemRef ref;
418  if(x_AssertIndexValid(index)) {
419  ref = m_Items[index];
420  }
421  return ref;
422 }
423 
424 
426 {
427  TCItemRef ref;
428  if(x_AssertIndexValid(index)) {
429  ref = m_Items[index];
430  }
431  return ref;
432 }
433 
434 
436 {
437  return m_UpdateLockCounter > 0;
438 }
439 
440 
442 {
443  int focused = (wxWindow::FindFocus() == this) ?
445 
446  int origin_x, origin_y;
447  GetViewStart(&origin_x, &origin_y);
448  wxRect rc;
449 
450  for( TIndex i = from; i <= to; i++ ) {
451  int state = GetItemState(i) | focused;
452  TItemRef item = m_Items[i];
453  item->GetRect(rc);
454  item->Draw(dc/*, rc*/, state, m_ItemProps);
455  }
456 }
457 
458 
460 {
461  wxSize old_virt_size = GetVirtualSize();
462  wxSize sz = GetClientSize();
463 
464  wxSize new_virt_sz = x_CalculateLayout(sz.x, sz.y);
465  if(new_virt_sz != old_virt_size) {
466  SetVirtualSize(new_virt_sz);
467  Refresh();
468  }
469 
470  return true;
471 }
472 
473 
474 wxSize CMapControl::x_CalculateLayout(int width, int height)
475 {
476  int item_x = 0;
477  int item_y = 0;
478  int max_y = height - 1;
479 
480  const int full_sep_w = m_Properties.m_SepLineWidth + 2 * m_Properties.m_ItemOffsetX;
481  const int item_w = (m_Properties.m_SingleColumn)
482  ? width - 2 * m_Properties.m_ItemOffsetX
483  : m_Properties.m_ColumnWidth - full_sep_w;
484 
485  wxSize sz(0, 0);
486  wxClientDC dc(this);
487 
488  for( size_t i = 0; i < m_Items.size(); i++ ) {
489  IwxMapItem& item = *m_Items[i];
490 
491  int pref_h = item.PreferredHeight(dc, m_ItemProps, item_w);
492  int real_h = min(pref_h, m_Properties.m_MaxItemHeight);
493 
494  bool column_full = (item_y + real_h > max_y) && (item_y > 0);
495  bool new_group = (item.IsGroupSeparator()) && (i > 0);
496 
497  // start a new column if needed
499  if(column_full || (new_group && m_Properties.m_SeparateGroups)) {
500  // start a new column
501  item_y = 0;
502  item_x += m_Properties.m_ColumnWidth;
503  }
504  }
505 
506  wxRect rc;
507  rc.SetLeftTop(wxPoint(item_x + m_Properties.m_ItemOffsetX,
508  item_y + m_Properties.m_ItemOffsetY));
509  rc.SetSize(wxSize(item_w, real_h));
510  item.SetRect(rc);
511 
512  item.Layout(dc, m_ItemProps);
513 
514  sz.x = max(sz.x, item_x + m_Properties.m_ColumnWidth);
515  sz.y = max(sz.y, item_y + real_h);
516 
517  item_y += real_h + 2 * m_Properties.m_ItemOffsetY;
518  }
519  return sz;
520 }
521 
522 
524 {
525  wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, GetId());
526  event.SetEventObject(this);
527  event.SetInt(index);
528 
529  (void)GetEventHandler()->ProcessEvent(event);
530 }
531 
532 
534 {
535  Refresh(); //TODO optimize
536 }
537 
538 
540 {
541  wxRect rc_draw;
542  for( TIndex i = start; i <= end; i++ ) {
543  wxRect rc;
544  m_Items[i]->GetRect(rc);
545  if(i == start) {
546  rc_draw = rc;
547  } else {
548  rc_draw.Union(rc);
549  }
550  }
551 
552  wxPoint pos = GetPosition();
553  int origin_x, origin_y;
554  GetViewStart(&origin_x, &origin_y);
555 
556  rc_draw.Offset(pos.x - origin_x, pos.y - origin_x );
557 
558  if( ! rc_draw.IsEmpty()) {
559  Refresh(); // TODO - optimize
560  }
561 }
562 
563 
564 int CMapControl::x_GetIndexByWindowPos(int x, int y, bool clip) //TODO - clip
565 {
566  CalcUnscrolledPosition(x, y, &x, &y);
567 
568  wxRect rc;
569  for( size_t i = 0; i < m_Items.size(); i++ ){
570  m_Items[i]->GetRect(rc);
571  if( rc.Contains( x, y ) ){
572  return (TIndex)i;
573  }
574  }
575  return -1;
576 }
577 
578 
580 {
581  bool valid = x_AssertIndexValid(index);
582  if(valid) {
583  wxRect rc;
584  m_Items[index]->GetRect(rc);
585 
586  wxSize sz = GetSize();
587  int origin_x, origin_y;
588  GetViewStart(&origin_x, &origin_y);
589 
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;
594  }
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;
599  }
600  Scroll(origin_x, origin_y);
601  }
602 }
603 
604 /* TODO this functionality needs to be rewritten wxWidgets-style
605 void CMapControl::x_OnShowPopupMenu()
606 {
607  CMenuItem* root = x_CreatePopupMenu();
608  if(root && ! root->IsSubmenuEmpty()) {
609  CPopupMenu menu(root, this);
610  menu.Popup();
611  } else {
612  delete root;
613  }
614 }
615 
616 
617 // override this function in derived classes
618 CMenuItem* CMapControl::x_CreatePopupMenu()
619 {
620  CPopupMenuEvent evt(this, new CMenuItem("Root")); // no menu by default
621 
622  // let parents provide the menu
623  Send(&evt, eDispatch_Default, ePool_Parent);
624  return evt.GetRootItem();
625 }
626 */
627 
628 void CMapControl::OnContextMenu(wxContextMenuEvent& event)
629 {
630  LOG_POST("CMapControl::OnContextMenu()");
631 }
632 
633 
634 void CMapControl::OnMouseDown(wxMouseEvent& event)
635 {
636  SetFocus();
638 
639  wxPoint ms_pos = event.GetPosition();
640  int index = x_GetIndexByWindowPos(ms_pos.x, ms_pos.y, true);
641  CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
642 
643  if(index != -1) {
644  IwxMapItem* item = x_GetItem(index);
645  item->OnMouseDown(ms_pos);
646  }
647 
648  x_UpdateHotItem(event.GetPosition());
649 }
650 
651 
652 void CMapControl::OnLeftDoubleClick(wxMouseEvent& event)
653 {
654  wxPoint ms_pos = event.GetPosition();
655  x_UpdateHotItem(ms_pos);
656 
657  int index = x_GetIndexByWindowPos(ms_pos.x, ms_pos.y, true);
658  CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
659 
660  if(index != -1) {
661  IwxMapItem* item = x_GetItem(index);
662  item->OnLeftDoubleClick(ms_pos);
663  }
664 }
665 
666 
667 void CMapControl::OnMouseUp(wxMouseEvent& event)
668 {
669  //CSelectionControl::OnMouseUp(event);
670  event.Skip();
671 }
672 
673 
674 void CMapControl::OnMouseWheel(wxMouseEvent& event)
675 {
676  int shift = event.GetWheelRotation() / event.GetWheelDelta();
677 
678  int origin_x, origin_y;
679  GetViewStart(&origin_x, &origin_y);
680 
681  int old_origin_x = origin_x;
682  int old_origin_y = origin_y;
683 
684  switch(m_Properties.m_SizePolicy) {
685  case eAdjustHorzSize: {{
687  int y = origin_y;
688 
689  if(shift > 0) {
690  wxRect rc;
691  for( size_t i = 0; i < m_Items.size(); i++ ) {
692  m_Items[i]->GetRect(rc);
693  if(rc.GetBottom() > y) {
694  // get next item and scroll to it
695  if(++i < m_Items.size()) {
696  wxRect rc_next;
697  m_Items[i]->GetRect(rc_next);
698  origin_y += rc_next.GetTop();
699  }
700  break;
701  }
702  }
703  } else {
704  wxRect rc;
705  for( size_t i = m_Items.size(); i > 0; ) {
706  --i;
707  m_Items[i]->GetRect(rc);
708  if(rc.GetTop() < y) {
709  origin_y = rc.GetTop();
710  break;
711  }
712  }
713  }
714  }
715  break;
716  }}
717  case eAdjustVertSize:
719  return;
720 /*
721  if(shift > 0) {
722  origin_x += m_Properties.m_ColumnWidth;
723  } else {
724  origin_x -= m_Properties.m_ColumnWidth;
725  }
726  break;
727 */
728  default:
729  break;
730  }
731 
732  if(origin_x != old_origin_x || origin_y != old_origin_y) {
733  Scroll(origin_x, origin_y);
734  Refresh();
735  }
736 }
737 
739 {
741 }
742 
743 void CMapControl::OnMouseMove(wxMouseEvent& event)
744 {
745  x_UpdateHotItem(event.GetPosition());
746 }
747 
748 void CMapControl::x_UpdateHotItem(wxPoint ms_pos)
749 {
750  int index = x_GetIndexByWindowPos(ms_pos.x, ms_pos.y, true);
751  CalcUnscrolledPosition(ms_pos.x, ms_pos.y, &ms_pos.x, &ms_pos.y);
752  if(index != -1) {
753  IwxMapItem* item = x_GetItem(index);
754  bool hot = item->OnHotTrack(ms_pos);
755  if(hot) {
756  if(index != m_HotItem) {
757  // clear old hot track
758  if(m_HotItem != -1) {
759  GetItem(m_HotItem)->OnHotTrack(ms_pos);
760  }
761  m_HotItem = index;
762  Refresh();
763  SetCursor(wxCursor(wxCURSOR_HAND));
764  UpdateSelection();
765  }
766  return;
767  }
768  }
769 
770  if (m_HotItem != -1) {
771  GetItem(m_HotItem)->OnHotTrack(ms_pos);
772  m_HotItem = -1;
773  Refresh();
774  SetCursor(wxCursor(wxCURSOR_DEFAULT));
775  UpdateSelection();
776  }
777 }
778 
779 void CMapControl::OnMouseLeave(wxMouseEvent& WXUNUSED(event))
780 {
781  x_UpdateHotItem(wxPoint(-1, -1));
782 }
783 
785 {
787 }
788 
789 void CMapControl::OnKeyDown(wxKeyEvent& event)
790 {
791  int key = event.GetKeyCode();
792 
793  switch(key) {
794  case WXK_LEFT:
795  case WXK_RIGHT: {
797  x_HorzMoveSelectionBy((key == WXK_LEFT) ? -1 : 1, state);
798  break;
799  }
800  case WXK_RETURN:
801  case WXK_NUMPAD_ENTER:
803  break;
804  case WXK_TAB: {
805  int flags = 0;
806  if (!event.ShiftDown())
808  if (event.ControlDown())
809  flags |= wxNavigationKeyEvent::WinChange ;
810  Navigate(flags);
811  break;
812  }
813  default:
815  break;
816  }
817 }
818 
819 
820 void CMapControl::OnFocusChanged(wxFocusEvent& event)
821 {
822  Refresh();
823 }
824 
825 
bool IsForward(ENa_strand s)
Definition: Na_strand.hpp:68
static EGUIState wxGetSelectState(const wxMouseEvent &event)
Definition: gui_event.cpp:42
CMapControl owns all its items.
Definition: map_control.hpp:67
void OnPaint(wxPaintEvent &event)
virtual void AddItem(IwxMapItem *item)
virtual bool Layout()
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
Definition: map_control.hpp:84
@ eAdjustHorzSize
widget adjusts its model space so that its horizontal size fits into available viewport
Definition: map_control.hpp:80
TItems m_Items
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
Definition: map_control.hpp:72
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"))
Definition: map_control.cpp:80
SProperties m_Properties
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_Init()
Definition: map_control.cpp:89
wxScrolledCanvas TParent
Definition: map_control.hpp:68
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 ~CMapControl()
int m_UpdateLockCounter
void UpdateSelection()
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.
Definition: imap_item.hpp:55
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
static uch flags
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
#define _VERIFY(expr)
Definition: ncbidbg.hpp:161
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
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.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
int i
static const int kMaxItemH
default column width
Definition: map_control.cpp:47
static const int kDefaultColumnW
CMapControl.
Definition: map_control.cpp:46
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
T max(T x_, T y_)
T min(T x_, T y_)
int m_ItemOffsetY
horz space between an item and separation line or border
Definition: map_control.hpp:93
int m_ItemOffsetX
vertical space between separation lines and the borders
Definition: map_control.hpp:92
bool m_SeparateGroups
vert space around an item
Definition: map_control.hpp:94
int m_SepLineWidth
max item height
Definition: map_control.hpp:90
int m_SepLineVertOffset
width of the separation line between the columns
Definition: map_control.hpp:91
SwxMapItemProperties - properties of the IwxMapItem.
Definition: imap_item.hpp:82
wxColour m_SelTextColor
Definition: imap_item.hpp:85
wxColour m_SelBackColor
Definition: imap_item.hpp:86
Definition: type.c:6
#define _ASSERT
void SetFocus(CRef< objects::CSeq_entry > entry)
wxColour GetAverage(const wxColor &c1, const wxColor &c2, double ratio)
Definition: wx_utils.cpp:810
Modified on Fri Sep 20 14:57:20 2024 by modify_doxy.py rev. 669887