From b3c367a168b0ca2cb395f0fcd9652ce0529aab1d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 16 Nov 2019 19:10:08 +0100 Subject: [PATCH] Fixes the numerical streaming value for FLineEdit and FLabel --- examples/background-color.cpp | 25 +++++++++--- src/Makefile.clang | 4 +- src/Makefile.gcc | 12 +++--- src/flabel.cpp | 4 +- src/flineedit.cpp | 4 +- src/fspinbox.cpp | 73 ++++++++++++++++++++--------------- src/fstring.cpp | 4 +- src/include/final/flabel.h | 4 +- src/include/final/flineedit.h | 4 +- src/include/final/fspinbox.h | 3 +- src/include/final/fstring.h | 4 +- 11 files changed, 84 insertions(+), 57 deletions(-) diff --git a/examples/background-color.cpp b/examples/background-color.cpp index ead1f9fa..a15fa407 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -38,6 +38,15 @@ class Background : public finalcut::FDialog public: explicit Background (finalcut::FWidget* = nullptr); + // Disable copy constructor + Background (const Background&) = delete; + + // Destructor + ~Background(); + + // Disable assignment operator (=) + Background& operator = (const Background&) = delete; + private: // Callback method void cb_changed (finalcut::FWidget*, FDataPtr); @@ -79,9 +88,9 @@ Background::Background (finalcut::FWidget* parent) // Set the initial palette values const auto& wc = getFWidgetColors(); finalcut::FTerm::setPalette ( wc.term_bg - , red.getValue() - , green.getValue() - , blue.getValue() ); + , int(red.getValue()) + , int(green.getValue()) + , int(blue.getValue()) ); // Quit button quit.setGeometry(FPoint(19, 5), FSize(10, 1)); @@ -112,14 +121,18 @@ Background::Background (finalcut::FWidget* parent) ); } +//---------------------------------------------------------------------- +Background::~Background() // destructor +{ } + //---------------------------------------------------------------------- void Background::cb_changed (finalcut::FWidget*, FDataPtr) { const auto& wc = getFWidgetColors(); finalcut::FTerm::setPalette ( wc.term_bg - , red.getValue() - , green.getValue() - , blue.getValue() ); + , int(red.getValue()) + , int(green.getValue()) + , int(blue.getValue()) ); redraw(); updateTerminal(); } diff --git a/src/Makefile.clang b/src/Makefile.clang index 339fcc35..3ef869e8 100644 --- a/src/Makefile.clang +++ b/src/Makefile.clang @@ -43,12 +43,13 @@ INCLUDE_HEADERS = \ fsystemimpl.h \ fscrollbar.h \ fscrollview.h \ + fspinbox.h \ fstatusbar.h \ fstring.h \ fmouse.h \ fkeyboard.h \ - ftermcap.h \ fstartoptions.h \ + ftermcap.h \ fterm.h \ ftermdata.h \ ftermdebugdata.h \ @@ -104,6 +105,7 @@ OBJS = \ fdialog.o \ fwindow.o \ fscrollview.o \ + fspinbox.o \ fmessagebox.o \ ftooltip.o \ ffiledialog.o \ diff --git a/src/Makefile.gcc b/src/Makefile.gcc index b2332c7f..eb51839d 100644 --- a/src/Makefile.gcc +++ b/src/Makefile.gcc @@ -39,12 +39,13 @@ INCLUDE_HEADERS = \ fprogressbar.h \ fradiobutton.h \ frect.h \ - fscrollbar.h \ - fscrollview.h \ - fstatusbar.h \ - fstring.h \ fsystem.h \ fsystemimpl.h \ + fscrollbar.h \ + fscrollview.h \ + fspinbox.h \ + fstatusbar.h \ + fstring.h \ fmouse.h \ fkeyboard.h \ fstartoptions.h \ @@ -104,6 +105,7 @@ OBJS = \ fdialog.o \ fwindow.o \ fscrollview.o \ + fspinbox.o \ fmessagebox.o \ ftooltip.o \ ffiledialog.o \ @@ -115,8 +117,8 @@ OBJS = \ fsystem.o \ fsystemimpl.o \ fkeyboard.o \ - ftermcap.o \ fstartoptions.o \ + ftermcap.o \ fterm.o \ fterm_functions.o \ ftermdebugdata.o \ diff --git a/src/flabel.cpp b/src/flabel.cpp index 52fb0524..2941a21e 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -107,7 +107,7 @@ FLabel& FLabel::operator << (const int num) } //---------------------------------------------------------------------- -FLabel& FLabel::operator << (const uLong num) +FLabel& FLabel::operator << (const uInt64 num) { FString num_str; num_str << num; @@ -116,7 +116,7 @@ FLabel& FLabel::operator << (const uLong num) } //---------------------------------------------------------------------- -FLabel& FLabel::operator << (const long num) +FLabel& FLabel::operator << (const sInt64 num) { FString num_str; num_str << num; diff --git a/src/flineedit.cpp b/src/flineedit.cpp index b9208e66..8fe0a46c 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -112,7 +112,7 @@ FLineEdit& FLineEdit::operator << (const int num) } //---------------------------------------------------------------------- -FLineEdit& FLineEdit::operator << (const uLong num) +FLineEdit& FLineEdit::operator << (const uInt64 num) { FString num_str; num_str << num; @@ -121,7 +121,7 @@ FLineEdit& FLineEdit::operator << (const uLong num) } //---------------------------------------------------------------------- -FLineEdit& FLineEdit::operator << (const long num) +FLineEdit& FLineEdit::operator << (const sInt64 num) { FString num_str; num_str << num; diff --git a/src/fspinbox.cpp b/src/fspinbox.cpp index d8f4acf4..a6555f9b 100644 --- a/src/fspinbox.cpp +++ b/src/fspinbox.cpp @@ -149,38 +149,12 @@ void FSpinBox::setSuffix (const FString& text) } //---------------------------------------------------------------------- -void FSpinBox::draw() +void FSpinBox::hide() { - const auto& wc = getFWidgetColors(); - - FColorPair inc_button_color = [&] () -> FColorPair - { - if ( value == max ) - return FColorPair ( wc.scrollbar_button_inactive_fg - , wc.scrollbar_button_inactive_bg ); - else - return FColorPair ( wc.scrollbar_button_fg - , wc.scrollbar_button_bg ); - }(); - - FColorPair dec_button_color = [&] () -> FColorPair - { - if ( value == min ) - return FColorPair ( wc.scrollbar_button_inactive_fg - , wc.scrollbar_button_inactive_bg ); - else - return FColorPair ( wc.scrollbar_button_fg - , wc.scrollbar_button_bg ); - }(); - - print() << FPoint(getWidth() - 1, 1) - << dec_button_color - << fc::BlackDownPointingTriangle // ▼ - << inc_button_color - << fc::BlackUpPointingTriangle; // ▲ - - if ( getFlags().shadow ) - drawShadow(this); + input_field.hide(); + FWidget::hide(); + FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0); + hideArea (getSize() + shadow); } //---------------------------------------------------------------------- @@ -309,7 +283,7 @@ void FSpinBox::onTimer (FTimerEvent*) updateInputField(); break; - default: + case FSpinBox::noSpin: break; } } @@ -335,6 +309,41 @@ void FSpinBox::init() ); } +//---------------------------------------------------------------------- +void FSpinBox::draw() +{ + const auto& wc = getFWidgetColors(); + + FColorPair inc_button_color = [&] () -> FColorPair + { + if ( value == max ) + return FColorPair ( wc.scrollbar_button_inactive_fg + , wc.scrollbar_button_inactive_bg ); + else + return FColorPair ( wc.scrollbar_button_fg + , wc.scrollbar_button_bg ); + }(); + + FColorPair dec_button_color = [&] () -> FColorPair + { + if ( value == min ) + return FColorPair ( wc.scrollbar_button_inactive_fg + , wc.scrollbar_button_inactive_bg ); + else + return FColorPair ( wc.scrollbar_button_fg + , wc.scrollbar_button_bg ); + }(); + + print() << FPoint(int(getWidth()) - 1, 1) + << dec_button_color + << fc::BlackDownPointingTriangle // ▼ + << inc_button_color + << fc::BlackUpPointingTriangle; // ▲ + + if ( getFlags().shadow ) + drawShadow(this); +} + //---------------------------------------------------------------------- inline void FSpinBox::updateInputField() { diff --git a/src/fstring.cpp b/src/fstring.cpp index 13410f7c..e06c8cd4 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -277,7 +277,7 @@ FString& FString::operator << (const uInt num) } //---------------------------------------------------------------------- -FString& FString::operator << (const long num) +FString& FString::operator << (const sInt64 num) { FString numstr(FString().setNumber(num)); _insert (length, numstr.length, numstr.string); @@ -285,7 +285,7 @@ FString& FString::operator << (const long num) } //---------------------------------------------------------------------- -FString& FString::operator << (const uLong num) +FString& FString::operator << (const uInt64 num) { FString numstr(FString().setNumber(num)); _insert (length, numstr.length, numstr.string); diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index 642ff597..47bbfb04 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -90,8 +90,8 @@ class FLabel : public FWidget FLabel& operator << (const wchar_t); FLabel& operator << (const uInt); FLabel& operator << (const int); - FLabel& operator << (const uLong); - FLabel& operator << (const long); + FLabel& operator << (const uInt64); + FLabel& operator << (const sInt64); FLabel& operator << (const float); FLabel& operator << (const double); FLabel& operator << (const lDouble); diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index 83b81608..e009ac5d 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -106,8 +106,8 @@ class FLineEdit : public FWidget FLineEdit& operator << (const wchar_t); FLineEdit& operator << (const uInt); FLineEdit& operator << (const int); - FLineEdit& operator << (const uLong); - FLineEdit& operator << (const long); + FLineEdit& operator << (const uInt64); + FLineEdit& operator << (const sInt64); FLineEdit& operator << (const float); FLineEdit& operator << (const double); FLineEdit& operator << (const lDouble); diff --git a/src/include/final/fspinbox.h b/src/include/final/fspinbox.h index 48de479c..694b7fdf 100644 --- a/src/include/final/fspinbox.h +++ b/src/include/final/fspinbox.h @@ -114,7 +114,7 @@ class FSpinBox : public FWidget bool hasShadow(); // Methods - void draw() override; + void hide() override; // Event handlers void onKeyPress (FKeyEvent*) override; @@ -134,6 +134,7 @@ class FSpinBox : public FWidget // Methods void init(); + void draw() override; void updateInputField(); void increaseValue(); void decreaseValue(); diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 943020cb..b83995e7 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -118,8 +118,8 @@ class FString FString& operator << (const uInt16); FString& operator << (const int); FString& operator << (const uInt); - FString& operator << (const long); - FString& operator << (const uLong); + FString& operator << (const sInt64); + FString& operator << (const uInt64); FString& operator << (const float); FString& operator << (const double); FString& operator << (const lDouble);