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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_TEXT_WIDGET___EXPAND_ITEM__HPP
2 #define GUI_WIDGETS_TEXT_WIDGET___EXPAND_ITEM__HPP
3 
4 /* $Id: expand_item.hpp 39653 2017-10-24 18:50:24Z 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: Roman Katargin
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/gui_export.h>
37 
38 #include <wx/event.h>
39 
42 
44 
45 class CTextPanelContext;
46 
48 {
49 public:
50  CExpandItem(CTextItem* collapsedItem, CTextItem* expandedItem,
51  bool expand = false);
52  virtual ~CExpandItem();
53 
54  void SetSelectable(bool selectable = true)
55  { m_Selectable = selectable; }
56 
57  void AddGlyph(CGlyph* glyph);
58 
59  CTextItem* GetCollapsedItem() { return m_Items[0]; }
60  CTextItem* GetExpandedItem() { return m_Items[1]; }
61 
62  // IExpandable implementation
63  virtual bool IsExpanded() const { return (m_Expanded != 0); }
64  virtual void Toggle(CTextPanelContext* context, bool update);
65  virtual string GetToolTipText(CTextPanelContext* context) const;
66 
67  // ITextItem overrides
68  virtual void SetContainer(IContainer* container, int index)
69  { m_Container = container; m_Index = index; }
70  virtual void GetContainer(IContainer*& container, int& index)
71  { container = m_Container; index = m_Index; }
72  virtual wxPoint GetPosition() const
73  { return m_Container ? m_Container->GetItemPosition(m_Index) : wxPoint(0, 0); }
74  virtual wxSize GetSize() const { return m_Items[m_Expanded]->GetSize(); }
75  virtual int GetStartLine() const
76  { return m_Container ? m_Container->GetItemStartLine(m_Index) : 0; }
77 
78  // Mouse handling
79  virtual void MouseEvent(wxMouseEvent& event, CTextPanelContext& context);
80 
81  virtual size_t GetLineCount() const { return m_Items[1]->GetLineCount(); }
82  virtual ITextItem* GetItemByLine(int lineNum, bool expanded)
83  { return m_Items[expanded ? 1 : m_Expanded]->GetItemByLine(lineNum, expanded); }
84 
86  { return m_Items[0]->GetTextLeftMargin(context); }
87 
88  virtual void CalcSize(wxDC& dc, CTextPanelContext* context);
89  virtual void Draw(wxDC& dc, const wxRect& updateRect, CTextPanelContext* context);
90 
91  virtual void GetText(wxTextOutputStream& os,
92  const CTextBlock& block,
94 
95  virtual const CConstRef<CObject> GetAssosiatedObject() const;
96 
97  virtual bool IsSelectable() const { return m_Selectable; }
98 
99  virtual bool Traverse(ICompositeTraverser& traverser);
100 
101  // IContainer implementation
102  virtual wxPoint GetItemPosition(int /*index*/) const { return GetPosition(); }
103  virtual int GetItemStartLine(int /*index*/) const { return GetStartLine(); }
104  virtual void ItemSizeChanged(int index) { if (m_Container) m_Container->ItemSizeChanged(m_Index); }
105  virtual void UpdatePositions();
106 
107 protected:
108  void x_LimitCollapsedSelection(CTextPanelContext* context) const;
109 
111  CTextItem* m_Items[2];
115 
117  int m_Index;
118 };
119 
121 
122 #endif // GUI_WIDGETS_TEXT_WIDGET___EXPAND_ITEM__HPP
123 
virtual int GetTextLeftMargin(CTextPanelContext *context) const
Definition: expand_item.hpp:85
IContainer * m_Container
virtual wxPoint GetPosition() const
Definition: expand_item.hpp:72
virtual bool IsSelectable() const
Definition: expand_item.hpp:97
virtual size_t GetLineCount() const
Definition: expand_item.hpp:81
virtual wxPoint GetItemPosition(int) const
void SetSelectable(bool selectable=true)
Definition: expand_item.hpp:54
virtual int GetStartLine() const
Definition: expand_item.hpp:75
virtual void GetContainer(IContainer *&container, int &index)
Definition: expand_item.hpp:70
virtual bool IsExpanded() const
Definition: expand_item.hpp:63
CGlyph * m_Glyph
virtual void ItemSizeChanged(int index)
virtual int GetItemStartLine(int) const
CGlyph * m_Glyph2
virtual void SetContainer(IContainer *container, int index)
Definition: expand_item.hpp:68
CTextItem * GetExpandedItem()
Definition: expand_item.hpp:60
virtual ITextItem * GetItemByLine(int lineNum, bool expanded)
Definition: expand_item.hpp:82
virtual wxSize GetSize() const
Definition: expand_item.hpp:74
CTextItem * GetCollapsedItem()
Definition: expand_item.hpp:59
Definition: glyph.hpp:45
virtual void UpdatePositions()=0
virtual string GetToolTipText(CTextPanelContext *context) const =0
virtual void Toggle(CTextPanelContext *context, bool update)=0
virtual ITextItem * GetItemByLine(int lineNum, bool expanded)=0
virtual void Draw(wxDC &dc, const wxRect &updateRect, CTextPanelContext *context)=0
virtual void MouseEvent(wxMouseEvent &, CTextPanelContext &)
Definition: text_item.hpp:86
virtual int GetStartLine() const =0
virtual wxPoint GetPosition() const =0
virtual bool Traverse(ICompositeTraverser &)=0
virtual void CalcSize(wxDC &dc, CTextPanelContext *context)=0
virtual void GetText(wxTextOutputStream &os, const CTextBlock &block, CTextPanelContext *context)=0
virtual const CConstRef< CObject > GetAssosiatedObject() const
Definition: text_item.hpp:109
#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_TEXT_WIDGET_EXPORT
Definition: gui_export.h:532
Defines to provide correct exporting from DLLs in Windows.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Sun Apr 21 03:43:00 2024 by modify_doxy.py rev. 669887