NCBI C++ ToolKit
map_item.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_WX___MAP_ITEM__HPP
2 #define GUI_WIDGETS_WX___MAP_ITEM__HPP
3 
4 /* $Id: map_item.hpp 24466 2011-09-28 16:19:36Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 
38 
40 
41 class wxDC;
42 class wxEvtHandler;
43 
45 
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// CMapItem
49 /// This is a base class for IwxMapItem implementations. Provides basic services.
51  public CObject,
52  public IwxMapItem
53 {
54 public:
55  CMapItem();
56  CMapItem(const string& label, wxBitmap& icon,
57  const string& descr, bool separator = false);
58  virtual ~CMapItem();
59 
60  const string& GetLabel() const { return m_Label; }
61  const string& GetDescr() const { return m_Descr; }
62 
63  void SetIcon(wxBitmap& image);
64 
65  /// enables sending commands on default action; set target to NULL
66  /// to disable
67  virtual void SetCommand(TCmdID cmd, wxEvtHandler* target);
68 
69  /// @name IwxMapItem implementation
70  /// @{
71  virtual void SetRect(const wxRect& rc);
72  virtual void GetRect(wxRect& rc) const;
73  virtual void Layout(wxDC& dc, SwxMapItemProperties& props);
74  virtual int PreferredHeight(wxDC& dc, SwxMapItemProperties& props, int width);
75  virtual bool IsGroupSeparator() const;
76  virtual void Draw(wxDC& dc, int state, SwxMapItemProperties& props);
77  virtual void OnDefaultAction();
78  virtual bool OnHotTrack(const wxPoint& ms_pos) { return false; }
79  virtual void OnMouseDown(const wxPoint& ms_pos) {}
80  virtual void OnLeftDoubleClick(const wxPoint& ms_pos) {}
81  /// @}
82 
83 protected:
84  void x_Init();
85 
86  virtual int x_GetItemShift() const;
87  virtual int x_GetTextAreaWidth(SwxMapItemProperties& props, int width) const;
88  virtual void x_UpdatePreferredHeights(wxDC& dc, SwxMapItemProperties& props, int width);
89  virtual int x_PreferredSeparatorHeight(wxDC& dc) const;
90  virtual int x_PreferredLabelHeight(wxDC& dc, SwxMapItemProperties& props, int text_w) const;
91  virtual int x_CalculateRealTextWidth(wxDC& dc, SwxMapItemProperties& props);
92 
93  virtual void x_DrawFocusRect(wxDC& dc, const wxRect& rc, int state, SwxMapItemProperties& props);
94  virtual void x_DrawBackground(wxDC& dc, const wxRect& rc, int state, SwxMapItemProperties& props);
95  virtual void x_DrawSeparator(wxDC& dc, const wxRect& rc, SwxMapItemProperties& props);
96  virtual void x_DrawText(wxDC& dc, const string& text, const wxRect& rc, bool selected, bool focused,
97  bool highlighted,
98  SwxMapItemProperties& props);
99 protected:
100  string m_Label;
101  wxBitmap m_Icon;
102  string m_Descr;
104 
106  wxEvtHandler* m_CmdTarget;
107 
108  // Geometry
109  bool m_PrefsDirty; // preferred sizes are out-of-date
111 
112  wxRect m_Rect; // item rect set by the control
113  wxPoint m_IconPos; // top left corner
114  wxRect m_LabelRect;
115 };
116 
117 
119 
120 
121 #endif // GUI_WIDGETS_WX___MAP_ITEM__HPP
CMapItem This is a base class for IwxMapItem implementations.
Definition: map_item.hpp:53
wxPoint m_IconPos
Definition: map_item.hpp:113
wxBitmap m_Icon
Definition: map_item.hpp:101
bool m_PrefsDirty
Definition: map_item.hpp:109
string m_Descr
Definition: map_item.hpp:102
virtual void OnMouseDown(const wxPoint &ms_pos)
Definition: map_item.hpp:79
virtual bool OnHotTrack(const wxPoint &ms_pos)
Definition: map_item.hpp:78
const string & GetLabel() const
Definition: map_item.hpp:60
int m_LabelPrefH
Definition: map_item.hpp:110
bool m_Separator
Definition: map_item.hpp:103
wxEvtHandler * m_CmdTarget
Definition: map_item.hpp:106
wxRect m_Rect
Definition: map_item.hpp:112
wxRect m_LabelRect
Definition: map_item.hpp:114
const string & GetDescr() const
Definition: map_item.hpp:61
virtual void OnLeftDoubleClick(const wxPoint &ms_pos)
Definition: map_item.hpp:80
TCmdID m_Cmd
Definition: map_item.hpp:105
string m_Label
Definition: map_item.hpp:100
CObject –.
Definition: ncbiobj.hpp:180
IwxMapItem Abstarct item of the Map Control.
Definition: imap_item.hpp:55
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 Draw(wxDC &dc, int state, SwxMapItemProperties &props)=0
Draws item in the given rectangle, state is a combination of EItemState flags.
virtual void OnDefaultAction()=0
a callback to perform a default action associated with the item
virtual void GetRect(wxRect &rc) const =0
Include a standard set of the NCBI C++ Toolkit most basic headers.
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
int TCmdID
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_WX_EXPORT
Definition: gui_export.h:543
static const char label[]
static void text(MDB_val *v)
Definition: mdb_dump.c:62
SwxMapItemProperties - properties of the IwxMapItem.
Definition: imap_item.hpp:82
Modified on Fri Sep 20 14:57:37 2024 by modify_doxy.py rev. 669887