diff --git a/ChangeLog b/ChangeLog index cf621370..7f025733 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,8 @@ -2017-09-20 Markus Gans +2017-09-21 Markus Gans * New data type FStringList introduced + * Stream and assignment operator support for FLineEdit -2017-09-19 Markus Gans +2017-09-20 Markus Gans * FString has now got its own streaming functionality for inbound and outbound type conversion * Added stream and assignment operator support for FLabel diff --git a/examples/ui.cpp b/examples/ui.cpp index 5f1e8e91..c213cdfb 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -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(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(widget); FLineEdit* lineedit = static_cast(data); - lineedit->setText( ListBox->getItem(ListBox->currentItem()).getText() ); + *lineedit = ListBox->getItem(ListBox->currentItem()).getText(); lineedit->redraw(); } diff --git a/include/final/flineedit.h b/include/final/flineedit.h index 41f6a939..7317b09c 100644 --- a/include/final/flineedit.h +++ b/include/final/flineedit.h @@ -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*); diff --git a/include/final/flistbox.h b/include/final/flistbox.h index b685f541..94964610 100644 --- a/include/final/flistbox.h +++ b/include/final/flistbox.h @@ -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 diff --git a/include/final/flistview.h b/include/final/flistview.h index 98437cce..38940578 100644 --- a/include/final/flistview.h +++ b/include/final/flistview.h @@ -342,32 +342,4 @@ inline FObject::FObjectIterator FListView::index2iterator (int index) return iter; } -//---------------------------------------------------------------------- -inline void FListView::nextElement (FObjectIterator& iter) -{ - FListViewItem* item = static_cast(*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 diff --git a/src/flineedit.cpp b/src/flineedit.cpp index c8cfc730..1a54aee8 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -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; diff --git a/src/flistview.cpp b/src/flistview.cpp index 25eb5c4b..05c23793 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1483,6 +1483,34 @@ void FListView::processChanged() emitCallback("row-changed"); } +//---------------------------------------------------------------------- +void FListView::nextElement (FObjectIterator& iter) +{ + FListViewItem* item = static_cast(*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) {