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

Go to the SVN repository for this file.

1 /* $Id: asn_element_block_collapsed.cpp 24019 2011-07-08 13:45:08Z wuliangs $
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: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
36 
40 
41 #include "asn_styles.hpp"
42 
43 #include <serial/objectinfo.hpp>
44 
45 #include <wx/dcclient.h>
46 #include <wx/txtstrm.h>
47 
49 
51  CStyledTextOStream& ostream,
52  CTextPanelContext* context,
54 {
57 
58  ostream << CAsnStyles::GetStyle(CAsnStyles::kBraces) << "{";
59 
60  if (CStyledTextOStream::kCopyText == ostream.GetHint()) {
61  if (ostream.IsVisible() && m_ExpandedValue) {
62  wxTextOutputStream* textStream = ostream.GetTextStream();
63  *textStream << endl;
64  m_ExpandedValue->GetText(*textStream, m_ExpandedValue->GetItemBlock(), context);
65  if (m_Indent > 0)
66  *textStream << wxString(m_Indent*kAsnIndentSize, ' ');
67  }
68  ostream.UpdatePosition(3);
69  }
70  else {
71  ostream << NB() <<CAsnStyles::GetStyle(CAsnStyles::kCollapsedBlock) << " ... " << NB();
72  }
73 
74  ostream << CAsnStyles::GetStyle(CAsnStyles::kBraces) << "}";
75 
76  x_RenderComma(ostream);
77 }
78 
80 {
81  int row = pos.GetRow(), col = pos.GetCol();
82 
83  if (row < 0 || row >= 1)
84  return;
85 
86  CCalcNBPosOStream ostr;
87  x_RenderText(ostr, context);
88 
89  int nbStart, nbEnd, nbRow;
90  ostr.GetNBPos(nbStart, nbEnd, nbRow);
91 
92  int indent = GetIndent();
93 
94  if (col >= nbEnd) {
95  row = GetLineCount() - 1;
96  col = indent + col - nbEnd;
97  }
98 
99  pos = CTextPosition(row, col);
100 }
101 
103 {
104  int row = pos.GetRow(), col = pos.GetCol();
105 
106  if (row < 0 || row >= (int)GetLineCount())
107  return;
108 
109  CCalcNBPosOStream ostr;
110  x_RenderText(ostr, context);
111 
112  int nbStart, nbEnd, nbRow;
113  ostr.GetNBPos(nbStart, nbEnd, nbRow);
114 
115  int indent = GetIndent();
116 
117  if (row == (int)GetLineCount() - 1 && col >= indent) {
118  if (col >= indent)
119  col += nbEnd - indent;
120  else
121  col = nbStart;
122  }
123  else if (row > 0 || col > nbStart)
124  col = nbStart;
125 
126  row = 0;
127 
128  pos = CTextPosition(row, col);
129 }
130 
virtual bool IsVisible() const
virtual StreamHint GetHint() const =0
virtual void UpdatePosition(int)
CTextBlock GetItemBlock() const
Definition: text_item.hpp:117
int GetCol() const
virtual void TextPosToCollapsed(CTextPosition &pos, CTextPanelContext *context) const
virtual void RenderValue(CStyledTextOStream &ostream, CTextPanelContext *context, TTypeInfo type, TConstObjectPtr ptr) const
const void * TConstObjectPtr
Definition: serialdef.hpp:59
void x_RenderComma(CStyledTextOStream &ostream) const
virtual void TextPosToExpanded(CTextPosition &pos, CTextPanelContext *context) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
Definition: type.c:8
virtual void GetText(wxTextOutputStream &os, const CTextBlock &block, CTextPanelContext *context)=0
virtual int GetIndent() const
const size_t kAsnIndentSize
ETypeFamily GetTypeFamily(void) const
int GetRow() const
virtual void x_RenderText(CStyledTextOStream &ostream, CTextPanelContext *context) const
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:74
#define _ASSERT
virtual wxTextOutputStream * GetTextStream() const
static const CTextStyle & GetStyle(Element element)
Definition: asn_styles.cpp:40
string indent(" ")
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
virtual size_t GetLineCount() const
Definition: text_item.hpp:148
void GetNBPos(int &start, int &end, int &row) const
Modified on Mon Jul 25 16:55:28 2016 by modify_doxy.py rev. 506947