From a547d484a625614cc6c64ef8c7e3da87872813e8 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 14 Oct 2023 14:58:29 +0200 Subject: [PATCH] Many small code improvements --- examples/listbox.cpp | 2 +- examples/term-attributes.cpp | 3 +- examples/ui.cpp | 10 +++--- examples/watch.cpp | 10 +++--- examples/xpmimage.h | 7 ++-- final/dialog/fdialog.cpp | 41 ++++++----------------- final/dialog/fdialog.h | 40 +++++++++++------------ final/dialog/ffiledialog.cpp | 5 ++- final/dialog/ffiledialog.h | 10 +++--- final/dialog/fmessagebox.h | 12 +++---- final/eventloop/timer_monitor.h | 1 + final/fapplication.cpp | 14 +++----- final/fconfig.h | 12 ++++--- final/fobject.cpp | 8 ++--- final/fwidget.cpp | 12 +++---- final/fwidget.h | 34 +++++++++---------- final/fwidget_functions.cpp | 4 +-- final/fwidget_functions.h | 2 +- final/input/fkey_hashmap.h | 4 +-- final/input/fkeyboard.cpp | 12 +++---- final/input/fkeyboard.h | 8 ++--- final/menu/fcheckmenuitem.h | 5 ++- final/menu/fmenu.cpp | 6 ++-- final/menu/fmenu.h | 26 +++++++-------- final/menu/fmenuitem.cpp | 15 +++------ final/menu/fmenuitem.h | 2 +- final/output/tty/fcharmap.cpp | 2 +- final/output/tty/fterm.cpp | 6 ++-- final/output/tty/fterm.h | 26 ++++++++------- final/output/tty/ftermios.cpp | 8 ++--- final/output/tty/ftermios.h | 16 ++++----- final/util/char_ringbuffer.h | 9 +++-- final/util/fdata.h | 6 ++-- final/util/fstring.cpp | 29 +++++++---------- final/util/fstring.h | 10 +++--- final/util/fsystemimpl.cpp | 4 --- final/widget/fbutton.cpp | 27 +++++++-------- final/widget/fbutton.h | 58 ++++++++++++++++----------------- final/widget/fbuttongroup.cpp | 6 ++-- final/widget/fbuttongroup.h | 14 ++++---- final/widget/fcombobox.cpp | 12 +++---- final/widget/fcombobox.h | 32 +++++++++--------- final/widget/flabel.cpp | 6 ++-- final/widget/flabel.h | 28 ++++++++-------- final/widget/flineedit.cpp | 14 ++++---- final/widget/flineedit.h | 30 ++++++++--------- final/widget/flistbox.cpp | 9 ----- final/widget/flistbox.h | 30 ++++------------- final/widget/flistview.cpp | 4 +-- final/widget/flistview.h | 12 +++---- final/widget/fprogressbar.cpp | 4 +-- final/widget/fprogressbar.h | 10 +++--- final/widget/fscrollview.cpp | 18 +++++----- final/widget/fscrollview.h | 16 ++++----- final/widget/fspinbox.cpp | 7 ++-- final/widget/fspinbox.h | 22 ++++++------- final/widget/fstatusbar.cpp | 6 ++-- final/widget/fstatusbar.h | 10 +++--- final/widget/ftextview.h | 4 +-- final/widget/ftogglebutton.cpp | 20 +++++------- final/widget/ftogglebutton.h | 33 ++++++++++--------- final/widget/ftooltip.cpp | 3 +- final/widget/ftooltip.h | 10 +++--- final/widget/fwindow.cpp | 30 +++++++---------- final/widget/fwindow.h | 48 +++++++++++++-------------- test/flogger-test.cpp | 8 +---- 66 files changed, 428 insertions(+), 524 deletions(-) diff --git a/examples/listbox.cpp b/examples/listbox.cpp index 8b940c22..6f7af7db 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -55,7 +55,7 @@ void doubleToItem ( FListBoxItem& item , std::size_t index ) { using DblList = std::list; - DblList& dbl_list = flistboxhelper::getContainer(container); + const DblList& dbl_list = flistboxhelper::getContainer(container); auto iter = dbl_list.begin(); std::advance (iter, index); item.setText (FString() << *iter); diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 11bb7ae2..b8e117d2 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2015-2022 Markus Gans * +* Copyright 2015-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -433,6 +433,7 @@ void AttribDemo::draw() const std::vector > effect { [this] { printNormal(); }, + [this] { printDim(); }, [this] { printBold(); }, [this] { printBoldDim(); }, [this] { printItalic(); }, diff --git a/examples/ui.cpp b/examples/ui.cpp index 40b74602..1555b091 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -952,12 +952,10 @@ void MyDialog::cb_showProgressBar() //---------------------------------------------------------------------- void MyDialog::cb_updateNumber() { - int select_num = 0; - - for (const auto& item : myList.getData() ) - if ( item.isSelected() ) - select_num++; - + auto is_selected = [] (auto item) { return item.isSelected(); }; + auto select_num = std::count_if ( std::begin(myList.getData()) + , std::end(myList.getData()) + , is_selected ); tagged_count.clear(); tagged_count << select_num; tagged_count.redraw(); diff --git a/examples/watch.cpp b/examples/watch.cpp index f847f45f..76a5450f 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2015-2022 Markus Gans * +* Copyright 2015-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -71,7 +71,8 @@ Watch::Watch (FWidget* parent) time_label.setEmphasis(); // Switch - sec = seconds_sw.setChecked(); + seconds_sw.setChecked(); + sec = seconds_sw.isChecked(); // Connect switch signal "toggled" with a callback member function clock_sw.addCallback @@ -146,10 +147,7 @@ void Watch::cb_clock() //---------------------------------------------------------------------- void Watch::cb_seconds() { - if ( seconds_sw.isChecked() ) - sec = true; - else - sec = false; + sec = seconds_sw.isChecked(); if ( clock_sw.isChecked() ) printTime(); diff --git a/examples/xpmimage.h b/examples/xpmimage.h index 3d6d2036..9140b91d 100644 --- a/examples/xpmimage.h +++ b/examples/xpmimage.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2022 Markus Gans * +* Copyright 2022-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -1124,10 +1124,7 @@ void XpmImage::parseXPM3 (XPMdataT& raw_xpm) { std::vector xpm{}; xpm.reserve(getArraySize(xpm)); - - for (const auto& line : raw_xpm) - xpm.emplace_back(line); - + std::copy (raw_xpm.begin(), raw_xpm.end(), std::back_inserter(xpm)); parseXPM3 (xpm); } diff --git a/final/dialog/fdialog.cpp b/final/dialog/fdialog.cpp index 585a5e5a..7546076e 100644 --- a/final/dialog/fdialog.cpp +++ b/final/dialog/fdialog.cpp @@ -82,10 +82,10 @@ FDialog::~FDialog() // destructor // public methods of FDialog //---------------------------------------------------------------------- -auto FDialog::setDialogWidget (bool enable) -> bool +void FDialog::setDialogWidget (bool enable) { if ( isDialogWidget() == enable ) - return true; + return; setFlags().type.dialog_widget = enable; @@ -93,15 +93,13 @@ auto FDialog::setDialogWidget (bool enable) -> bool setTermOffsetWithPadding(); else setParentOffset(); - - return enable; } //---------------------------------------------------------------------- -auto FDialog::setModal (bool enable) -> bool +void FDialog::setModal (bool enable) { if ( isModal() == enable ) - return true; + return; setFlags().visibility.modal = enable; @@ -113,12 +111,10 @@ auto FDialog::setModal (bool enable) -> bool } else setModalDialogCounter()--; - - return enable; } //---------------------------------------------------------------------- -auto FDialog::setBorder (bool enable) -> bool +void FDialog::setBorder (bool enable) { if ( enable ) { @@ -134,8 +130,6 @@ auto FDialog::setBorder (bool enable) -> bool setBottomPadding(0); setRightPadding(0); } - - return ( setFlags().feature.no_border = (! enable) ); } //---------------------------------------------------------------------- @@ -148,7 +142,7 @@ void FDialog::resetColors() } //---------------------------------------------------------------------- -auto FDialog::setResizeable (bool enable) -> bool +void FDialog::setResizeable (bool enable) { FWindow::setResizeable (enable); @@ -156,12 +150,10 @@ auto FDialog::setResizeable (bool enable) -> bool zoom_item->setEnable(); else zoom_item->setDisable(); - - return enable; } //---------------------------------------------------------------------- -auto FDialog::setMinimizable (bool enable) -> bool +void FDialog::setMinimizable (bool enable) { FWindow::setMinimizable (enable); @@ -169,8 +161,6 @@ auto FDialog::setMinimizable (bool enable) -> bool minimize_item->setEnable(); else minimize_item->setDisable(); - - return enable; } //---------------------------------------------------------------------- @@ -581,10 +571,6 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev) if ( ev->getButton() != MouseButton::Left ) return; - const int x = getTermX(); - const int y = getTermY(); - const FRect title_button{x, y, 3, 1}; - if ( isMouseOverMenuButton(ms) ) { // Double click on title button @@ -1430,11 +1416,8 @@ inline void FDialog::deactivateMinimizeButton() inline void FDialog::leaveMinimizeButton (const MouseStates& ms) { bool minimize_button_pressed_before = minimize_button_pressed; - - if ( isMouseOverMinimizeButton(ms) && minimize_button_active ) - minimize_button_pressed = true; - else if ( minimize_button_pressed ) - minimize_button_pressed = false; + minimize_button_pressed = isMouseOverMinimizeButton(ms) + && minimize_button_active; if ( minimize_button_pressed_before != minimize_button_pressed ) drawTitleBar(); @@ -1480,11 +1463,7 @@ inline void FDialog::deactivateZoomButton() inline void FDialog::leaveZoomButton (const MouseStates& ms) { bool zoom_button_pressed_before = zoom_button_pressed; - - if ( isMouseOverZoomButton(ms) && zoom_button_active ) - zoom_button_pressed = true; - else if ( zoom_button_pressed ) - zoom_button_pressed = false; + zoom_button_pressed = isMouseOverZoomButton(ms) && zoom_button_active; if ( zoom_button_pressed_before != zoom_button_pressed ) drawTitleBar(); diff --git a/final/dialog/fdialog.h b/final/dialog/fdialog.h index ef0e1071..74f96ab5 100644 --- a/final/dialog/fdialog.h +++ b/final/dialog/fdialog.h @@ -104,16 +104,16 @@ class FDialog : public FWindow virtual auto getText() const -> FString; // Mutators - auto setDialogWidget (bool = true) -> bool; - auto unsetDialogWidget() -> bool; - auto setModal (bool = true) -> bool; - auto unsetModal() -> bool; - auto setResizeable (bool = true) -> bool override; - auto setMinimizable (bool = true) -> bool override; - auto setTitlebarButtonVisibility (bool = true) -> bool; - auto unsetTitlebarButtonVisibility() -> bool; - auto setBorder (bool = true) -> bool; - auto unsetBorder() -> bool; + void setDialogWidget (bool = true); + void unsetDialogWidget(); + void setModal (bool = true); + void unsetModal(); + void setResizeable (bool = true) override; + void setMinimizable (bool = true) override; + void setTitlebarButtonVisibility (bool = true); + void unsetTitlebarButtonVisibility(); + void setBorder (bool = true); + void unsetBorder(); void resetColors() override; virtual void setText (const FString&); @@ -287,24 +287,24 @@ inline auto FDialog::getText() const -> FString { return tb_text; } //---------------------------------------------------------------------- -inline auto FDialog::unsetDialogWidget() -> bool -{ return setDialogWidget(false); } +inline void FDialog::unsetDialogWidget() +{ setDialogWidget(false); } //---------------------------------------------------------------------- -inline auto FDialog::unsetModal() -> bool -{ return setModal(false); } +inline void FDialog::unsetModal() +{ setModal(false); } //---------------------------------------------------------------------- -inline auto FDialog::setTitlebarButtonVisibility (bool enable) -> bool -{ return (titlebar_buttons = enable); } +inline void FDialog::setTitlebarButtonVisibility (bool enable) +{ titlebar_buttons = enable; } //---------------------------------------------------------------------- -inline auto FDialog::unsetTitlebarButtonVisibility() -> bool -{ return setTitlebarButtonVisibility(false); } +inline void FDialog::unsetTitlebarButtonVisibility() +{ setTitlebarButtonVisibility(false); } //---------------------------------------------------------------------- -inline auto FDialog::unsetBorder() -> bool -{ return setBorder(false); } +inline void FDialog::unsetBorder() +{ setBorder(false); } //---------------------------------------------------------------------- inline void FDialog::setText (const FString& txt) diff --git a/final/dialog/ffiledialog.cpp b/final/dialog/ffiledialog.cpp index 6b6b9db9..165ca243 100644 --- a/final/dialog/ffiledialog.cpp +++ b/final/dialog/ffiledialog.cpp @@ -181,15 +181,14 @@ void FFileDialog::setFilter (const FString& filter) } //---------------------------------------------------------------------- -auto FFileDialog::setShowHiddenFiles (bool enable) -> bool +void FFileDialog::setShowHiddenFiles (bool enable) { if ( show_hidden == enable ) - return show_hidden; + return; show_hidden = enable; readDir(); filebrowser.redraw(); - return show_hidden; } //---------------------------------------------------------------------- diff --git a/final/dialog/ffiledialog.h b/final/dialog/ffiledialog.h index 5e10289d..5b9bf5c9 100644 --- a/final/dialog/ffiledialog.h +++ b/final/dialog/ffiledialog.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2022 Markus Gans * +* Copyright 2014-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -115,8 +115,8 @@ class FFileDialog : public FDialog // Mutators void setPath (const FString&); void setFilter (const FString&); - auto setShowHiddenFiles (bool = true) -> bool; - auto unsetShowHiddenFiles() -> bool; + void setShowHiddenFiles (bool = true); + void unsetShowHiddenFiles(); // Event handler void onKeyPress (FKeyEvent*) override; @@ -226,8 +226,8 @@ inline auto FFileDialog::getFilter() const -> FString { return filter_pattern; } //---------------------------------------------------------------------- -inline auto FFileDialog::unsetShowHiddenFiles() -> bool -{ return setShowHiddenFiles(false); } +inline void FFileDialog::unsetShowHiddenFiles() +{ setShowHiddenFiles(false); } //---------------------------------------------------------------------- inline auto FFileDialog::getShowHiddenFiles() const noexcept -> bool diff --git a/final/dialog/fmessagebox.h b/final/dialog/fmessagebox.h index 2fa27ece..8b656951 100644 --- a/final/dialog/fmessagebox.h +++ b/final/dialog/fmessagebox.h @@ -111,8 +111,8 @@ class FMessageBox : public FDialog // Mutator void setTitlebarText (const FString&); void setHeadline (const FString&); - auto setCenterText (bool = true) -> bool; - auto unsetCenterText() -> bool; + void setCenterText (bool = true); + void unsetCenterText(); void setText (const FString&) override; // Methods @@ -197,12 +197,12 @@ inline void FMessageBox::setTitlebarText (const FString& txt) { return FDialog::setText(txt); } //---------------------------------------------------------------------- -inline auto FMessageBox::setCenterText(bool enable) -> bool -{ return (center_text = enable); } +inline void FMessageBox::setCenterText (bool enable) +{ center_text = enable; } //---------------------------------------------------------------------- -inline auto FMessageBox::unsetCenterText() -> bool -{ return setCenterText(false); } +inline void FMessageBox::unsetCenterText() +{ setCenterText(false); } //---------------------------------------------------------------------- template diff --git a/final/eventloop/timer_monitor.h b/final/eventloop/timer_monitor.h index 7f240d19..9394620b 100644 --- a/final/eventloop/timer_monitor.h +++ b/final/eventloop/timer_monitor.h @@ -148,6 +148,7 @@ inline void PosixTimer::init (handler_t hdl, T&& uc) } #endif // defined(USE_POSIX_TIMER) + //---------------------------------------------------------------------- // class KqueueTimer //---------------------------------------------------------------------- diff --git a/final/fapplication.cpp b/final/fapplication.cpp index 94ff6d0f..97c549a0 100644 --- a/final/fapplication.cpp +++ b/final/fapplication.cpp @@ -136,17 +136,17 @@ auto FApplication::getKeyboardWidget() -> FWidget* auto FApplication::getLog() -> FLogPtr& { // Global logger object - static auto logger_ptr = new FLogPtr(); + static const auto& logger = std::make_unique(); - if ( logger_ptr && *logger_ptr == nullptr ) + if ( logger && *logger == nullptr ) { - *logger_ptr = std::make_shared(); + *logger = std::make_shared(); // Set the logger as rdbuf of clog - std::clog.rdbuf(logger_ptr->get()); + std::clog.rdbuf(logger->get()); } - return *logger_ptr; + return *logger; } //---------------------------------------------------------------------- @@ -650,10 +650,6 @@ inline void FApplication::destroyLog() // Reset the rdbuf of clog std::clog << std::flush; std::clog.rdbuf(default_clog_rdbuf); - - // Delete the logger - const FLogPtr* logger = &(getLog()); - delete logger; } //---------------------------------------------------------------------- diff --git a/final/fconfig.h b/final/fconfig.h index a2a48589..97f2776b 100644 --- a/final/fconfig.h +++ b/final/fconfig.h @@ -1,6 +1,6 @@ #ifndef _FINAL_FCONFIG_H #define _FINAL_FCONFIG_H 1 - + /* final/fconfig.h. Generated automatically at end of configure. */ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ @@ -154,10 +154,14 @@ #endif /* Define to 1 if you have the `timer_create' function. */ -/* #undef HAVE_TIMER_CREATE */ +#ifndef F_HAVE_TIMER_CREATE +#define F_HAVE_TIMER_CREATE 1 +#endif /* Define to 1 if you have the `timer_settime' function. */ -/* #undef HAVE_TIMER_SETTIME */ +#ifndef F_HAVE_TIMER_SETTIME +#define F_HAVE_TIMER_SETTIME 1 +#endif /* Define to 1 if you have the header file. */ #ifndef F_HAVE_TTYENT_H @@ -263,6 +267,6 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef _POSIX_SOURCE */ - + /* once: _FINAL_FCONFIG_H */ #endif diff --git a/final/fobject.cpp b/final/fobject.cpp index d2ca9f33..da6de911 100644 --- a/final/fobject.cpp +++ b/final/fobject.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2015-2022 Markus Gans * +* Copyright 2015-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -134,9 +134,9 @@ void FObject::delChild (FObject* obj) & obj->parent_obj = nullptr; obj->has_parent = false; - auto end = children_list.end(); - auto last = std::remove (children_list.begin(), end, obj); - children_list.erase(last, end); + auto list_end = children_list.end(); + auto last = std::remove (children_list.begin(), list_end, obj); + children_list.erase(last, list_end); } //---------------------------------------------------------------------- diff --git a/final/fwidget.cpp b/final/fwidget.cpp index 0ad065ef..e25ad129 100644 --- a/final/fwidget.cpp +++ b/final/fwidget.cpp @@ -226,20 +226,20 @@ void FWidget::setMainWidget (FWidget* obj) } //---------------------------------------------------------------------- -auto FWidget::setVisible (bool enable) -> bool +void FWidget::setVisible (bool enable) { - return (flags.visibility.visible = enable); + flags.visibility.visible = enable; } //---------------------------------------------------------------------- -auto FWidget::setEnable (bool enable) -> bool +void FWidget::setEnable (bool enable) { if ( enable ) emitCallback("enable"); else emitCallback("disable"); - return (flags.feature.active = enable); + flags.feature.active = enable; } //---------------------------------------------------------------------- @@ -719,11 +719,11 @@ auto FWidget::numOfFocusableChildren() & -> int int num{0}; - for (auto* child : getChildren()) + for (const auto* child : getChildren()) { if ( child->isWidget() ) { - const auto& widget = static_cast(child); + const auto& widget = static_cast(child); if ( widget->isEnabled() && widget->isShown() diff --git a/final/fwidget.h b/final/fwidget.h index 9c6d2e03..77d31ce6 100644 --- a/final/fwidget.h +++ b/final/fwidget.h @@ -207,13 +207,13 @@ class FWidget : public FVTerm static void setColorTheme(); auto setAcceleratorList() & -> FAcceleratorList&; virtual void setStatusbarMessage (const FString&); - auto setVisible (bool = true) -> bool; - auto unsetVisible() -> bool; - virtual auto setEnable (bool = true) -> bool; - virtual auto unsetEnable() -> bool; - virtual auto setDisable() -> bool; - virtual auto setVisibleCursor (bool = true) -> bool; // input cursor visibility - virtual auto unsetVisibleCursor() -> bool; // for the widget + void setVisible (bool = true); + void unsetVisible(); + virtual void setEnable (bool = true); + virtual void unsetEnable(); + virtual void setDisable(); + virtual void setVisibleCursor (bool = true); // input cursor visibility + virtual void unsetVisibleCursor(); // for the widget virtual auto setFocus ( bool = true , FocusTypes = FocusTypes::DefiniteWidget) -> bool; virtual auto unsetFocus() -> bool; @@ -756,24 +756,24 @@ inline void FWidget::setStatusbarMessage (const FString& msg) { statusbar_message = msg; } //---------------------------------------------------------------------- -inline auto FWidget::unsetVisible() -> bool -{ return setVisible(false); } +inline void FWidget::unsetVisible() +{ setVisible(false); } //---------------------------------------------------------------------- -inline auto FWidget::unsetEnable() -> bool -{ return setEnable(false); } +inline void FWidget::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FWidget::setDisable() -> bool -{ return setEnable(false); } +inline void FWidget::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FWidget::setVisibleCursor (bool enable) -> bool -{ return (flags.visibility.visible_cursor = enable); } +inline void FWidget::setVisibleCursor (bool enable) +{ flags.visibility.visible_cursor = enable; } //---------------------------------------------------------------------- -inline auto FWidget::unsetVisibleCursor() -> bool -{ return setVisibleCursor(false); } +inline void FWidget::unsetVisibleCursor() +{ setVisibleCursor(false); } //---------------------------------------------------------------------- inline auto FWidget::unsetFocus() -> bool diff --git a/final/fwidget_functions.cpp b/final/fwidget_functions.cpp index f0f3158b..a501eb98 100644 --- a/final/fwidget_functions.cpp +++ b/final/fwidget_functions.cpp @@ -285,7 +285,7 @@ void setWidgetFocus (FWidget* widget) } //---------------------------------------------------------------------- -auto setWidgetShadow (FWidget* w, bool enable) -> bool +void setWidgetShadow (FWidget* w, bool enable) { if ( enable && FVTerm::getFOutput()->getEncoding() != Encoding::VT100 @@ -299,8 +299,6 @@ auto setWidgetShadow (FWidget* w, bool enable) -> bool w->setFlags().shadow.shadow = false; w->setShadowSize(FSize{0, 0}); } - - return w->getFlags().shadow.shadow; } //---------------------------------------------------------------------- diff --git a/final/fwidget_functions.h b/final/fwidget_functions.h index 3c3c6451..14ad4aea 100644 --- a/final/fwidget_functions.h +++ b/final/fwidget_functions.h @@ -62,7 +62,7 @@ auto getHotkey (const FString&) -> FKey; auto getHotkeyPos (const FString& src, FString& dest) -> std::size_t; void setHotkeyViaString (FWidget*, const FString&); void setWidgetFocus (FWidget*); -auto setWidgetShadow (FWidget*, bool) -> bool; +void setWidgetShadow (FWidget*, bool); void passResizeCornerEventToDialog (const FWidget*, const FMouseEvent&); void drawShadow (FWidget*); void drawTransparentShadow (FWidget*); diff --git a/final/input/fkey_hashmap.h b/final/input/fkey_hashmap.h index c142582e..9d8ce6db 100644 --- a/final/input/fkey_hashmap.h +++ b/final/input/fkey_hashmap.h @@ -151,11 +151,11 @@ using HashMap = std::unordered_map template auto createKeyCapMap() -> HashMap { - auto& fkey_cap_table = FKeyMap::getKeyCapMap(); + const auto& fkey_cap_table = FKeyMap::getKeyCapMap(); HashMap fkey_cap_map; fkey_cap_map.reserve(fkey_cap_table.size()); - for (auto& item : fkey_cap_table) + for (const auto& item : fkey_cap_table) if ( item.string && item.length != 0 ) fkey_cap_map[{item.string, item.length}] = item.num; diff --git a/final/input/fkeyboard.cpp b/final/input/fkeyboard.cpp index 2369824e..b6d65923 100644 --- a/final/input/fkeyboard.cpp +++ b/final/input/fkeyboard.cpp @@ -120,10 +120,10 @@ auto FKeyboard::getKeyName (const FKey keynum) const -> FString } //---------------------------------------------------------------------- -auto FKeyboard::setNonBlockingInput (bool enable) -> bool +void FKeyboard::setNonBlockingInput (bool enable) { if ( enable == non_blocking_stdin ) - return non_blocking_stdin; + return; if ( enable ) // make stdin non-blocking { @@ -139,8 +139,6 @@ auto FKeyboard::setNonBlockingInput (bool enable) -> bool if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 ) non_blocking_stdin = false; } - - return non_blocking_stdin; } //---------------------------------------------------------------------- @@ -263,11 +261,11 @@ inline auto FKeyboard::getMouseProtocolKey() const -> FKey return NOT_SET; // x11 mouse tracking - if ( fifo_buf[1] == '[' && fifo_buf[2] == 'M' ) + if ( fifo_buf[2] == 'M' ) return ( buf_len < 6 ) ? FKey::Incomplete : FKey::X11mouse; // SGR mouse tracking - if ( fifo_buf[1] == '[' && fifo_buf[2] == '<' ) + if ( fifo_buf[2] == '<' ) { if ( buf_len < 9 || (fifo_buf[buf_len - 1] != 'M' && fifo_buf[buf_len - 1] != 'm') ) return FKey::Incomplete; // Incomplete mouse sequence @@ -276,7 +274,7 @@ inline auto FKeyboard::getMouseProtocolKey() const -> FKey } // urxvt mouse tracking - if ( fifo_buf[1] == '[' && fifo_buf[2] >= '1' && fifo_buf[2] <= '9' + if ( fifo_buf[2] >= '1' && fifo_buf[2] <= '9' && std::isdigit(fifo_buf[3]) && buf_len >= 9 && fifo_buf[buf_len - 1] == 'M' ) return FKey::Urxvt_mouse; diff --git a/final/input/fkeyboard.h b/final/input/fkeyboard.h index 8363b6ea..0a434bcf 100644 --- a/final/input/fkeyboard.h +++ b/final/input/fkeyboard.h @@ -127,8 +127,8 @@ class FKeyboard final static void setKeypressTimeout (const uInt64) noexcept; static void setReadBlockingTime (const uInt64) noexcept; static void setNonBlockingInputSupport (bool = true) noexcept; - auto setNonBlockingInput (bool = true) -> bool; - auto unsetNonBlockingInput() noexcept -> bool; + void setNonBlockingInput (bool = true); + void unsetNonBlockingInput() noexcept; void enableUTF8() noexcept; void disableUTF8() noexcept; void enableMouseSequences() noexcept; @@ -270,8 +270,8 @@ inline void FKeyboard::setNonBlockingInputSupport (bool enable) noexcept { non_blocking_input_support = enable; } //---------------------------------------------------------------------- -inline auto FKeyboard::unsetNonBlockingInput() noexcept -> bool -{ return setNonBlockingInput(false); } +inline void FKeyboard::unsetNonBlockingInput() noexcept +{ setNonBlockingInput(false); } //---------------------------------------------------------------------- inline auto FKeyboard::hasPendingInput() const noexcept -> bool diff --git a/final/menu/fcheckmenuitem.h b/final/menu/fcheckmenuitem.h index 41038b36..4f42a02e 100644 --- a/final/menu/fcheckmenuitem.h +++ b/final/menu/fcheckmenuitem.h @@ -86,7 +86,10 @@ class FCheckMenuItem : public FMenuItem // FCheckMenuItem inline functions //---------------------------------------------------------------------- inline auto FCheckMenuItem::getClassName() const -> FString -{ return "FCheckMenuItem"; } +{ + auto name = FString(L"FCheckMenuItem"); + return {}; +} } // namespace finalcut diff --git a/final/menu/fmenu.cpp b/final/menu/fmenu.cpp index 2c634d26..8e38f693 100644 --- a/final/menu/fmenu.cpp +++ b/final/menu/fmenu.cpp @@ -68,12 +68,12 @@ FMenu::~FMenu() // destructor // public methods of FMenu //---------------------------------------------------------------------- -auto FMenu::setMenuWidget (bool enable) -> bool +void FMenu::setMenuWidget (bool enable) { if ( isMenuWidget() == enable ) - return true; + return; - return (setFlags().type.menu_widget = enable); + setFlags().type.menu_widget = enable; } //---------------------------------------------------------------------- diff --git a/final/menu/fmenu.h b/final/menu/fmenu.h index dc7e9f50..e6f1e22c 100644 --- a/final/menu/fmenu.h +++ b/final/menu/fmenu.h @@ -105,13 +105,13 @@ class FMenu : public FWindow auto getItem() -> FMenuItem*; // Mutators - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; void setSelected(); void unsetSelected(); - auto setMenuWidget (bool = true) -> bool; - auto unsetMenuWidget() -> bool; + void setMenuWidget (bool = true); + void unsetMenuWidget(); void setStatusbarMessage (const FString&) override; void setMenu (FMenu*); void setText (const FString&); @@ -270,16 +270,16 @@ inline auto FMenu::getItem() -> FMenuItem* { return &menuitem; } //---------------------------------------------------------------------- -inline auto FMenu::setEnable (bool enable) -> bool -{ return menuitem.setEnable(enable); } +inline void FMenu::setEnable (bool enable) +{ menuitem.setEnable(enable); } //---------------------------------------------------------------------- -inline auto FMenu::unsetEnable() -> bool -{ return menuitem.unsetEnable(); } +inline void FMenu::unsetEnable() +{ menuitem.unsetEnable(); } //---------------------------------------------------------------------- -inline auto FMenu::setDisable() -> bool -{ return menuitem.setDisable(); } +inline void FMenu::setDisable() +{ menuitem.setDisable(); } //---------------------------------------------------------------------- inline void FMenu::setSelected() @@ -290,8 +290,8 @@ inline void FMenu::unsetSelected() { menuitem.unsetSelected(); } //---------------------------------------------------------------------- -inline auto FMenu::unsetMenuWidget() -> bool -{ return setMenuWidget(false); } +inline void FMenu::unsetMenuWidget() +{ setMenuWidget(false); } //---------------------------------------------------------------------- inline void FMenu::setMenu (FMenu* m) diff --git a/final/menu/fmenuitem.cpp b/final/menu/fmenuitem.cpp index 8fdb43fd..85702c5e 100644 --- a/final/menu/fmenuitem.cpp +++ b/final/menu/fmenuitem.cpp @@ -86,7 +86,7 @@ FMenuItem::~FMenuItem() // destructor // public methods of FMenuItem //---------------------------------------------------------------------- -auto FMenuItem::setEnable (bool enable) -> bool +void FMenuItem::setEnable (bool enable) { FWidget::setEnable(enable); auto super = getSuperMenu(); @@ -105,8 +105,6 @@ auto FMenuItem::setEnable (bool enable) -> bool if ( super && isMenuBar(super) ) super->delAccelerator (this); } - - return enable; } //---------------------------------------------------------------------- @@ -218,13 +216,10 @@ void FMenuItem::onKeyPress (FKeyEvent* ev) { auto mbar = static_cast(super_menu); - if ( mbar ) - { - if ( mbar->hotkeyMenu(ev) ) - return; + if ( mbar->hotkeyMenu(ev) ) + return; - mbar->onKeyPress(ev); - } + mbar->onKeyPress(ev); } } @@ -710,7 +705,7 @@ void FMenuItem::cb_switchToDialog (FDialog* win) const //---------------------------------------------------------------------- void FMenuItem::cb_destroyDialog (FDialog* win) { - const auto& fapp = FApplication::getApplicationObject(); + const auto* fapp = FApplication::getApplicationObject(); if ( ! win || ! fapp ) return; diff --git a/final/menu/fmenuitem.h b/final/menu/fmenuitem.h index 58c66289..9b533204 100644 --- a/final/menu/fmenuitem.h +++ b/final/menu/fmenuitem.h @@ -101,7 +101,7 @@ class FMenuItem : public FWidget auto getText() const -> FString; // Mutators - auto setEnable (bool = true) -> bool override; + void setEnable (bool = true) override; void setSelected(); void unsetSelected(); void setSeparator(); diff --git a/final/output/tty/fcharmap.cpp b/final/output/tty/fcharmap.cpp index 9a0b486a..f5f074c8 100644 --- a/final/output/tty/fcharmap.cpp +++ b/final/output/tty/fcharmap.cpp @@ -49,7 +49,7 @@ auto FCharMap::getCharacter ( const CharEncodeMap& char_enc auto FCharMap::setCharacter ( CharEncodeMap& char_enc , const Encoding& enc ) -> wchar_t& { - const auto array = reinterpret_cast(&char_enc); + auto* array = reinterpret_cast(&char_enc); return array[std::size_t(enc)]; } diff --git a/final/output/tty/fterm.cpp b/final/output/tty/fterm.cpp index ee15eff1..a64023c1 100644 --- a/final/output/tty/fterm.cpp +++ b/final/output/tty/fterm.cpp @@ -307,20 +307,18 @@ void FTerm::useAlternateScreen (bool enable) } //---------------------------------------------------------------------- -auto FTerm::setUTF8 (bool enable) -> bool // UTF-8 (Unicode) +void FTerm::setUTF8 (bool enable) // UTF-8 (Unicode) { static auto& data = FTermData::getInstance(); if ( data.isUTF8() == enable ) - return enable; + return; data.setUTF8(enable); #if defined(__linux__) FTermLinux::getInstance().setUTF8 (enable); #endif - - return data.isUTF8(); } //---------------------------------------------------------------------- diff --git a/final/output/tty/fterm.h b/final/output/tty/fterm.h index 245ec005..1db386ae 100644 --- a/final/output/tty/fterm.h +++ b/final/output/tty/fterm.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2012-2022 Markus Gans * +* Copyright 2012-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -198,8 +198,8 @@ class FTerm final static void redefineDefaultColors (bool = true); static void setDblclickInterval (const uInt64); static void useAlternateScreen (bool = true); - static auto setUTF8 (bool = true) -> bool; - static auto unsetUTF8() -> bool; + static void setUTF8 (bool = true); + static void unsetUTF8(); // Methods static auto setVGAFont() -> bool; @@ -308,25 +308,29 @@ inline void FTerm::setFSystem (std::unique_ptr& fsystem) //---------------------------------------------------------------------- inline void FTerm::unsetInsertCursor() -{ return setInsertCursor(false); } +{ setInsertCursor(false); } //---------------------------------------------------------------------- -inline auto FTerm::unsetUTF8() -> bool -{ return setUTF8(false); } +inline void FTerm::unsetUTF8() +{ setUTF8(false); } //---------------------------------------------------------------------- template inline void FTerm::paddingPrintf (const std::string& format, Args&&... args) { - const int size = std::snprintf (nullptr, 0, format.data(), args...) + 1; + const int size = std::snprintf (nullptr, 0, format.data(), args...); if ( size <= 0 ) return; - const auto count = std::size_t(size); - std::vector buf(count); - std::snprintf (&buf[0], count, format.data(), std::forward(args)...); - paddingPrint (std::string(&buf[0]), 1); + std::string buffer{}; + auto buffer_size = std::size_t(size + 1); + buffer.resize(buffer_size); + std::snprintf ( const_cast(buffer.data()), buffer_size + , format.data(), std::forward(args)... ); + buffer_size--; + buffer.resize(buffer_size); + paddingPrint (buffer, 1); } //---------------------------------------------------------------------- diff --git a/final/output/tty/ftermios.cpp b/final/output/tty/ftermios.cpp index 0f619599..484908e5 100644 --- a/final/output/tty/ftermios.cpp +++ b/final/output/tty/ftermios.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2018-2022 Markus Gans * +* Copyright 2018-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -172,11 +172,11 @@ void FTermios::unsetCaptureSendCharacters() } //---------------------------------------------------------------------- -auto FTermios::setRawMode (bool enable) -> bool +void FTermios::setRawMode (bool enable) { // set + unset flags for raw mode if ( raw_mode == enable ) - return raw_mode; + return; // Info under: man 3 termios struct termios t{}; @@ -215,8 +215,6 @@ auto FTermios::setRawMode (bool enable) -> bool setTTY (t); raw_mode = false; } - - return raw_mode; } //---------------------------------------------------------------------- diff --git a/final/output/tty/ftermios.h b/final/output/tty/ftermios.h index 6f136a11..4eae0006 100644 --- a/final/output/tty/ftermios.h +++ b/final/output/tty/ftermios.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2018-2022 Markus Gans * +* Copyright 2018-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -73,9 +73,9 @@ class FTermios final static void unsetHardwareEcho(); static void setCaptureSendCharacters(); static void unsetCaptureSendCharacters(); - static auto setRawMode (bool = true) -> bool; - static auto unsetRawMode() -> bool; - static auto setCookedMode() -> bool; + static void setRawMode (bool = true); + static void unsetRawMode(); + static void setCookedMode(); static auto getBaudRate() -> uInt; private: @@ -110,12 +110,12 @@ inline auto FTermios::isRaw() noexcept -> bool { return raw_mode; } //---------------------------------------------------------------------- -inline auto FTermios::unsetRawMode() -> bool -{ return setRawMode(false); } +inline void FTermios::unsetRawMode() +{ setRawMode(false); } //---------------------------------------------------------------------- -inline auto FTermios::setCookedMode() -> bool -{ return setRawMode(false); } +inline void FTermios::setCookedMode() +{ setRawMode(false); } } // namespace finalcut diff --git a/final/util/char_ringbuffer.h b/final/util/char_ringbuffer.h index abb74bd1..ce6256dd 100644 --- a/final/util/char_ringbuffer.h +++ b/final/util/char_ringbuffer.h @@ -68,12 +68,15 @@ class FRingBuffer //------------------------------------------------------------------ template - class ring_iterator : public std::iterator + class ring_iterator { public: // Using-declarations - using pointer = Type*; - using reference = Type&; + using iterator_category = std::forward_iterator_tag; + using value_type = Type; + using difference_type = std::ptrdiff_t; + using pointer = Type*; + using reference = Type&; explicit ring_iterator (pointer p, std::size_t start, std::size_t pos) : ptr{p} diff --git a/final/util/fdata.h b/final/util/fdata.h index 7b569fab..2199ad5c 100644 --- a/final/util/fdata.h +++ b/final/util/fdata.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2020-2022 Markus Gans * +* Copyright 2020-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -248,8 +248,8 @@ class FData : public FDataAccess // Inquiries constexpr auto isInitializedCopy() const -> bool { - const auto& v = reinterpret_cast(const_cast(&value)); - const auto& r = reinterpret_cast(const_cast(&value_ref.get())); + const auto* v = reinterpret_cast(const_cast(&value)); + const auto* r = reinterpret_cast(const_cast(&value_ref.get())); return v == r; } diff --git a/final/util/fstring.cpp b/final/util/fstring.cpp index 3bf0dec9..24c48c10 100644 --- a/final/util/fstring.cpp +++ b/final/util/fstring.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2012-2022 Markus Gans * +* Copyright 2012-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -82,9 +82,8 @@ FString::FString (const std::wstring& s) //---------------------------------------------------------------------- FString::FString (std::wstring&& s) -{ - string = std::move(s); -} + : string{std::move(s)} +{ } //---------------------------------------------------------------------- FString::FString (const wchar_t s[]) @@ -294,7 +293,7 @@ auto FString::operator () () const -> const FString& // public methods of FString //---------------------------------------------------------------------- -auto FString::clear() -> FString +auto FString::clear() -> FString& { string.clear(); return *this; @@ -1057,16 +1056,14 @@ auto FString::internal_toCharString (const std::wstring& s) const -> std::string auto src = s.c_str(); auto state = std::mbstate_t(); - const auto& size = std::wcsrtombs(nullptr, &src, 0, &state) + 1; + const auto size = std::wcsrtombs(nullptr, &src, 0, &state) + 1; std::vector dest(size); const auto mblength = std::wcsrtombs (dest.data(), &src, size, &state); - if ( mblength == static_cast(-1) && errno != EILSEQ ) - { + if ( mblength == MALFORMED_STRING && errno != EILSEQ ) return {}; - } return dest.data(); } @@ -1079,21 +1076,17 @@ inline auto FString::internal_toWideString (const std::string& s) const -> std:: auto src = s.c_str(); auto state = std::mbstate_t(); - const auto& size = std::mbsrtowcs(nullptr, &src, 0, &state) + 1; + auto size = std::mbsrtowcs(nullptr, &src, 0, &state); - if ( size == 0 ) // ...malformed UTF-8 string + if ( size == MALFORMED_STRING ) return {}; + size++; std::vector dest(size); - const auto& wide_length = std::mbsrtowcs (dest.data(), &src, size, &state); - - if ( wide_length == static_cast(-1) ) - { - if ( src != s.c_str() ) - return dest.data(); + const auto wide_length = std::mbsrtowcs (dest.data(), &src, size, &state); + if ( wide_length == MALFORMED_STRING ) return {}; - } if ( wide_length == size ) dest[size - 1] = '\0'; diff --git a/final/util/fstring.h b/final/util/fstring.h index 06eea2f2..0401e943 100644 --- a/final/util/fstring.h +++ b/final/util/fstring.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2012-2022 Markus Gans * +* Copyright 2012-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -253,7 +253,7 @@ class FString template auto sprintf (const FString&, Args&&...) -> FString&; - auto clear() -> FString; + auto clear() -> FString&; auto wc_str() const -> const wchar_t*; auto wc_str() -> wchar_t*; @@ -314,7 +314,8 @@ class FString private: // Constants - static constexpr uInt INPBUFFER = 200; + static constexpr auto INPBUFFER = uInt(200); + static constexpr auto MALFORMED_STRING = static_cast(-1); // Methods void internal_assign (std::wstring); @@ -671,8 +672,7 @@ inline auto FString::sprintf (const FString& format, Args&&... args) -> FString& std::swprintf ( buf.data(), buf.size(), format.wc_str() , std::forward(args)... ); - setString(buf.data()); - return *this; + return setString(buf.data()); } //---------------------------------------------------------------------- diff --git a/final/util/fsystemimpl.cpp b/final/util/fsystemimpl.cpp index 3886cc75..71eb8885 100644 --- a/final/util/fsystemimpl.cpp +++ b/final/util/fsystemimpl.cpp @@ -24,10 +24,6 @@ #define USE_KQUEUE_TIMER #endif -#if !(defined(__APPLE__) && defined(__MACH__)) && !(defined(__OpenBSD__)) - #define USE_POSIX_TIMER -#endif - #if defined(USE_KQUEUE_TIMER) #include #include diff --git a/final/widget/fbutton.cpp b/final/widget/fbutton.cpp index a3c7a383..d96cc615 100644 --- a/final/widget/fbutton.cpp +++ b/final/widget/fbutton.cpp @@ -144,13 +144,13 @@ void FButton::resetColors() } //---------------------------------------------------------------------- -auto FButton::setNoUnderline (bool enable) -> bool +void FButton::setNoUnderline (bool enable) { - return (setFlags().feature.no_underline = enable); + setFlags().feature.no_underline = enable; } //---------------------------------------------------------------------- -auto FButton::setEnable (bool enable) -> bool +void FButton::setEnable (bool enable) { FWidget::setEnable(enable); @@ -160,31 +160,28 @@ auto FButton::setEnable (bool enable) -> bool delAccelerator(); updateButtonColor(); - return enable; } //---------------------------------------------------------------------- -auto FButton::setFlat (bool enable) -> bool +void FButton::setFlat (bool enable) { - return (setFlags().feature.flat = enable); + setFlags().feature.flat = enable; } //---------------------------------------------------------------------- -auto FButton::setShadow (bool enable) -> bool +void FButton::setShadow (bool enable) { - return setWidgetShadow(this, enable); + setWidgetShadow(this, enable); } //---------------------------------------------------------------------- -auto FButton::setDown (bool enable) -> bool +void FButton::setDown (bool enable) { - if ( button_down != enable ) - { - button_down = enable; - redraw(); - } + if ( button_down == enable ) + return; - return enable; + button_down = enable; + redraw(); } //---------------------------------------------------------------------- diff --git a/final/widget/fbutton.h b/final/widget/fbutton.h index c2e7f85a..55a8cac1 100644 --- a/final/widget/fbutton.h +++ b/final/widget/fbutton.h @@ -83,19 +83,19 @@ class FButton : public FWidget void setInactiveForegroundColor (FColor); void setInactiveBackgroundColor (FColor); void resetColors() override; - auto setNoUnderline (bool = true) -> bool; - auto unsetNoUnderline() -> bool; - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; - auto setFlat (bool = true) -> bool; - auto unsetFlat() -> bool; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; - auto setDown (bool = true) -> bool; - auto setUp() -> bool; - auto setClickAnimation (bool = true) -> bool; - auto unsetClickAnimation() -> bool; + void setNoUnderline (bool = true); + void unsetNoUnderline(); + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; + void setFlat (bool = true); + void unsetFlat(); + void setShadow (bool = true); + void unsetShadow(); + void setDown (bool = true); + void setUp(); + void setClickAnimation (bool = true); + void unsetClickAnimation(); void setText (const FString&); // Inquiries @@ -174,36 +174,36 @@ inline auto FButton::getText() const -> FString { return text; } //---------------------------------------------------------------------- -inline auto FButton::unsetNoUnderline() -> bool -{ return setNoUnderline(false); } +inline void FButton::unsetNoUnderline() +{ setNoUnderline(false); } //---------------------------------------------------------------------- -inline auto FButton::unsetEnable() -> bool -{ return setEnable(false); } +inline void FButton::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FButton::setDisable() -> bool -{ return setEnable(false); } +inline void FButton::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FButton::unsetFlat() -> bool -{ return setFlat(false); } +inline void FButton::unsetFlat() +{ setFlat(false); } //---------------------------------------------------------------------- -inline auto FButton::unsetShadow() -> bool -{ return setShadow(false); } +inline void FButton::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- -inline auto FButton::setUp() -> bool -{ return setDown(false); } +inline void FButton::setUp() +{ setDown(false); } //---------------------------------------------------------------------- -inline auto FButton::setClickAnimation(bool enable) -> bool -{ return (click_animation = enable); } +inline void FButton::setClickAnimation(bool enable) +{ click_animation = enable; } //---------------------------------------------------------------------- -inline auto FButton::unsetClickAnimation() -> bool -{ return setClickAnimation(false); } +inline void FButton::unsetClickAnimation() +{ setClickAnimation(false); } //---------------------------------------------------------------------- inline auto FButton::isFlat() const -> bool diff --git a/final/widget/fbuttongroup.cpp b/final/widget/fbuttongroup.cpp index 8d75634b..bda6c2cc 100644 --- a/final/widget/fbuttongroup.cpp +++ b/final/widget/fbuttongroup.cpp @@ -99,7 +99,7 @@ auto FButtonGroup::getCheckedButton() const -> FToggleButton* } //---------------------------------------------------------------------- -auto FButtonGroup::setEnable (bool enable) -> bool +void FButtonGroup::setEnable (bool enable) { FWidget::setEnable(enable); @@ -107,8 +107,6 @@ auto FButtonGroup::setEnable (bool enable) -> bool setHotkeyAccelerator(); else delAccelerator(); - - return enable; } //---------------------------------------------------------------------- @@ -465,7 +463,7 @@ void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const // FToggleButton friend function definition //---------------------------------------------------------------------- -auto getGroup (FToggleButton& toggle_btn) -> FButtonGroup* +auto getGroup (const FToggleButton& toggle_btn) -> FButtonGroup* { return toggle_btn.button_group; } diff --git a/final/widget/fbuttongroup.h b/final/widget/fbuttongroup.h index 1a0c044e..53744485 100644 --- a/final/widget/fbuttongroup.h +++ b/final/widget/fbuttongroup.h @@ -79,9 +79,9 @@ class FButtonGroup : public FScrollView auto getCount() const -> std::size_t; // Mutator - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; // Inquiries auto isChecked (int) const -> bool; @@ -135,12 +135,12 @@ inline auto FButtonGroup::getClassName() const -> FString { return "FButtonGroup"; } //---------------------------------------------------------------------- -inline auto FButtonGroup::unsetEnable() -> bool -{ return setEnable(false); } +inline void FButtonGroup::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FButtonGroup::setDisable() -> bool -{ return setEnable(false); } +inline void FButtonGroup::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- inline auto FButtonGroup::getCount() const -> std::size_t diff --git a/final/widget/fcombobox.cpp b/final/widget/fcombobox.cpp index eafd0682..7d37b645 100644 --- a/final/widget/fcombobox.cpp +++ b/final/widget/fcombobox.cpp @@ -201,24 +201,23 @@ void FComboBox::setGeometry ( const FPoint& pos, const FSize& size } //---------------------------------------------------------------------- -auto FComboBox::setEnable (bool enable) -> bool +void FComboBox::setEnable (bool enable) { FWidget::setEnable(enable); input_field.setEnable(enable); - return enable; } //---------------------------------------------------------------------- -auto FComboBox::setShadow (bool enable) -> bool +void FComboBox::setShadow (bool enable) { - return setWidgetShadow(this, enable); + setWidgetShadow(this, enable); } //---------------------------------------------------------------------- -auto FComboBox::setEditable (bool enable) -> bool +void FComboBox::setEditable (bool enable) { if ( is_editable == enable ) - return is_editable; + return; if ( enable ) unsetVisibleCursor(); @@ -226,7 +225,6 @@ auto FComboBox::setEditable (bool enable) -> bool setVisibleCursor(); input_field.setReadOnly(! enable); - return (is_editable = enable); } //---------------------------------------------------------------------- diff --git a/final/widget/fcombobox.h b/final/widget/fcombobox.h index bbd51023..69828465 100644 --- a/final/widget/fcombobox.h +++ b/final/widget/fcombobox.h @@ -145,13 +145,13 @@ class FComboBox : public FWidget // Mutators void setSize (const FSize&, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override; - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; - auto setEditable (bool = true) -> bool; - auto unsetEditable() -> bool; + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; + void setShadow (bool = true); + void unsetShadow(); + void setEditable (bool = true); + void unsetEditable(); void setCurrentItem (std::size_t); void setMaxVisibleItems (std::size_t); void setText (const FString&); @@ -244,20 +244,20 @@ inline auto FComboBox::getLabelOrientation() const -> FLineEdit::LabelOrientatio { return input_field.getLabelOrientation(); } //---------------------------------------------------------------------- -inline auto FComboBox::unsetEnable() -> bool -{ return setEnable(false); } +inline void FComboBox::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FComboBox::setDisable() -> bool -{ return setEnable(false); } +inline void FComboBox::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FComboBox::unsetShadow() -> bool -{ return setShadow(false); } +inline void FComboBox::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- -inline auto FComboBox::unsetEditable() -> bool -{ return setEditable(false); } +inline void FComboBox::unsetEditable() +{ setEditable(false); } //---------------------------------------------------------------------- inline auto FComboBox::hasShadow() const -> bool @@ -268,7 +268,7 @@ template void FComboBox::insert (const std::initializer_list& list, DT&& d) { - for (auto& item : list) + for (const auto& item : list) { FListBoxItem listItem (FString() << item, std::forward
(d)); insert (listItem); diff --git a/final/widget/flabel.cpp b/final/widget/flabel.cpp index c06488f5..9b03d914 100644 --- a/final/widget/flabel.cpp +++ b/final/widget/flabel.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2022 Markus Gans * +* Copyright 2014-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -123,7 +123,7 @@ void FLabel::resetColors() } //---------------------------------------------------------------------- -auto FLabel::setEnable (bool enable) -> bool +void FLabel::setEnable (bool enable) { FWidget::setEnable(enable); @@ -131,8 +131,6 @@ auto FLabel::setEnable (bool enable) -> bool setHotkeyAccelerator(); else delAccelerator(); - - return enable; } //---------------------------------------------------------------------- diff --git a/final/widget/flabel.h b/final/widget/flabel.h index 0ce4dee0..62e97473 100644 --- a/final/widget/flabel.h +++ b/final/widget/flabel.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2022 Markus Gans * +* Copyright 2014-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -101,12 +101,12 @@ class FLabel : public FWidget // Mutators void setAccelWidget (FWidget* = nullptr); void setAlignment (Align) noexcept; - auto setEmphasis (bool = true) noexcept -> bool; - auto unsetEmphasis() noexcept -> bool; + void setEmphasis (bool = true) noexcept; + void unsetEmphasis() noexcept; void resetColors() override; - auto setReverseMode (bool = true) noexcept -> bool; - auto unsetReverseMode() noexcept -> bool; - auto setEnable (bool = true) -> bool override; + void setReverseMode (bool = true) noexcept; + void unsetReverseMode() noexcept; + void setEnable (bool = true) override; void setNumber (uLong); void setNumber (long); void setNumber (float, int = FLT_DIG); @@ -187,20 +187,20 @@ inline auto FLabel::getText() & -> FString& { return text; } //---------------------------------------------------------------------- -inline auto FLabel::setEmphasis (bool enable) noexcept -> bool -{ return (emphasis = enable); } +inline void FLabel::setEmphasis (bool enable) noexcept +{ emphasis = enable; } //---------------------------------------------------------------------- -inline auto FLabel::unsetEmphasis() noexcept -> bool -{ return setEmphasis(false); } +inline void FLabel::unsetEmphasis() noexcept +{ setEmphasis(false); } //---------------------------------------------------------------------- -inline auto FLabel::setReverseMode (bool enable) noexcept -> bool -{ return (reverse_mode = enable); } +inline void FLabel::setReverseMode (bool enable) noexcept +{ reverse_mode = enable; } //---------------------------------------------------------------------- -inline auto FLabel::unsetReverseMode() noexcept -> bool -{ return setReverseMode(false); } +inline void FLabel::unsetReverseMode() noexcept +{ setReverseMode(false); } //---------------------------------------------------------------------- inline void FLabel::setNumber (uLong num) diff --git a/final/widget/flineedit.cpp b/final/widget/flineedit.cpp index 77c0d4e0..afbfb1a2 100644 --- a/final/widget/flineedit.cpp +++ b/final/widget/flineedit.cpp @@ -64,8 +64,7 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent) FLineEdit::~FLineEdit() // destructor { if ( input_type == InputType::Password ) // Zero password in memory - for (auto&& ch : text) - ch = '\0'; + std::fill (text.begin(), text.end(), '\0'); if ( ! insert_mode ) FVTerm::getFOutput()->setCursor(CursorMode::Insert); @@ -103,28 +102,27 @@ auto FLineEdit::operator >> (FString& s) const -> const FLineEdit& // public methods of FLineEdit //---------------------------------------------------------------------- -auto FLineEdit::setEnable (bool enable) -> bool +void FLineEdit::setEnable (bool enable) { FWidget::setEnable(enable); resetColors(); - return enable; } //---------------------------------------------------------------------- -auto FLineEdit::setShadow (bool enable) -> bool +void FLineEdit::setShadow (bool enable) { - return setWidgetShadow(this, enable); + setWidgetShadow(this, enable); } //---------------------------------------------------------------------- -auto FLineEdit::setReadOnly (bool enable) -> bool +void FLineEdit::setReadOnly (bool enable) { if ( enable ) unsetVisibleCursor(); else setVisibleCursor(); - return (read_only = enable); + read_only = enable; } //---------------------------------------------------------------------- diff --git a/final/widget/flineedit.h b/final/widget/flineedit.h index 22a32e08..b48f2a72 100644 --- a/final/widget/flineedit.h +++ b/final/widget/flineedit.h @@ -141,13 +141,13 @@ class FLineEdit : public FWidget void setSize (const FSize&, bool = true) override; void setGeometry ( const FPoint&, const FSize& , bool = true ) override; - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; - auto setReadOnly (bool = true) -> bool; - auto unsetReadOnly() -> bool; + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; + void setShadow (bool = true); + void unsetShadow(); + void setReadOnly (bool = true); + void unsetReadOnly(); // Inquiry auto hasShadow() const -> bool; @@ -290,20 +290,20 @@ inline void FLineEdit::setLabelAssociatedWidget (FWidget* w) { label_associated_widget = w; } //---------------------------------------------------------------------- -inline auto FLineEdit::unsetEnable() -> bool -{ return setEnable(false); } +inline void FLineEdit::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FLineEdit::setDisable() -> bool -{ return setEnable(false); } +inline void FLineEdit::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FLineEdit::unsetShadow() -> bool -{ return setShadow(false); } +inline void FLineEdit::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- -inline auto FLineEdit::unsetReadOnly() -> bool -{ return setReadOnly(true); } +inline void FLineEdit::unsetReadOnly() +{ setReadOnly(true); } //---------------------------------------------------------------------- inline auto FLineEdit::hasShadow() const -> bool diff --git a/final/widget/flistbox.cpp b/final/widget/flistbox.cpp index 747c44ed..5228f21f 100644 --- a/final/widget/flistbox.cpp +++ b/final/widget/flistbox.cpp @@ -34,15 +34,6 @@ namespace finalcut { -//---------------------------------------------------------------------- -// class FListBoxItem -//---------------------------------------------------------------------- - -// constructor and destructor -//---------------------------------------------------------------------- -FListBoxItem::~FListBoxItem() noexcept = default; // destructor - - //---------------------------------------------------------------------- // class FListBox //---------------------------------------------------------------------- diff --git a/final/widget/flistbox.h b/final/widget/flistbox.h index f5e056c5..718d1098 100644 --- a/final/widget/flistbox.h +++ b/final/widget/flistbox.h @@ -72,28 +72,12 @@ class FListBoxItem { public: // Constructors - FListBoxItem() = default; template - explicit FListBoxItem (const FString&, DT&& = DT() ); - - // Copy constructor - FListBoxItem (const FListBoxItem&) = default; - - // Move constructor - FListBoxItem (FListBoxItem&&) noexcept = default; - - // Destructor - virtual ~FListBoxItem() noexcept; - - // Copy assignment operator (=) - auto operator = (const FListBoxItem&) -> FListBoxItem& = default; - - // Move assignment operator (=) - auto operator = (FListBoxItem&&) noexcept -> FListBoxItem& = default; + explicit FListBoxItem (const FString& = FString{}, DT&& = DT() ); // Accessors - virtual auto getClassName() const -> FString; - virtual auto getText() const -> FString; + auto getClassName() const -> FString; + auto getText() const -> FString; template auto getData() const -> clean_fdata_t
&; @@ -243,7 +227,7 @@ class FListBox : public FWidget void setGeometry (const FPoint&, const FSize&, bool = true) override; void setMultiSelection (bool = true); void unsetMultiSelection (); - auto setDisable() -> bool override; + void setDisable() override; void setText (const FString&); // Inquiries @@ -536,8 +520,8 @@ inline void FListBox::unsetMultiSelection() { setMultiSelection(false); } //---------------------------------------------------------------------- -inline auto FListBox::setDisable() -> bool -{ return setEnable(false); } +inline void FListBox::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- inline auto FListBox::isSelected (std::size_t index) const -> bool @@ -611,7 +595,7 @@ void FListBox::insert ( const std::initializer_list& list , bool s , DT&& d ) { - for (auto& item : list) + for (const auto& item : list) { FListBoxItem listItem (FString() << item, std::forward
(d)); listItem.brackets = b; diff --git a/final/widget/flistview.cpp b/final/widget/flistview.cpp index fc76cb65..54a817a3 100644 --- a/final/widget/flistview.cpp +++ b/final/widget/flistview.cpp @@ -946,8 +946,8 @@ void FListView::remove (FListViewItem* item) return; auto parent = item->getParent(); - const auto& current_item = static_cast(*current_iter); - const auto& first_item = itemlist.front(); + const auto* current_item = static_cast(*current_iter); + const auto* first_item = itemlist.front(); auto end_iter = static_cast(itemlist.end()); const auto& last_item = *(--end_iter); const bool is_current_line( item == current_item ); diff --git a/final/widget/flistview.h b/final/widget/flistview.h index 92d88c3c..e0586137 100644 --- a/final/widget/flistview.h +++ b/final/widget/flistview.h @@ -357,8 +357,8 @@ class FListView : public FWidget void hideSortIndicator (bool = true); void showColumn (int); void hideColumn (int); - auto setTreeView (bool = true) -> bool; - auto unsetTreeView() -> bool; + void setTreeView (bool = true); + void unsetTreeView(); // Inquiries auto isColumnHidden (int) const -> bool; @@ -613,12 +613,12 @@ inline void FListView::hideSortIndicator (bool hide) { hide_sort_indicator = hide; } //---------------------------------------------------------------------- -inline auto FListView::setTreeView (bool enable) -> bool -{ return (tree_view = enable); } +inline void FListView::setTreeView (bool enable) +{ tree_view = enable; } //---------------------------------------------------------------------- -inline auto FListView::unsetTreeView() -> bool -{ return setTreeView(false); } +inline void FListView::unsetTreeView() +{ setTreeView(false); } //---------------------------------------------------------------------- inline auto FListView::insert (FListViewItem* item) -> FObject::iterator diff --git a/final/widget/fprogressbar.cpp b/final/widget/fprogressbar.cpp index db5e535b..ddbeeed6 100644 --- a/final/widget/fprogressbar.cpp +++ b/final/widget/fprogressbar.cpp @@ -84,9 +84,9 @@ void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size } //---------------------------------------------------------------------- -auto FProgressbar::setShadow (bool enable) -> bool +void FProgressbar::setShadow (bool enable) { - return setWidgetShadow(this, enable); + setWidgetShadow(this, enable); } //---------------------------------------------------------------------- diff --git a/final/widget/fprogressbar.h b/final/widget/fprogressbar.h index 2ba0a877..f5f876ae 100644 --- a/final/widget/fprogressbar.h +++ b/final/widget/fprogressbar.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2022 Markus Gans * +* Copyright 2014-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -76,8 +76,8 @@ class FProgressbar : public FWidget void setPercentage (std::size_t); void setSize (const FSize&, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; + void setShadow (bool = true) ; + void unsetShadow(); // Inquiries auto hasShadow() const -> bool; @@ -114,8 +114,8 @@ inline auto FProgressbar::getPercentage() const noexcept -> std::size_t { return percentage; } //---------------------------------------------------------------------- -inline auto FProgressbar::unsetShadow() -> bool -{ return setShadow(false); } +inline void FProgressbar::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- inline auto FProgressbar::hasShadow() const -> bool diff --git a/final/widget/fscrollview.cpp b/final/widget/fscrollview.cpp index f235a7cb..f86f8246 100644 --- a/final/widget/fscrollview.cpp +++ b/final/widget/fscrollview.cpp @@ -302,9 +302,9 @@ void FScrollView::setText (const FString& txt) } //---------------------------------------------------------------------- -auto FScrollView::setViewportPrint (bool enable) -> bool +void FScrollView::setViewportPrint (bool enable) { - return (use_own_print_area = ! enable); + use_own_print_area = ! enable; } //---------------------------------------------------------------------- @@ -317,9 +317,9 @@ void FScrollView::resetColors() } //---------------------------------------------------------------------- -auto FScrollView::setBorder (bool enable) -> bool +void FScrollView::setBorder (bool enable) { - return (setFlags().feature.no_border = ! enable); + setFlags().feature.no_border = ! enable; } //---------------------------------------------------------------------- @@ -344,7 +344,7 @@ void FScrollView::setVerticalScrollBarMode (ScrollBarMode mode) void FScrollView::clearArea (wchar_t fillchar) { if ( viewport ) - clearArea (viewport.get(), fillchar); + FScrollView::clearArea (viewport.get(), fillchar); } //---------------------------------------------------------------------- @@ -607,11 +607,11 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev) { // Change the focus away from FScrollView to another widget - const auto& focus = FWidget::getFocusWidget(); + const auto* focus = FWidget::getFocusWidget(); if ( out_ev->getFocusType() == FocusTypes::NextWidget ) { - const auto& last_widget = getLastFocusableWidget(getChildren()); + const auto* last_widget = getLastFocusableWidget(getChildren()); if ( focus != last_widget ) return; @@ -621,7 +621,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev) } else if ( out_ev->getFocusType() == FocusTypes::PreviousWidget ) { - const auto& first_widget = getFirstFocusableWidget(getChildren()); + const auto* first_widget = getFirstFocusableWidget(getChildren()); if ( focus != first_widget ) return; @@ -819,7 +819,7 @@ inline void FScrollView::createViewport (const FSize& size) noexcept scroll_geometry.setSize(size); viewport = createArea(scroll_geometry); setColor(); - clearArea(); + FScrollView::clearArea(); } //---------------------------------------------------------------------- diff --git a/final/widget/fscrollview.h b/final/widget/fscrollview.h index 3b952472..ced76181 100644 --- a/final/widget/fscrollview.h +++ b/final/widget/fscrollview.h @@ -117,11 +117,11 @@ class FScrollView : public FWidget auto setCursorPos (const FPoint&) -> bool override; void setPrintPos (const FPoint&) override; void setText (const FString&); - auto setViewportPrint (bool = true) -> bool; - auto unsetViewportPrint() -> bool; + void setViewportPrint (bool = true); + void unsetViewportPrint(); void resetColors() override; - auto setBorder (bool = true) -> bool; - auto unsetBorder() -> bool; + void setBorder (bool = true); + void unsetBorder(); void setHorizontalScrollBarMode (ScrollBarMode); void setVerticalScrollBarMode (ScrollBarMode); @@ -260,12 +260,12 @@ inline auto FScrollView::getScrollY() const -> int { return viewport_geometry.getY(); } //---------------------------------------------------------------------- -inline auto FScrollView::unsetViewportPrint() -> bool -{ return setViewportPrint(false); } +inline void FScrollView::unsetViewportPrint() +{ setViewportPrint(false); } //---------------------------------------------------------------------- -inline auto FScrollView::unsetBorder() -> bool -{ return setBorder(false); } +inline void FScrollView::unsetBorder() +{ setBorder(false); } //---------------------------------------------------------------------- inline auto FScrollView::hasBorder() const -> bool diff --git a/final/widget/fspinbox.cpp b/final/widget/fspinbox.cpp index 5817f6ff..d440ba00 100644 --- a/final/widget/fspinbox.cpp +++ b/final/widget/fspinbox.cpp @@ -72,17 +72,16 @@ void FSpinBox::setGeometry ( const FPoint& pos, const FSize& size } //---------------------------------------------------------------------- -auto FSpinBox::setEnable (bool enable) -> bool +void FSpinBox::setEnable (bool enable) { FWidget::setEnable(enable); input_field.setEnable(enable); - return enable; } //---------------------------------------------------------------------- -auto FSpinBox::setShadow (bool enable) -> bool +void FSpinBox::setShadow (bool enable) { - return setWidgetShadow(this, enable); + setWidgetShadow(this, enable); } //---------------------------------------------------------------------- diff --git a/final/widget/fspinbox.h b/final/widget/fspinbox.h index d186ddbc..ae9cd1a8 100644 --- a/final/widget/fspinbox.h +++ b/final/widget/fspinbox.h @@ -85,11 +85,11 @@ class FSpinBox : public FWidget // Mutators void setSize (const FSize&, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override; - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; + void setShadow (bool = true); + void unsetShadow(); void setValue (sInt64); void setMinValue (sInt64); void setMaxValue (sInt64); @@ -173,16 +173,16 @@ inline auto FSpinBox::getLabelOrientation() const -> FLineEdit::LabelOrientation { return input_field.getLabelOrientation(); } //---------------------------------------------------------------------- -inline auto FSpinBox::unsetEnable() -> bool -{ return setEnable(false); } +inline void FSpinBox::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FSpinBox::setDisable() -> bool -{ return setEnable(false); } +inline void FSpinBox::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FSpinBox::unsetShadow() -> bool -{ return setShadow(false); } +inline void FSpinBox::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- inline auto FSpinBox::hasShadow() const -> bool diff --git a/final/widget/fstatusbar.cpp b/final/widget/fstatusbar.cpp index b34eaeb0..a3db313f 100644 --- a/final/widget/fstatusbar.cpp +++ b/final/widget/fstatusbar.cpp @@ -89,12 +89,12 @@ void FStatusKey::setActive() } //---------------------------------------------------------------------- -auto FStatusKey::setMouseFocus(bool enable) -> bool +void FStatusKey::setMouseFocus (bool enable) { if ( mouse_focus == enable ) - return true; + return; - return (mouse_focus = enable); + mouse_focus = enable; } diff --git a/final/widget/fstatusbar.h b/final/widget/fstatusbar.h index 5ae6cad1..30b6fa85 100644 --- a/final/widget/fstatusbar.h +++ b/final/widget/fstatusbar.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2022 Markus Gans * +* Copyright 2014-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -102,8 +102,8 @@ class FStatusKey : public FWidget void setText (const FString&); void setActive(); void unsetActive() noexcept; - auto setMouseFocus (bool = true) -> bool; - auto unsetMouseFocus() -> bool; + void setMouseFocus (bool = true); + void unsetMouseFocus(); // Inquiry auto isActivated() const noexcept -> bool; @@ -157,8 +157,8 @@ inline void FStatusKey::unsetActive() noexcept { active = false; } //---------------------------------------------------------------------- -inline auto FStatusKey::unsetMouseFocus() -> bool -{ return setMouseFocus(false); } +inline void FStatusKey::unsetMouseFocus() +{ setMouseFocus(false); } //---------------------------------------------------------------------- inline auto FStatusKey::isActivated() const noexcept -> bool diff --git a/final/widget/ftextview.h b/final/widget/ftextview.h index 9411d2b0..2db053d1 100644 --- a/final/widget/ftextview.h +++ b/final/widget/ftextview.h @@ -332,7 +332,7 @@ inline void FTextView::scrollTo (const FPoint& pos) template void FTextView::append (const std::initializer_list& list) { - for (auto& str : list) + for (const auto& str : list) insert(str, -1); } @@ -340,7 +340,7 @@ void FTextView::append (const std::initializer_list& list) template void FTextView::insert (const std::initializer_list& list, int pos) { - for (auto& str : list) + for (const auto& str : list) { insert(str, pos); pos++; diff --git a/final/widget/ftogglebutton.cpp b/final/widget/ftogglebutton.cpp index b1dfc4f9..74e85793 100644 --- a/final/widget/ftogglebutton.cpp +++ b/final/widget/ftogglebutton.cpp @@ -139,13 +139,13 @@ void FToggleButton::resetColors() } //---------------------------------------------------------------------- -auto FToggleButton::setNoUnderline (bool enable) -> bool +void FToggleButton::setNoUnderline (bool enable) { - return (setFlags().feature.no_underline = enable); + setFlags().feature.no_underline = enable; } //---------------------------------------------------------------------- -auto FToggleButton::setEnable (bool enable) -> bool +void FToggleButton::setEnable (bool enable) { FWidget::setEnable(enable); resetColors(); @@ -154,20 +154,16 @@ auto FToggleButton::setEnable (bool enable) -> bool setHotkeyAccelerator(); else delAccelerator(); - - return enable; } //---------------------------------------------------------------------- -auto FToggleButton::setChecked (bool enable) -> bool +void FToggleButton::setChecked (bool enable) { - if ( checked != enable ) - { - checked = enable; - processToggle(); - } + if ( checked == enable ) + return; - return checked; + checked = enable; + processToggle(); } //---------------------------------------------------------------------- diff --git a/final/widget/ftogglebutton.h b/final/widget/ftogglebutton.h index 35810cbe..55a24a48 100644 --- a/final/widget/ftogglebutton.h +++ b/final/widget/ftogglebutton.h @@ -91,13 +91,13 @@ class FToggleButton : public FWidget void setSize (const FSize&, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override; void resetColors() override; - auto setNoUnderline (bool = true) -> bool; - auto unsetNoUnderline() -> bool; - auto setEnable (bool = true) -> bool override; - auto unsetEnable() -> bool override; - auto setDisable() -> bool override; - auto setChecked (bool = true) -> bool; - auto unsetChecked() -> bool; + void setNoUnderline (bool = true); + void unsetNoUnderline(); + void setEnable (bool = true) override; + void unsetEnable() override; + void setDisable() override; + void setChecked (bool = true); + void unsetChecked(); virtual void setText (const FString&); // Inquiries @@ -118,7 +118,7 @@ class FToggleButton : public FWidget protected: // Accessor auto getGroup() const -> FButtonGroup*; - friend auto getGroup (FToggleButton& toggle_btn) -> FButtonGroup*; + friend auto getGroup (const FToggleButton& toggle_btn) -> FButtonGroup*; // Mutator void setHotkeyAccelerator(); @@ -172,19 +172,20 @@ inline auto FToggleButton::getText() & -> FString& { return text; } //---------------------------------------------------------------------- -inline auto FToggleButton::unsetNoUnderline() -> bool -{ return setNoUnderline(false); } +inline void FToggleButton::unsetNoUnderline() +{ setNoUnderline(false); } + //---------------------------------------------------------------------- -inline auto FToggleButton::unsetEnable() -> bool -{ return setEnable(false); } +inline void FToggleButton::unsetEnable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FToggleButton::setDisable() -> bool -{ return setEnable(false); } +inline void FToggleButton::setDisable() +{ setEnable(false); } //---------------------------------------------------------------------- -inline auto FToggleButton::unsetChecked() -> bool -{ return setChecked(false); } +inline void FToggleButton::unsetChecked() +{ setChecked(false); } //---------------------------------------------------------------------- inline auto FToggleButton::isChecked() const noexcept -> bool diff --git a/final/widget/ftooltip.cpp b/final/widget/ftooltip.cpp index f7efa006..3ddf223c 100644 --- a/final/widget/ftooltip.cpp +++ b/final/widget/ftooltip.cpp @@ -83,11 +83,10 @@ void FToolTip::resetColors() } //---------------------------------------------------------------------- -auto FToolTip::setBorder (bool enable) -> bool +void FToolTip::setBorder (bool enable) { setFlags().feature.no_border = ! enable; calculateDimensions(); - return hasBorder(); } //---------------------------------------------------------------------- diff --git a/final/widget/ftooltip.h b/final/widget/ftooltip.h index e531a187..7f98d330 100644 --- a/final/widget/ftooltip.h +++ b/final/widget/ftooltip.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2016-2022 Markus Gans * +* Copyright 2016-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -82,8 +82,8 @@ class FToolTip : public FWindow void enableAutoTrim(); void disableAutoTrim(); void resetColors() override; - auto setBorder (bool = true) -> bool; - auto unsetBorder() -> bool; + void setBorder (bool = true); + void unsetBorder(); // Inquiries auto hasBorder() const -> bool; @@ -129,8 +129,8 @@ inline void FToolTip::disableAutoTrim() { text_auto_trim = false; } //---------------------------------------------------------------------- -inline auto FToolTip::unsetBorder() -> bool -{ return setBorder(false); } +inline void FToolTip::unsetBorder() +{ setBorder(false); } //---------------------------------------------------------------------- inline auto FToolTip::hasBorder() const -> bool diff --git a/final/widget/fwindow.cpp b/final/widget/fwindow.cpp index 5ae48dae..45ad8ad3 100644 --- a/final/widget/fwindow.cpp +++ b/final/widget/fwindow.cpp @@ -103,10 +103,10 @@ auto FWindow::getWindowFocusWidget() const -> FWidget* } //---------------------------------------------------------------------- -auto FWindow::setWindowWidget (bool enable) -> bool +void FWindow::setWindowWidget (bool enable) { if ( isWindowWidget() == enable ) - return true; + return; setFlags().type.window_widget = enable; @@ -114,8 +114,6 @@ auto FWindow::setWindowWidget (bool enable) -> bool setTermOffset(); else setParentOffset(); - - return enable; } //---------------------------------------------------------------------- @@ -179,19 +177,19 @@ void FWindow::unsetActiveWindow() const } //---------------------------------------------------------------------- -auto FWindow::setResizeable (bool enable) -> bool +void FWindow::setResizeable (bool enable) { - return (setFlags().feature.resizeable = enable); + setFlags().feature.resizeable = enable; } //---------------------------------------------------------------------- -auto FWindow::setMinimizable (bool enable) -> bool +void FWindow::setMinimizable (bool enable) { - return (setFlags().feature.minimizable = enable); + setFlags().feature.minimizable = enable; } //---------------------------------------------------------------------- -auto FWindow::setTransparentShadow (bool enable) -> bool +void FWindow::setTransparentShadow (bool enable) { setFlags().shadow.shadow = setFlags().shadow.trans_shadow = enable; @@ -199,15 +197,13 @@ auto FWindow::setTransparentShadow (bool enable) -> bool setShadowSize (FSize{2, 1}); else setShadowSize (FSize{0, 0}); - - return enable; } //---------------------------------------------------------------------- -auto FWindow::setShadow (bool enable) -> bool +void FWindow::setShadow (bool enable) { if ( FVTerm::getFOutput()->isMonochron() ) - return false; + return; if ( enable ) { @@ -221,15 +217,13 @@ auto FWindow::setShadow (bool enable) -> bool setFlags().shadow.trans_shadow = false; setShadowSize (FSize{0, 0}); } - - return enable; } //---------------------------------------------------------------------- -auto FWindow::setAlwaysOnTop (bool enable) -> bool +void FWindow::setAlwaysOnTop (bool enable) { if ( isAlwaysOnTop() == enable ) - return true; + return; setFlags().visibility.always_on_top = enable; @@ -245,8 +239,6 @@ auto FWindow::setAlwaysOnTop (bool enable) -> bool } else deleteFromAlwaysOnTopList (this); - - return enable; } //---------------------------------------------------------------------- diff --git a/final/widget/fwindow.h b/final/widget/fwindow.h index e95c6f28..c7b1d848 100644 --- a/final/widget/fwindow.h +++ b/final/widget/fwindow.h @@ -97,23 +97,23 @@ class FWindow : public FWidget auto getWindowFocusWidget() const -> FWidget*; // Mutators - auto setWindowWidget (bool = true) -> bool; - auto unsetWindowWidget() -> bool; + void setWindowWidget (bool = true); + void unsetWindowWidget(); static void setActiveWindow (FWindow*); void setWindowFocusWidget (FWidget*); auto activateWindow (bool = true) -> bool; void unsetActiveWindow() const; auto deactivateWindow() -> bool; - virtual auto setResizeable (bool = true) -> bool; - auto unsetResizeable() -> bool; - virtual auto setMinimizable (bool = true) -> bool; - auto unsetMinimizable() -> bool; - auto setTransparentShadow (bool = true) -> bool; - auto unsetTransparentShadow() -> bool; - auto setShadow (bool = true) -> bool; - auto unsetShadow() -> bool; - auto setAlwaysOnTop (bool = true) -> bool; - auto unsetAlwaysOnTop() -> bool; + virtual void setResizeable (bool = true); + void unsetResizeable(); + virtual void setMinimizable (bool = true); + void unsetMinimizable(); + void setTransparentShadow (bool = true); + void unsetTransparentShadow(); + void setShadow (bool = true); + void unsetShadow(); + void setAlwaysOnTop (bool = true); + void unsetAlwaysOnTop(); // Inquiries auto isZoomed() const noexcept -> bool; @@ -215,32 +215,32 @@ inline auto FWindow::getWindowLayer (WidgetT* obj) -> int } //---------------------------------------------------------------------- -inline auto FWindow::unsetWindowWidget() -> bool -{ return setWindowWidget(false); } +inline void FWindow::unsetWindowWidget() +{ setWindowWidget(false); } //---------------------------------------------------------------------- inline auto FWindow::deactivateWindow() -> bool { return activateWindow(false); } //---------------------------------------------------------------------- -inline auto FWindow::unsetResizeable() -> bool -{ return setResizeable(false); } +inline void FWindow::unsetResizeable() +{ setResizeable(false); } //---------------------------------------------------------------------- -inline auto FWindow::unsetMinimizable() -> bool -{ return setMinimizable(false); } +inline void FWindow::unsetMinimizable() +{ setMinimizable(false); } //---------------------------------------------------------------------- -inline auto FWindow::unsetTransparentShadow() -> bool -{ return setTransparentShadow(false); } +inline void FWindow::unsetTransparentShadow() +{ setTransparentShadow(false); } //---------------------------------------------------------------------- -inline auto FWindow::unsetShadow() -> bool -{ return setShadow(false); } +inline void FWindow::unsetShadow() +{ setShadow(false); } //---------------------------------------------------------------------- -inline auto FWindow::unsetAlwaysOnTop() -> bool -{ return setAlwaysOnTop(false); } +inline void FWindow::unsetAlwaysOnTop() +{ setAlwaysOnTop(false); } //---------------------------------------------------------------------- inline auto FWindow::isZoomed() const noexcept -> bool diff --git a/test/flogger-test.cpp b/test/flogger-test.cpp index 61593c28..7731cb7d 100644 --- a/test/flogger-test.cpp +++ b/test/flogger-test.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2020-2022 Markus Gans * +* Copyright 2020-2023 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -406,12 +406,6 @@ void FLoggerTest::applicationObjectTest() // Reset to the default rdbuf of clog std::clog.rdbuf(default_clog_rdbuf); - - // Delete the global FApplication logger object - auto logger = &(finalcut::FApplication::getLog()); - - if ( logger ) - delete logger; }