diff --git a/.codacy.yml b/.codacy.yml new file mode 100644 index 00000000..cb0b05bd --- /dev/null +++ b/.codacy.yml @@ -0,0 +1,15 @@ +--- +engines: + duplication: + enabled: true + exclude_paths: + - 'fonts/**' + - 'test/**' +exclude_paths: + - 'debian/**' + - 'doc/**' + - 'icon/**' + - 'logo/**' + - 'm4/**' + - 'scripts/**' + diff --git a/ChangeLog b/ChangeLog index 2d38e2a4..334d9513 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-05-26 Markus Gans + * FWidgetColors now uses polymorphism, so you can now easily + create your own widget color theme + 2020-05-24 Markus Gans * New class FStringStream implements input and output operations on FString based streams diff --git a/confdefs.h b/confdefs.h deleted file mode 100644 index 28a75ba7..00000000 --- a/confdefs.h +++ /dev/null @@ -1,46 +0,0 @@ -/* confdefs.h */ -#define PACKAGE_NAME "finalcut" -#define PACKAGE_TARNAME "finalcut" -#define PACKAGE_VERSION "0.6.1" -#define PACKAGE_STRING "finalcut 0.6.1" -#define PACKAGE_BUGREPORT "" -#define PACKAGE_URL "" -#define STDC_HEADERS 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_UNISTD_H 1 -#define __EXTENSIONS__ 1 -#define _ALL_SOURCE 1 -#define _GNU_SOURCE 1 -#define _POSIX_PTHREAD_SEMANTICS 1 -#define _TANDEM_SOURCE 1 -#define PACKAGE "finalcut" -#define VERSION "0.6.1" -#define STDC_HEADERS 1 -#define HAVE_LINUX_FB_H 1 -#define HAVE_SYS_IO_H 1 -#define HAVE_SYS_KD_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_TIME_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_LANGINFO_H 1 -#define HAVE_TERM_H 1 -#define HAVE_TERMIOS_H 1 -#define HAVE_TTYENT_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_GETUID 1 -#define HAVE_GETEUID 1 -#define HAVE_GETTTYNAM 1 -#define HAVE_SELECT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRSTR 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_DLFCN_H 1 -#define LT_OBJDIR ".libs/" -#define HAVE_LIBGPM 1 diff --git a/examples/calculator.cpp b/examples/calculator.cpp index 6beba5e8..aff63430 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -81,10 +81,10 @@ void Button::setChecked (bool enable) } else { - const auto& wc = getFWidgetColors(); - setBackgroundColor(wc.button_active_bg); - setFocusForegroundColor(wc.button_active_focus_fg); - setFocusBackgroundColor(wc.button_active_focus_bg); + const auto& wc = getColorTheme(); + setBackgroundColor(wc->button_active_bg); + setFocusForegroundColor(wc->button_active_focus_fg); + setFocusBackgroundColor(wc->button_active_focus_bg); } redraw(); @@ -424,10 +424,10 @@ void Calc::drawDispay() if ( finalcut::FTerm::isMonochron() ) setReverse(false); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); print() << FColorPair{fc::Black, fc::LightGray} << FPoint{3, 3} << display << ' ' - << FColorPair{wc.dialog_fg, wc.dialog_bg}; + << FColorPair{wc->dialog_fg, wc->dialog_bg}; if ( finalcut::FTerm::isMonochron() ) setReverse(true); diff --git a/examples/keyboard.cpp b/examples/keyboard.cpp index cd7e0c8a..a92330fc 100644 --- a/examples/keyboard.cpp +++ b/examples/keyboard.cpp @@ -46,8 +46,8 @@ class Keyboard final : public finalcut::FWidget Keyboard::Keyboard (finalcut::FWidget* parent) : finalcut::FWidget{parent} { - setFWidgetColors().term_fg = finalcut::fc::Default; - setFWidgetColors().term_bg = finalcut::fc::Default; + getColorTheme()->term_fg = finalcut::fc::Default; + getColorTheme()->term_bg = finalcut::fc::Default; } //---------------------------------------------------------------------- diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 0d5bdb60..bb3a9eb2 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -131,8 +131,8 @@ void Scrollview::draw() if ( finalcut::FTerm::isMonochron() ) setReverse(true); - const auto& wc = getFWidgetColors(); - setColor (wc.label_inactive_fg, wc.dialog_bg); + const auto& wc = getColorTheme(); + setColor (wc->label_inactive_fg, wc->dialog_bg); clearArea(); for (int y{0}; y < int(getScrollHeight()); y++) diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index c549cf4e..c8528bba 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -66,7 +66,7 @@ class AttribDlg final : public finalcut::FDialog void adjustSize() override; // Data members - FColor bgcolor{getFWidgetColors().label_bg}; + FColor bgcolor{getColorTheme()->label_bg}; finalcut::FButton next_button{"&Next >", this}; finalcut::FButton back_button{"< &Back", this}; }; @@ -267,11 +267,11 @@ void AttribDemo::printColorLine() //---------------------------------------------------------------------- void AttribDemo::printAltCharset() { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const auto& parent = static_cast(getParent()); if ( ! finalcut::FTerm::isMonochron() ) - setColor (wc.label_fg, wc.label_bg); + setColor (wc->label_fg, wc->label_bg); print() << FPoint{1, 1} << "alternate charset: "; @@ -418,7 +418,7 @@ void AttribDemo::printProtected() void AttribDemo::draw() { // test alternate character set - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); printAltCharset(); const std::vector > effect @@ -442,14 +442,14 @@ void AttribDemo::draw() print() << FPoint{1, 2 + int(y)}; if ( ! finalcut::FTerm::isMonochron() ) - setColor (wc.label_fg, wc.label_bg); + setColor (wc->label_fg, wc->label_bg); if ( y < effect.size() ) effect[y](); } if ( ! finalcut::FTerm::isMonochron() ) - setColor(wc.label_fg, wc.label_bg); + setColor(wc->label_fg, wc->label_bg); print() << FPoint{1, 15}; const FColor bg = static_cast(getParent())->getBGColor(); diff --git a/examples/timer.cpp b/examples/timer.cpp index 10086e7b..81a94fbf 100644 --- a/examples/timer.cpp +++ b/examples/timer.cpp @@ -54,8 +54,8 @@ Timer::Timer (finalcut::FWidget* parent) delTimer (id); addTimer (250); // 250-millisecond timer - setFWidgetColors().term_fg = fc::Default; - setFWidgetColors().term_bg = fc::Default; + getColorTheme()->term_fg = fc::Default; + getColorTheme()->term_bg = fc::Default; } //---------------------------------------------------------------------- diff --git a/examples/transparent.cpp b/examples/transparent.cpp index e9f23fc2..67ef2fd1 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -94,8 +94,8 @@ void Transparent::draw() if ( type == shadow ) { - const auto& wc = getFWidgetColors(); - print() << FColorPair {wc.shadow_bg, wc.shadow_fg} + const auto& wc = getColorTheme(); + print() << FColorPair {wc->shadow_bg, wc->shadow_fg} << FStyle {fc::ColorOverlay}; } else if ( type == inherit_background ) diff --git a/examples/windows.cpp b/examples/windows.cpp index 6aaab8be..f53a7f77 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -68,30 +68,30 @@ class SmallWindow final : public finalcut::FDialog SmallWindow::SmallWindow (finalcut::FWidget* parent) : finalcut::FDialog{parent} { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const wchar_t arrow_up = fc::BlackUpPointingTriangle; const wchar_t arrow_down = fc::BlackDownPointingTriangle; left_arrow = arrow_up; - left_arrow.setForegroundColor (wc.label_inactive_fg); + left_arrow.setForegroundColor (wc->label_inactive_fg); left_arrow.setEmphasis(); left_arrow.ignorePadding(); left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1}); right_arrow = arrow_up; - right_arrow.setForegroundColor (wc.label_inactive_fg); + right_arrow.setForegroundColor (wc->label_inactive_fg); right_arrow.setEmphasis(); right_arrow.ignorePadding(); right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1}); top_left_label = "menu"; - top_left_label.setForegroundColor (wc.label_inactive_fg); + top_left_label.setForegroundColor (wc->label_inactive_fg); top_left_label.setEmphasis(); top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1}); top_right_label = "zoom"; top_right_label.setAlignment (fc::alignRight); - top_right_label.setForegroundColor (wc.label_inactive_fg); + top_right_label.setForegroundColor (wc->label_inactive_fg); top_right_label.setEmphasis(); top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1}); @@ -100,7 +100,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent) bottom_label_text += arrow_down; bottom_label = bottom_label_text; bottom_label.setAlignment (fc::alignRight); - bottom_label.setForegroundColor (wc.label_inactive_fg); + bottom_label.setForegroundColor (wc->label_inactive_fg); bottom_label.setEmphasis(); bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3}); } diff --git a/src/fapplication.cpp b/src/fapplication.cpp index c8380954..eb4710a1 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -120,6 +120,10 @@ FApplication::FLogPtr& FApplication::getLog() { // Global logger object static FLogPtr* logger = new FLogPtr(); + + if ( logger && logger->get() == nullptr ) + *logger = std::make_shared(); + return *logger; } @@ -375,7 +379,6 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time) mouse->setDblclickInterval (dblclick_time); // Initialize logging - setLog (std::make_shared()); getLog()->setLineEnding(FLog::CRLF); } @@ -484,7 +487,7 @@ inline FStartOptions& FApplication::getStartOptions() //---------------------------------------------------------------------- inline void FApplication::destroyLog() { - FLogPtr* logger = &(getLog()); + const FLogPtr* logger = &(getLog()); delete logger; } @@ -1165,7 +1168,8 @@ void FApplication::performTimerAction (FObject* receiver, FEvent* event) } //---------------------------------------------------------------------- -bool FApplication::isEventProcessable (const FObject* receiver, const FEvent* event ) +bool FApplication::isEventProcessable ( const FObject* receiver + , const FEvent* event ) { if ( ! receiver->isWidget() ) // No restrictions for non-widgets return true; diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 4b2f792c..498c201b 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -218,9 +218,9 @@ void FButton::hide() } else { - auto wc = getFWidgetColors(); - fg = wc.dialog_fg; - bg = wc.dialog_bg; + const auto& wc = getColorTheme(); + fg = wc->dialog_fg; + bg = wc->dialog_bg; } setColor (fg, bg); @@ -387,9 +387,9 @@ void FButton::onFocusOut (FFocusEvent*) //---------------------------------------------------------------------- void FButton::init() { - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.button_active_fg); - setBackgroundColor (wc.button_active_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->button_active_fg); + setBackgroundColor (wc->button_active_bg); setShadow(); if ( ! text.isEmpty() ) diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index b20a01a1..54a35c0e 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -196,9 +196,9 @@ void FButtonGroup::hide() } else { - const auto& wc = getFWidgetColors(); - fg = wc.dialog_fg; - bg = wc.dialog_bg; + const auto& wc = getColorTheme(); + fg = wc->dialog_fg; + bg = wc->dialog_bg; } setColor (fg, bg); @@ -427,9 +427,9 @@ bool FButtonGroup::isRadioButton (const FToggleButton* button) const //---------------------------------------------------------------------- void FButtonGroup::init() { - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.label_fg); - setBackgroundColor (wc.label_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->label_fg); + setBackgroundColor (wc->label_bg); setMinimumSize (FSize{7, 3}); buttonlist.clear(); // no buttons yet } @@ -438,7 +438,7 @@ void FButtonGroup::init() void FButtonGroup::drawText ( const FString& label_text , std::size_t hotkeypos ) { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const std::size_t column_width = getColumnWidth(label_text); std::size_t length = label_text.getLength(); bool ellipsis{false}; @@ -455,15 +455,15 @@ void FButtonGroup::drawText ( const FString& label_text setReverse(true); if ( isEnabled() ) - setColor(wc.label_emphasis_fg, wc.label_bg); + setColor(wc->label_emphasis_fg, wc->label_bg); else - setColor(wc.label_inactive_fg, wc.label_inactive_bg); + setColor(wc->label_inactive_fg, wc->label_inactive_bg); for (std::size_t z{0}; z < length; z++) { if ( (z == hotkeypos) && getFlags().active ) { - setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); + setColor (wc->label_hotkey_fg, wc->label_hotkey_bg); if ( ! getFlags().no_underline ) setUnderline(); @@ -473,14 +473,14 @@ void FButtonGroup::drawText ( const FString& label_text if ( ! getFlags().no_underline ) unsetUnderline(); - setColor (wc.label_emphasis_fg, wc.label_bg); + setColor (wc->label_emphasis_fg, wc->label_bg); } else print (label_text[z]); } if ( ellipsis ) // Print ellipsis - print() << FColorPair {wc.label_ellipsis_fg, wc.label_bg} << ".."; + print() << FColorPair {wc->label_ellipsis_fg, wc->label_bg} << ".."; if ( FTerm::isMonochron() ) setReverse(true); diff --git a/src/fcombobox.cpp b/src/fcombobox.cpp index 28aec7b2..c3471847 100644 --- a/src/fcombobox.cpp +++ b/src/fcombobox.cpp @@ -124,8 +124,8 @@ void FDropDownListBox::init() void FDropDownListBox::draw() { // Fill the background - const auto& wc = getFWidgetColors(); - setColor (wc.menu_active_fg, wc.menu_active_bg); + const auto& wc = getColorTheme(); + setColor (wc->menu_active_fg, wc->menu_active_bg); if ( FTerm::isMonochron() ) setReverse(true); @@ -140,9 +140,9 @@ void FDropDownListBox::draw() //---------------------------------------------------------------------- void FDropDownListBox::drawShadow() { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); finalcut::drawShadow(this); - setColor (wc.shadow_fg, wc.shadow_bg); + setColor (wc->shadow_fg, wc->shadow_bg); print() << FPoint{int(getWidth()) + 1, 1} << fc::FullBlock; // █ } @@ -533,16 +533,16 @@ void FComboBox::initCallbacks() //---------------------------------------------------------------------- void FComboBox::draw() { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const FColorPair button_color = [this, &wc] () { if ( list_window.isEmpty() ) - return FColorPair { wc.scrollbar_button_inactive_fg - , wc.scrollbar_button_inactive_bg }; + return FColorPair { wc->scrollbar_button_inactive_fg + , wc->scrollbar_button_inactive_bg }; else - return FColorPair { wc.scrollbar_button_fg - , wc.scrollbar_button_bg }; + return FColorPair { wc->scrollbar_button_fg + , wc->scrollbar_button_bg }; }(); print() << FPoint{int(getWidth()) - nf, 1} diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 26d41583..eeb46d5a 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -800,9 +800,9 @@ void FDialog::init() addDialog(this); setActiveWindow(this); setTransparentShadow(); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); auto old_focus = FWidget::getFocusWidget(); if ( old_focus ) @@ -924,8 +924,8 @@ void FDialog::drawBorder() if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() ) && ! isZoomed() ) { - const auto& wc = getFWidgetColors(); - setColor (wc.dialog_resize_fg, getBackgroundColor()); + const auto& wc = getColorTheme(); + setColor (wc->dialog_resize_fg, getBackgroundColor()); } else setColor(); @@ -983,12 +983,12 @@ void FDialog::drawBarButton() { // Print the title button print() << FPoint{1, 1}; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( dialog_menu && dialog_menu->isShown() ) - setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); + setColor (wc->titlebar_button_focus_fg, wc->titlebar_button_focus_bg); else - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); + setColor (wc->titlebar_button_fg, wc->titlebar_button_bg); if ( FTerm::isMonochron() ) { @@ -1034,12 +1034,12 @@ void FDialog::drawZoomButton() if ( ! isResizeable() ) return; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( zoom_button_pressed ) - setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg); + setColor (wc->titlebar_button_focus_fg, wc->titlebar_button_focus_bg); else - setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); + setColor (wc->titlebar_button_fg, wc->titlebar_button_bg); if ( isZoomed() ) drawRestoreSizeButton(); @@ -1101,15 +1101,15 @@ void FDialog::drawTextBar() // Fill with spaces (left of the title) std::size_t center_offset{0}; std::size_t x{1}; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( FTerm::getMaxColor() < 16 ) setBold(); if ( isWindowActive() || (dialog_menu && dialog_menu->isShown()) ) - setColor (wc.titlebar_active_fg, wc.titlebar_active_bg); + setColor (wc->titlebar_active_fg, wc->titlebar_active_bg); else - setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); + setColor (wc->titlebar_inactive_fg, wc->titlebar_inactive_bg); const auto width = getWidth(); const auto zoom_btn = getZoomButtonWidth(); diff --git a/src/flabel.cpp b/src/flabel.cpp index dbeb5d48..dc3f143f 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -256,9 +256,9 @@ void FLabel::init() } else { - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); } } @@ -416,8 +416,8 @@ void FLabel::printLine (FString& line) if ( z == hotkeypos && getFlags().active ) { - const auto& wc = getFWidgetColors(); - setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); + const auto& wc = getColorTheme(); + setColor (wc->label_hotkey_fg, wc->label_hotkey_bg); if ( ! getFlags().no_underline ) setUnderline(); diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 5c37740a..640c7a42 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -99,26 +99,26 @@ const FLineEdit& FLineEdit::operator >> (FString& s) //---------------------------------------------------------------------- bool FLineEdit::setEnable (bool enable) { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); FWidget::setEnable(enable); if ( enable ) { if ( hasFocus() ) { - setForegroundColor (wc.inputfield_active_focus_fg); - setBackgroundColor (wc.inputfield_active_focus_bg); + setForegroundColor (wc->inputfield_active_focus_fg); + setBackgroundColor (wc->inputfield_active_focus_bg); } else { - setForegroundColor (wc.inputfield_active_fg); - setBackgroundColor (wc.inputfield_active_bg); + setForegroundColor (wc->inputfield_active_fg); + setBackgroundColor (wc->inputfield_active_bg); } } else { - setForegroundColor (wc.inputfield_inactive_fg); - setBackgroundColor (wc.inputfield_inactive_bg); + setForegroundColor (wc->inputfield_inactive_fg); + setBackgroundColor (wc->inputfield_inactive_bg); } return enable; @@ -131,17 +131,17 @@ bool FLineEdit::setFocus (bool enable) if ( isEnabled() ) { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( enable ) { - setForegroundColor (wc.inputfield_active_focus_fg); - setBackgroundColor (wc.inputfield_active_focus_bg); + setForegroundColor (wc->inputfield_active_focus_fg); + setBackgroundColor (wc->inputfield_active_focus_bg); } else { - setForegroundColor (wc.inputfield_active_fg); - setBackgroundColor (wc.inputfield_active_bg); + setForegroundColor (wc->inputfield_active_fg); + setBackgroundColor (wc->inputfield_active_bg); } } @@ -655,7 +655,7 @@ void FLineEdit::adjustSize() //---------------------------------------------------------------------- void FLineEdit::init() { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); label->setAccelWidget(this); if ( isReadOnly() ) @@ -669,19 +669,19 @@ void FLineEdit::init() { if ( hasFocus() ) { - setForegroundColor (wc.inputfield_active_focus_fg); - setBackgroundColor (wc.inputfield_active_focus_bg); + setForegroundColor (wc->inputfield_active_focus_fg); + setBackgroundColor (wc->inputfield_active_focus_bg); } else { - setForegroundColor (wc.inputfield_active_fg); - setBackgroundColor (wc.inputfield_active_bg); + setForegroundColor (wc->inputfield_active_fg); + setBackgroundColor (wc->inputfield_active_bg); } } else // inactive { - setForegroundColor (wc.inputfield_inactive_fg); - setBackgroundColor (wc.inputfield_inactive_bg); + setForegroundColor (wc->inputfield_inactive_fg); + setBackgroundColor (wc->inputfield_inactive_bg); } } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 808ec4d7..c718aa0f 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -274,8 +274,8 @@ void FListBox::clear() hbar->hide(); // clear list from screen - const auto& wc = getFWidgetColors(); - setColor (wc.list_fg, wc.list_bg); + const auto& wc = getColorTheme(); + setColor (wc->list_fg, wc->list_bg); const std::size_t size = getWidth() - 2; drawBorder(); drawHeadline(); @@ -655,9 +655,9 @@ void FListBox::init() initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange); initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange); setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); nf_offset = FTerm::isNewFont() ? 1 : 0; setTopPadding(1); setLeftPadding(1); @@ -792,12 +792,12 @@ void FListBox::drawHeadline() const FString txt{" " + text + " "}; const auto column_width = getColumnWidth(txt); print() << FPoint{2, 1}; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( isEnabled() ) - setColor(wc.label_emphasis_fg, wc.label_bg); + setColor(wc->label_emphasis_fg, wc->label_bg); else - setColor(wc.label_inactive_fg, wc.label_inactive_bg); + setColor(wc->label_inactive_fg, wc->label_inactive_bg); if ( column_width <= getClientWidth() ) print (txt); @@ -805,7 +805,7 @@ void FListBox::drawHeadline() { // Print ellipsis print() << getColumnSubString (text, 1, getClientWidth() - 2) - << FColorPair {wc.label_ellipsis_fg, wc.label_bg} << ".."; + << FColorPair {wc->label_ellipsis_fg, wc->label_bg} << ".."; } } @@ -870,7 +870,7 @@ inline void FListBox::drawListLine ( int y , bool serach_mark ) { const std::size_t inc_len = inc_search.getLength(); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const bool isCurrentLine( y + yoffset + 1 == int(current) ); const std::size_t first = std::size_t(xoffset) + 1; const std::size_t max_width = getWidth() - nf_offset - 4; @@ -883,14 +883,14 @@ inline void FListBox::drawListLine ( int y print (' '); if ( serach_mark ) - setColor ( wc.current_inc_search_element_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_inc_search_element_fg + , wc->current_element_focus_bg ); for (std::size_t i{0}; i < element.getLength(); i++) { if ( serach_mark && i == inc_len && getFlags().focus ) - setColor ( wc.current_element_focus_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_element_focus_fg + , wc->current_element_focus_bg ); print (element[i]); } @@ -945,17 +945,17 @@ inline void FListBox::drawListBracketsLine ( int y std::size_t column_width = getColumnWidth(element); const std::size_t text_width = getColumnWidth(getString(iter)); std::size_t i{0}; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); for (; i < element.getLength(); i++) { if ( serach_mark && i == 0 ) - setColor ( wc.current_inc_search_element_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_inc_search_element_fg + , wc->current_element_focus_bg ); if ( serach_mark && i == inc_len ) - setColor ( wc.current_element_focus_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_element_focus_fg + , wc->current_element_focus_bg ); print (element[i]); } @@ -964,8 +964,8 @@ inline void FListBox::drawListBracketsLine ( int y && std::size_t(xoffset) <= text_width ) { if ( serach_mark && i == inc_len ) - setColor ( wc.current_element_focus_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_element_focus_fg + , wc->current_element_focus_bg ); printRightBracket (iter->brackets); column_width++; @@ -990,7 +990,7 @@ inline void FListBox::setLineAttributes ( int y const bool isCurrentLine( y + yoffset + 1 == int(current) ); const std::size_t inc_len = inc_search.getLength(); const std::size_t inc_width = getColumnWidth(inc_search); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); print() << FPoint{2, 2 + int(y)}; if ( isLineSelected ) @@ -998,14 +998,14 @@ inline void FListBox::setLineAttributes ( int y if ( FTerm::isMonochron() ) setBold(); else - setColor (wc.selected_list_fg, wc.selected_list_bg); + setColor (wc->selected_list_fg, wc->selected_list_bg); } else { if ( FTerm::isMonochron() ) unsetBold(); else - setColor (wc.list_fg, wc.list_bg); + setColor (wc->list_fg, wc->list_bg); } if ( isCurrentLine ) @@ -1018,11 +1018,11 @@ inline void FListBox::setLineAttributes ( int y if ( FTerm::isMonochron() ) setBold(); else if ( getFlags().focus ) - setColor ( wc.selected_current_element_focus_fg - , wc.selected_current_element_focus_bg ); + setColor ( wc->selected_current_element_focus_fg + , wc->selected_current_element_focus_bg ); else - setColor ( wc.selected_current_element_fg - , wc.selected_current_element_bg ); + setColor ( wc->selected_current_element_fg + , wc->selected_current_element_bg ); setCursorPos ({3, 2 + int(y)}); // first character } @@ -1033,8 +1033,8 @@ inline void FListBox::setLineAttributes ( int y if ( getFlags().focus ) { - setColor ( wc.current_element_focus_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_element_focus_fg + , wc->current_element_focus_bg ); const int b = ( lineHasBrackets ) ? 1: 0; if ( inc_len > 0 ) // incremental search @@ -1047,8 +1047,8 @@ inline void FListBox::setLineAttributes ( int y setCursorPos ({3 + b, 2 + int(y)}); // first character } else - setColor ( wc.current_element_fg - , wc.current_element_bg ); + setColor ( wc->current_element_fg + , wc->current_element_bg ); } if ( FTerm::isMonochron() ) diff --git a/src/flistview.cpp b/src/flistview.cpp index 133e3b99..eff0293a 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1523,9 +1523,9 @@ void FListView::init() root = selflist.begin(); getNullIterator() = selflist.end(); setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); nf_offset = FTerm::isNewFont() ? 1 : 0; setTopPadding(1); setLeftPadding(1); @@ -1876,8 +1876,8 @@ void FListView::clearList() { // Clear list from terminal screen - const auto& wc = getFWidgetColors(); - setColor (wc.list_fg, wc.list_bg); + const auto& wc = getColorTheme(); + setColor (wc->list_fg, wc->list_bg); const std::size_t size = getWidth() - 2; drawBorder(); drawHeadlines(); @@ -1897,8 +1897,8 @@ void FListView::clearList() inline void FListView::setLineAttributes ( bool is_current , bool is_focus ) { - const auto& wc = getFWidgetColors(); - setColor (wc.list_fg, wc.list_bg); + const auto& wc = getColorTheme(); + setColor (wc->list_fg, wc->list_bg); if ( is_current ) { @@ -1910,12 +1910,12 @@ inline void FListView::setLineAttributes ( bool is_current if ( is_focus ) { - setColor ( wc.current_element_focus_fg - , wc.current_element_focus_bg ); + setColor ( wc->current_element_focus_fg + , wc->current_element_focus_bg ); } else - setColor ( wc.current_element_fg - , wc.current_element_bg ); + setColor ( wc->current_element_fg + , wc->current_element_bg ); if ( FTerm::isMonochron() ) setReverse(false); @@ -2039,12 +2039,12 @@ void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter) const headerItems::const_iterator first = header.begin(); const int column = int(std::distance(first, iter)) + 1; const bool has_sort_indicator( sort_column == column && ! hide_sort_indicator ); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( isEnabled() ) - setColor (wc.label_emphasis_fg, wc.label_bg); + setColor (wc->label_emphasis_fg, wc->label_bg); else - setColor (wc.label_inactive_fg, wc.label_inactive_bg); + setColor (wc->label_inactive_fg, wc->label_inactive_bg); if ( has_sort_indicator && column_width >= column_max - 1 && column_width > 1 ) { @@ -2169,11 +2169,11 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter // Print label ellipsis static constexpr int ellipsis_length = 2; const int width = iter->width; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); headerline << ' ' << getColumnSubString (text, 1, uInt(width - ellipsis_length)) - << FColorPair {wc.label_ellipsis_fg, wc.label_bg} + << FColorPair {wc->label_ellipsis_fg, wc->label_bg} << ".."; if ( iter == header.end() - 1 ) // Last element diff --git a/src/fmenu.cpp b/src/fmenu.cpp index c0a7b956..a525fc61 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -459,9 +459,9 @@ void FMenu::init(FWidget* parent) setMenuWidget(); hide(); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.menu_active_fg); - setBackgroundColor (wc.menu_active_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->menu_active_fg); + setBackgroundColor (wc->menu_active_bg); menuitem.setMenu(this); if ( parent ) @@ -1209,8 +1209,8 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev) void FMenu::draw() { // Fill the background - const auto& wc = getFWidgetColors(); - setColor (wc.menu_active_fg, wc.menu_active_bg); + const auto& wc = getColorTheme(); + setColor (wc->menu_active_fg, wc->menu_active_bg); if ( FTerm::isMonochron() ) setReverse(true); @@ -1243,9 +1243,9 @@ void FMenu::drawItems() //---------------------------------------------------------------------- inline void FMenu::drawSeparator (int y) { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); print() << FPoint{1, 2 + y} - << FColorPair{wc.menu_active_fg, wc.menu_active_bg}; + << FColorPair{wc->menu_active_fg, wc->menu_active_bg}; if ( FTerm::isMonochron() ) setReverse(true); @@ -1349,8 +1349,8 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item) } else { - const auto& wc = getFWidgetColors(); - setColor (wc.menu_inactive_fg, getBackgroundColor()); + const auto& wc = getColorTheme(); + setColor (wc->menu_inactive_fg, getBackgroundColor()); if ( FTerm::getEncoding() == fc::ASCII ) print ('-'); @@ -1382,8 +1382,8 @@ inline void FMenu::drawMenuText (menuText& data) if ( z == data.hotkeypos ) { - const auto& wc = getFWidgetColors(); - setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); + const auto& wc = getColorTheme(); + setColor (wc->menu_hotkey_fg, wc->menu_hotkey_bg); if ( ! data.no_underline ) setUnderline(); @@ -1448,22 +1448,22 @@ inline void FMenu::setLineAttributes (const FMenuItem* m_item, int y) { const bool is_enabled = m_item->isEnabled(); const bool is_selected = m_item->isSelected(); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( is_enabled ) { if ( is_selected ) { - setForegroundColor (wc.menu_active_focus_fg); - setBackgroundColor (wc.menu_active_focus_bg); + setForegroundColor (wc->menu_active_focus_fg); + setBackgroundColor (wc->menu_active_focus_bg); if ( FTerm::isMonochron() ) setReverse(false); } else { - setForegroundColor (wc.menu_active_fg); - setBackgroundColor (wc.menu_active_bg); + setForegroundColor (wc->menu_active_fg); + setBackgroundColor (wc->menu_active_bg); if ( FTerm::isMonochron() ) setReverse(true); @@ -1471,8 +1471,8 @@ inline void FMenu::setLineAttributes (const FMenuItem* m_item, int y) } else { - setForegroundColor (wc.menu_inactive_fg); - setBackgroundColor (wc.menu_inactive_bg); + setForegroundColor (wc->menu_inactive_fg); + setBackgroundColor (wc->menu_inactive_bg); if ( FTerm::isMonochron() ) setReverse(true); diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 449d9c80..cda7f659 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -65,9 +65,9 @@ void FMenuBar::resetMenu() //---------------------------------------------------------------------- void FMenuBar::hide() { - const auto& wc = getFWidgetColors(); - FColor fg = wc.term_fg; - FColor bg = wc.term_bg; + const auto& wc = getColorTheme(); + FColor fg = wc->term_fg; + FColor bg = wc->term_bg; setColor (fg, bg); print() << FPoint{1, 1} << FString{getDesktopWidth(), L' '}; updateTerminal(); @@ -249,9 +249,9 @@ void FMenuBar::init() addAccelerator (fc::Fkey_f10); addAccelerator (fc::Fckey_space); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.menu_active_fg); - setBackgroundColor (wc.menu_active_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->menu_active_fg); + setBackgroundColor (wc->menu_active_bg); unsetFocusable(); } @@ -529,8 +529,8 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x) drawEllipsis (txtdata, x); drawTrailingSpace (x); - const auto& wc = getFWidgetColors(); - setColor (wc.menu_active_fg, wc.menu_active_bg); + const auto& wc = getColorTheme(); + setColor (wc->menu_active_fg, wc->menu_active_bg); if ( FTerm::isMonochron() && is_enabled && is_selected ) setReverse(true); @@ -541,7 +541,7 @@ inline void FMenuBar::setLineAttributes (const FMenuItem* menuitem) { bool is_enabled = menuitem->isEnabled(); bool is_selected = menuitem->isSelected(); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( is_enabled ) { @@ -550,19 +550,19 @@ inline void FMenuBar::setLineAttributes (const FMenuItem* menuitem) if ( FTerm::isMonochron() ) setReverse(false); - setForegroundColor (wc.menu_active_focus_fg); - setBackgroundColor (wc.menu_active_focus_bg); + setForegroundColor (wc->menu_active_focus_fg); + setBackgroundColor (wc->menu_active_focus_bg); } else { - setForegroundColor (wc.menu_active_fg); - setBackgroundColor (wc.menu_active_bg); + setForegroundColor (wc->menu_active_fg); + setBackgroundColor (wc->menu_active_bg); } } else { - setForegroundColor (wc.menu_inactive_fg); - setBackgroundColor (wc.menu_inactive_bg); + setForegroundColor (wc->menu_inactive_fg); + setBackgroundColor (wc->menu_inactive_bg); } setColor(); @@ -607,8 +607,8 @@ inline void FMenuBar::drawMenuText (menuText& data) if ( z == data.hotkeypos ) { - const auto& wc = getFWidgetColors(); - setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); + const auto& wc = getColorTheme(); + setColor (wc->menu_hotkey_fg, wc->menu_hotkey_bg); if ( ! data.no_underline ) setUnderline(); diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 030274db..52a28250 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -155,8 +155,8 @@ void FProgressbar::drawProgressLabel() , parent_widget->getBackgroundColor() ); else { - const auto& wc = getFWidgetColors(); - setColor (wc.dialog_fg, wc.dialog_bg); + const auto& wc = getColorTheme(); + setColor (wc->dialog_fg, wc->dialog_bg); } if ( FTerm::isMonochron() ) @@ -199,10 +199,10 @@ std::size_t FProgressbar::drawProgressIndicator() if ( FTerm::isMonochron() ) setReverse(true); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const double length = double(bar_length * percentage) / 100; auto len = std::size_t(trunc(length)); - print() << FColorPair {wc.progressbar_fg, wc.progressbar_fg} + print() << FColorPair {wc->progressbar_fg, wc->progressbar_fg} << FString {len, fc::FullBlock}; // █ if ( len >= bar_length ) @@ -220,7 +220,7 @@ std::size_t FProgressbar::drawProgressIndicator() } else { - print() << FColorPair{wc.progressbar_fg, wc.progressbar_bg} + print() << FColorPair{wc->progressbar_fg, wc->progressbar_bg} << fc::LeftHalfBlock; // ▌ } @@ -234,8 +234,8 @@ void FProgressbar::drawProgressBackground (std::size_t len) // Draw the progress background const std::size_t bg_len = bar_length - len; - const auto& wc = getFWidgetColors(); - setColor (wc.progressbar_fg, wc.progressbar_bg); + const auto& wc = getColorTheme(); + setColor (wc->progressbar_fg, wc->progressbar_bg); if ( FTerm::getMaxColor() < 16 ) print() << FString {bg_len, fc::MediumShade}; // ▒ diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index b956cbcf..ecf0cd8c 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -459,8 +459,8 @@ void FScrollbar::draw() //---------------------------------------------------------------------- void FScrollbar::drawVerticalBar() { - const auto& wc = getFWidgetColors(); - setColor (wc.scrollbar_fg, wc.scrollbar_bg); + const auto& wc = getColorTheme(); + setColor (wc->scrollbar_fg, wc->scrollbar_bg); for (int z{1}; z <= slider_pos; z++) { @@ -468,7 +468,7 @@ void FScrollbar::drawVerticalBar() drawVerticalBackgroundLine(); } - setColor (wc.scrollbar_bg, wc.scrollbar_fg); + setColor (wc->scrollbar_bg, wc->scrollbar_fg); if ( FTerm::isMonochron() ) setReverse(false); @@ -486,7 +486,7 @@ void FScrollbar::drawVerticalBar() if ( FTerm::isMonochron() ) setReverse(true); - setColor (wc.scrollbar_fg, wc.scrollbar_bg); + setColor (wc->scrollbar_fg, wc->scrollbar_bg); for (int z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++) { @@ -520,8 +520,8 @@ inline void FScrollbar::drawVerticalBackgroundLine() //---------------------------------------------------------------------- void FScrollbar::drawHorizontalBar() { - const auto& wc = getFWidgetColors(); - setColor (wc.scrollbar_fg, wc.scrollbar_bg); + const auto& wc = getColorTheme(); + setColor (wc->scrollbar_fg, wc->scrollbar_bg); if ( FTerm::isNewFont() ) print() << FPoint{3, 1}; @@ -531,7 +531,7 @@ void FScrollbar::drawHorizontalBar() for (int z{0}; z < slider_pos; z++) drawHorizontalBackgroundColumn(); - setColor (wc.scrollbar_bg, wc.scrollbar_fg); + setColor (wc->scrollbar_bg, wc->scrollbar_fg); if ( FTerm::isMonochron() ) setReverse(false); @@ -542,7 +542,7 @@ void FScrollbar::drawHorizontalBar() if ( FTerm::isMonochron() ) setReverse(true); - setColor (wc.scrollbar_fg, wc.scrollbar_bg); + setColor (wc->scrollbar_fg, wc->scrollbar_bg); int z = slider_pos + int(slider_length) + 1; for (; z <= int(bar_length); z++) @@ -566,8 +566,8 @@ inline void FScrollbar::drawHorizontalBackgroundColumn() //---------------------------------------------------------------------- void FScrollbar::drawButtons() { - const auto& wc = getFWidgetColors(); - setColor (wc.scrollbar_button_fg, wc.scrollbar_button_bg); + const auto& wc = getColorTheme(); + setColor (wc->scrollbar_button_fg, wc->scrollbar_button_bg); if ( FTerm::isNewFont() ) { diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 134d6c6f..1408527f 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -712,9 +712,9 @@ void FScrollView::init (const FWidget* parent) initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange); initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange); mapKeyFunctions(); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); setGeometry (FPoint{1, 1}, FSize{4, 4}); setMinimumSize (FSize{4, 4}); const int xoffset_end = int(getScrollWidth() - getViewportWidth()); diff --git a/src/fspinbox.cpp b/src/fspinbox.cpp index e19e99bc..6b12e0c8 100644 --- a/src/fspinbox.cpp +++ b/src/fspinbox.cpp @@ -326,26 +326,26 @@ void FSpinBox::init() //---------------------------------------------------------------------- void FSpinBox::draw() { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); const FColorPair inc_button_color = [this, &wc] () { if ( value == max ) - return FColorPair { wc.scrollbar_button_inactive_fg - , wc.scrollbar_button_inactive_bg }; + return FColorPair { wc->scrollbar_button_inactive_fg + , wc->scrollbar_button_inactive_bg }; else - return FColorPair { wc.scrollbar_button_fg - , wc.scrollbar_button_bg }; + return FColorPair { wc->scrollbar_button_fg + , wc->scrollbar_button_bg }; }(); const FColorPair dec_button_color = [this, &wc] () { if ( value == min ) - return FColorPair { wc.scrollbar_button_inactive_fg - , wc.scrollbar_button_inactive_bg }; + return FColorPair { wc->scrollbar_button_inactive_fg + , wc->scrollbar_button_inactive_bg }; else - return FColorPair { wc.scrollbar_button_fg - , wc.scrollbar_button_bg }; + return FColorPair { wc->scrollbar_button_fg + , wc->scrollbar_button_bg }; }(); print() << FPoint{int(getWidth()) - 1, 1} diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 8b8c2326..a27b09c0 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -174,9 +174,9 @@ bool FStatusBar::hasActivatedKey() const //---------------------------------------------------------------------- void FStatusBar::hide() { - const auto& wc = getFWidgetColors(); - const FColor fg = wc.term_fg; - const FColor bg = wc.term_bg; + const auto& wc = getColorTheme(); + const FColor fg = wc->term_fg; + const FColor bg = wc->term_bg; setColor (fg, bg); print() << FPoint{1, 1} << FString{getDesktopWidth(), L' '}; updateTerminal(); @@ -210,8 +210,8 @@ void FStatusBar::drawMessage() if ( isLastActiveFocus ) space_offset = 0; - const auto& wc = getFWidgetColors(); - setColor (wc.statusbar_fg, wc.statusbar_bg); + const auto& wc = getColorTheme(); + setColor (wc->statusbar_fg, wc->statusbar_bg); setPrintPos ({x, 1}); if ( FTerm::isMonochron() ) @@ -513,9 +513,9 @@ void FStatusBar::init() if ( getRootWidget() ) getRootWidget()->setBottomPadding(1, true); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.statusbar_fg); - setBackgroundColor (wc.statusbar_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->statusbar_fg); + setBackgroundColor (wc->statusbar_bg); unsetFocusable(); } @@ -573,8 +573,8 @@ void FStatusBar::drawKeys() } else { - const auto& wc = getFWidgetColors(); - setColor (wc.statusbar_fg, wc.statusbar_bg); + const auto& wc = getColorTheme(); + setColor (wc->statusbar_fg, wc->statusbar_bg); for (; x <= int(screenWidth); x++) print (' '); @@ -595,13 +595,13 @@ void FStatusBar::drawKey (keyList::const_iterator iter) // Draw not active key const auto item = *iter; - const auto& wc = getFWidgetColors(); - setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg); + const auto& wc = getColorTheme(); + setColor (wc->statusbar_hotkey_fg, wc->statusbar_hotkey_bg); x++; print (' '); x += keyname_len; print (FTerm::getKeyName(item->getKey())); - setColor (wc.statusbar_fg, wc.statusbar_bg); + setColor (wc->statusbar_fg, wc->statusbar_bg); x++; print ('-'); const auto column_width = getColumnWidth (item->getText()); @@ -627,7 +627,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter) if ( FTerm::hasHalfBlockCharacter() ) { - setColor (wc.statusbar_active_fg, wc.statusbar_active_bg); + setColor (wc->statusbar_active_fg, wc->statusbar_active_bg); print (fc::LeftHalfBlock); // ▐ } else @@ -641,7 +641,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter) else if ( iter + 1 != key_list.end() && x < int(screenWidth) ) { // Not the last element - setColor (wc.statusbar_separator_fg, wc.statusbar_bg); + setColor (wc->statusbar_separator_fg, wc->statusbar_bg); x++; print (fc::BoxDrawingsVertical); // │ } @@ -657,14 +657,14 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter) if ( FTerm::isMonochron() ) setReverse(false); - const auto& wc = getFWidgetColors(); - setColor ( wc.statusbar_active_hotkey_fg - , wc.statusbar_active_hotkey_bg ); + const auto& wc = getColorTheme(); + setColor ( wc->statusbar_active_hotkey_fg + , wc->statusbar_active_hotkey_bg ); x++; print (' '); x += keyname_len; print (FTerm::getKeyName(item->getKey())); - setColor (wc.statusbar_active_fg, wc.statusbar_active_bg); + setColor (wc->statusbar_active_fg, wc->statusbar_active_bg); x++; print ('-'); const auto column_width = getColumnWidth (item->getText()); diff --git a/src/fstring.cpp b/src/fstring.cpp index 53dcc6dd..a2e9ffe7 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -45,21 +45,21 @@ const wchar_t FString::const_null_char{L'\0'}; FString::FString (int len) { if ( len > 0 ) - initLength(std::size_t(len)); + _initLength(std::size_t(len)); else - initLength(0); + _initLength(0); } //---------------------------------------------------------------------- FString::FString (std::size_t len) { - initLength(len); + _initLength(len); } //---------------------------------------------------------------------- FString::FString (std::size_t len, wchar_t c) { - initLength(len); + _initLength(len); const wchar_t* ps = string; wchar_t* pe = string + len; @@ -106,7 +106,7 @@ FString::FString (const std::string& s) { if ( ! s.empty() ) { - const wchar_t* wc_string = c_to_wc_str(s.c_str()); + const wchar_t* wc_string = _to_wcstring(s.c_str()); _assign(wc_string); delete[] wc_string; } @@ -117,7 +117,7 @@ FString::FString (const char s[]) { if ( s ) { - const wchar_t* wc_string = c_to_wc_str(s); + const wchar_t* wc_string = _to_wcstring(s); _assign( wc_string ); delete[] wc_string; } @@ -421,9 +421,9 @@ const char* FString::c_str() const // Returns a constant c-string if ( length > 0 ) - return wc_to_c_str (string); + return _to_cstring(string); else if ( string ) - return const_cast(""); + return ""; else return nullptr; } @@ -434,7 +434,7 @@ char* FString::c_str() // Returns a c-string if ( length > 0 ) - return wc_to_c_str (string); + return const_cast(_to_cstring(string)); else if ( string ) return const_cast(""); else @@ -781,12 +781,12 @@ FStringList FString::split (const FString& delimiter) return string_list; wchar_t* rest{nullptr}; - const wchar_t* token = extractToken(&rest, s.string, delimiter.wc_str()); + const wchar_t* token = _extractToken(&rest, s.string, delimiter.wc_str()); while ( token ) { string_list.push_back (FString{token}); - token = extractToken (&rest, nullptr, delimiter.wc_str()); + token = _extractToken (&rest, nullptr, delimiter.wc_str()); } return string_list; @@ -1241,7 +1241,7 @@ bool FString::includes (const FString& s) const // private methods of FString //---------------------------------------------------------------------- -inline void FString::initLength (std::size_t len) +inline void FString::_initLength (std::size_t len) { if ( len == 0 ) return; @@ -1426,7 +1426,7 @@ void FString::_remove (std::size_t pos, std::size_t len) } //---------------------------------------------------------------------- -inline char* FString::wc_to_c_str (const wchar_t s[]) const +inline const char* FString::_to_cstring (const wchar_t s[]) const { if ( ! s ) // handle NULL string return nullptr; @@ -1476,14 +1476,14 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const { delete[](c_string); c_string = nullptr; - return const_cast(""); + return ""; } return c_string; } //---------------------------------------------------------------------- -inline wchar_t* FString::c_to_wc_str (const char s[]) const +inline const wchar_t* FString::_to_wcstring (const char s[]) const { if ( ! s ) // handle NULL string return nullptr; @@ -1548,9 +1548,9 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const } //---------------------------------------------------------------------- -inline wchar_t* FString::extractToken ( wchar_t* rest[] - , const wchar_t s[] - , const wchar_t delim[] ) +inline const wchar_t* FString::_extractToken ( wchar_t* rest[] + , const wchar_t s[] + , const wchar_t delim[] ) { wchar_t* token = ( s ) ? const_cast(s) : *rest; @@ -1663,12 +1663,12 @@ std::ostream& operator << (std::ostream& outstr, const FString& s) if ( s.length > 0 ) { - outstr << s.wc_to_c_str(s.string); + outstr << s._to_cstring(s.string); } else if ( width > 0 ) { const FString fill_str{width, wchar_t(outstr.fill())}; - outstr << s.wc_to_c_str(fill_str.string); + outstr << s._to_cstring(fill_str.string); } return outstr; @@ -1679,7 +1679,7 @@ std::istream& operator >> (std::istream& instr, FString& s) { char buf[FString::INPBUFFER + 1]{}; instr.getline (buf, FString::INPBUFFER); - const wchar_t* wc_str = s.c_to_wc_str(buf); + const wchar_t* wc_str = s._to_wcstring(buf); if ( wc_str ) { diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 6bef30ec..1db06e7d 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -143,7 +143,7 @@ inline void FSwitch::drawChecked() { wchar_t on[6]{L" On "}; const wchar_t off[6]{L" Off "}; - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( hasFocus() && ! button_pressed ) { @@ -155,17 +155,17 @@ inline void FSwitch::drawChecked() else if ( FTerm::getMaxColor() < 16 ) { setBold(true); - setColor (wc.button_active_focus_fg, wc.button_active_focus_bg); + setColor (wc->button_active_focus_fg, wc->button_active_focus_bg); } else - setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + setColor (wc->button_hotkey_fg, wc->button_active_focus_bg); } else { if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 ) - setColor (wc.button_active_focus_fg, wc.button_active_bg); + setColor (wc->button_active_focus_fg, wc->button_active_bg); else - setColor (wc.button_hotkey_fg, wc.button_active_bg); + setColor (wc->button_hotkey_fg, wc->button_active_bg); } if ( FTerm::isMonochron() ) @@ -179,7 +179,7 @@ inline void FSwitch::drawChecked() if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 ) setBold(false); - print() << FColorPair{wc.button_inactive_fg, wc.button_inactive_bg} + print() << FColorPair{wc->button_inactive_fg, wc->button_inactive_bg} << off; if ( FTerm::isMonochron() ) @@ -194,8 +194,8 @@ inline void FSwitch::drawUnchecked() const wchar_t on[6]{L" On "}; wchar_t off[6]{L" Off "}; - const auto& wc = getFWidgetColors(); - setColor (wc.button_inactive_fg, wc.button_inactive_bg); + const auto& wc = getColorTheme(); + setColor (wc->button_inactive_fg, wc->button_inactive_bg); if ( FTerm::isMonochron() ) setReverse(true); @@ -212,17 +212,17 @@ inline void FSwitch::drawUnchecked() else if ( FTerm::getMaxColor() < 16 ) { setBold(true); - setColor (wc.button_active_focus_fg, wc.button_active_focus_bg); + setColor (wc->button_active_focus_fg, wc->button_active_focus_bg); } else - setColor (wc.button_hotkey_fg, wc.button_active_focus_bg); + setColor (wc->button_hotkey_fg, wc->button_active_focus_bg); } else { if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 ) - setColor (wc.button_active_focus_fg, wc.button_active_bg); + setColor (wc->button_active_focus_fg, wc->button_active_bg); else - setColor (wc.button_hotkey_fg, wc.button_active_bg); + setColor (wc->button_hotkey_fg, wc->button_active_bg); } if ( FTerm::isMonochron() ) diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index 7e361cd1..a1e4ff2a 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -132,15 +132,17 @@ void FTermcap::termcapError (int status) { const char* termtype = fterm_data->getTermType(); log << FLog::Error - << "Unknown terminal: " << termtype << "\n" - << "Check the TERM environment variable\n" - << "Also make sure that the terminal\n" - << "is defined in the termcap/terminfo database.\n"; + << "Unknown terminal: \"" << termtype << "\". " + << "Check the TERM environment variable. " + << "Also make sure that the terminal " + << "is defined in the termcap/terminfo database." + << std::endl; std::abort(); } else if ( status == db_not_found ) { - log << "The termcap/terminfo database could not be found.\n"; + log << "The termcap/terminfo database could not be found." + << std::endl; std::abort(); } } diff --git a/src/ftextview.cpp b/src/ftextview.cpp index b23fae45..7c6bb4dd 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -569,9 +569,9 @@ void FTextView::init() { initScrollbar (vbar, fc::vertical, this, &FTextView::cb_vbarChange); initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_hbarChange); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.dialog_fg); - setBackgroundColor (wc.dialog_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->dialog_fg); + setBackgroundColor (wc->dialog_bg); nf_offset = FTerm::isNewFont() ? 1 : 0; setTopPadding(1); setLeftPadding(1); diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index eff08b2b..a1c2cda8 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -121,7 +121,7 @@ bool FToggleButton::setNoUnderline (bool enable) bool FToggleButton::setEnable (bool enable) { FWidget::setEnable(enable); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( enable ) { @@ -129,20 +129,20 @@ bool FToggleButton::setEnable (bool enable) if ( hasFocus() ) { - setForegroundColor (wc.toggle_button_active_focus_fg); - setBackgroundColor (wc.toggle_button_active_focus_bg); + setForegroundColor (wc->toggle_button_active_focus_fg); + setBackgroundColor (wc->toggle_button_active_focus_bg); } else { - setForegroundColor (wc.toggle_button_active_fg); - setBackgroundColor (wc.toggle_button_active_bg); + setForegroundColor (wc->toggle_button_active_fg); + setBackgroundColor (wc->toggle_button_active_bg); } } else { delAccelerator(); - setForegroundColor (wc.toggle_button_inactive_fg); - setBackgroundColor (wc.toggle_button_inactive_bg); + setForegroundColor (wc->toggle_button_inactive_fg); + setBackgroundColor (wc->toggle_button_inactive_bg); } return enable; @@ -155,20 +155,20 @@ bool FToggleButton::setFocus (bool enable) if ( isEnabled() ) { - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( enable ) { if ( isRadioButton() ) focus_inside_group = false; - setForegroundColor (wc.toggle_button_active_focus_fg); - setBackgroundColor (wc.toggle_button_active_focus_bg); + setForegroundColor (wc->toggle_button_active_focus_fg); + setBackgroundColor (wc->toggle_button_active_focus_bg); } else { - setForegroundColor (wc.toggle_button_active_fg); - setBackgroundColor (wc.toggle_button_active_bg); + setForegroundColor (wc->toggle_button_active_fg); + setBackgroundColor (wc->toggle_button_active_bg); } } @@ -497,25 +497,25 @@ void FToggleButton::setGroup (FButtonGroup* btngroup) void FToggleButton::init() { setGeometry (FPoint{1, 1}, FSize{4, 1}, false); // initialize geometry values - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( isEnabled() ) { if ( hasFocus() ) { - setForegroundColor (wc.toggle_button_active_focus_fg); - setBackgroundColor (wc.toggle_button_active_focus_bg); + setForegroundColor (wc->toggle_button_active_focus_fg); + setBackgroundColor (wc->toggle_button_active_focus_bg); } else { - setForegroundColor (wc.toggle_button_active_fg); - setBackgroundColor (wc.toggle_button_active_bg); + setForegroundColor (wc->toggle_button_active_fg); + setBackgroundColor (wc->toggle_button_active_bg); } } else // inactive { - setForegroundColor (wc.label_inactive_fg); - setBackgroundColor (wc.label_inactive_bg); + setForegroundColor (wc->label_inactive_fg); + setBackgroundColor (wc->label_inactive_bg); } } @@ -525,18 +525,18 @@ void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos) if ( FTerm::isMonochron() ) setReverse(true); - const auto& wc = getFWidgetColors(); + const auto& wc = getColorTheme(); if ( isEnabled() ) - setColor (wc.label_fg, wc.label_bg); + setColor (wc->label_fg, wc->label_bg); else - setColor (wc.label_inactive_fg, wc.label_inactive_bg); + setColor (wc->label_inactive_fg, wc->label_inactive_bg); for (std::size_t z{0}; z < label_text.getLength(); z++) { if ( (z == hotkeypos) && flags.active ) { - setColor (wc.label_hotkey_fg, wc.label_hotkey_bg); + setColor (wc->label_hotkey_fg, wc->label_hotkey_bg); if ( ! flags.no_underline ) setUnderline(); @@ -546,7 +546,7 @@ void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos) if ( ! flags.no_underline ) unsetUnderline(); - setColor (wc.label_fg, wc.label_bg); + setColor (wc->label_fg, wc->label_bg); } else print (label_text[z]); diff --git a/src/ftooltip.cpp b/src/ftooltip.cpp index 570b24d0..f921ef14 100644 --- a/src/ftooltip.cpp +++ b/src/ftooltip.cpp @@ -107,9 +107,9 @@ void FToolTip::init() // initialize geometry values setGeometry (FPoint{1, 1}, FSize{3, 3}, false); setMinimumSize (FSize{3, 3}); - const auto& wc = getFWidgetColors(); - setForegroundColor (wc.tooltip_fg); - setBackgroundColor (wc.tooltip_bg); + const auto& wc = getColorTheme(); + setForegroundColor (wc->tooltip_fg); + setBackgroundColor (wc->tooltip_bg); calculateDimensions(); } diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 13769994..b0218ff5 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -48,7 +48,6 @@ FWidget::FWidgetList* FWidget::window_list{nullptr}; FWidget::FWidgetList* FWidget::dialog_list{nullptr}; FWidget::FWidgetList* FWidget::always_on_top_list{nullptr}; FWidget::FWidgetList* FWidget::close_widget{nullptr}; -FWidgetColors FWidget::wcolors{}; bool FWidget::init_desktop{false}; bool FWidget::hideable{false}; uInt FWidget::modal_dialog_counter{}; @@ -939,7 +938,8 @@ void FWidget::redraw() { startTerminalUpdate(); // clean desktop - setColor (wcolors.term_fg, wcolors.term_bg); + auto color_theme = getColorTheme(); + setColor (color_theme->term_fg, color_theme->term_bg); clearArea (getVirtualDesktop()); } else if ( ! isShown() ) @@ -1370,8 +1370,9 @@ void FWidget::hideArea (const FSize& size) } else { - fg = wcolors.dialog_fg; - bg = wcolors.dialog_bg; + auto color_theme = getColorTheme(); + fg = color_theme->dialog_fg; + bg = color_theme->dialog_bg; } setColor (fg, bg); @@ -1708,11 +1709,12 @@ void FWidget::initRootWidget() double_flatline_mask.left.resize (getHeight(), false); // Initialize default widget colors - setColorTheme(); + initColorTheme(); // Default foreground and background color of the desktop/terminal - foreground_color = wcolors.term_fg; - background_color = wcolors.term_bg; + auto color_theme = getColorTheme(); + foreground_color = color_theme->term_fg; + background_color = color_theme->term_bg; init_desktop = false; } @@ -1742,6 +1744,8 @@ void FWidget::finish() delete window_list; window_list = nullptr; } + + destroyColorTheme(); } //---------------------------------------------------------------------- @@ -1984,14 +1988,21 @@ void FWidget::drawChildren() } //---------------------------------------------------------------------- -void FWidget::setColorTheme() +void FWidget::initColorTheme() { // Sets the default color theme if ( FTerm::getMaxColor() < 16 ) // for 8 color mode - wcolors.set8ColorTheme(); + setColorTheme(); else - wcolors.set16ColorTheme(); + setColorTheme(); +} + +//---------------------------------------------------------------------- +void FWidget::destroyColorTheme() +{ + FWidgetColorsPtr* theme = &(getColorTheme()); + delete theme; } //---------------------------------------------------------------------- diff --git a/src/fwidget_functions.cpp b/src/fwidget_functions.cpp index 5620ba88..d97426d7 100644 --- a/src/fwidget_functions.cpp +++ b/src/fwidget_functions.cpp @@ -161,12 +161,12 @@ void drawTransparentShadow (FWidget* w) const std::size_t width = w->getWidth(); const std::size_t height = w->getHeight(); - const auto& wcolors = FWidget::wcolors; + const auto& wc = FWidget::getColorTheme(); w->print() << FStyle {fc::Transparent} << FPoint {int(width) + 1, 1} << " " << FStyle {fc::Reset} - << FColorPair {wcolors.shadow_bg, wcolors.shadow_fg} + << FColorPair {wc->shadow_bg, wc->shadow_fg} << FStyle {fc::ColorOverlay}; for (std::size_t y{1}; y < height; y++) @@ -178,7 +178,7 @@ void drawTransparentShadow (FWidget* w) << FPoint {1, int(height) + 1} << " " << FStyle {fc::Reset} - << FColorPair {wcolors.shadow_bg, wcolors.shadow_fg} + << FColorPair {wc->shadow_bg, wc->shadow_fg} << FStyle {fc::ColorOverlay} << FString {width, L' '} << FStyle {fc::Reset}; @@ -197,16 +197,16 @@ void drawBlockShadow (FWidget* w) const std::size_t width = w->getWidth(); const std::size_t height = w->getHeight(); - const auto& wcolors = FWidget::wcolors; + const auto& wc = FWidget::getColorTheme(); w->print() << FPoint {int(width) + 1, 1}; if ( w->isWindowWidget() ) { - w->print() << FColorPair {wcolors.shadow_fg, wcolors.shadow_bg} + w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg} << FStyle {fc::InheritBackground}; // current background color will be ignored } else if ( auto p = w->getParentWidget() ) - w->print() << FColorPair {wcolors.shadow_fg, p->getBackgroundColor()}; + w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()}; w->print (fc::LowerHalfBlock); // ▄ @@ -238,15 +238,15 @@ void clearShadow (FWidget* w) const std::size_t width = w->getWidth(); const std::size_t height = w->getHeight(); - const auto& wcolors = FWidget::wcolors; + const auto& wc = FWidget::getColorTheme(); if ( w->isWindowWidget() ) { - w->print() << FColorPair {wcolors.shadow_fg, wcolors.shadow_bg} + w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg} << FStyle {fc::InheritBackground}; // current background color will be ignored } else if ( auto p = w->getParentWidget() ) - w->print() << FColorPair {wcolors.shadow_fg, p->getBackgroundColor()}; + w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()}; if ( int(width) <= w->woffset.getX2() ) { @@ -275,12 +275,12 @@ void drawFlatBorder (FWidget* w) const std::size_t width = w->getWidth(); const std::size_t height = w->getHeight(); - const auto& wcolors = FWidget::wcolors; + const auto& wc = FWidget::getColorTheme(); if ( auto p = w->getParentWidget() ) - w->setColor (wcolors.dialog_fg, p->getBackgroundColor()); + w->setColor (wc->dialog_fg, p->getBackgroundColor()); else - w->setColor (wcolors.dialog_fg, wcolors.dialog_bg); + w->setColor (wc->dialog_fg, wc->dialog_bg); for (std::size_t y{0}; y < height; y++) { @@ -336,12 +336,12 @@ void clearFlatBorder (FWidget* w) const std::size_t width = w->getWidth(); const std::size_t height = w->getHeight(); - const auto& wcolors = FWidget::wcolors; + const auto& wc = FWidget::getColorTheme(); if ( auto p = w->getParentWidget() ) - w->setColor (wcolors.dialog_fg, p->getBackgroundColor()); + w->setColor (wc->dialog_fg, p->getBackgroundColor()); else - w->setColor (wcolors.dialog_fg, wcolors.dialog_bg); + w->setColor (wc->dialog_fg, wc->dialog_bg); for (std::size_t y{0}; y < height; y++) { diff --git a/src/fwidgetcolors.cpp b/src/fwidgetcolors.cpp index 6c3d3474..4bc0a6f2 100644 --- a/src/fwidgetcolors.cpp +++ b/src/fwidgetcolors.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018-2019 Markus Gans * +* Copyright 2018-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -31,9 +31,34 @@ namespace finalcut // class FWidgetColors //---------------------------------------------------------------------- -// public methods of FWidgetColors +// constructors and destructor //---------------------------------------------------------------------- -void FWidgetColors::set8ColorTheme() +FWidgetColors::FWidgetColors() +{ } + +//---------------------------------------------------------------------- +FWidgetColors::~FWidgetColors() +{ } + + +//---------------------------------------------------------------------- +// class default8ColorTheme +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +default8ColorTheme::default8ColorTheme() +{ + default8ColorTheme::setColorTheme(); +} + +//---------------------------------------------------------------------- +default8ColorTheme::~default8ColorTheme() +{ } + +// public methods of default8ColorTheme +//---------------------------------------------------------------------- +void default8ColorTheme::setColorTheme() { term_fg = fc::Black; term_bg = fc::Blue; @@ -123,8 +148,25 @@ void FWidgetColors::set8ColorTheme() progressbar_bg = fc::LightGray; } + //---------------------------------------------------------------------- -void FWidgetColors::set16ColorTheme() +// class default16ColorTheme +//---------------------------------------------------------------------- + +// constructors and destructor +//---------------------------------------------------------------------- +default16ColorTheme::default16ColorTheme() +{ + default16ColorTheme::setColorTheme(); +} + +//---------------------------------------------------------------------- +default16ColorTheme::~default16ColorTheme() +{ } + +// public methods of default16ColorTheme +//---------------------------------------------------------------------- +void default16ColorTheme::setColorTheme() { term_fg = fc::Black; term_bg = fc::LightBlue; diff --git a/src/include/final/fbutton.h b/src/include/final/fbutton.h index d06821ba..c5baccb2 100644 --- a/src/include/final/fbutton.h +++ b/src/include/final/fbutton.h @@ -157,13 +157,13 @@ class FButton : public FWidget bool click_animation{true}; int click_time{150}; int space_char{int(' ')}; - FColor button_fg{getFWidgetColors().button_active_fg}; - FColor button_bg{getFWidgetColors().button_active_bg}; - FColor button_hotkey_fg{getFWidgetColors().button_hotkey_fg}; - FColor button_focus_fg{getFWidgetColors().button_active_focus_fg}; - FColor button_focus_bg{getFWidgetColors().button_active_focus_bg}; - FColor button_inactive_fg{getFWidgetColors().button_inactive_fg}; - FColor button_inactive_bg{getFWidgetColors().button_inactive_bg}; + FColor button_fg{getColorTheme()->button_active_fg}; + FColor button_bg{getColorTheme()->button_active_bg}; + FColor button_hotkey_fg{getColorTheme()->button_hotkey_fg}; + FColor button_focus_fg{getColorTheme()->button_active_focus_fg}; + FColor button_focus_bg{getColorTheme()->button_active_focus_bg}; + FColor button_inactive_fg{getColorTheme()->button_inactive_fg}; + FColor button_inactive_bg{getColorTheme()->button_inactive_bg}; std::size_t hotkeypos{NOT_SET}; std::size_t indent{0}; std::size_t center_offset{0}; diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index a0a8fc97..20d55bbc 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -145,8 +145,8 @@ class FLabel : public FWidget std::size_t align_offset{0}; std::size_t hotkeypos{NOT_SET}; std::size_t column_width{0}; - FColor emphasis_color{getFWidgetColors().label_emphasis_fg}; - FColor ellipsis_color{getFWidgetColors().label_ellipsis_fg}; + FColor emphasis_color{getColorTheme()->label_emphasis_fg}; + FColor ellipsis_color{getColorTheme()->label_ellipsis_fg}; bool multiline{false}; bool emphasis{false}; bool reverse_mode{false}; diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index 39c983f0..7ee09d56 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -153,7 +153,7 @@ class FMessageBox : public FDialog FStringList text_components{}; FButton* button[3]{nullptr}; std::size_t max_line_width{0}; - FColor emphasis_color{getFWidgetColors().dialog_emphasis_fg}; + FColor emphasis_color{getColorTheme()->dialog_emphasis_fg}; int button_digit[3]{0}; uInt num_buttons{0}; std::size_t text_num_lines{0}; @@ -231,10 +231,10 @@ int FMessageBox::error ( FWidget* parent FTerm::beep(); mbox.setHeadline("Warning:"); mbox.setCenterText(); - const auto& wc = mbox.getFWidgetColors(); - mbox.setForegroundColor(wc.error_box_fg); - mbox.setBackgroundColor(wc.error_box_bg); - mbox.emphasis_color = wc.error_box_emphasis_fg; + const auto& wc = getColorTheme(); + mbox.setForegroundColor(wc->error_box_fg); + mbox.setBackgroundColor(wc->error_box_bg); + mbox.emphasis_color = wc->error_box_emphasis_fg; const int reply = mbox.exec(); return reply; } diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index f1d2f43b..ae8c7ef6 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -247,14 +247,14 @@ class FString static constexpr uInt CHAR_SIZE = sizeof(wchar_t); // bytes per character // Methods - void initLength (std::size_t); - void _assign (const wchar_t[]); - void _insert (std::size_t, const wchar_t[]); - void _insert (std::size_t, std::size_t, const wchar_t[]); - void _remove (std::size_t, std::size_t); - char* wc_to_c_str (const wchar_t[]) const; - wchar_t* c_to_wc_str (const char[]) const; - wchar_t* extractToken (wchar_t*[], const wchar_t[], const wchar_t[]); + void _initLength (std::size_t); + void _assign (const wchar_t[]); + void _insert (std::size_t, const wchar_t[]); + void _insert (std::size_t, std::size_t, const wchar_t[]); + void _remove (std::size_t, std::size_t); + const char* _to_cstring (const wchar_t[]) const; + const wchar_t* _to_wcstring (const char[]) const; + const wchar_t* _extractToken (wchar_t*[], const wchar_t[], const wchar_t[]); // Data members wchar_t* string{nullptr}; diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 8abaef75..0ea4899c 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -146,6 +146,7 @@ class FWidget : public FVTerm, public FObject typedef void (*FCallbackPtr)(FWidget*, FDataPtr); typedef void (FWidget::*FMemberCallback)(FWidget*, FDataPtr); typedef std::function FCallback; + typedef std::shared_ptr FWidgetColorsPtr; struct FWidgetFlags // Properties of a widget ⚑ { @@ -184,161 +185,164 @@ class FWidget : public FVTerm, public FObject FWidget& operator = (const FWidget&) = delete; // Accessors - const FString getClassName() const override; - FWidget* getRootWidget() const; - FWidget* getParentWidget() const; - static FWidget*& getMainWidget(); - static FWidget*& getActiveWindow(); - static FWidget*& getFocusWidget(); - static FWidget*& getClickedWidget(); - static FWidget*& getOpenMenu(); - static FWidget*& getMoveSizeWidget(); - static FWidgetList*& getWindowList(); - static FMenuBar* getMenuBar(); - static FStatusBar* getStatusBar(); - virtual FWidget* getFirstFocusableWidget (FObjectList); - virtual FWidget* getLastFocusableWidget (FObjectList); - const FAcceleratorList& getAcceleratorList() const; - FAcceleratorList& setAcceleratorList(); - FString getStatusbarMessage() const; - FColor getForegroundColor() const; // get the primary - FColor getBackgroundColor() const; // widget colors - std::vector& doubleFlatLine_ref (fc::sides); + const FString getClassName() const override; + FWidget* getRootWidget() const; + FWidget* getParentWidget() const; + static FWidget*& getMainWidget(); + static FWidget*& getActiveWindow(); + static FWidget*& getFocusWidget(); + static FWidget*& getClickedWidget(); + static FWidget*& getOpenMenu(); + static FWidget*& getMoveSizeWidget(); + static FWidgetList*& getWindowList(); + static FMenuBar* getMenuBar(); + static FStatusBar* getStatusBar(); + static FWidgetColorsPtr& getColorTheme(); + virtual FWidget* getFirstFocusableWidget (FObjectList); + virtual FWidget* getLastFocusableWidget (FObjectList); + const FAcceleratorList& getAcceleratorList() const; + FString getStatusbarMessage() const; + FColor getForegroundColor() const; // get the primary + FColor getBackgroundColor() const; // widget colors + std::vector& doubleFlatLine_ref (fc::sides); // Positioning and sizes accessors... - int getX() const; - int getY() const; - const FPoint getPos() const; - int getTermX() const; - int getTermY() const; - const FPoint getTermPos() const; - std::size_t getWidth() const; - std::size_t getHeight() const; - const FSize getSize() const; - int getTopPadding() const; - int getLeftPadding() const; - int getBottomPadding() const; - int getRightPadding() const; - std::size_t getClientWidth() const; - std::size_t getClientHeight() const; - const FSize getClientSize() const; - std::size_t getMaxWidth() const; - std::size_t getMaxHeight() const; - const FSize& getShadow() const; - const FRect& getGeometry() const; - const FRect& getGeometryWithShadow(); - const FRect& getTermGeometry(); - const FRect& getTermGeometryWithShadow(); - std::size_t getDesktopWidth(); - std::size_t getDesktopHeight(); - const FWidgetFlags& getFlags() const; - const FPoint getCursorPos(); - const FPoint getPrintPos(); + int getX() const; + int getY() const; + const FPoint getPos() const; + int getTermX() const; + int getTermY() const; + const FPoint getTermPos() const; + std::size_t getWidth() const; + std::size_t getHeight() const; + const FSize getSize() const; + int getTopPadding() const; + int getLeftPadding() const; + int getBottomPadding() const; + int getRightPadding() const; + std::size_t getClientWidth() const; + std::size_t getClientHeight() const; + const FSize getClientSize() const; + std::size_t getMaxWidth() const; + std::size_t getMaxHeight() const; + const FSize& getShadow() const; + const FRect& getGeometry() const; + const FRect& getGeometryWithShadow(); + const FRect& getTermGeometry(); + const FRect& getTermGeometryWithShadow(); + std::size_t getDesktopWidth(); + std::size_t getDesktopHeight(); + const FWidgetFlags& getFlags() const; + const FPoint getCursorPos(); + const FPoint getPrintPos(); // Mutators - static void setMainWidget (FWidget*); - static void setFocusWidget (FWidget*); - static void setClickedWidget (FWidget*); - static void setMoveSizeWidget (FWidget*); - static void setActiveWindow (FWidget*); - static void setOpenMenu (FWidget*); - virtual void setStatusbarMessage (const FString&); - bool setVisible (bool); - bool setVisible(); - bool unsetVisible(); - virtual bool setEnable (bool); - virtual bool setEnable(); - virtual bool unsetEnable(); - virtual bool setDisable(); - virtual bool setVisibleCursor (bool); // input cursor visibility - virtual bool setVisibleCursor(); // for the widget - virtual bool unsetVisibleCursor(); - virtual bool setFocus (bool); - virtual bool setFocus(); - virtual bool unsetFocus(); - void setFocusable(); - void unsetFocusable(); - bool ignorePadding (bool); // ignore padding from - bool ignorePadding(); // the parent widget - bool acceptPadding(); - virtual void setForegroundColor (FColor); - virtual void setBackgroundColor (FColor); - void setColor(); - FWidgetFlags& setFlags(); + static void setMainWidget (FWidget*); + static void setFocusWidget (FWidget*); + static void setClickedWidget (FWidget*); + static void setMoveSizeWidget (FWidget*); + static void setActiveWindow (FWidget*); + static void setOpenMenu (FWidget*); + template + static void setColorTheme(); + FAcceleratorList& setAcceleratorList(); + virtual void setStatusbarMessage (const FString&); + bool setVisible (bool); + bool setVisible(); + bool unsetVisible(); + virtual bool setEnable (bool); + virtual bool setEnable(); + virtual bool unsetEnable(); + virtual bool setDisable(); + virtual bool setVisibleCursor (bool); // input cursor visibility + virtual bool setVisibleCursor(); // for the widget + virtual bool unsetVisibleCursor(); + virtual bool setFocus (bool); + virtual bool setFocus(); + virtual bool unsetFocus(); + void setFocusable(); + void unsetFocusable(); + bool ignorePadding (bool); // ignore padding from + bool ignorePadding(); // the parent widget + bool acceptPadding(); + virtual void setForegroundColor (FColor); + virtual void setBackgroundColor (FColor); + void setColor(); + FWidgetFlags& setFlags(); // Positioning and sizes mutators... - virtual void setX (int, bool = true); - virtual void setY (int, bool = true); - virtual void setPos (const FPoint&, bool = true); - virtual void setWidth (std::size_t, bool = true); - virtual void setHeight (std::size_t, bool = true); - virtual void setSize (const FSize&, bool = true); - void setTopPadding (int, bool = true); - void setLeftPadding (int, bool = true); - void setBottomPadding (int, bool = true); - void setRightPadding (int, bool = true); - void setTermSize (const FSize&); - virtual void setGeometry (const FRect&, bool = true); - virtual void setGeometry (const FPoint&, const FSize&, bool = true); - virtual void setShadowSize (const FSize&); - void setMinimumWidth (std::size_t); - void setMinimumHeight (std::size_t); - void setMinimumSize (const FSize&); - void setMaximumWidth (std::size_t); - void setMaximumHeight (std::size_t); - void setMaximumSize (const FSize&); - void setFixedSize (const FSize&); - virtual bool setCursorPos (const FPoint&); - void unsetCursorPos(); - virtual void setPrintPos (const FPoint&); - void setDoubleFlatLine (fc::sides, bool = true); - void unsetDoubleFlatLine (fc::sides); - void setDoubleFlatLine (fc::sides, int, bool = true); - void unsetDoubleFlatLine (fc::sides, int); + virtual void setX (int, bool = true); + virtual void setY (int, bool = true); + virtual void setPos (const FPoint&, bool = true); + virtual void setWidth (std::size_t, bool = true); + virtual void setHeight (std::size_t, bool = true); + virtual void setSize (const FSize&, bool = true); + void setTopPadding (int, bool = true); + void setLeftPadding (int, bool = true); + void setBottomPadding (int, bool = true); + void setRightPadding (int, bool = true); + void setTermSize (const FSize&); + virtual void setGeometry (const FRect&, bool = true); + virtual void setGeometry (const FPoint&, const FSize&, bool = true); + virtual void setShadowSize (const FSize&); + void setMinimumWidth (std::size_t); + void setMinimumHeight (std::size_t); + void setMinimumSize (const FSize&); + void setMaximumWidth (std::size_t); + void setMaximumHeight (std::size_t); + void setMaximumSize (const FSize&); + void setFixedSize (const FSize&); + virtual bool setCursorPos (const FPoint&); + void unsetCursorPos(); + virtual void setPrintPos (const FPoint&); + void setDoubleFlatLine (fc::sides, bool = true); + void unsetDoubleFlatLine (fc::sides); + void setDoubleFlatLine (fc::sides, int, bool = true); + void unsetDoubleFlatLine (fc::sides, int); // Inquiries - bool isRootWidget() const; - bool isWindowWidget() const; - bool isDialogWidget() const; - bool isMenuWidget() const; - bool isVisible() const; - bool isShown() const; - bool isHidden() const; - bool isEnabled() const; - bool hasVisibleCursor() const; - bool hasFocus() const; - bool acceptFocus() const; // is focusable - bool isPaddingIgnored() const; + bool isRootWidget() const; + bool isWindowWidget() const; + bool isDialogWidget() const; + bool isMenuWidget() const; + bool isVisible() const; + bool isShown() const; + bool isHidden() const; + bool isEnabled() const; + bool hasVisibleCursor() const; + bool hasFocus() const; + bool acceptFocus() const; // is focusable + bool isPaddingIgnored() const; // Methods - FWidget* childWidgetAt (const FPoint&); - int numOfFocusableChildren(); - virtual bool close(); - void clearStatusbarMessage(); - void addCallback ( const FString& - , const FCallback& - , FDataPtr = nullptr ); - void addCallback ( const FString& - , FWidget* - , const FCallback& - , FDataPtr = nullptr ); - void delCallback (const FCallback&); - void delCallback (const FWidget*); - void delCallbacks(); - void emitCallback (const FString&); - void addAccelerator (FKey); - virtual void addAccelerator (FKey, FWidget*); - void delAccelerator (); - virtual void delAccelerator (FWidget*); - virtual void redraw(); - virtual void resize(); - virtual void show(); - virtual void hide(); - virtual bool focusFirstChild(); // widget focusing - virtual bool focusLastChild(); - const FPoint termToWidgetPos (const FPoint&); - void print (const FPoint&) override; - virtual void move (const FPoint&); - virtual void drawBorder(); - static void quit(); + FWidget* childWidgetAt (const FPoint&); + int numOfFocusableChildren(); + virtual bool close(); + void clearStatusbarMessage(); + void addCallback ( const FString& + , const FCallback& + , FDataPtr = nullptr ); + void addCallback ( const FString& + , FWidget* + , const FCallback& + , FDataPtr = nullptr ); + void delCallback (const FCallback&); + void delCallback (const FWidget*); + void delCallbacks(); + void emitCallback (const FString&); + void addAccelerator (FKey); + virtual void addAccelerator (FKey, FWidget*); + void delAccelerator (); + virtual void delAccelerator (FWidget*); + virtual void redraw(); + virtual void resize(); + virtual void show(); + virtual void hide(); + virtual bool focusFirstChild(); // widget focusing + virtual bool focusLastChild(); + const FPoint termToWidgetPos (const FPoint&); + void print (const FPoint&) override; + virtual void move (const FPoint&); + virtual void drawBorder(); + static void quit(); protected: struct FCallbackData; // forward declaration @@ -347,54 +351,52 @@ class FWidget : public FVTerm, public FObject typedef std::vector FCallbackObjects; // Accessor - FTermArea* getPrintArea() override; - const FWidgetColors& getFWidgetColors() const; - static uInt getModalDialogCounter(); - static FWidgetList*& getDialogList(); - static FWidgetList*& getAlwaysOnTopList(); - static FWidgetList*& getWidgetCloseList(); - void addPreprocessingHandler ( const FVTerm* - , const FPreprocessingFunction& ) override; - void delPreprocessingHandler (const FVTerm*) override; + FTermArea* getPrintArea() override; + static uInt getModalDialogCounter(); + static FWidgetList*& getDialogList(); + static FWidgetList*& getAlwaysOnTopList(); + static FWidgetList*& getWidgetCloseList(); + void addPreprocessingHandler ( const FVTerm* + , const FPreprocessingFunction& ) override; + void delPreprocessingHandler (const FVTerm*) override; // Inquiry - bool isChildPrintArea() const; + bool isChildPrintArea() const; // Mutators - virtual void setStatusBar (FStatusBar*); - virtual void setMenuBar (FMenuBar*); - FWidgetColors& setFWidgetColors(); - static uInt& setModalDialogCounter(); - void setParentOffset(); - void setTermOffset(); - void setTermOffsetWithPadding(); + virtual void setStatusBar (FStatusBar*); + virtual void setMenuBar (FMenuBar*); + static uInt& setModalDialogCounter(); + void setParentOffset(); + void setTermOffset(); + void setTermOffsetWithPadding(); // Methods - virtual void adjustSize(); - void adjustSizeGlobal(); - void hideArea (const FSize&); - virtual bool focusNextChild(); // Change child... - virtual bool focusPrevChild(); // ...focus + virtual void adjustSize(); + void adjustSizeGlobal(); + void hideArea (const FSize&); + virtual bool focusNextChild(); // Change child... + virtual bool focusPrevChild(); // ...focus // Event handlers - bool event (FEvent*) override; - virtual void onKeyPress (FKeyEvent*); - virtual void onKeyUp (FKeyEvent*); - virtual void onKeyDown (FKeyEvent*); - virtual void onMouseDown (FMouseEvent*); - virtual void onMouseUp (FMouseEvent*); - virtual void onMouseDoubleClick (FMouseEvent*); - virtual void onWheel (FWheelEvent*); - virtual void onMouseMove (FMouseEvent*); - virtual void onFocusIn (FFocusEvent*); - virtual void onFocusOut (FFocusEvent*); - virtual void onChildFocusIn (FFocusEvent*); - virtual void onChildFocusOut (FFocusEvent*); - virtual void onAccel (FAccelEvent*); - virtual void onResize (FResizeEvent*); - virtual void onShow (FShowEvent*); - virtual void onHide (FHideEvent*); - virtual void onClose (FCloseEvent*); + bool event (FEvent*) override; + virtual void onKeyPress (FKeyEvent*); + virtual void onKeyUp (FKeyEvent*); + virtual void onKeyDown (FKeyEvent*); + virtual void onMouseDown (FMouseEvent*); + virtual void onMouseUp (FMouseEvent*); + virtual void onMouseDoubleClick (FMouseEvent*); + virtual void onWheel (FWheelEvent*); + virtual void onMouseMove (FMouseEvent*); + virtual void onFocusIn (FFocusEvent*); + virtual void onFocusOut (FFocusEvent*); + virtual void onChildFocusIn (FFocusEvent*); + virtual void onChildFocusOut (FFocusEvent*); + virtual void onAccel (FAccelEvent*); + virtual void onResize (FResizeEvent*); + virtual void onShow (FShowEvent*); + virtual void onHide (FHideEvent*); + virtual void onClose (FCloseEvent*); private: struct widget_size_hints @@ -443,68 +445,68 @@ class FWidget : public FVTerm, public FObject }; // Methods - void initRootWidget(); - void finish(); - void insufficientSpaceAdjust(); - void KeyPressEvent (FKeyEvent*); - void KeyDownEvent (FKeyEvent*); - void emitWheelCallback (const FWheelEvent*); - void setWindowFocus (bool); - FCallbackPtr getCallbackPtr (const FCallback&); - bool changeFocus (FWidget*, FWidget*, fc::FocusTypes); - void processDestroy(); - virtual void draw(); - void drawWindows(); - void drawChildren(); - static void setColorTheme(); - void setStatusbarText (bool); + void initRootWidget(); + void finish(); + void insufficientSpaceAdjust(); + void KeyPressEvent (FKeyEvent*); + void KeyDownEvent (FKeyEvent*); + void emitWheelCallback (const FWheelEvent*); + void setWindowFocus (bool); + FCallbackPtr getCallbackPtr (const FCallback&); + bool changeFocus (FWidget*, FWidget*, fc::FocusTypes); + void processDestroy(); + virtual void draw(); + void drawWindows(); + void drawChildren(); + static void initColorTheme(); + void destroyColorTheme(); + void setStatusbarText (bool); // Data members - struct FWidgetFlags flags{}; - FPoint widget_cursor_position{-1, -1}; - widget_size_hints size_hints{}; - dbl_line_mask double_flatline_mask{}; - widget_padding padding{}; - bool ignore_padding{false}; + struct FWidgetFlags flags{}; + FPoint widget_cursor_position{-1, -1}; + widget_size_hints size_hints{}; + dbl_line_mask double_flatline_mask{}; + widget_padding padding{}; + bool ignore_padding{false}; // widget size - FRect wsize{1, 1, 1, 1}; - FRect adjust_wsize{1, 1, 1, 1}; - FRect adjust_wsize_term{}; - FRect adjust_wsize_shadow{}; - FRect adjust_wsize_term_shadow{}; + FRect wsize{1, 1, 1, 1}; + FRect adjust_wsize{1, 1, 1, 1}; + FRect adjust_wsize_term{}; + FRect adjust_wsize_shadow{}; + FRect adjust_wsize_term_shadow{}; // widget offset - FRect woffset{}; + FRect woffset{}; // offset of the widget client area - FRect wclient_offset{}; + FRect wclient_offset{}; // widget shadow size (on the right and bottom side) - FSize wshadow{0, 0}; + FSize wshadow{0, 0}; // default widget foreground and background color - FColor foreground_color{fc::Default}; - FColor background_color{fc::Default}; - FString statusbar_message{}; - FAcceleratorList accelerator_list{}; - FCallbackObjects callback_objects{}; + FColor foreground_color{fc::Default}; + FColor background_color{fc::Default}; + FString statusbar_message{}; + FAcceleratorList accelerator_list{}; + FCallbackObjects callback_objects{}; - static FStatusBar* statusbar; - static FMenuBar* menubar; - static FWidget* main_widget; - static FWidget* active_window; - static FWidget* focus_widget; - static FWidget* clicked_widget; - static FWidget* open_menu; - static FWidget* move_size_widget; - static FWidget* show_root_widget; - static FWidget* redraw_root_widget; - static FWidgetList* window_list; - static FWidgetList* dialog_list; - static FWidgetList* always_on_top_list; - static FWidgetList* close_widget; - static FWidgetColors wcolors; - static uInt modal_dialog_counter; - static bool init_desktop; - static bool hideable; + static FStatusBar* statusbar; + static FMenuBar* menubar; + static FWidget* main_widget; + static FWidget* active_window; + static FWidget* focus_widget; + static FWidget* clicked_widget; + static FWidget* open_menu; + static FWidget* move_size_widget; + static FWidget* show_root_widget; + static FWidget* redraw_root_widget; + static FWidgetList* window_list; + static FWidgetList* dialog_list; + static FWidgetList* always_on_top_list; + static FWidgetList* close_widget; + static uInt modal_dialog_counter; + static bool init_desktop; + static bool hideable; // Friend classes friend class FToggleButton; @@ -645,6 +647,13 @@ inline FMenuBar* FWidget::getMenuBar() inline FStatusBar* FWidget::getStatusBar() { return statusbar; } +//---------------------------------------------------------------------- +inline FWidget::FWidgetColorsPtr& FWidget::getColorTheme() +{ + static FWidgetColorsPtr* color_theme = new FWidgetColorsPtr(); + return *color_theme; +} + //---------------------------------------------------------------------- inline const FWidget::FAcceleratorList& FWidget::getAcceleratorList() const { return accelerator_list; } @@ -828,6 +837,13 @@ inline void FWidget::setClickedWidget (FWidget* obj) inline void FWidget::setOpenMenu (FWidget* obj) { open_menu = obj; } +//---------------------------------------------------------------------- +template +inline void FWidget::setColorTheme() +{ + getColorTheme() = std::make_shared(); +} + //---------------------------------------------------------------------- inline void FWidget::setMoveSizeWidget (FWidget* obj) { move_size_widget = obj; } @@ -1069,10 +1085,6 @@ inline void FWidget::drawBorder() finalcut::drawBorder (this, FRect(FPoint{1, 1}, getSize())); } -//---------------------------------------------------------------------- -inline const FWidgetColors& FWidget::getFWidgetColors() const -{ return wcolors; } - //---------------------------------------------------------------------- inline uInt FWidget::getModalDialogCounter() { return modal_dialog_counter; } @@ -1089,10 +1101,6 @@ inline FWidget::FWidgetList*& FWidget::getAlwaysOnTopList() inline FWidget::FWidgetList*& FWidget::getWidgetCloseList() { return close_widget; } -//---------------------------------------------------------------------- -inline FWidgetColors& FWidget::setFWidgetColors() -{ return wcolors; } - //---------------------------------------------------------------------- inline uInt& FWidget::setModalDialogCounter() { return modal_dialog_counter; } diff --git a/src/include/final/fwidgetcolors.h b/src/include/final/fwidgetcolors.h index 53815492..65372621 100644 --- a/src/include/final/fwidgetcolors.h +++ b/src/include/final/fwidgetcolors.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018-2019 Markus Gans * +* Copyright 2018-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -44,12 +44,17 @@ namespace finalcut // class FWidgetColors //---------------------------------------------------------------------- -class FWidgetColors final +class FWidgetColors { public: - // Methods - void set8ColorTheme(); - void set16ColorTheme(); + // Constructor + FWidgetColors(); + + // Destructor + virtual ~FWidgetColors(); + + // Method + virtual void setColorTheme() = 0; // Data members FColor term_fg{fc::Default}; @@ -140,6 +145,42 @@ class FWidgetColors final FColor progressbar_bg{fc::Default}; }; + +//---------------------------------------------------------------------- +// class default8ColorTheme +//---------------------------------------------------------------------- + +class default8ColorTheme final : public FWidgetColors +{ + public: + // Constructor + default8ColorTheme(); + + // Destructor + virtual ~default8ColorTheme() override; + + // Method + void setColorTheme() override; +}; + + +//---------------------------------------------------------------------- +// class default16ColorTheme +//---------------------------------------------------------------------- + +class default16ColorTheme final : public FWidgetColors +{ + public: + // Constructor + default16ColorTheme(); + + // Destructor + virtual ~default16ColorTheme() override; + + // Method + void setColorTheme() override; +}; + } // namespace finalcut #endif // FWIDGETCOLORS_H