diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 6a16fd6c..b2021d74 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -44,8 +44,7 @@ class SegmentView final : public finalcut::FDialog explicit SegmentView (finalcut::FWidget* = nullptr); private: - // Typedef - typedef struct + struct sevenSegment { unsigned char a : 1; unsigned char b : 1; @@ -55,7 +54,7 @@ class SegmentView final : public finalcut::FDialog unsigned char f : 1; unsigned char g : 1; unsigned char : 1; // padding bit - } sevenSegment; + }; // Methods void hexEncoding(); diff --git a/examples/background-color.cpp b/examples/background-color.cpp index d52c6a1f..97c49f3a 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -38,8 +38,8 @@ using finalcut::FSize; class Background final : public finalcut::FDialog { public: - // Typedef - typedef std::tuple RGB; + // Using-declaration + using RGB = std::tuple; // Constructor explicit Background (finalcut::FWidget* = nullptr); @@ -48,7 +48,7 @@ class Background final : public finalcut::FDialog Background (const Background&) = delete; // Destructor - ~Background(); + ~Background() noexcept override; // Disable copy assignment operator (=) Background& operator = (const Background&) = delete; @@ -169,8 +169,7 @@ Background::Background (finalcut::FWidget* parent) } //---------------------------------------------------------------------- -Background::~Background() // destructor -{ } +Background::~Background() noexcept = default; // destructor //---------------------------------------------------------------------- void Background::cb_changed() diff --git a/examples/calculator.cpp b/examples/calculator.cpp index a1e46fa1..c8912c33 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -118,7 +118,7 @@ class Calc final : public finalcut::FDialog explicit Calc (finalcut::FWidget* parent = nullptr); // Destructor - ~Calc() override; + ~Calc() override = default; private: // Typedef and Enumeration @@ -305,10 +305,6 @@ Calc::Calc (FWidget* parent) calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter); } -//---------------------------------------------------------------------- -Calc::~Calc() -{ } - //---------------------------------------------------------------------- void Calc::onKeyPress (finalcut::FKeyEvent* ev) { diff --git a/examples/checklist.cpp b/examples/checklist.cpp index 6469a68e..a6ca7b90 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -51,7 +51,7 @@ class CheckList final : public finalcut::FDialog CheckList (const CheckList&) = delete; // Destructor - ~CheckList() override; + ~CheckList() override = default; // Disable copy assignment operator (=) CheckList& operator = (const CheckList&) = delete; @@ -115,10 +115,6 @@ CheckList::CheckList (finalcut::FWidget* parent) ); } -//---------------------------------------------------------------------- -CheckList::~CheckList() // destructor -{ } - //---------------------------------------------------------------------- void CheckList::populate() { diff --git a/examples/choice.cpp b/examples/choice.cpp index beec8393..c0c2f4b2 100644 --- a/examples/choice.cpp +++ b/examples/choice.cpp @@ -27,8 +27,8 @@ using finalcut::FPoint; using finalcut::FSize; -// Typedef -typedef std::shared_ptr FRadioButtonPtr; +// Using-declaration +using FRadioButtonPtr = std::shared_ptr; // Function prototypes void cb_quit (finalcut::FDialog&); diff --git a/examples/listbox.cpp b/examples/listbox.cpp index e1af5c0e..f47a937b 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -87,7 +87,7 @@ class Listbox final : public FDialog Listbox (const Listbox&) = delete; // Destructor - ~Listbox() override; + ~Listbox() override = default; // Disable copy assignment operator (=) Listbox& operator = (const Listbox&) = delete; @@ -164,10 +164,6 @@ Listbox::Listbox (FWidget* parent) ); } -//---------------------------------------------------------------------- -Listbox::~Listbox() // destructor -{ } - //---------------------------------------------------------------------- void Listbox::onClose (FCloseEvent* ev) { diff --git a/examples/listview.cpp b/examples/listview.cpp index a0478895..d039a82b 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -47,7 +47,7 @@ class Listview final : public finalcut::FDialog Listview (const Listview&) = delete; // Destructor - ~Listview() override; + ~Listview() override = default; // Disable copy assignment operator (=) Listview& operator = (const Listview&) = delete; @@ -124,10 +124,6 @@ Listview::Listview (finalcut::FWidget* parent) ); } -//---------------------------------------------------------------------- -Listview::~Listview() // destructor -{ } - //---------------------------------------------------------------------- void Listview::populate() { diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index e087776a..8c70b9e7 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -38,7 +38,7 @@ class Mandelbrot final : public finalcut::FDialog explicit Mandelbrot (finalcut::FWidget* = nullptr); // Destructor - ~Mandelbrot() override; + ~Mandelbrot() override = default; // Event handlers void onKeyPress (finalcut::FKeyEvent*) override; @@ -58,10 +58,6 @@ Mandelbrot::Mandelbrot (finalcut::FWidget* parent) FDialog::setText ("Mandelbrot set"); } -//---------------------------------------------------------------------- -Mandelbrot::~Mandelbrot() -{ } - //---------------------------------------------------------------------- void Mandelbrot::draw() { diff --git a/examples/menu.cpp b/examples/menu.cpp index a60dd65e..9b36fcd2 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -41,7 +41,7 @@ class Menu final : public finalcut::FDialog Menu (const Menu&) = delete; // Destructor - ~Menu() override; + ~Menu() override = default; // Disable copy assignment operator (=) Menu& operator = (const Menu&) = delete; @@ -157,10 +157,6 @@ Menu::Menu (finalcut::FWidget* parent) Info.setGeometry(FPoint{2, 1}, FSize{36, 5}); } -//---------------------------------------------------------------------- -Menu::~Menu() -{ } - //---------------------------------------------------------------------- void Menu::configureFileMenuItems() { diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 99730553..924fb7a6 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -43,7 +43,7 @@ class ColorChooser final : public finalcut::FWidget ColorChooser (const ColorChooser&) = delete; // Destructor - ~ColorChooser() override; + ~ColorChooser() override = default; // Disable copy assignment operator (=) ColorChooser& operator = (const ColorChooser&) = delete; @@ -85,10 +85,6 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent) headline << "Color"; } -//---------------------------------------------------------------------- -ColorChooser::~ColorChooser() -{ } - //---------------------------------------------------------------------- inline FColor ColorChooser::getForeground() const { @@ -186,7 +182,7 @@ class Brushes final : public finalcut::FWidget Brushes (const Brushes&) = delete; // Destructor - ~Brushes() override; + ~Brushes() override = default; // Disable copy assignment operator (=) Brushes& operator = (const Brushes&) = delete; @@ -231,10 +227,6 @@ Brushes::Brushes (finalcut::FWidget* parent) headline << "Brush"; } -//---------------------------------------------------------------------- -Brushes::~Brushes() -{ } - //---------------------------------------------------------------------- void Brushes::setSize (const FSize& size, bool adjust) { @@ -328,7 +320,7 @@ class MouseDraw final : public finalcut::FDialog MouseDraw (const MouseDraw&) = delete; // Destructor - ~MouseDraw() override; + ~MouseDraw() override = default; // Disable copy assignment operator (=) MouseDraw& operator = (const MouseDraw&) = delete; @@ -377,10 +369,6 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent) brush.setPos (FPoint{1, 12}); } -//---------------------------------------------------------------------- -MouseDraw::~MouseDraw() -{ } - //---------------------------------------------------------------------- void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust) { diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 698ea38e..753631a7 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -53,7 +53,7 @@ class RotoZoomer final : public finalcut::FDialog explicit RotoZoomer (finalcut::FWidget* = nullptr, bool = false, int = 314); // Destructor - ~RotoZoomer() override; + ~RotoZoomer() override = default; // Accessors finalcut::FString getReport() const; @@ -123,10 +123,6 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) } } -//---------------------------------------------------------------------- -RotoZoomer::~RotoZoomer() -{ } - //---------------------------------------------------------------------- void RotoZoomer::draw() { diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 7453bfbf..0042e9db 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -41,7 +41,7 @@ class Scrollview final : public finalcut::FScrollView Scrollview (const Scrollview&) = delete; // Destructor - ~Scrollview() override; + ~Scrollview() override = default; // Disable copy assignment operator (=) Scrollview& operator = (const Scrollview&) = delete; @@ -110,10 +110,6 @@ Scrollview::Scrollview (finalcut::FWidget* parent) ); } -//---------------------------------------------------------------------- -Scrollview::~Scrollview() -{ } - //---------------------------------------------------------------------- void Scrollview::setScrollSize (const FSize& size) { @@ -197,7 +193,7 @@ class Scrollviewdemo final : public finalcut::FDialog explicit Scrollviewdemo (finalcut::FWidget* = nullptr); // Destructor - ~Scrollviewdemo() override; + ~Scrollviewdemo() override = default; // Event handler void onClose (finalcut::FCloseEvent*) override; @@ -240,10 +236,6 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent) label << L"Use scrollbars to change the viewport position"; } -//---------------------------------------------------------------------- -Scrollviewdemo::~Scrollviewdemo() -{ } - //---------------------------------------------------------------------- void Scrollviewdemo::cb_quit() { diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index f7da8ef3..e26d4a24 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -44,7 +44,7 @@ class AttribDlg final : public finalcut::FDialog AttribDlg (const AttribDlg&) = delete; // Destructor - ~AttribDlg() override; + ~AttribDlg() override = default; // Disable copy assignment operator (=) AttribDlg& operator = (const AttribDlg&) = delete; @@ -100,10 +100,6 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent) ); } -//---------------------------------------------------------------------- -AttribDlg::~AttribDlg() -{ } - //---------------------------------------------------------------------- FColor AttribDlg::getBGColor() const { @@ -226,8 +222,7 @@ class AttribDemo final : public finalcut::FWidget explicit AttribDemo (FWidget* = nullptr); // Destructor - ~AttribDemo() override - { } + ~AttribDemo() override = default; // Event handler void onWheel (finalcut::FWheelEvent* ev) override diff --git a/examples/transparent.cpp b/examples/transparent.cpp index b4cca03b..307e5208 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -36,23 +36,23 @@ using finalcut::FStyle; class Transparent final : public finalcut::FDialog { public: - // Typedef and Enumeration - typedef enum ttype + // Enumeration + enum class Type { transparent = 0, shadow = 1, inherit_background = 2 - } trans_type; + }; // Constructor explicit Transparent ( finalcut::FWidget* = nullptr - , trans_type = transparent ); + , Type = Type::transparent ); // Disable copy constructor Transparent (const Transparent&) = delete; // Destructor - ~Transparent() override; + ~Transparent() override = default; // Disable copy assignment operator (=) Transparent& operator = (const Transparent&) = delete; @@ -65,12 +65,12 @@ class Transparent final : public finalcut::FDialog void onKeyPress (finalcut::FKeyEvent* ev) override; // Data members - trans_type type; + Type type; }; //---------------------------------------------------------------------- Transparent::Transparent ( finalcut::FWidget* parent - , Transparent::trans_type tt ) + , Transparent::Type tt ) : finalcut::FDialog{parent} , type{tt} { @@ -80,10 +80,6 @@ Transparent::Transparent ( finalcut::FWidget* parent FWidget::setStatusbarMessage("Press Q to quit"); } -//---------------------------------------------------------------------- -Transparent::~Transparent() -{ } - //---------------------------------------------------------------------- void Transparent::draw() { @@ -92,13 +88,13 @@ void Transparent::draw() if ( finalcut::FTerm::isMonochron() ) setReverse(true); - if ( type == shadow ) + if ( type == Type::shadow ) { const auto& wc = getColorTheme(); print() << FColorPair {wc->shadow_bg, wc->shadow_fg} << FStyle {fc::ColorOverlay}; } - else if ( type == inherit_background ) + else if ( type == Type::inherit_background ) { if ( finalcut::FTerm::getMaxColor() > 8 ) print() << FColorPair {fc::Blue, fc::Black}; @@ -152,7 +148,7 @@ class MainWindow final : public finalcut::FDialog MainWindow (const MainWindow&) = delete; // Destructor - ~MainWindow() override; + ~MainWindow() override = default; // Disable copy assignment operator (=) MainWindow& operator = (const MainWindow&) = delete; @@ -202,12 +198,12 @@ MainWindow::MainWindow (finalcut::FWidget* parent) transpwin->setGeometry (FPoint{6, 3}, FSize{29, 12}); transpwin->unsetTransparentShadow(); - shadowwin = new Transparent(this, Transparent::shadow); + shadowwin = new Transparent(this, Transparent::Type::shadow); shadowwin->setText("shadow"); shadowwin->setGeometry (FPoint{46, 11}, FSize{29, 12}); shadowwin->unsetTransparentShadow(); - ibg = new Transparent(this, Transparent::inherit_background); + ibg = new Transparent(this, Transparent::Type::inherit_background); ibg->setText("inherit background"); ibg->setGeometry (FPoint{42, 3}, FSize{29, 7}); ibg->unsetTransparentShadow(); @@ -219,10 +215,6 @@ MainWindow::MainWindow (finalcut::FWidget* parent) activateDialog(); } -//---------------------------------------------------------------------- -MainWindow::~MainWindow() -{ } - //---------------------------------------------------------------------- void MainWindow::draw() { diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 3f3d8123..469f265e 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -151,7 +151,7 @@ class Treeview final : public finalcut::FDialog Treeview (const Treeview&) = delete; // Destructor - ~Treeview() override; + ~Treeview() override = default; // Disable copy assignment operator (=) Treeview& operator = (const Treeview&) = delete; @@ -161,6 +161,12 @@ class Treeview final : public finalcut::FDialog struct TreeItem; // forward declaration // Methods + auto initAfrica() -> std::initializer_list; + auto initAsia() -> std::initializer_list; + auto initEurope() -> std::initializer_list; + auto initNorthAmerica() -> std::initializer_list; + auto initSouthAmerica() -> std::initializer_list; + auto initOceania() -> std::initializer_list; void adjustSize() override; // Event handler @@ -170,12 +176,12 @@ class Treeview final : public finalcut::FDialog bool initialized{false}; finalcut::FListView listview{this}; finalcut::FButton quit{this}; - static TreeItem africa[]; - static TreeItem asia[]; - static TreeItem europe[]; - static TreeItem north_america[]; - static TreeItem south_america[]; - static TreeItem oceania[]; + std::vector africa{initAfrica()}; + std::vector asia{initAsia()}; + std::vector europe{initEurope()}; + std::vector north_america{initNorthAmerica()}; + std::vector south_america{initSouthAmerica()}; + std::vector oceania{initOceania()}; }; @@ -195,133 +201,9 @@ struct Treeview::TreeItem const char* name; const char* population; const char* density; - TreeItem* child_element; + std::vector child_element; }; -//---------------------------------------------------------------------- -// class Treeview - array data -//---------------------------------------------------------------------- -Treeview::TreeItem Treeview::africa[] = -{ - { "Algeria", "40,400,000", "15.9", nullptr }, - { "Angola", "25,789,024", "20.69", nullptr }, - { "Botswana", "2,250,260", "3.7", nullptr }, - { "Cameroon", "22,534,532", "39.7", nullptr }, - { "Chad", "13,670,084", "8.6", nullptr }, - { "Egypt", "94,666,000", "87", nullptr }, - { "Ethiopia", "102,374,044", "92.7", nullptr }, - { "Ivory Coast", "23,740,424", "63.9", nullptr }, - { "Libya", "6,541,948", "3.55", nullptr }, - { "Madagascar", "24,430,325", "35.2", nullptr }, - { "Mali", "14,517,176", "11.7", nullptr }, - { "Mauritania", "4,301,018", "3.4", nullptr }, - { "Mozambique", "24,692,144", "28.7", nullptr }, - { "Namibia", "2,113,077", "2.54", nullptr }, - { "Niger", "20,672,987", "12.1", nullptr }, - { "Nigeria", "185,989,640", "197.2", nullptr }, - { "Somalia", "14,317,996", "19.31", nullptr }, - { "South Africa", "54,956,900", "42.4", nullptr }, - { "South Sudan", "12,340,000", "13.33", nullptr }, - { "Sudan", "39,578,828", "21.3", nullptr }, - { "Tanzania", "51,820,00", "47.5", nullptr }, - { "Zambia", "16,212,000", "17.2", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; - -Treeview::TreeItem Treeview::asia[] = -{ - { "Afghanistan", "34,656,032", "49.88", nullptr }, - { "China", "1,403,500,365", "145.0", nullptr }, - { "India", "1,324,171,354", "393.9", nullptr }, - { "Indonesia", "261,115,456", "124.66", nullptr }, - { "Iran", "80,829,192", "48.0", nullptr }, - { "Iraq", "37,202,572", "82.7", nullptr }, - { "Japan", "126,740,000", "336.0", nullptr }, - { "Kazakhstan", "17,987,736", "6.49", nullptr }, - { "Mongolia", "3,081,677", "1.97", nullptr }, - { "Myanmar", "51,486,253", "76.0", nullptr }, - { "Pakistan", "207,774,520", "244.4", nullptr }, - { "Russia", "144,463,451", "8.4", nullptr }, - { "Saudi Arabia", "33,000,000", "15.0", nullptr }, - { "Thailand", "68,863,514", "132.1", nullptr }, - { "Turkey", "79,814,871", "102.0", nullptr }, - { "Turkmenistan", "5,662,544", "10.5", nullptr }, - { "Uzbekistan", "32,979,000", "70.5", nullptr }, - { "Vietnam", "94,569,072", "276.03", nullptr }, - { "Yemen", "27,584,213", "44.7", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; - -Treeview::TreeItem Treeview::europe[] = -{ - { "Austria", "8,794,267", "104.0", nullptr }, - { "Belarus", "9,498,700", "45.8", nullptr }, - { "Bulgaria", "7,101,859", "64.9", nullptr }, - { "Czech Republic", "10,610,947", "134.0", nullptr }, - { "Finland", "5,506,312", "16.0", nullptr }, - { "France", "66,991,000", "103.0", nullptr }, - { "Germany", "82,175,700", "227.0", nullptr }, - { "Greece", "11,183,716", "82.0", nullptr }, - { "Hungary", "9,797,561", "105.3", nullptr }, - { "Iceland", "332,529", "3.2", nullptr }, - { "Italy", "60,589,445", "201.3", nullptr }, - { "Norway", "5,267,146", "15.8", nullptr }, - { "Poland", "38,634,007", "123.0", nullptr }, - { "Portugal", "10,309,573", "115.0", nullptr }, - { "Romania", "19,638,000", "84.4", nullptr }, - { "Serbia", "7,058,322", "91.1", nullptr }, - { "Spain", "46,468,102", "92.0", nullptr }, - { "Sweden", "10,065,389", "22.0", nullptr }, - { "United Kingdom", "65,648,000", "270.7", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; - - -Treeview::TreeItem Treeview::north_america[] = -{ - { "Canada", "35,151,728", "3.92", nullptr }, - { "Cuba", "11,239,224", "102.3", nullptr }, - { "Greenland", "56,483", "0.028", nullptr }, - { "Guatemala", "16,582,469", "129.0", nullptr }, - { "Honduras", "9,112,867", "64.0", nullptr }, - { "Mexico", "119,530,753", "61.0", nullptr }, - { "Nicaragua", "6,167,237", "51.0", nullptr }, - { "USA", "325,365,189", "35.0", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; - -Treeview::TreeItem Treeview::south_america[] = -{ - { "Argentina", "43,847,430", "14.4", nullptr }, - { "Bolivia", "11,410,651", "10.4", nullptr }, - { "Brazil", "208,064,000", "24.35", nullptr }, - { "Chile", "18,006,407", "24.0", nullptr }, - { "Colombia", "49,364,592", "40.74", nullptr }, - { "Ecuador", "16,385,068", "58.95", nullptr }, - { "Guyana", "773,303", "3.502", nullptr }, - { "Paraguay", "6,725,308", "17.2", nullptr }, - { "Peru", "31,826,018", "23.0", nullptr }, - { "Venezuela", "31,568,179", "33.75", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; - -Treeview::TreeItem Treeview::oceania[] = -{ - { "Australia", "24,675,900", "3.2", nullptr }, - { "Papua New Guinea", "7,059,653", "15.0", nullptr }, - { "Papua", "3,486,432", "11.0", nullptr }, - { "New Zealand", "4,823,090", "17.5", nullptr }, - { "West Papua", "877,437", "6.3", nullptr }, - { "Solomon Islands", "599,419", "18.1", nullptr }, - { "New Caledonia", "268,767", "14.5", nullptr }, - { "Fiji", "898,76", "46.4", nullptr }, - { "Hawaii", "1,428,557", "82.6", nullptr }, - { "Vanuatu", "270,402", "19.7", nullptr }, - { "French Polynesia", "280,208", "76.0", nullptr }, - { "Samoa", "192,342", "68.0", nullptr }, - { "Kiribati", "110,136", "152.0", nullptr }, - { nullptr, nullptr, nullptr, nullptr } -}; // constructors and destructor //---------------------------------------------------------------------- @@ -351,30 +233,28 @@ Treeview::Treeview (finalcut::FWidget* parent) listview.setTreeView(); // Populate FListView with a list of items - static TreeItem continent_list[] = + const std::vector continent_list { { "Africa", "944,000,000", "31.2", africa }, { "Asia", "4,010,000,000", "90.3", asia }, { "Europe", "733,000,000", "69.9", europe }, { "North America", "523,000,000", "21", north_america }, { "South America", "381,000,000", "21.4", south_america }, - { "Antarctica", "1000", "0", nullptr }, + { "Antarctica", "1000", "0", {} }, { "Australia/Oceania", "34,000,000", "4", oceania } }; for (const auto& continent : continent_list) { - const TreeItem* country_list = continent.child_element; finalcut::FStringList continent_line ( continent.begin() , continent.end() ); auto iter = listview.insert (continent_line); - while ( country_list && country_list->name ) + for (const auto& country : continent.child_element) { - finalcut::FStringList country_line ( country_list->begin() - , country_list->end() ); + finalcut::FStringList country_line ( country.begin() + , country.end() ); listview.insert (country_line, iter); - country_list++; } } @@ -395,8 +275,149 @@ Treeview::Treeview (finalcut::FWidget* parent) } //---------------------------------------------------------------------- -Treeview::~Treeview() // destructor -{ } +auto Treeview::initAfrica() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Algeria", "40,400,000", "15.9", {} }, + { "Angola", "25,789,024", "20.69", {} }, + { "Botswana", "2,250,260", "3.7", {} }, + { "Cameroon", "22,534,532", "39.7", {} }, + { "Chad", "13,670,084", "8.6", {} }, + { "Egypt", "94,666,000", "87", {} }, + { "Ethiopia", "102,374,044", "92.7", {} }, + { "Ivory Coast", "23,740,424", "63.9", {} }, + { "Libya", "6,541,948", "3.55", {} }, + { "Madagascar", "24,430,325", "35.2", {} }, + { "Mali", "14,517,176", "11.7", {} }, + { "Mauritania", "4,301,018", "3.4", {} }, + { "Mozambique", "24,692,144", "28.7", {} }, + { "Namibia", "2,113,077", "2.54", {} }, + { "Niger", "20,672,987", "12.1", {} }, + { "Nigeria", "185,989,640", "197.2", {} }, + { "Somalia", "14,317,996", "19.31", {} }, + { "South Africa", "54,956,900", "42.4", {} }, + { "South Sudan", "12,340,000", "13.33", {} }, + { "Sudan", "39,578,828", "21.3", {} }, + { "Tanzania", "51,820,00", "47.5", {} }, + { "Zambia", "16,212,000", "17.2", {} } + }; + return list; +} + +//---------------------------------------------------------------------- +auto Treeview::initAsia() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Afghanistan", "34,656,032", "49.88", {} }, + { "China", "1,403,500,365", "145.0", {} }, + { "India", "1,324,171,354", "393.9", {} }, + { "Indonesia", "261,115,456", "124.66", {} }, + { "Iran", "80,829,192", "48.0", {} }, + { "Iraq", "37,202,572", "82.7", {} }, + { "Japan", "126,740,000", "336.0", {} }, + { "Kazakhstan", "17,987,736", "6.49", {} }, + { "Mongolia", "3,081,677", "1.97", {} }, + { "Myanmar", "51,486,253", "76.0", {} }, + { "Pakistan", "207,774,520", "244.4", {} }, + { "Russia", "144,463,451", "8.4", {} }, + { "Saudi Arabia", "33,000,000", "15.0", {} }, + { "Thailand", "68,863,514", "132.1", {} }, + { "Turkey", "79,814,871", "102.0", {} }, + { "Turkmenistan", "5,662,544", "10.5", {} }, + { "Uzbekistan", "32,979,000", "70.5", {} }, + { "Vietnam", "94,569,072", "276.03", {} }, + { "Yemen", "27,584,213", "44.7", {} } + }; + return list; +} + +//---------------------------------------------------------------------- +auto Treeview::initEurope() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Austria", "8,794,267", "104.0", {} }, + { "Belarus", "9,498,700", "45.8", {} }, + { "Bulgaria", "7,101,859", "64.9", {} }, + { "Czech Republic", "10,610,947", "134.0", {} }, + { "Finland", "5,506,312", "16.0", {} }, + { "France", "66,991,000", "103.0", {} }, + { "Germany", "82,175,700", "227.0", {} }, + { "Greece", "11,183,716", "82.0", {} }, + { "Hungary", "9,797,561", "105.3", {} }, + { "Iceland", "332,529", "3.2", {} }, + { "Italy", "60,589,445", "201.3", {} }, + { "Norway", "5,267,146", "15.8", {} }, + { "Poland", "38,634,007", "123.0", {} }, + { "Portugal", "10,309,573", "115.0", {} }, + { "Romania", "19,638,000", "84.4", {} }, + { "Serbia", "7,058,322", "91.1", {} }, + { "Spain", "46,468,102", "92.0", {} }, + { "Sweden", "10,065,389", "22.0", {} }, + { "United Kingdom", "65,648,000", "270.7", {} } + }; + return list; +} + +//---------------------------------------------------------------------- +auto Treeview::initNorthAmerica() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Canada", "35,151,728", "3.92", {} }, + { "Cuba", "11,239,224", "102.3", {} }, + { "Greenland", "56,483", "0.028", {} }, + { "Guatemala", "16,582,469", "129.0", {} }, + { "Honduras", "9,112,867", "64.0", {} }, + { "Mexico", "119,530,753", "61.0", {} }, + { "Nicaragua", "6,167,237", "51.0", {} }, + { "USA", "325,365,189", "35.0", {} } + }; + return list; +} + +//---------------------------------------------------------------------- +auto Treeview::initSouthAmerica() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Argentina", "43,847,430", "14.4", {} }, + { "Bolivia", "11,410,651", "10.4", {} }, + { "Brazil", "208,064,000", "24.35", {} }, + { "Chile", "18,006,407", "24.0", {} }, + { "Colombia", "49,364,592", "40.74", {} }, + { "Ecuador", "16,385,068", "58.95", {} }, + { "Guyana", "773,303", "3.502", {} }, + { "Paraguay", "6,725,308", "17.2", {} }, + { "Peru", "31,826,018", "23.0", {} }, + { "Venezuela", "31,568,179", "33.75", {} } + }; + return list; +} + +//---------------------------------------------------------------------- +auto Treeview::initOceania() -> std::initializer_list +{ + static const auto list = std::initializer_list + { + { "Australia", "24,675,900", "3.2", {} }, + { "Papua New Guinea", "7,059,653", "15.0", {} }, + { "Papua", "3,486,432", "11.0", {} }, + { "New Zealand", "4,823,090", "17.5", {} }, + { "West Papua", "877,437", "6.3", {} }, + { "Solomon Islands", "599,419", "18.1", {} }, + { "New Caledonia", "268,767", "14.5", {} }, + { "Fiji", "898,76", "46.4", {} }, + { "Hawaii", "1,428,557", "82.6", {} }, + { "Vanuatu", "270,402", "19.7", {} }, + { "French Polynesia", "280,208", "76.0", {} }, + { "Samoa", "192,342", "68.0", {} }, + { "Kiribati", "110,136", "152.0", {} } + }; + return list; +} //---------------------------------------------------------------------- void Treeview::adjustSize() diff --git a/examples/ui.cpp b/examples/ui.cpp index 94f453b3..5f7d128a 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -196,7 +196,7 @@ class TextWindow final : public finalcut::FDialog TextWindow (const TextWindow&) = delete; // Destructor - ~TextWindow() override; + ~TextWindow() override = default; // Disable copy assignment operator (=) TextWindow& operator = (const TextWindow&) = delete; @@ -230,10 +230,6 @@ TextWindow::TextWindow (finalcut::FWidget* parent) scrolltext.deleteRange(3, 4); } -//---------------------------------------------------------------------- -TextWindow::~TextWindow() // destructor -{ } - //---------------------------------------------------------------------- void TextWindow::append (const finalcut::FString& str) { @@ -262,7 +258,7 @@ class MyDialog final : public finalcut::FDialog MyDialog (const MyDialog&) = delete; // Destructor - ~MyDialog() override; + ~MyDialog() override = default; // Disable copy assignment operator (=) MyDialog& operator = (const MyDialog&) = delete; @@ -375,10 +371,6 @@ MyDialog::MyDialog (finalcut::FWidget* parent) init(); } -//---------------------------------------------------------------------- -MyDialog::~MyDialog() // destructor -{ } - //---------------------------------------------------------------------- void MyDialog::init() { diff --git a/examples/watch.cpp b/examples/watch.cpp index 89adc220..130c9450 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -41,7 +41,7 @@ class Watch final : public finalcut::FDialog Watch (const Watch&) = delete; // Destructor - ~Watch() override; + ~Watch() override = default; // Disable copy assignment operator (=) Watch& operator = (const Watch&) = delete; @@ -118,10 +118,6 @@ Watch::Watch (FWidget* parent) ); } -//---------------------------------------------------------------------- -Watch::~Watch() -{ } - //---------------------------------------------------------------------- void Watch::printTime() { diff --git a/examples/windows.cpp b/examples/windows.cpp index 3276ac72..5edf2a5f 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -44,7 +44,7 @@ class SmallWindow final : public finalcut::FDialog SmallWindow (const SmallWindow&) = delete; // Destructor - ~SmallWindow() override; + ~SmallWindow() override = default; // Disable copy assignment operator (=) SmallWindow& operator = (const SmallWindow&) = delete; @@ -107,10 +107,6 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent) bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3}); } -//---------------------------------------------------------------------- -SmallWindow::~SmallWindow() -{ } - //---------------------------------------------------------------------- void SmallWindow::adjustSize() { @@ -177,15 +173,22 @@ class Window final : public finalcut::FDialog Window& operator = (const Window&) = delete; private: - struct win_data + struct WinData { // Constructor - win_data() = default; - // Disable copy constructor - win_data (const win_data&) = delete; + WinData() = default; - // Disable copy assignment operator (=) - win_data& operator = (const win_data&) = delete; + // copy constructor + WinData (const WinData&) = default; + + // move constructor + WinData (WinData&&) noexcept = default; + + // copy assignment operator (=) + WinData& operator = (const WinData&) = default; + + // move assignment operator (=) + WinData& operator = (WinData&&) noexcept = default; // Data members bool is_open{false}; @@ -216,10 +219,10 @@ class Window final : public finalcut::FDialog void cb_closeWindows(); void cb_next(); void cb_previous(); - void cb_destroyWindow (win_data*) const; + void cb_destroyWindow (WinData&) const; // Data members - std::vector windows{}; + std::vector windows{}; finalcut::FString drop_down_symbol{fc::BlackDownPointingTriangle}; finalcut::FMenuBar Menubar{this}; finalcut::FMenu File{"&File", &Menubar}; @@ -262,9 +265,9 @@ Window::Window (finalcut::FWidget* parent) // Generate data vector for the windows for (uInt n{1}; n < 7; n++) { - auto win_dat = new win_data; - win_dat->title.sprintf("Window %1u", n); - windows.push_back(win_dat); + WinData win_dat; + win_dat.title.sprintf("Window %1u", n); + windows.emplace_back(std::move(win_dat)); } } @@ -275,13 +278,12 @@ Window::~Window() while ( iter != windows.end() ) { - auto win_dat = *iter; + auto& win_dat = *iter; // Remove all callbacks before Window::cb_destroyWindow() will be called - if ( win_dat->is_open && win_dat->dgl ) - win_dat->dgl->delCallback(); + if ( win_dat.is_open && win_dat.dgl ) + win_dat.dgl->delCallback(); - delete win_dat; iter = windows.erase(iter); } } @@ -366,12 +368,12 @@ void Window::adjustSize() while ( iter != windows.end() ) { - if ( (*iter)->is_open ) + if ( (*iter).is_open ) { const auto n = int(std::distance(first, iter)); const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; const int y = dy + 11 + int(n / 3) * 3; - (*iter)->dgl->setPos (FPoint{x, y}); + (*iter).dgl->setPos (FPoint{x, y}); } ++iter; @@ -459,13 +461,13 @@ void Window::cb_createWindows() while ( iter != windows.end() ) { - if ( ! (*iter)->is_open ) + if ( ! (*iter).is_open ) { - auto win_dat = *iter; + auto& win_dat = *iter; auto win = new SmallWindow(this); - win_dat->dgl = win; - win_dat->is_open = true; - win->setText(win_dat->title); + win_dat.dgl = win; + win_dat.is_open = true; + win->setText(win_dat.title); const auto n = int(std::distance(first, iter)); const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; const int y = dy + 11 + int(n / 3) * 3; @@ -478,7 +480,7 @@ void Window::cb_createWindows() ( "destroy", this, &Window::cb_destroyWindow, - win_dat + std::ref(win_dat) ); } @@ -551,13 +553,10 @@ void Window::cb_previous() } //---------------------------------------------------------------------- -void Window::cb_destroyWindow (win_data* win_dat) const +void Window::cb_destroyWindow (WinData& win_dat) const { - if ( win_dat ) - { - win_dat->is_open = false; - win_dat->dgl = nullptr; - } + win_dat.is_open = false; + win_dat.dgl = nullptr; } diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 41317b3b..9bd22d62 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -374,7 +374,7 @@ void FButtonGroup::drawLabel() else FWidget::setPrintPos (FPoint{0, 1}); - drawText (label_text, hotkeypos); + drawText (std::move(label_text), hotkeypos); setViewportPrint(); } @@ -397,7 +397,7 @@ void FButtonGroup::init() } //---------------------------------------------------------------------- -void FButtonGroup::drawText ( const FString& label_text +void FButtonGroup::drawText ( FString&& label_text , std::size_t hotkeypos ) { const auto& wc = getColorTheme(); diff --git a/src/fcheckbox.cpp b/src/fcheckbox.cpp index f06f3d07..4f464505 100644 --- a/src/fcheckbox.cpp +++ b/src/fcheckbox.cpp @@ -46,9 +46,7 @@ FCheckBox::FCheckBox (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FCheckBox::~FCheckBox() // destructor -{ } - +FCheckBox::~FCheckBox() noexcept = default; // destructor // private methods of FCheckBox //---------------------------------------------------------------------- diff --git a/src/fcheckmenuitem.cpp b/src/fcheckmenuitem.cpp index 4c77f837..89ff8061 100644 --- a/src/fcheckmenuitem.cpp +++ b/src/fcheckmenuitem.cpp @@ -47,8 +47,7 @@ FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FCheckMenuItem::~FCheckMenuItem() // destructor -{ } +FCheckMenuItem::~FCheckMenuItem() noexcept = default; // destructor // private methods of FCheckMenuItem diff --git a/src/fcombobox.cpp b/src/fcombobox.cpp index be66c27d..e7ec8cf0 100644 --- a/src/fcombobox.cpp +++ b/src/fcombobox.cpp @@ -177,9 +177,7 @@ FComboBox::FComboBox (FWidget* parent) } //---------------------------------------------------------------------- -FComboBox::~FComboBox() // destructor -{ } - +FComboBox::~FComboBox() noexcept = default; // destructor // public methods of FComboBox //---------------------------------------------------------------------- diff --git a/src/fdialoglistmenu.cpp b/src/fdialoglistmenu.cpp index a301b65b..064fa246 100644 --- a/src/fdialoglistmenu.cpp +++ b/src/fdialoglistmenu.cpp @@ -46,8 +46,7 @@ FDialogListMenu::FDialogListMenu (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FDialogListMenu::~FDialogListMenu() -{ } +FDialogListMenu::~FDialogListMenu() noexcept = default; // destructor // private methods of FMenu diff --git a/src/fevent.cpp b/src/fevent.cpp index e3885c76..45888095 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -56,10 +56,6 @@ FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor , k{key_num} { } -//---------------------------------------------------------------------- -FKeyEvent::~FKeyEvent() // destructor -{ } - //---------------------------------------------------------------------- FKey FKeyEvent::key() const { return k; } @@ -98,10 +94,6 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor : FMouseEvent{ev_type, pos, FPoint{}, button} { } -//---------------------------------------------------------------------- -FMouseEvent::~FMouseEvent() // destructor -{ } - //---------------------------------------------------------------------- const FPoint& FMouseEvent::getPos() const { return p; } @@ -152,10 +144,6 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor : FWheelEvent{ev_type, pos, FPoint{}, wheel} { } -//---------------------------------------------------------------------- -FWheelEvent::~FWheelEvent() // destructor -{ } - //---------------------------------------------------------------------- const FPoint& FWheelEvent::getPos() const { return p; } @@ -193,10 +181,6 @@ FFocusEvent::FFocusEvent (fc::events ev_type) // constructor : FEvent{ev_type} { } -//---------------------------------------------------------------------- -FFocusEvent::~FFocusEvent() // destructor -{ } - //---------------------------------------------------------------------- bool FFocusEvent::gotFocus() const { @@ -239,10 +223,6 @@ FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor , focus_widget{focused} { } -//---------------------------------------------------------------------- -FAccelEvent::~FAccelEvent() // destructor -{ } - //---------------------------------------------------------------------- FWidget* FAccelEvent::focusedWidget() const { return focus_widget; } @@ -268,10 +248,6 @@ FResizeEvent::FResizeEvent (fc::events ev_type) // constructor : FEvent{ev_type} { } -//---------------------------------------------------------------------- -FResizeEvent::~FResizeEvent() // destructor -{ } - //---------------------------------------------------------------------- bool FResizeEvent::isAccepted() const { return accpt; } @@ -293,10 +269,6 @@ FShowEvent::FShowEvent (fc::events ev_type) // constructor : FEvent{ev_type} { } -//---------------------------------------------------------------------- -FShowEvent::~FShowEvent() // destructor -{ } - //---------------------------------------------------------------------- // class FHideEvent @@ -306,10 +278,6 @@ FHideEvent::FHideEvent (fc::events ev_type) // constructor : FEvent{ev_type} { } -//---------------------------------------------------------------------- -FHideEvent::~FHideEvent() // destructor -{ } - //---------------------------------------------------------------------- // class FCloseEvent @@ -319,10 +287,6 @@ FCloseEvent::FCloseEvent (fc::events ev_type) // constructor : FEvent{ev_type} { } -//---------------------------------------------------------------------- -FCloseEvent::~FCloseEvent() // destructor -{ } - //---------------------------------------------------------------------- bool FCloseEvent::isAccepted() const { return accpt; } @@ -345,10 +309,6 @@ FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor , id{timer_id} { } -//---------------------------------------------------------------------- -FTimerEvent::~FTimerEvent() // destructor -{ } - //---------------------------------------------------------------------- int FTimerEvent::getTimerId() const { return id; } @@ -363,10 +323,6 @@ FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor , uid{user_event_id} { } -//---------------------------------------------------------------------- -FUserEvent::~FUserEvent() // destructor -{ } - //---------------------------------------------------------------------- int FUserEvent::getUserId() const { return uid; } diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index e6e29016..5e8c0319 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -81,9 +81,6 @@ FKeyboard::FKeyboard() term_detection = FTerm::getFTermDetection(); } -//---------------------------------------------------------------------- -FKeyboard::~FKeyboard() // destructor -{ } // public methods of FKeyboard //---------------------------------------------------------------------- diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 496abec2..bfc278c6 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -39,10 +39,6 @@ namespace finalcut //---------------------------------------------------------------------- // constructor and destructor -//---------------------------------------------------------------------- -FListBoxItem::FListBoxItem() -{ } - //---------------------------------------------------------------------- FListBoxItem::FListBoxItem (const FListBoxItem& item) : text{item.text} @@ -52,8 +48,8 @@ FListBoxItem::FListBoxItem (const FListBoxItem& item) { } //---------------------------------------------------------------------- -FListBoxItem::~FListBoxItem() // destructor -{ } +FListBoxItem::~FListBoxItem() noexcept = default; // destructor + // public methods of FListBoxItem //---------------------------------------------------------------------- diff --git a/src/flistview.cpp b/src/flistview.cpp index 7490367f..aeb99961 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -477,52 +477,12 @@ void FListViewItem::resetVisibleLineCounter() //---------------------------------------------------------------------- // constructor and destructor -//---------------------------------------------------------------------- -FListViewIterator::FListViewIterator() -{ } - //---------------------------------------------------------------------- FListViewIterator::FListViewIterator (iterator iter) : node{iter} { } -//---------------------------------------------------------------------- -FListViewIterator::~FListViewIterator() // destructor -{ } - -//---------------------------------------------------------------------- -FListViewIterator::FListViewIterator (const FListViewIterator& i) - : iter_path{i.iter_path} // copy constructor - , node{i.node} - , position{i.position} -{ } - -//---------------------------------------------------------------------- -FListViewIterator::FListViewIterator (FListViewIterator&& i) noexcept - : iter_path{std::move(i.iter_path)} // move constructor - , node{std::move(i.node)} - , position{std::move(i.position)} -{ } - // FListViewIterator operators -//---------------------------------------------------------------------- -FListViewIterator& FListViewIterator::operator = (const FListViewIterator& i) -{ - iter_path = i.iter_path; - node = i.node; - position = i.position; - return *this; -} - -//---------------------------------------------------------------------- -FListViewIterator& FListViewIterator::operator = (FListViewIterator&& i) noexcept -{ - iter_path = std::move(i.iter_path); - node = std::move(i.node); - position = std::move(i.position); - return *this; -} - //---------------------------------------------------------------------- FListViewIterator& FListViewIterator::operator ++ () // prefix { @@ -554,25 +514,19 @@ FListViewIterator FListViewIterator::operator -- (int) // postfix } //---------------------------------------------------------------------- -FListViewIterator& FListViewIterator::operator += (volatile int n) +FListViewIterator& FListViewIterator::operator += (int n) { - while ( n > 0 ) - { + for (int i = n; i > 0 ; i--) nextElement(node); - n--; - } return *this; } //---------------------------------------------------------------------- -FListViewIterator& FListViewIterator::operator -= (volatile int n) +FListViewIterator& FListViewIterator::operator -= (int n) { - while ( n > 0 ) - { + for (int i = n; i > 0 ; i--) prevElement(node); - n--; - } return *this; } diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index d707e89f..16cd26b4 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -92,10 +92,7 @@ FMessageBox::FMessageBox ( const FString& caption } //---------------------------------------------------------------------- -FMessageBox::~FMessageBox() // destructor -{ - deallocation(); -} +FMessageBox::~FMessageBox() noexcept = default; // destructor // public methods of FMessageBox @@ -108,10 +105,6 @@ FMessageBox& FMessageBox::operator = (const FMessageBox& mbox) } else { - for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++) - if ( button[n] ) - delete button[n]; - if ( mbox.getParentWidget() ) mbox.getParentWidget()->addChild (this); @@ -238,7 +231,7 @@ inline void FMessageBox::allocation() { try { - button[0] = new FButton (this); + button[0].reset(new FButton (this)); button[0]->setText(button_text[button_digit[0]]); button[0]->setPos(FPoint{3, int(getHeight()) - 4}, false); button[0]->setWidth(1, false); @@ -247,7 +240,7 @@ inline void FMessageBox::allocation() if ( button_digit[1] > FMessageBox::Reject ) { - button[1] = new FButton(this); + button[1].reset(new FButton(this)); button[1]->setText(button_text[button_digit[1]]); button[1]->setPos(FPoint{17, int(getHeight()) - 4}, false); button[1]->setWidth(0, false); @@ -256,7 +249,7 @@ inline void FMessageBox::allocation() if ( button_digit[2] > FMessageBox::Reject ) { - button[2] = new FButton(this); + button[2].reset(new FButton(this)); button[2]->setText(button_text[button_digit[2]]); button[2]->setPos(FPoint{32, int(getHeight()) - 4}, false); button[2]->setWidth(0, false); @@ -270,14 +263,6 @@ inline void FMessageBox::allocation() } } -//---------------------------------------------------------------------- -inline void FMessageBox::deallocation() -{ - for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++) - if ( button[n] ) - delete button[n]; -} - //---------------------------------------------------------------------- inline void FMessageBox::initCallbacks() { @@ -391,7 +376,7 @@ void FMessageBox::draw() //---------------------------------------------------------------------- void FMessageBox::resizeButtons() const { - std::array len{}; + std::array len{}; std::size_t max_size{}; for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++) diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 5db6a52c..6bd4bd6b 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -313,10 +313,6 @@ FMouseGPM::FMouseGPM() gpm_ev.x = -1; } -//---------------------------------------------------------------------- -FMouseGPM::~FMouseGPM() // destructor -{ } - // public methods of FMouseX11 //---------------------------------------------------------------------- @@ -1217,27 +1213,25 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time) FMouseControl::FMouseControl() { #ifdef F_HAVE_LIBGPM - mouse_protocol[FMouse::gpm] = FMouse::createMouseObject(); + if ( FTerm::isLinuxTerm() ) + mouse_protocol[FMouse::gpm].reset(FMouse::createMouseObject()); #endif - mouse_protocol[FMouse::x11] = FMouse::createMouseObject(); - mouse_protocol[FMouse::sgr] = FMouse::createMouseObject(); - mouse_protocol[FMouse::urxvt] = FMouse::createMouseObject(); + mouse_protocol[FMouse::x11].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::sgr].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::urxvt].reset(FMouse::createMouseObject()); } //---------------------------------------------------------------------- -FMouseControl::~FMouseControl() // destructor -{ - for (auto&& m : mouse_protocol) - delete m.second; -} +FMouseControl::~FMouseControl() = default; // destructor // public methods of FMouseControl //---------------------------------------------------------------------- const FPoint& FMouseControl::getPos() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); + const auto& mouse_object = mouse_protocol[mtype].get(); if ( mouse_object ) return mouse_object->getPos(); @@ -1248,17 +1242,23 @@ const FPoint& FMouseControl::getPos() //---------------------------------------------------------------------- void FMouseControl::clearEvent() { - FMouse* mouse_object; + FMouse::mouse_type mtype; - while ( (mouse_object = getMouseWithEvent()) != nullptr ) - mouse_object->clearEvent(); + do + { + mtype = getMouseWithEvent(); + + if ( mouse_protocol[mtype] ) + mouse_protocol[mtype]->clearEvent(); + } + while ( mtype != FMouse::none ); } //---------------------------------------------------------------------- #ifdef F_HAVE_LIBGPM void FMouseControl::setStdinNo (int file_descriptor) { - auto mouse = mouse_protocol[FMouse::gpm]; + auto mouse = mouse_protocol[FMouse::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1304,7 +1304,8 @@ void FMouseControl::useXtermMouse (bool enable) //---------------------------------------------------------------------- bool FMouseControl::hasData() { - const auto& mouse_object = getMouseWithData(); + auto mtype = getMouseWithData(); + const auto& mouse_object = mouse_protocol[mtype].get(); if ( mouse_object ) // with data return true; @@ -1315,9 +1316,9 @@ bool FMouseControl::hasData() //---------------------------------------------------------------------- bool FMouseControl::hasEvent() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) // with event + if ( mouse_protocol[mtype] ) // with event return true; return false; @@ -1326,10 +1327,10 @@ bool FMouseControl::hasEvent() //---------------------------------------------------------------------- bool FMouseControl::isLeftButtonPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isLeftButtonPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isLeftButtonPressed(); return false; } @@ -1337,10 +1338,10 @@ bool FMouseControl::isLeftButtonPressed() //---------------------------------------------------------------------- bool FMouseControl::isLeftButtonReleased() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isLeftButtonReleased(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isLeftButtonReleased(); return false; } @@ -1348,10 +1349,10 @@ bool FMouseControl::isLeftButtonReleased() //---------------------------------------------------------------------- bool FMouseControl::isLeftButtonDoubleClick() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isLeftButtonDoubleClick(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isLeftButtonDoubleClick(); return false; } @@ -1359,10 +1360,10 @@ bool FMouseControl::isLeftButtonDoubleClick() //---------------------------------------------------------------------- bool FMouseControl::isRightButtonPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isRightButtonPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isRightButtonPressed(); return false; } @@ -1370,10 +1371,10 @@ bool FMouseControl::isRightButtonPressed() //---------------------------------------------------------------------- bool FMouseControl::isRightButtonReleased() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isRightButtonReleased(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isRightButtonReleased(); return false; } @@ -1381,10 +1382,10 @@ bool FMouseControl::isRightButtonReleased() //---------------------------------------------------------------------- bool FMouseControl::isMiddleButtonPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isMiddleButtonPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isMiddleButtonPressed(); return false; } @@ -1392,10 +1393,10 @@ bool FMouseControl::isMiddleButtonPressed() //---------------------------------------------------------------------- bool FMouseControl::isMiddleButtonReleased() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isMiddleButtonReleased(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isMiddleButtonReleased(); return false; } @@ -1403,10 +1404,10 @@ bool FMouseControl::isMiddleButtonReleased() //---------------------------------------------------------------------- bool FMouseControl::isShiftKeyPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isShiftKeyPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isShiftKeyPressed(); return false; } @@ -1414,10 +1415,10 @@ bool FMouseControl::isShiftKeyPressed() //---------------------------------------------------------------------- bool FMouseControl::isControlKeyPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isControlKeyPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isControlKeyPressed(); return false; } @@ -1425,10 +1426,10 @@ bool FMouseControl::isControlKeyPressed() //---------------------------------------------------------------------- bool FMouseControl::isMetaKeyPressed() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isMetaKeyPressed(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isMetaKeyPressed(); return false; } @@ -1436,10 +1437,10 @@ bool FMouseControl::isMetaKeyPressed() //---------------------------------------------------------------------- bool FMouseControl::isWheelUp() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isWheelUp(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isWheelUp(); return false; } @@ -1447,10 +1448,10 @@ bool FMouseControl::isWheelUp() //---------------------------------------------------------------------- bool FMouseControl::isWheelDown() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isWheelDown(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isWheelDown(); return false; } @@ -1458,10 +1459,10 @@ bool FMouseControl::isWheelDown() //---------------------------------------------------------------------- bool FMouseControl::isMoved() { - const auto& mouse_object = getMouseWithEvent(); + auto mtype = getMouseWithEvent(); - if ( mouse_object ) - return mouse_object->isMoved(); + if ( mouse_protocol[mtype] ) + return mouse_protocol[mtype]->isMoved(); return false; } @@ -1486,7 +1487,7 @@ bool FMouseControl::isGpmMouseEnabled() if ( mouse_protocol.empty() ) return false; - const auto& mouse = mouse_protocol[FMouse::gpm]; + const auto& mouse = mouse_protocol[FMouse::gpm].get(); const auto& gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1507,7 +1508,7 @@ void FMouseControl::enable() #ifdef F_HAVE_LIBGPM if ( use_gpm_mouse ) { - auto mouse = mouse_protocol[FMouse::gpm]; + auto mouse = mouse_protocol[FMouse::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1525,7 +1526,7 @@ void FMouseControl::disable() #ifdef F_HAVE_LIBGPM if ( use_gpm_mouse ) { - auto mouse = mouse_protocol[FMouse::gpm]; + auto mouse = mouse_protocol[FMouse::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1541,7 +1542,7 @@ void FMouseControl::disable() void FMouseControl::setRawData ( FMouse::mouse_type mt , FKeyboard::keybuffer& fifo_buf) { - auto mouse = mouse_protocol[mt]; + auto mouse = mouse_protocol[mt].get(); if ( mouse ) mouse->setRawData (fifo_buf); @@ -1569,7 +1570,9 @@ void FMouseControl::processQueuedInput() //---------------------------------------------------------------------- void FMouseControl::processEvent (struct timeval* time) { - auto mouse_object = getMouseWithData(); + auto mtype = getMouseWithData(); + auto mouse_object = mouse_protocol[mtype].get(); + // Clear all old mouse events clearEvent(); @@ -1588,7 +1591,7 @@ bool FMouseControl::getGpmKeyPressed (bool pending) if ( mouse_protocol.empty() ) return false; - auto mouse = mouse_protocol[FMouse::gpm]; + auto mouse = mouse_protocol[FMouse::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1610,7 +1613,7 @@ void FMouseControl::drawPointer() if ( mouse_protocol.empty() ) return; - auto mouse = mouse_protocol[FMouse::gpm]; + auto mouse = mouse_protocol[FMouse::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1624,7 +1627,7 @@ void FMouseControl::drawPointer() // private methods of FMouseControl //---------------------------------------------------------------------- -FMouse* FMouseControl::getMouseWithData() +FMouse::mouse_type FMouseControl::getMouseWithData() { const auto& iter = \ std::find_if ( std::begin(mouse_protocol) @@ -1636,11 +1639,11 @@ FMouse* FMouseControl::getMouseWithData() } ); - return ( iter != mouse_protocol.end() ) ? iter->second : nullptr; + return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::none; } //---------------------------------------------------------------------- -FMouse* FMouseControl::getMouseWithEvent() +FMouse::mouse_type FMouseControl::getMouseWithEvent() { const auto& iter = \ std::find_if ( std::begin(mouse_protocol) @@ -1652,7 +1655,7 @@ FMouse* FMouseControl::getMouseWithEvent() } ); - return ( iter != mouse_protocol.end() ) ? iter->second : nullptr; + return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::none; } //---------------------------------------------------------------------- diff --git a/src/fobject.cpp b/src/fobject.cpp index c29ab4e9..db0a8943 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -32,7 +32,6 @@ namespace finalcut // static class attributes bool FObject::timer_modify_lock; -FObject::FTimerList* FObject::timer_list{nullptr}; const FString* fc::emptyFString::empty_string{nullptr}; @@ -45,27 +44,10 @@ const FString* fc::emptyFString::empty_string{nullptr}; FObject::FObject (FObject* parent) : parent_obj{parent} { - if ( parent ) // add object to parent - { + if ( parent ) // add object to parent parent->addChild(this); - } else - { timer_modify_lock = false; - - if ( ! timer_list ) - { - try - { - timer_list = new FTimerList; - } - catch (const std::bad_alloc&) - { - badAllocOutput ("FTimerList"); - return; - } - } - } } //---------------------------------------------------------------------- @@ -73,12 +55,6 @@ FObject::~FObject() // destructor { delOwnTimers(); // Delete all timers of this object - if ( ! has_parent && timer_list ) - { - delete timer_list; - timer_list = nullptr; - } - if ( ! has_parent && ! fc::emptyFString::isNull() ) fc::emptyFString::clear(); @@ -268,6 +244,7 @@ int FObject::addTimer (int interval) timeval currentTime{}; int id{1}; timer_modify_lock = true; + auto& timer_list = globalTimerList(); // find an unused timer id if ( ! timer_list->empty() ) @@ -317,6 +294,7 @@ bool FObject::delTimer (int id) const return false; timer_modify_lock = true; + auto& timer_list = globalTimerList(); auto iter = timer_list->begin(); const auto& last = timer_list->end(); @@ -339,6 +317,8 @@ bool FObject::delOwnTimers() const { // Deletes all timers of this object + auto& timer_list = globalTimerList(); + if ( ! timer_list ) return false; @@ -365,6 +345,8 @@ bool FObject::delAllTimers() const { // Deletes all timers of all objects + auto& timer_list = globalTimerList(); + if ( ! timer_list ) return false; @@ -405,6 +387,8 @@ uInt FObject::processTimerEvent() if ( isTimerInUpdating() ) return 0; + auto& timer_list = globalTimerList(); + if ( ! timer_list ) return 0; @@ -440,4 +424,11 @@ void FObject::performTimerAction (FObject*, FEvent*) // to process the passed object and timer event } +//---------------------------------------------------------------------- +FObject::FTimerListPtr& FObject::globalTimerList() +{ + static const auto& timer_list = make_unique(); + return timer_list; +} + } // namespace finalcut diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index caf4d09d..43ad3264 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -47,10 +47,6 @@ FOptiAttr::FOptiAttr() reset_byte_mask.attr.bit.printed = true; } -//---------------------------------------------------------------------- -FOptiAttr::~FOptiAttr() // destructor -{ } - // public methods of FOptiAttr //---------------------------------------------------------------------- diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 38e05c20..54715e79 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -52,10 +52,6 @@ FOptiMove::FOptiMove (int baud) set_cursor_down ("\n"); } -//---------------------------------------------------------------------- -FOptiMove::~FOptiMove() // destructor -{ } - // public methods of FOptiMove //---------------------------------------------------------------------- @@ -608,7 +604,7 @@ int FOptiMove::capDurationToLength (int duration) const //---------------------------------------------------------------------- int FOptiMove::repeatedAppend ( const Capability& o - , volatile int count + , int count , char* dst ) const { const std::size_t src_len = std::strlen(o.cap); @@ -623,8 +619,9 @@ int FOptiMove::repeatedAppend ( const Capability& o { dst += dst_len; std::size_t free = BUF_SIZE - dst_len - 2; + int cnt = count; - while ( count-- > 0 ) + while ( cnt-- > 0 ) { std::strncpy (dst, o.cap, free); dst += src_len; diff --git a/src/fpoint.cpp b/src/fpoint.cpp index 6c6f8efc..f4603e40 100644 --- a/src/fpoint.cpp +++ b/src/fpoint.cpp @@ -31,26 +31,7 @@ namespace finalcut // class FPoint //---------------------------------------------------------------------- -FPoint::~FPoint() // destructor -{ } - // public methods of FPoint -//---------------------------------------------------------------------- -FPoint& FPoint::operator = (const FPoint& p) -{ - xpos = p.xpos; - ypos = p.ypos; - return *this; -} - -//---------------------------------------------------------------------- -FPoint& FPoint::operator = (FPoint&& p) noexcept -{ - xpos = std::move(p.xpos); - ypos = std::move(p.ypos); - return *this; -} - //---------------------------------------------------------------------- FPoint& FPoint::operator += (const FPoint& p) { diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 5c4060ef..867b8c88 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -42,8 +42,7 @@ FProgressbar::FProgressbar(FWidget* parent) } //---------------------------------------------------------------------- -FProgressbar::~FProgressbar() // destructor -{ } +FProgressbar::~FProgressbar() noexcept = default; // destructor // public methods of FProgressbar diff --git a/src/fradiobutton.cpp b/src/fradiobutton.cpp index 8c8e1a16..7ea88571 100644 --- a/src/fradiobutton.cpp +++ b/src/fradiobutton.cpp @@ -46,8 +46,7 @@ FRadioButton::FRadioButton (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FRadioButton::~FRadioButton() // destructor -{ } +FRadioButton::~FRadioButton() noexcept = default; // destructor // private methods of FRadioButton diff --git a/src/fradiomenuitem.cpp b/src/fradiomenuitem.cpp index 8b882c8b..12bedf5f 100644 --- a/src/fradiomenuitem.cpp +++ b/src/fradiomenuitem.cpp @@ -49,8 +49,7 @@ FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FRadioMenuItem::~FRadioMenuItem() // destructor -{ } +FRadioMenuItem::~FRadioMenuItem() noexcept = default; // destructor // private methods of FRadioMenuItem diff --git a/src/frect.cpp b/src/frect.cpp index e62c8c40..f02337f7 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -51,32 +51,8 @@ FRect::FRect (const FPoint& p1, const FPoint& p2) , Y2{p2.getY()} { } -//---------------------------------------------------------------------- -FRect::~FRect() // destructor -{ } - // public methods of FRect -//---------------------------------------------------------------------- -FRect& FRect::operator = (const FRect& r) -{ - X1 = r.X1; - Y1 = r.Y1; - X2 = r.X2; - Y2 = r.Y2; - return *this; -} - -//---------------------------------------------------------------------- -FRect& FRect::operator = (FRect&& r) noexcept -{ - X1 = std::move(r.X1); - Y1 = std::move(r.Y1); - X2 = std::move(r.X2); - Y2 = std::move(r.Y2); - return *this; -} - //---------------------------------------------------------------------- bool FRect::isEmpty() const { diff --git a/src/fsize.cpp b/src/fsize.cpp index 74ee9f5d..18f88330 100644 --- a/src/fsize.cpp +++ b/src/fsize.cpp @@ -33,26 +33,7 @@ namespace finalcut // class FSize //---------------------------------------------------------------------- -FSize::~FSize() // destructor -{ } - // public methods of FSize -//---------------------------------------------------------------------- -FSize& FSize::operator = (const FSize& s) -{ - width = s.width; - height = s.height; - return *this; -} - -//---------------------------------------------------------------------- -FSize& FSize::operator = (FSize&& s) noexcept -{ - width = std::move(s.width); - height = std::move(s.height); - return *this; -} - //---------------------------------------------------------------------- FSize& FSize::operator += (const FSize& s) { diff --git a/src/fspinbox.cpp b/src/fspinbox.cpp index 09fd46e0..4355d1c7 100644 --- a/src/fspinbox.cpp +++ b/src/fspinbox.cpp @@ -48,8 +48,7 @@ FSpinBox::FSpinBox (FWidget* parent) } //---------------------------------------------------------------------- -FSpinBox::~FSpinBox() // destructor -{ } +FSpinBox::~FSpinBox() noexcept = default; // destructor // public methods of FSpinBox diff --git a/src/fstartoptions.cpp b/src/fstartoptions.cpp index 3250eadb..196e65d3 100644 --- a/src/fstartoptions.cpp +++ b/src/fstartoptions.cpp @@ -54,35 +54,13 @@ FStartOptions::FStartOptions() , dark_theme{false} { } -//---------------------------------------------------------------------- -FStartOptions::~FStartOptions() // destructor -{ } // public methods of FStartOptions //---------------------------------------------------------------------- FStartOptions& FStartOptions::getFStartOptions() { - if ( start_options == nullptr ) - { - try - { - start_options = new FStartOptions; - } - catch (const std::bad_alloc&) - { - badAllocOutput ("FStartOptions"); - std::abort(); - } - } - - return *start_options; -} - -//---------------------------------------------------------------------- -void FStartOptions::destroyObject() -{ - if ( start_options ) - delete start_options; + static const auto& start_options = make_unique(); + return *start_options.get(); } //---------------------------------------------------------------------- diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index fac517cf..b226ec4c 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -143,12 +143,12 @@ FStatusBar::~FStatusBar() // destructor while ( iter != key_list.end() ) { (*iter)->setConnectedStatusbar(nullptr); - delAccelerator (*iter); + FWidget::delAccelerator (*iter); iter = key_list.erase(iter); } } - setStatusBar(nullptr); + FWidget::setStatusBar(nullptr); } diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 71a8a61d..1bd5d723 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -49,8 +49,7 @@ FSwitch::FSwitch (const FString& txt, FWidget* parent) } //---------------------------------------------------------------------- -FSwitch::~FSwitch() // destructor -{ } +FSwitch::~FSwitch() noexcept = default; // destructor // public methods of FSwitch diff --git a/src/fsystem.cpp b/src/fsystem.cpp index 2f1dd98e..0193ed0f 100644 --- a/src/fsystem.cpp +++ b/src/fsystem.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2019 Markus Gans * +* Copyright 2019-2020 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 * @@ -31,12 +31,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- -FSystem::FSystem() -{ } - -//---------------------------------------------------------------------- -FSystem::~FSystem() // destructor -{ } +FSystem::~FSystem() noexcept = default; // destructor } // namespace finalcut diff --git a/src/fsystemimpl.cpp b/src/fsystemimpl.cpp index 498c86c2..dd097ebe 100644 --- a/src/fsystemimpl.cpp +++ b/src/fsystemimpl.cpp @@ -35,12 +35,8 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- -FSystemImpl::FSystemImpl() -{ } +FSystemImpl::~FSystemImpl() noexcept = default; // destructor -//---------------------------------------------------------------------- -FSystemImpl::~FSystemImpl() // destructor -{ } // public methods of FSystemImpl //---------------------------------------------------------------------- diff --git a/src/fterm.cpp b/src/fterm.cpp index ca220c30..e54eaf2f 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1419,7 +1419,7 @@ void FTerm::init_alt_charset() } } - enum column + enum Column : int { vt100_key = 0, utf8_char = 1 @@ -2272,7 +2272,6 @@ inline void FTerm::deallocationValues() const defaultPutChar* putchar_ptr = &(putchar()); delete putchar_ptr; destroyColorPaletteTheme(); - FStartOptions::destroyObject(); } //---------------------------------------------------------------------- diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index 07dd90c0..22915191 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -43,15 +43,15 @@ namespace finalcut { // Enumeration -enum fullWidthSupport +enum class FullWidthSupport { - unknown_fullwidth_support = -1, - supports_fullwidth = 0, - no_fullwidth_support = 1 + unknown = -1, + no = 0, + yes = 1 }; // global state -static fullWidthSupport has_fullwidth_support = unknown_fullwidth_support; +static FullWidthSupport has_fullwidth_support = FullWidthSupport::unknown; // Function prototypes bool hasAmbiguousWidth (wchar_t); @@ -250,7 +250,7 @@ bool hasFullWidthSupports() { // Checks if the terminal has full-width character support - if ( has_fullwidth_support == unknown_fullwidth_support ) + if ( has_fullwidth_support == FullWidthSupport::unknown ) { if ( ! FTerm::isInitialized() ) return true; // Assume that it is a modern terminal with full-width support @@ -262,12 +262,12 @@ bool hasFullWidthSupports() || FTerm::isOpenBSDTerm() || FTerm::isSunTerminal() || FTerm::isAnsiTerminal() ) - has_fullwidth_support = no_fullwidth_support; + has_fullwidth_support = FullWidthSupport::no; else - has_fullwidth_support = supports_fullwidth; + has_fullwidth_support = FullWidthSupport::yes; } - return ( has_fullwidth_support == supports_fullwidth) ? true : false; + return ( has_fullwidth_support == FullWidthSupport::yes) ? true : false; } //---------------------------------------------------------------------- @@ -528,7 +528,7 @@ std::size_t getColumnWidth (const FTermBuffer& tb) , tb.front().attr.bit.char_width , [] (std::size_t s, const FChar& c) { - return std::move(s) + c.attr.bit.char_width; + return s + c.attr.bit.char_width; } ); } diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index 9f088dfc..f6cb0c3c 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -38,8 +38,8 @@ namespace finalcut //---------------------------------------------------------------------- // class FTermBuffer //---------------------------------------------------------------------- -FTermBuffer::~FTermBuffer() // destructor -{ } +FTermBuffer::~FTermBuffer() noexcept = default; // destructor + // public methods of FTermBuffer //---------------------------------------------------------------------- @@ -72,7 +72,7 @@ int FTermBuffer::write (const FString& string) nc.attr.byte[2] = 0; nc.attr.byte[3] = 0; getColumnWidth(nc); // add column width - data.push_back(std::move(nc)); + data.emplace_back(std::move(nc)); } return len; @@ -86,8 +86,7 @@ int FTermBuffer::write (wchar_t ch) getColumnWidth(nc); // add column width nc.attr.bit.no_changes = false; nc.attr.bit.printed = false; - - data.push_back(nc); + data.emplace_back(std::move(nc)); return 1; } diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index d5fc36e8..30c49b2f 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -43,16 +43,6 @@ FTermDetection* FTermcapQuirks::term_detection {nullptr}; // class FTermcapQuirks //---------------------------------------------------------------------- -// constructors and destructor -//---------------------------------------------------------------------- -FTermcapQuirks::FTermcapQuirks() -{ } - -//---------------------------------------------------------------------- -FTermcapQuirks::~FTermcapQuirks() // destructor -{ } - - // public methods of FTermcapQuirks //---------------------------------------------------------------------- void FTermcapQuirks::terminalFixup() diff --git a/src/ftermios.cpp b/src/ftermios.cpp index 6abb3249..9c8a60d5 100644 --- a/src/ftermios.cpp +++ b/src/ftermios.cpp @@ -52,10 +52,6 @@ FTermios::FTermios() init(); } -//---------------------------------------------------------------------- -FTermios::~FTermios() // destructor -{ } - // public methods of FTermios //---------------------------------------------------------------------- void FTermios::init() diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index 6b789543..0b2fda5d 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -52,11 +52,6 @@ namespace finalcut // class FTermOpenBSD //---------------------------------------------------------------------- -// constructors and destructor -//---------------------------------------------------------------------- -FTermOpenBSD::~FTermOpenBSD() // destructor -{ } - // public methods of FTermOpenBSD //---------------------------------------------------------------------- #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index d9651dd6..54d67158 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -70,10 +70,6 @@ FTermXTerminal::FTermXTerminal() keyboard = FTerm::getFKeyboard(); } -//---------------------------------------------------------------------- -FTermXTerminal::~FTermXTerminal() // destructor -{ } - // public methods of FTermXTerminal //---------------------------------------------------------------------- diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 8e1ed36b..a7f1c7c2 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -48,8 +48,7 @@ FTextView::FTextView(FWidget* parent) } //---------------------------------------------------------------------- -FTextView::~FTextView() // destructor -{ } +FTextView::~FTextView() noexcept = default; // destructor // public methods of FTextView diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index f90ade84..3d9d56c6 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -485,7 +485,7 @@ void FToggleButton::init() } //---------------------------------------------------------------------- -void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos) +void FToggleButton::drawText (FString&& label_text, std::size_t hotkeypos) { if ( FTerm::isMonochron() ) setReverse(true); diff --git a/src/fvterm.cpp b/src/fvterm.cpp index a46c1513..e7eddb2a 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -443,8 +443,7 @@ int FVTerm::print (FTermArea* area, const FTermBuffer& term_buffer) //---------------------------------------------------------------------- int FVTerm::print (wchar_t c) { - FChar nc{}; // next character - nc = FVTerm::getAttribute(); + FChar nc{FVTerm::getAttribute()}; // next character nc.ch[0] = c; nc.attr.byte[2] = 0; nc.attr.byte[3] = 0; diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index d2c59f0c..a6731a6b 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -126,7 +126,7 @@ class FButtonGroup : public FScrollView // Methods void init(); - void drawText (const FString&, std::size_t); + void drawText (FString&&, std::size_t); bool directFocusCheckedRadioButton (FToggleButton*) const; bool directFocusRadioButton() const; void directFocus(); diff --git a/src/include/final/fcheckbox.h b/src/include/final/fcheckbox.h index 40e74bb7..43cd9f31 100644 --- a/src/include/final/fcheckbox.h +++ b/src/include/final/fcheckbox.h @@ -72,7 +72,7 @@ class FCheckBox : public FToggleButton FCheckBox (const FCheckBox&) = delete; // Destructor - ~FCheckBox() override; + ~FCheckBox() noexcept override; // Disable copy assignment operator (=) FCheckBox& operator = (const FCheckBox&) = delete; diff --git a/src/include/final/fcheckmenuitem.h b/src/include/final/fcheckmenuitem.h index c5ea112b..97883ff0 100644 --- a/src/include/final/fcheckmenuitem.h +++ b/src/include/final/fcheckmenuitem.h @@ -72,7 +72,7 @@ class FCheckMenuItem : public FMenuItem FCheckMenuItem (const FCheckMenuItem&) = delete; // Destructor - ~FCheckMenuItem() override; + ~FCheckMenuItem() noexcept override; // Disable copy assignment operator (=) FCheckMenuItem& operator = (const FCheckMenuItem&) = delete; diff --git a/src/include/final/fcombobox.h b/src/include/final/fcombobox.h index 4c2f6af1..46f122ec 100644 --- a/src/include/final/fcombobox.h +++ b/src/include/final/fcombobox.h @@ -142,7 +142,7 @@ class FComboBox : public FWidget FComboBox (const FComboBox&) = delete; // Destructor - ~FComboBox() override; + ~FComboBox() noexcept override; // Disable copy assignment operator (=) FComboBox& operator = (const FComboBox&) = delete; diff --git a/src/include/final/fdialoglistmenu.h b/src/include/final/fdialoglistmenu.h index f753242e..0ab3ba5b 100644 --- a/src/include/final/fdialoglistmenu.h +++ b/src/include/final/fdialoglistmenu.h @@ -78,7 +78,7 @@ class FDialogListMenu : public FMenu FDialogListMenu (const FDialogListMenu&) = delete; // Destructor - ~FDialogListMenu() override; + ~FDialogListMenu() noexcept override; // Disable copy assignment operator (=) FDialogListMenu& operator = (const FDialogListMenu&) = delete; diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h index d59610ac..82373d54 100644 --- a/src/include/final/fevent.h +++ b/src/include/final/fevent.h @@ -127,7 +127,7 @@ class FKeyEvent : public FEvent // keyboard event public: FKeyEvent() = default; FKeyEvent (fc::events, FKey); - ~FKeyEvent(); + ~FKeyEvent() = default; FKey key() const; bool isAccepted() const; @@ -150,7 +150,7 @@ class FMouseEvent : public FEvent // mouse event FMouseEvent() = default; FMouseEvent (fc::events, const FPoint&, const FPoint&, int); FMouseEvent (fc::events, const FPoint&, int); - ~FMouseEvent(); + ~FMouseEvent() = default; const FPoint& getPos() const; const FPoint& getTermPos() const; @@ -177,7 +177,7 @@ class FWheelEvent : public FEvent // wheel event FWheelEvent() = default; FWheelEvent (fc::events, const FPoint&, int); FWheelEvent (fc::events, const FPoint&, const FPoint&, int); - ~FWheelEvent(); + ~FWheelEvent() = default; const FPoint& getPos() const; const FPoint& getTermPos() const; @@ -203,7 +203,7 @@ class FFocusEvent : public FEvent // focus event public: FFocusEvent() = default; explicit FFocusEvent (fc::events); - ~FFocusEvent(); + ~FFocusEvent() = default; bool gotFocus() const; bool lostFocus() const; @@ -230,7 +230,7 @@ class FAccelEvent : public FEvent // focus event FAccelEvent() = default; FAccelEvent (fc::events, FWidget*); FAccelEvent (const FAccelEvent&) = delete; - ~FAccelEvent(); + ~FAccelEvent() = default; FAccelEvent& operator = (const FAccelEvent&) = delete; FWidget* focusedWidget() const; @@ -253,7 +253,7 @@ class FResizeEvent : public FEvent // resize event public: FResizeEvent() = default; explicit FResizeEvent (fc::events); - ~FResizeEvent(); + ~FResizeEvent() = default; bool isAccepted() const; void accept(); @@ -273,7 +273,7 @@ class FShowEvent : public FEvent // show event public: FShowEvent() = default; explicit FShowEvent (fc::events); - ~FShowEvent(); + ~FShowEvent() = default; }; @@ -286,7 +286,7 @@ class FHideEvent : public FEvent // hide event public: FHideEvent() = default; explicit FHideEvent (fc::events); - ~FHideEvent(); + ~FHideEvent() = default; }; @@ -299,7 +299,7 @@ class FCloseEvent : public FEvent // close event public: FCloseEvent() = default; explicit FCloseEvent(fc::events); - ~FCloseEvent(); + ~FCloseEvent() = default; bool isAccepted() const; void accept(); @@ -319,7 +319,7 @@ class FTimerEvent : public FEvent // timer event public: FTimerEvent() = default; FTimerEvent (fc::events, int); - ~FTimerEvent(); + ~FTimerEvent() = default; int getTimerId() const; @@ -341,7 +341,7 @@ class FUserEvent : public FEvent // user event FUserEvent (const FUserEvent&) = delete; FUserEvent (fc::events, int); - ~FUserEvent(); + ~FUserEvent() = default; // Disable copy assignment operator (=) FUserEvent& operator = (const FUserEvent&) = delete; diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index 567a7e2c..7ac7b1b5 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -100,7 +100,7 @@ class FKeyboard final FKeyboard (const FKeyboard&) = delete; // Destructor - ~FKeyboard(); + ~FKeyboard() = default; // Disable copy assignment operator (=) FKeyboard& operator = (const FKeyboard&) = delete; diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index 7c28aebe..3ab68976 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -163,8 +163,8 @@ class FLineEdit : public FWidget void adjustSize() override; private: - // Typedef - typedef std::pair offsetPair; + // Using-declaration + using offsetPair = std::pair; // Enumeration enum dragScroll diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index d763a5eb..0d27a1ae 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -73,13 +73,13 @@ class FListBoxItem { public: // Constructors - FListBoxItem (); + FListBoxItem() = default; FListBoxItem (const FListBoxItem&); // copy constructor template explicit FListBoxItem (const FString&, DT&& = DT() ); // Destructor - virtual ~FListBoxItem(); + virtual ~FListBoxItem() noexcept; // copy copy assignment operator (=) FListBoxItem& operator = (const FListBoxItem&); diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index b75c7f0d..fe164f88 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -219,23 +219,16 @@ class FListViewIterator using iterator_stack = std::stack; // Constructor - FListViewIterator (); + FListViewIterator () = default; FListViewIterator (iterator); - FListViewIterator (const FListViewIterator&); // copy constructor - FListViewIterator (FListViewIterator&&) noexcept; // move constructor - - // Destructor - ~FListViewIterator(); // Overloaded operators - FListViewIterator& operator = (const FListViewIterator&); - FListViewIterator& operator = (FListViewIterator&&) noexcept; FListViewIterator& operator ++ (); // prefix FListViewIterator operator ++ (int); // postfix FListViewIterator& operator -- (); // prefix FListViewIterator operator -- (int); // postfix - FListViewIterator& operator += (volatile int); - FListViewIterator& operator -= (volatile int); + FListViewIterator& operator += (int); + FListViewIterator& operator -= (int); FObject*& operator * () const; FObject* operator -> () const; bool operator == (const FListViewIterator&) const; @@ -542,8 +535,7 @@ class FListView : public FWidget struct FListView::Header { public: - Header() - { } + Header () = default; FString name{}; fc::text_alignment alignment{fc::alignLeft}; diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index 4807386b..348b5eb0 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -102,17 +102,16 @@ class FMenuBar : public FWindow, public FMenuList void cb_itemDeactivated (const FMenuItem*) const; private: - // Constants - static constexpr auto NOT_SET = static_cast(-1); - - // Typedef - typedef struct + struct menuText { FString text; std::size_t startpos; std::size_t hotkeypos; bool no_underline; - } menuText; + }; + + // Constants + static constexpr auto NOT_SET = static_cast(-1); // Inquiry bool isMenu (const FMenuItem*) const; diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index 4b79c0c5..d24b2e51 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -59,6 +59,10 @@ #include +#include +#include + +#include "final/fbutton.h" #include "final/fdialog.h" #include "final/fwidgetcolors.h" @@ -95,7 +99,7 @@ class FMessageBox : public FDialog , ButtonType, ButtonType, ButtonType , FWidget* = nullptr ); // Destructor - ~FMessageBox() override; + virtual ~FMessageBox() noexcept override; // copy assignment operator (=) FMessageBox& operator = (const FMessageBox&); @@ -140,10 +144,12 @@ class FMessageBox : public FDialog // Constants static constexpr std::size_t MAX_BUTTONS = 3; + // Using-declaration + using FButtons = std::array, MAX_BUTTONS>; + // Methods void init(); void allocation(); - void deallocation(); void initCallbacks(); void calculateDimensions(); void draw() override; @@ -154,7 +160,8 @@ class FMessageBox : public FDialog FString headline_text{}; FString text{}; FStringList text_components{}; - FButton* button[MAX_BUTTONS]{nullptr}; + + FButtons button; std::size_t max_line_width{0}; FColor emphasis_color{getColorTheme()->dialog_emphasis_fg}; ButtonType button_digit[MAX_BUTTONS]{FMessageBox::Reject}; diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index e265c9e7..a4b6c00a 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -257,7 +257,7 @@ class FMouseGPM final : public FMouse FMouseGPM(); // Destructor - ~FMouseGPM() override; + ~FMouseGPM() override = default; // Accessors FString getClassName() const override; @@ -581,13 +581,14 @@ class FMouseControl void drawPointer(); private: - // Typedef - typedef std::map FMouseProtocol; - typedef std::unique_ptr FMouseDataPtr; + // Using-declaration + using FMousePtr = std::unique_ptr; + using FMouseDataPtr = std::unique_ptr; + using FMouseProtocol = std::map; // Accessor - FMouse* getMouseWithData(); - FMouse* getMouseWithEvent(); + FMouse::mouse_type getMouseWithData(); + FMouse::mouse_type getMouseWithEvent(); void xtermMouse (bool) const; void enableXTermMouse() const; void disableXTermMouse() const; diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h index a5fb8a14..bff7cb6b 100644 --- a/src/include/final/fobject.h +++ b/src/include/final/fobject.h @@ -150,8 +150,9 @@ class FObject FObject* object; }; - // Typedefs - typedef std::vector FTimerList; + // Using-declaration + using FTimerList = std::vector; + using FTimerListPtr = const std::unique_ptr; // Accessor FTimerList* getTimerList() const; @@ -169,6 +170,7 @@ class FObject private: // Method virtual void performTimerAction (FObject*, FEvent*); + static FTimerListPtr& globalTimerList(); // Data members FObject* parent_obj{nullptr}; @@ -177,7 +179,6 @@ class FObject bool has_parent{false}; bool widget_object{false}; static bool timer_modify_lock; - static FTimerList* timer_list; }; @@ -267,7 +268,7 @@ inline bool FObject::isTimerInUpdating() const //---------------------------------------------------------------------- inline FObject::FTimerList* FObject::getTimerList() const -{ return timer_list; } +{ return globalTimerList().get(); } //---------------------------------------------------------------------- inline void FObject::setWidgetProperty (bool property) diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index a9103174..cfa48398 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -51,8 +51,7 @@ namespace finalcut class FOptiAttr final { public: - // Typedef - typedef struct + struct TermEnv { const char* t_enter_bold_mode; const char* t_exit_bold_mode; @@ -92,7 +91,7 @@ class FOptiAttr final int max_color; int attr_without_color; bool ansi_default_color; - } TermEnv; + }; // Constructor FOptiAttr(); @@ -101,7 +100,7 @@ class FOptiAttr final FOptiAttr (const FOptiAttr&) = delete; // Destructor - ~FOptiAttr(); + ~FOptiAttr() noexcept = default; // Disable copy assignment operator (=) FOptiAttr& operator = (const FOptiAttr&) = delete; diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index 1fcea1fb..c9003fee 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -89,7 +89,7 @@ class FOptiMove final explicit FOptiMove (int = 0); // Destructor - ~FOptiMove(); + ~FOptiMove() noexcept = default; // Accessors FString getClassName() const; @@ -168,7 +168,7 @@ class FOptiMove final void calculateCharDuration(); int capDuration (const char[], int) const; int capDurationToLength (int) const; - int repeatedAppend (const Capability&, volatile int, char*) const; + int repeatedAppend (const Capability&, int, char*) const; int relativeMove (char[], int, int, int, int) const; int verticalMove (char[], int, int) const; void downMove (char[], int&, int, int) const; diff --git a/src/include/final/fpoint.h b/src/include/final/fpoint.h index 17ba5628..b4019623 100644 --- a/src/include/final/fpoint.h +++ b/src/include/final/fpoint.h @@ -52,21 +52,14 @@ class FPoint public: // Constructors FPoint () = default; - FPoint (const FPoint&); // copy constructor - FPoint (FPoint&&) noexcept; // move constructor FPoint (int, int); - // Destructor - virtual ~FPoint(); - // Overloaded operators - FPoint& operator = (const FPoint&); - FPoint& operator = (FPoint&&) noexcept; FPoint& operator += (const FPoint&); FPoint& operator -= (const FPoint&); // Accessors - virtual FString getClassName(); + FString getClassName(); int getX() const; int getY() const; void setX (int); @@ -102,18 +95,6 @@ class FPoint // FPoint inline functions -//---------------------------------------------------------------------- -inline FPoint::FPoint (const FPoint& p) // copy constructor - : xpos{p.xpos} - , ypos{p.ypos} -{ } - -//---------------------------------------------------------------------- -inline FPoint::FPoint (FPoint&& p) noexcept // move constructor - : xpos{std::move(p.xpos)} - , ypos{std::move(p.ypos)} -{ } - //---------------------------------------------------------------------- inline FPoint::FPoint (int x, int y) : xpos{x} diff --git a/src/include/final/fprogressbar.h b/src/include/final/fprogressbar.h index 05d2005b..c7f89fb6 100644 --- a/src/include/final/fprogressbar.h +++ b/src/include/final/fprogressbar.h @@ -66,7 +66,7 @@ class FProgressbar : public FWidget explicit FProgressbar(FWidget* = nullptr); // Destructor - ~FProgressbar() override; + ~FProgressbar() noexcept override; // Accessors FString getClassName() const override; diff --git a/src/include/final/fradiobutton.h b/src/include/final/fradiobutton.h index 5187017f..6af13e5a 100644 --- a/src/include/final/fradiobutton.h +++ b/src/include/final/fradiobutton.h @@ -72,7 +72,7 @@ class FRadioButton : public FToggleButton FRadioButton (const FRadioButton&) = delete; // Destructor - ~FRadioButton() override; + ~FRadioButton() noexcept override; // Disable copy assignment operator (=) FRadioButton& operator = (const FRadioButton&) = delete; diff --git a/src/include/final/fradiomenuitem.h b/src/include/final/fradiomenuitem.h index 4ba3b0c3..ba306c8f 100644 --- a/src/include/final/fradiomenuitem.h +++ b/src/include/final/fradiomenuitem.h @@ -72,7 +72,7 @@ class FRadioMenuItem : public FMenuItem FRadioMenuItem (const FRadioMenuItem&) = delete; // Destructor - ~FRadioMenuItem() override; + ~FRadioMenuItem() noexcept override; // Disable copy assignment operator (=) FRadioMenuItem& operator = (const FRadioMenuItem&) = delete; diff --git a/src/include/final/frect.h b/src/include/final/frect.h index 15c4a25e..ec588e33 100644 --- a/src/include/final/frect.h +++ b/src/include/final/frect.h @@ -60,21 +60,12 @@ class FRect public: // Constructors FRect () = default; - FRect (const FRect&); // copy constructor - FRect (FRect&&) noexcept; // move constructor FRect (int, int, std::size_t, std::size_t); FRect (const FPoint&, const FSize&); FRect (const FPoint&, const FPoint&); - // Destructor - virtual ~FRect(); - - // Overloaded operators - FRect& operator = (const FRect&); - FRect& operator = (FRect&&) noexcept; - // Accessors - virtual FString getClassName(); + FString getClassName(); int getX1() const; int getY1() const; int getX2() const; @@ -147,22 +138,6 @@ class FRect }; // FRect inline functions -//---------------------------------------------------------------------- -inline FRect::FRect (const FRect& r) // copy constructor - : X1{r.X1} - , Y1{r.Y1} - , X2{r.X2} - , Y2{r.Y2} -{ } - -//---------------------------------------------------------------------- -inline FRect::FRect (FRect&& r) noexcept // move constructor - : X1{std::move(r.X1)} - , Y1{std::move(r.Y1)} - , X2{std::move(r.X2)} - , Y2{std::move(r.Y2)} -{ } - //---------------------------------------------------------------------- inline FRect::FRect (int x, int y, std::size_t width, std::size_t height) : X1{x} diff --git a/src/include/final/fscrollbar.h b/src/include/final/fscrollbar.h index f4b7fe95..6e394fb5 100644 --- a/src/include/final/fscrollbar.h +++ b/src/include/final/fscrollbar.h @@ -60,8 +60,8 @@ namespace finalcut // class forward declaration class FScrollbar; -// Global typedef -typedef std::shared_ptr FScrollbarPtr; +// Global using-declaration +using FScrollbarPtr = std::shared_ptr; //---------------------------------------------------------------------- // class FScrollbar @@ -70,7 +70,7 @@ typedef std::shared_ptr FScrollbarPtr; class FScrollbar : public FWidget { public: - // Using-declarations + // Using-declaration using FWidget::setGeometry; // Enumeration diff --git a/src/include/final/fsize.h b/src/include/final/fsize.h index 9de799ef..90c94f4f 100644 --- a/src/include/final/fsize.h +++ b/src/include/final/fsize.h @@ -57,21 +57,14 @@ class FSize public: // Constructors FSize () = default; - FSize (const FSize&); // copy constructor - FSize (FSize&&) noexcept; // move constructor FSize (std::size_t, std::size_t); - // Destructor - virtual ~FSize(); - // Overloaded operators - FSize& operator = (const FSize&); - FSize& operator = (FSize&&) noexcept; FSize& operator += (const FSize&); FSize& operator -= (const FSize&); // Accessors - virtual FString getClassName(); + FString getClassName(); std::size_t getWidth() const; std::size_t getHeight() const; std::size_t getArea() const; @@ -111,18 +104,6 @@ class FSize }; // FSize inline functions -//---------------------------------------------------------------------- -inline FSize::FSize (const FSize& s) // copy constructor - : width{s.width} - , height{s.height} -{ } - -//---------------------------------------------------------------------- -inline FSize::FSize (FSize&& s) noexcept // move constructor - : width{std::move(s.width)} - , height{std::move(s.height)} -{ } - //---------------------------------------------------------------------- inline FSize::FSize (std::size_t w, std::size_t h) : width{w} diff --git a/src/include/final/fspinbox.h b/src/include/final/fspinbox.h index b13c306f..24963f9b 100644 --- a/src/include/final/fspinbox.h +++ b/src/include/final/fspinbox.h @@ -74,7 +74,7 @@ class FSpinBox : public FWidget FSpinBox (const FSpinBox&) = delete; // Destructor - ~FSpinBox() override; + ~FSpinBox() noexcept override; // Disable copy assignment operator (=) FSpinBox& operator = (const FSpinBox&) = delete; diff --git a/src/include/final/fstartoptions.h b/src/include/final/fstartoptions.h index a5430228..715e013e 100644 --- a/src/include/final/fstartoptions.h +++ b/src/include/final/fstartoptions.h @@ -59,7 +59,7 @@ class FStartOptions final FStartOptions (const FStartOptions&) = delete; // Destructor - ~FStartOptions(); + ~FStartOptions() = default; // Disable copy assignment operator (=) FStartOptions& operator = (const FStartOptions&) = delete; @@ -71,9 +71,6 @@ class FStartOptions final // Mutator void setDefault(); - // Method - static void destroyObject(); - // Data members uInt8 cursor_optimisation : 1; uInt8 mouse_support : 1; diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 8a1bf59d..fda86f79 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -68,8 +68,8 @@ namespace finalcut // class forward declaration class FString; -// Global typedef -typedef std::vector FStringList; +// Global using-declaration +using FStringList = std::vector; //---------------------------------------------------------------------- diff --git a/src/include/final/fstyle.h b/src/include/final/fstyle.h index dbb93162..d6188beb 100644 --- a/src/include/final/fstyle.h +++ b/src/include/final/fstyle.h @@ -54,21 +54,6 @@ class FStyle : attribute{attr} { } - // Copy constructor - FStyle (const FStyle& style) - : attribute{style.attribute} - { } - - // Destructor - ~FStyle() = default; - - // copy assignment operator (=) - FStyle& operator = (const FStyle& style) - { - attribute = style.attribute; - return *this; - } - // Accessor FString getClassName() const { return "FStyle"; } diff --git a/src/include/final/fswitch.h b/src/include/final/fswitch.h index 3978a4db..a450f973 100644 --- a/src/include/final/fswitch.h +++ b/src/include/final/fswitch.h @@ -72,7 +72,7 @@ class FSwitch : public FToggleButton FSwitch (const FSwitch&) = delete; // Destructor - ~FSwitch() override; + ~FSwitch() noexcept override; // Disable copy assignment operator (=) FSwitch& operator = (const FSwitch&) = delete; diff --git a/src/include/final/fsystem.h b/src/include/final/fsystem.h index e07fed7b..8ac8723a 100644 --- a/src/include/final/fsystem.h +++ b/src/include/final/fsystem.h @@ -52,10 +52,10 @@ class FSystem using fn_putc = int (*)(int); // Constructor - FSystem(); + FSystem () = default; // Destructor - virtual ~FSystem(); + virtual ~FSystem() noexcept; // Methods virtual uChar inPortByte (uShort) = 0; diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index 17d56a4b..aa9bad91 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -97,10 +97,10 @@ class FSystemImpl : public FSystem { public: // Constructor - FSystemImpl(); + FSystemImpl() = default; // Destructor - ~FSystemImpl() override; + ~FSystemImpl() noexcept override; // Methods #if defined(ISA_SYSCTL_SUPPORT) diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index aefaf4ba..7abd7cf6 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -161,10 +161,10 @@ class FTermXTerminal; class FTerm final { public: - // Typedef - typedef std::function defaultPutChar; - typedef std::shared_ptr FColorPalettePtr; - typedef FColorPalette::FSetPalette FSetPalette; + // Using-declarations + using defaultPutChar = std::function; + using FColorPalettePtr = std::shared_ptr; + using FSetPalette = FColorPalette::FSetPalette; // Constructor FTerm(); diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index 3ef4455e..4d8fc918 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -69,7 +69,7 @@ class FTermBuffer FTermBuffer (Iterator, Iterator); // Destructor - virtual ~FTermBuffer(); + virtual ~FTermBuffer() noexcept; // Overloaded operators template diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index c73df24b..384918d5 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -50,10 +50,10 @@ class FTermcapQuirks final { public: // Constructors - FTermcapQuirks(); + FTermcapQuirks() = default; // Destructor - ~FTermcapQuirks(); + ~FTermcapQuirks() noexcept = default; // Accessor FString getClassName() const; diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index 5ba213c6..3b77b4fc 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -57,15 +57,13 @@ class FTermData final typedef std::unordered_map EncodingMap; // Constructors - FTermData() - { } + FTermData () = default; // Disable copy constructor FTermData (const FTermData&) = delete; // Destructor - ~FTermData() - { } + ~FTermData() noexcept = default; // Disable copy assignment operator (=) FTermData& operator = (const FTermData&) = delete; diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 89798b87..6935372e 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -50,8 +50,7 @@ namespace finalcut class FTermDetection final { public: - // Typedefs - typedef struct + struct FTerminalType { // byte #0 uInt8 ansi : 1; @@ -77,7 +76,7 @@ class FTermDetection final uInt8 kterm : 1; uInt8 mlterm : 1; uInt8 : 4; // padding bits - } FTerminalType; + }; // Constructors FTermDetection(); diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 93ac5405..23214c59 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -79,8 +79,8 @@ class FTermData; class FTermFreeBSD final { public: - // Typedef - typedef fc::freebsdConsoleCursorStyle CursorStyle; + // Using-declaration + using CursorStyle = fc::freebsdConsoleCursorStyle; // Constructors FTermFreeBSD() = default; diff --git a/src/include/final/ftermios.h b/src/include/final/ftermios.h index e1a31e35..14178b9c 100644 --- a/src/include/final/ftermios.h +++ b/src/include/final/ftermios.h @@ -55,7 +55,7 @@ class FTermios final FTermios(); // Destructor - ~FTermios(); + ~FTermios() noexcept = default; // Accessors FString getClassName() const; diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 84b8b0a0..989b8028 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -77,8 +77,8 @@ class FTermDetection; class FTermLinux final { public: - // Typedef - typedef fc::linuxConsoleCursorStyle CursorStyle; + // Using-declaration + using CursorStyle = fc::linuxConsoleCursorStyle; // Constructors FTermLinux() = default; @@ -123,7 +123,6 @@ class FTermLinux final FKey modifierKeyCorrection (const FKey&); private: - // Typedef struct ModifierKey // bit field { uChar shift : 1; // 0..1 @@ -133,17 +132,17 @@ class FTermLinux final uChar : 4; // padding bits }; - typedef struct + struct RGB { uChar red; uChar green; uChar blue; - } RGB; + }; - typedef struct + struct ColorMap { RGB color[16]; - } ColorMap; + }; // Accessors int getFramebuffer_bpp(); diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index 97799dbb..86590cca 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -81,7 +81,7 @@ class FTermOpenBSD final FTermOpenBSD (const FTermOpenBSD&) = delete; // Destructor - ~FTermOpenBSD(); + ~FTermOpenBSD() noexcept = default; // Disable copy assignment operator (=) FTermOpenBSD& operator = (const FTermOpenBSD&) = delete; diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index 805f58a3..2f53c910 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -58,7 +58,7 @@ class FTermXTerminal final FTermXTerminal (const FTermXTerminal&) = delete; // Destructor - ~FTermXTerminal(); + ~FTermXTerminal() noexcept = default; // Disable copy assignment operator (=) FTermXTerminal& operator = (const FTermXTerminal&) = delete; diff --git a/src/include/final/ftextview.h b/src/include/final/ftextview.h index 8fb66e65..6ddd3946 100644 --- a/src/include/final/ftextview.h +++ b/src/include/final/ftextview.h @@ -77,7 +77,7 @@ class FTextView : public FWidget FTextView (const FTextView&) = delete; // Destructor - ~FTextView() override; + ~FTextView() noexcept override; // Disable copy assignment operator (=) FTextView& operator = (const FTextView&) = delete; diff --git a/src/include/final/ftogglebutton.h b/src/include/final/ftogglebutton.h index 35e35565..0780e32f 100644 --- a/src/include/final/ftogglebutton.h +++ b/src/include/final/ftogglebutton.h @@ -148,7 +148,7 @@ class FToggleButton : public FWidget // Methods void init(); - void drawText (const FString&, std::size_t); + void drawText (FString&&, std::size_t); void correctSize (FSize&) const; // Data members diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index 42e7088b..4bbba54d 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -49,29 +50,28 @@ << " in " \ << __func__ << std::endl; -typedef unsigned char uChar; -typedef unsigned short uShort; -typedef unsigned int uInt; -typedef unsigned long uLong; -typedef std::uint8_t uInt8; -typedef std::uint16_t uInt16; -typedef std::uint32_t uInt32; -typedef std::uint64_t uInt64; +using uChar = unsigned char; +using uShort = unsigned short; +using uInt = unsigned int; +using uLong = unsigned long; +using uInt8 = std::uint8_t; +using uInt16 = std::uint16_t; +using uInt32 = std::uint32_t; +using uInt64 = std::uint64_t; -typedef signed int sInt; -typedef signed long sLong; -typedef std::int8_t sInt8; -typedef std::int16_t sInt16; -typedef std::int32_t sInt32; -typedef std::int64_t sInt64; +using sInt = signed int; +using sLong = signed long; +using sInt8 = std::int8_t; +using sInt16 = std::int16_t; +using sInt32 = std::int32_t; +using sInt64 = std::int64_t; -typedef long double lDouble; +using lDouble = long double; -typedef uInt16 FColor; -typedef uInt16 FAttribute; -typedef uInt32 FKey; -typedef void* FDataPtr; -typedef std::function FCall; +using FColor = uInt16; +using FAttribute = uInt16; +using FKey = uInt32; +using FCall = std::function; namespace finalcut { @@ -115,7 +115,13 @@ struct getPrecision } }; -typedef std::unordered_map charSubstitution; +template +std::unique_ptr make_unique (Args&&... args) +{ + return std::unique_ptr(new T(std::forward(args)...)); +} + +using charSubstitution = std::unordered_map; struct FCharAttribute { @@ -155,42 +161,39 @@ union attribute static constexpr uInt UNICODE_MAX = 5; -typedef std::array FUnicode; +using FUnicode = std::array; -typedef struct +struct FChar { - FUnicode ch; // Character code - FUnicode encoded_char; // Encoded output character - FColor fg_color; // Foreground color - FColor bg_color; // Background color - attribute attr; // Attributes -} FChar; + FUnicode ch{}; // Character code + FUnicode encoded_char{}; // Encoded output character + FColor fg_color{}; // Foreground color + FColor bg_color{}; // Background color + attribute attr{}; // Attributes +}; namespace fc { -typedef struct +struct FKeyMap { FKey num; const char* string; char tname[4]; -} -FKeyMap; +}; -typedef struct +struct FMetakeyMap { FKey num; char string[8]; -} -FMetakeyMap; +}; -typedef struct +struct FKeyName { FKey num; char string[25]; -} -FKeyName; +}; } // namespace fc @@ -198,7 +201,7 @@ FKeyName; //---------------------------------------------------------------------- inline bool operator == (const FChar& lhs, const FChar& rhs) { - return operator == (lhs.ch, rhs.ch) + return operator == (lhs.ch, rhs.ch) // Compare FUnicode && lhs.fg_color == rhs.fg_color && lhs.bg_color == rhs.bg_color && lhs.attr.byte[0] == rhs.attr.byte[0] diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index db0c3a91..be265c79 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -87,22 +87,22 @@ class FWidget; class FVTerm { public: - // Typedefs and Enumeration - typedef struct + struct FTermArea; // forward declaration + struct FVTermPreprocessing; // forward declaration + + struct FLineChanges { uInt xmin; // X-position with the first change uInt xmax; // X-position with the last change uInt trans_count; // Number of transparent characters - } FLineChanges; + }; - typedef void (FVTerm::*FPreprocessingHandler)(); - typedef std::function FPreprocessingFunction; - - struct FTermArea; // forward declaration - struct FVTermPreprocessing; // forward declaration - - typedef std::vector FPreprocessing; + // Using-declarations + using FPreprocessingHandler = void (FVTerm::*)(); + using FPreprocessingFunction = std::function ; + using FPreprocessing = std::vector; + // Enumerations enum covered_state { non_covered, @@ -500,50 +500,16 @@ struct FVTerm::FTermArea // define virtual terminal character properties struct FVTerm::FVTermPreprocessing { // Constructor - FVTermPreprocessing() - : instance(nullptr) - , function(nullptr) - { } + FVTermPreprocessing() = default; FVTermPreprocessing (const FVTerm* i, const FPreprocessingFunction& f) : instance(i) , function(f) { } - FVTermPreprocessing (const FVTermPreprocessing& p) // copy constructor - : instance(p.instance) - , function(p.function) - { } - - FVTermPreprocessing (FVTermPreprocessing&& p) noexcept // move constructor - : instance(std::move(p.instance)) - , function(std::move(p.function)) - { } - - // Overloaded operators - FVTermPreprocessing& operator = (const FVTermPreprocessing& p) - { - instance = p.instance; - function = p.function; - return *this; - } - - FVTermPreprocessing& operator = (FVTermPreprocessing&& p) noexcept - { - instance = p.instance; - function = p.function; - p.instance = nullptr; - p.function = nullptr; - return *this; - } - - // Destructor - ~FVTermPreprocessing() - { } - // Data members - const FVTerm* instance{}; - FPreprocessingFunction function{}; + const FVTerm* instance{nullptr}; + FPreprocessingFunction function{nullptr}; }; diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index c482b8ef..187aea0d 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -125,20 +125,18 @@ class FWidgetColors; class FWidget : public FVTerm, public FObject { public: - // Using-declaration - using FVTerm::setColor; - using FVTerm::print; - struct FAccelerator { alignas(8) FKey key; FWidget* object; }; - // Typedefs - typedef std::vector FWidgetList; - typedef std::vector FAcceleratorList; - typedef std::shared_ptr FWidgetColorsPtr; + // Using-declarations + using FVTerm::setColor; + using FVTerm::print; + using FWidgetList = std::vector; + using FAcceleratorList = std::vector; + using FWidgetColorsPtr = std::shared_ptr; struct FWidgetFlags // Properties of a widget ⚑ { diff --git a/src/include/final/sgr_optimizer.h b/src/include/final/sgr_optimizer.h index e67dcdd3..67a604b2 100644 --- a/src/include/final/sgr_optimizer.h +++ b/src/include/final/sgr_optimizer.h @@ -61,7 +61,7 @@ class SGRoptimizer final SGRoptimizer (const SGRoptimizer&) = delete; // Destructor - ~SGRoptimizer(); + ~SGRoptimizer() noexcept = default; // Disable copy assignment operator (=) SGRoptimizer& operator = (const SGRoptimizer&) = delete; diff --git a/src/sgr_optimizer.cpp b/src/sgr_optimizer.cpp index b38ecbf4..a26f7e6f 100644 --- a/src/sgr_optimizer.cpp +++ b/src/sgr_optimizer.cpp @@ -39,10 +39,6 @@ SGRoptimizer::SGRoptimizer (AttributeBuffer& sequence) : seq{sequence} { } -//---------------------------------------------------------------------- -SGRoptimizer::~SGRoptimizer() // destructor -{ } - // public methods of SGRoptimizer //----------------------------------------------------------------------