27 #define YUILogComponent "ui" 30 #include "YUISymbols.h" 35 typedef std::deque<string> StringDeque;
36 typedef std::deque<string>::iterator StringDequeIterator;
37 typedef std::deque<string>::const_iterator StringDequeConstIterator;
45 , visibleLines( visibleLines )
46 , maxLines( maxLines )
63 YUI_CHECK_NEW( priv );
93 return priv->visibleLines;
100 priv->visibleLines = newVisibleLines;
107 return priv->maxLines;
114 int linesToDelete = priv->maxLines - newMaxLines;
115 priv->maxLines = newMaxLines;
117 for (
int i=0; i < linesToDelete; i++ )
118 priv->logText.pop_front();
120 if ( linesToDelete > 0 )
130 for ( StringDequeConstIterator it = priv->logText.begin();
131 it != priv->logText.end();
137 if ( ! text.empty() )
141 if ( *(text.rbegin()) ==
'\n' )
143 text.resize( text.size() - 1 );
154 if ( priv->logText.empty() )
157 return priv->logText.back();
164 string text = newText;
165 string::size_type from = 0;
166 string::size_type to = 0;
171 while ( to < text.size() )
174 to = text.find(
'\n', from );
175 if ( to == string::npos )
181 appendLine( text.substr( from, to - from ) );
184 if ( to < text.size() )
187 appendLine( text.substr( to, text.size() - to ) );
195 YLogView::appendLine(
const string & line )
197 priv->logText.push_back( line );
201 priv->logText.pop_front();
213 priv->logText.clear();
221 priv->logText.clear();
228 return priv->logText.size();
233 YLogView::updateDisplay()
254 propSet.
add(
YProperty( YUIProperty_Value, YStringProperty ) );
255 propSet.
add(
YProperty( YUIProperty_LastLine, YStringProperty ) );
256 propSet.
add(
YProperty( YUIProperty_VisibleLines, YIntegerProperty ) );
257 propSet.
add(
YProperty( YUIProperty_MaxLines, YIntegerProperty ) );
258 propSet.
add(
YProperty( YUIProperty_Label, YStringProperty ) );
273 else if ( propertyName == YUIProperty_VisibleLines )
setVisibleLines ( val.integerVal() );
274 else if ( propertyName == YUIProperty_MaxLines )
setMaxLines ( val.integerVal() );
std::string lastLine() const
Return the last log line.
bool isEmpty() const
Returns 'true' if this property set does not contain anything.
void appendLines(const std::string &text)
Append one or more lines to the log text and trigger a display update.
YLogView(YWidget *parent, const std::string &label, int visibleLines, int maxLines)
Constructor.
Transport class for the value of simple properties.
void setVisibleLines(int newVisibleLines)
Set the number of visible lines.
void add(const YProperty &prop)
Add a property to this property set.
A set of properties to check names and types against.
int lines() const
Return the current number of lines.
virtual const YPropertySet & propertySet()
Return this class's property set.
virtual void setLabel(const std::string &label)
Set the label (the caption above the log text).
std::string logText() const
Return the entire log text as one large string of concatenated lines delimited with newlines...
void setLogText(const std::string &text)
Set (replace) the entire log text and trigger a display update.
virtual void displayLogText(const std::string &text)=0
Display the part of the log text that should be displayed.
std::string label() const
Return the label (the caption above the log text).
std::string stringVal() const
Methods to get the value of this property.
virtual ~YLogView()
Destructor.
Class for widget properties.
int visibleLines() const
Return the number of visible lines.
int maxLines() const
Return the maximum number of lines to store.
void clearText()
Clear the log text and trigger a display update.
virtual bool setProperty(const std::string &propertyName, const YPropertyValue &val)
Set a property.
void check(const std::string &propertyName) const
Check if a property 'propertyName' exists in this property set.
void setMaxLines(int newMaxLines)
Set the maximum number of lines to store.
YPropertyType type() const
Returns the type of this property value.
virtual YPropertyValue getProperty(const std::string &propertyName)
Get a property.