Stream and assignment operator support for FLineEdit

This commit is contained in:
Markus Gans 2017-09-21 07:22:08 +02:00
parent b3e9a0bba1
commit b9f6a6bee6
7 changed files with 154 additions and 39 deletions

View File

@ -1,7 +1,8 @@
2017-09-20 Markus Gans <guru.mail@muenster.de>
2017-09-21 Markus Gans <guru.mail@muenster.de>
* New data type FStringList introduced
* Stream and assignment operator support for FLineEdit
2017-09-19 Markus Gans <guru.mail@muenster.de>
2017-09-20 Markus Gans <guru.mail@muenster.de>
* FString has now got its own streaming functionality for
inbound and outbound type conversion
* Added stream and assignment operator support for FLabel

View File

@ -480,9 +480,9 @@ MyDialog::MyDialog (FWidget* parent)
// A text input field
myLineEdit = new FLineEdit (this);
myLineEdit->setGeometry(22, 1, 10, 1);
myLineEdit->setText (FString("EnTry").toLower());
myLineEdit->setLabelText (L"&Input");
myLineEdit->setStatusbarMessage ("Press Enter to set the title");
*myLineEdit << FString("EnTry").toLower();
// Buttons
FButton* MyButton4 = new FButton (this);
@ -759,7 +759,7 @@ void MyDialog::cb_cutClipboard (FWidget*, data_ptr)
return;
clipboard = myLineEdit->getText();
myLineEdit->clearText();
myLineEdit->clear();
myLineEdit->redraw();
}
@ -778,7 +778,7 @@ void MyDialog::cb_pasteClipboard (FWidget*, data_ptr)
if ( ! myLineEdit )
return;
myLineEdit->setText(clipboard);
*myLineEdit = clipboard;
myLineEdit->redraw();
}
@ -789,7 +789,7 @@ void MyDialog::cb_clearInput (FWidget*, data_ptr)
return;
clipboard.clear();
myLineEdit->clearText();
myLineEdit->clear();
myLineEdit->redraw();
}
@ -806,8 +806,10 @@ void MyDialog::cb_input2buttonText (FWidget* widget, data_ptr data)
void MyDialog::cb_setTitlebar (FWidget* widget, data_ptr)
{
FLineEdit* lineedit = static_cast<FLineEdit*>(widget);
lineedit->setXTermTitle(lineedit->getText());
setText(lineedit->getText());
FString title;
*lineedit >> title;
setXTermTitle(title);;
setText(title);
redraw();
}
@ -893,7 +895,7 @@ void MyDialog::cb_setInput (FWidget* widget, data_ptr data)
{
FListBox* ListBox = static_cast<FListBox*>(widget);
FLineEdit* lineedit = static_cast<FLineEdit*>(data);
lineedit->setText( ListBox->getItem(ListBox->currentItem()).getText() );
*lineedit = ListBox->getItem(ListBox->currentItem()).getText();
lineedit->redraw();
}

View File

@ -56,6 +56,19 @@ class FLineEdit : public FWidget
// Destructor
virtual ~FLineEdit();
// Overloaded operators
FLineEdit& operator = (const FString&);
FLineEdit& operator << (const FString&);
FLineEdit& operator << (const wchar_t);
FLineEdit& operator << (const uInt);
FLineEdit& operator << (const int);
FLineEdit& operator << (const uLong);
FLineEdit& operator << (const long);
FLineEdit& operator << (const float);
FLineEdit& operator << (const double);
FLineEdit& operator << (const lDouble);
const FLineEdit& operator >> (FString&);
// Accessors
const char* getClassName() const;
FString getText() const;
@ -81,7 +94,7 @@ class FLineEdit : public FWidget
// Methods
void hide();
void clearText();
void clear();
// Event handlers
void onKeyPress (FKeyEvent*);

View File

@ -66,6 +66,9 @@ class FListBoxItem
void setText (const FString&);
void setData (FWidget::data_ptr);
// Methods
void clear();
private:
// Friend classes
friend class FListBox;
@ -96,6 +99,10 @@ inline void FListBoxItem::setText (const FString& txt)
inline void FListBoxItem::setData (FWidget::data_ptr data)
{ data_pointer = data; }
//----------------------------------------------------------------------
inline void FListBoxItem::clear()
{ text.clear(); }
//----------------------------------------------------------------------
// class FListBox

View File

@ -342,32 +342,4 @@ inline FObject::FObjectIterator FListView::index2iterator (int index)
return iter;
}
//----------------------------------------------------------------------
inline void FListView::nextElement (FObjectIterator& iter)
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
if ( item->isExpandable() && item->isExpand() )
{
iter_path.push(iter);
iter = item->begin();
}
else
{
++iter;
if ( ! iter_path.empty() )
{
FObjectIterator& parent_iter = iter_path.top();
if ( iter == (*parent_iter)->end() )
{
iter = parent_iter;
iter_path.pop();
++iter;
}
}
}
}
#endif // FLISTVIEW_H

View File

@ -53,6 +53,98 @@ FLineEdit::~FLineEdit() // destructor
setInsertCursorStyle();
}
// FLineEdit operators
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator = (const FString& s)
{
setText(s);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const FString& s)
{
setText(text + s);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const wchar_t c)
{
setText(text + c);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const uInt num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const int num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const uLong num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const long num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const float num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const double num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const lDouble num)
{
FString num_str;
num_str << num;
setText(text + num_str);
return *this;
}
//----------------------------------------------------------------------
const FLineEdit& FLineEdit::operator >> (FString& s)
{
s += text;
return *this;
}
// public methods of FLineEdit
//----------------------------------------------------------------------
@ -219,7 +311,7 @@ void FLineEdit::hide()
}
//----------------------------------------------------------------------
void FLineEdit::clearText()
void FLineEdit::clear()
{
text_offset = 0;
cursor_pos = 0;

View File

@ -1483,6 +1483,34 @@ void FListView::processChanged()
emitCallback("row-changed");
}
//----------------------------------------------------------------------
void FListView::nextElement (FObjectIterator& iter)
{
FListViewItem* item = static_cast<FListViewItem*>(*iter);
if ( item->isExpandable() && item->isExpand() )
{
iter_path.push(iter);
iter = item->begin();
}
else
{
++iter;
if ( ! iter_path.empty() )
{
FObjectIterator& parent_iter = iter_path.top();
if ( iter == (*parent_iter)->end() )
{
iter = parent_iter;
iter_path.pop();
++iter;
}
}
}
}
//----------------------------------------------------------------------
void FListView::cb_VBarChange (FWidget*, data_ptr)
{