diff --git a/ChangeLog b/ChangeLog index f2a426ae..42f819c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2019-08-11 Markus Gans * FRect has now got a scaleBy() method * Convert drawBorder() to a non-member function using FRect + * Converts getHotkeyPos() for sharing into a non-member function 2019-08-10 Markus Gans * Pitch and duration of system speaker can now be changed diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 5145a64b..fd237ef2 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -58,6 +58,7 @@ class ColorChooser : public finalcut::FWidget private: // Method void draw() override; + void drawBorder() override; // Event handler void onMouseDown (finalcut::FMouseEvent*) override; @@ -130,7 +131,7 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev) void ColorChooser::draw() { setColor(); - finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 10))); + drawBorder(); for (FColor c = 0; c < 16; c++) { @@ -152,6 +153,12 @@ void ColorChooser::draw() } } +//---------------------------------------------------------------------- +void ColorChooser::drawBorder() +{ + finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 10))); +} + //---------------------------------------------------------------------- inline FColor ColorChooser::getForeground() { @@ -197,6 +204,7 @@ class Brushes : public finalcut::FWidget private: // Method void draw() override; + void drawBorder() override; // Event handler void onMouseDown (finalcut::FMouseEvent*) override; @@ -238,13 +246,12 @@ Brushes::Brushes (finalcut::FWidget* parent) Brushes::~Brushes() { } - //---------------------------------------------------------------------- void Brushes::draw() { int pos; setColor(); - finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 3))); + drawBorder(); print() << FPoint(2, 3) << FColorPair(fg_color, bg_color) << " " << finalcut::FString(3, fc::MediumShade); @@ -261,6 +268,12 @@ void Brushes::draw() << fc::BlackUpPointingTriangle; } +//---------------------------------------------------------------------- +void Brushes::drawBorder() +{ + finalcut::drawBorder (this, FRect(FPoint(1, 2), FSize(8, 3))); +} + //---------------------------------------------------------------------- void Brushes::onMouseDown (finalcut::FMouseEvent* ev) { diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 62a81d72..faa2fd9a 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -449,31 +449,6 @@ inline void FButton::detectHotkey() } } -//---------------------------------------------------------------------- -std::size_t FButton::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // find hotkey position in string - // + generate a new string without the '&'-sign - wchar_t* txt = src; - std::size_t pos = NOT_SET; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && pos == NOT_SET ) - { - pos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return pos; -} - //---------------------------------------------------------------------- inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget) { @@ -689,7 +664,7 @@ void FButton::draw() if ( flags.flat && ! button_down ) drawFlatBorder(); - hotkeypos = getHotkeyPos(text.wc_str(), button_text, uInt(txtlength)); + hotkeypos = finalcut::getHotkeyPos(text.wc_str(), button_text, uInt(txtlength)); if ( hotkeypos != NOT_SET ) txtlength--; diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 9a017676..5e4872bf 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -445,7 +445,7 @@ void FButtonGroup::drawLabel() wchar_t* src = const_cast(txt.wc_str()); wchar_t* dest = const_cast(LabelText); unsetViewportPrint(); - auto hotkeypos = getHotkeyPos(src, dest, length); + auto hotkeypos = finalcut::getHotkeyPos(src, dest, length); if ( hotkeypos != NOT_SET ) length--; @@ -481,31 +481,6 @@ void FButtonGroup::init() buttonlist.clear(); // no buttons yet } -//---------------------------------------------------------------------- -std::size_t FButtonGroup::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // find hotkey position in string - // + generate a new string without the '&'-sign - std::size_t pos = NOT_SET; - wchar_t* txt = src; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && pos == NOT_SET ) - { - pos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return pos; -} - //---------------------------------------------------------------------- void FButtonGroup::drawText ( wchar_t LabelText[] , std::size_t hotkeypos diff --git a/src/fcheckbox.cpp b/src/fcheckbox.cpp index 6d4e8630..15844b30 100644 --- a/src/fcheckbox.cpp +++ b/src/fcheckbox.cpp @@ -62,6 +62,9 @@ void FCheckBox::init() //---------------------------------------------------------------------- void FCheckBox::draw() { + if ( ! isVisible() ) + return; + drawCheckButton(); drawLabel(); FToggleButton::draw(); @@ -70,9 +73,6 @@ void FCheckBox::draw() //---------------------------------------------------------------------- void FCheckBox::drawCheckButton() { - if ( ! isVisible() ) - return; - print() << FPoint(1, 1); setColor(); @@ -85,30 +85,38 @@ void FCheckBox::drawCheckButton() } if ( checked ) - { - if ( isNewFont() ) - print (CHECKBOX_ON); - else - { - print ('['); - print (fc::Times); // Times × - print (']'); - } - } + drawChecked(); else - { - if ( isNewFont() ) - print (CHECKBOX); - else - { - print ('['); - print (' '); - print (']'); - } - } + drawUnchecked(); if ( isMonochron() ) setReverse(false); } +//---------------------------------------------------------------------- +inline void FCheckBox::drawChecked() +{ + if ( isNewFont() ) + print (CHECKBOX_ON); + else + { + print ('['); + print (fc::Times); // Times × + print (']'); + } +} + +//---------------------------------------------------------------------- +inline void FCheckBox::drawUnchecked() +{ + if ( isNewFont() ) + print (CHECKBOX); + else + { + print ('['); + print (' '); + print (']'); + } +} + } // namespace finalcut diff --git a/src/fcolorpalette.cpp b/src/fcolorpalette.cpp index 249d25c1..e415cd29 100644 --- a/src/fcolorpalette.cpp +++ b/src/fcolorpalette.cpp @@ -79,22 +79,7 @@ void FColorPalette::set16ColorPalette (funcp setPalette) //---------------------------------------------------------------------- void FColorPalette::reset8ColorPalette (funcp setPalette) { - setPalette (fc::Black, 0x00, 0x00, 0x00); - setPalette (fc::Blue, 0x00, 0x00, 0xaa); - setPalette (fc::Green, 0x00, 0xaa, 0x00); - setPalette (fc::Cyan, 0x00, 0x55, 0xaa); - setPalette (fc::Red, 0xaa, 0x00, 0x00); - setPalette (fc::Magenta, 0xaa, 0x00, 0xaa); - setPalette (fc::Brown, 0xaa, 0xaa, 0x00); - setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa); - setPalette (fc::DarkGray, 0x55, 0x55, 0x55); - setPalette (fc::LightBlue, 0x55, 0x55, 0xff); - setPalette (fc::LightGreen, 0x55, 0xff, 0x55); - setPalette (fc::LightCyan, 0x55, 0xff, 0xff); - setPalette (fc::LightRed, 0xff, 0x55, 0x55); - setPalette (fc::LightMagenta, 0xff, 0x55, 0xff); - setPalette (fc::Yellow, 0xff, 0xff, 0x55); - setPalette (fc::White, 0xff, 0xff, 0xff); + reset16ColorPalette(setPalette); } //---------------------------------------------------------------------- diff --git a/src/flabel.cpp b/src/flabel.cpp index 11891115..9a6d8c42 100644 --- a/src/flabel.cpp +++ b/src/flabel.cpp @@ -347,31 +347,6 @@ void FLabel::init() } } -//---------------------------------------------------------------------- -std::size_t FLabel::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // find hotkey position in string - // + generate a new string without the '&'-sign - std::size_t hotkeypos = NOT_SET; - wchar_t* txt = src; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET ) - { - hotkeypos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return hotkeypos; -} - //---------------------------------------------------------------------- void FLabel::setHotkeyAccelerator() { @@ -478,7 +453,7 @@ void FLabel::drawMultiLine() auto dest = const_cast(label_text); if ( ! hotkey_printed ) - hotkeypos = getHotkeyPos(src, dest, length); + hotkeypos = finalcut::getHotkeyPos(src, dest, length); else std::wcsncpy(dest, src, length); @@ -519,7 +494,7 @@ void FLabel::drawSingleLine() return; } - hotkeypos = getHotkeyPos (text.wc_str(), label_text, length); + hotkeypos = finalcut::getHotkeyPos (text.wc_str(), label_text, length); if ( hotkeypos != NOT_SET ) length--; diff --git a/src/flistbox.cpp b/src/flistbox.cpp index cab1503f..93191bdc 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -815,14 +815,7 @@ void FListBox::draw() if ( isMonochron() ) setReverse(true); - if ( isNewFont() ) - { - FRect box(FPoint(1, 1), getSize()); - box.scaleBy(-1, 0); - finalcut::drawBorder (this, box); - } - else - drawBorder(); + drawBorder(); if ( isNewFont() && ! vbar->isShown() ) { @@ -856,6 +849,19 @@ void FListBox::draw() } } +//---------------------------------------------------------------------- +void FListBox::drawBorder() +{ + if ( isNewFont() ) + { + FRect box(FPoint(1, 1), getSize()); + box.scaleBy(-1, 0); + finalcut::drawBorder (this, box); + } + else + FWidget::drawBorder(); +} + //---------------------------------------------------------------------- void FListBox::drawScrollbars() { diff --git a/src/flistview.cpp b/src/flistview.cpp index 973f261a..3886aa78 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1475,14 +1475,7 @@ void FListView::draw() if ( isMonochron() ) setReverse(true); - if ( isNewFont() ) - { - FRect box(FPoint(1, 1), getSize()); - box.scaleBy(-1, 0); - finalcut::drawBorder (this, box); - } - else - drawBorder(); + drawBorder(); if ( isNewFont() && ! vbar->isShown() ) { @@ -1516,6 +1509,19 @@ void FListView::draw() } } +//---------------------------------------------------------------------- +void FListView::drawBorder() +{ + if ( isNewFont() ) + { + FRect box(FPoint(1, 1), getSize()); + box.scaleBy(-1, 0); + finalcut::drawBorder (this, box); + } + else + FWidget::drawBorder(); +} + //---------------------------------------------------------------------- void FListView::drawScrollbars() { diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 8602f52a..e1e088ea 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -1191,31 +1191,6 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev) return false; } -//---------------------------------------------------------------------- -std::size_t FMenu::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // Find hotkey position in string - // + generate a new string without the '&'-sign - std::size_t pos = NOT_SET; - wchar_t* txt = src; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && pos == NOT_SET ) - { - pos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return pos; -} - //---------------------------------------------------------------------- void FMenu::draw() { @@ -1313,7 +1288,7 @@ inline void FMenu::drawMenuLine (FMenuItem* menuitem, int y) return; } - hotkeypos = getHotkeyPos(txt.wc_str(), txtdata.text, txt_length); + hotkeypos = finalcut::getHotkeyPos(txt.wc_str(), txtdata.text, txt_length); if ( hotkeypos != NOT_SET ) to_char--; diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 008e2237..9f32a86b 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -467,31 +467,6 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev) return false; } -//---------------------------------------------------------------------- -std::size_t FMenuBar::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // find hotkey position in string - // + generate a new string without the '&'-sign - std::size_t hotkeypos = NOT_SET; - wchar_t* txt = src; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET ) - { - hotkeypos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return hotkeypos; -} - //---------------------------------------------------------------------- void FMenuBar::draw() { @@ -561,7 +536,7 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x) else to_char = txt_length - screenWidth - x - 1; - hotkeypos = getHotkeyPos (txt.wc_str(), txtdata.text, txt_length); + hotkeypos = finalcut::getHotkeyPos (txt.wc_str(), txtdata.text, txt_length); if ( hotkeypos != NOT_SET ) { diff --git a/src/fradiobutton.cpp b/src/fradiobutton.cpp index 93e9867a..7e44cd1d 100644 --- a/src/fradiobutton.cpp +++ b/src/fradiobutton.cpp @@ -62,6 +62,9 @@ void FRadioButton::init() //---------------------------------------------------------------------- void FRadioButton::draw() { + if ( ! isVisible() ) + return; + drawRadioButton(); drawLabel(); FToggleButton::draw(); @@ -70,9 +73,6 @@ void FRadioButton::draw() //---------------------------------------------------------------------- void FRadioButton::drawRadioButton() { - if ( ! isVisible() ) - return; - print() << FPoint(1, 1); setColor(); @@ -85,30 +85,38 @@ void FRadioButton::drawRadioButton() } if ( checked ) - { - if ( isNewFont() ) - print (CHECKED_RADIO_BUTTON); - else - { - print ('('); - print (fc::Bullet); // Bullet ● - print (')'); - } - } + drawChecked(); else - { - if ( isNewFont() ) - print (RADIO_BUTTON); - else - { - print ('('); - print (' '); - print (')'); - } - } + drawUnchecked(); if ( isMonochron() ) setReverse(false); } +//---------------------------------------------------------------------- +inline void FRadioButton::drawChecked() +{ + if ( isNewFont() ) + print (CHECKED_RADIO_BUTTON); + else + { + print ('('); + print (fc::Bullet); // Bullet ● + print (')'); + } +} + +//---------------------------------------------------------------------- +inline void FRadioButton::drawUnchecked() +{ + if ( isNewFont() ) + print (RADIO_BUTTON); + else + { + print ('('); + print (' '); + print (')'); + } +} + } // namespace finalcut diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index f635fcb7..d74cc744 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -235,120 +235,7 @@ void FScrollbar::calculateSliderValues() slider_pos = int(bar_length - slider_length); } -//---------------------------------------------------------------------- -void FScrollbar::drawVerticalBar() -{ - int z; - setColor (wc.scrollbar_fg, wc.scrollbar_bg); - for (z = 1; z <= slider_pos; z++) - { - print() << FPoint(1, 1 + z); - - if ( isNewFont() ) - { - if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ - else - print (fc::NF_border_line_left); // ⎸ - } - - if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ - else - print (' '); - } - - setColor (wc.scrollbar_bg, wc.scrollbar_fg); - - if ( isMonochron() ) - setReverse(false); - - for (z = 1; z <= int(slider_length); z++) - { - print() << FPoint(1, 1 + slider_pos + z); - - if ( isNewFont() ) - print (' '); - - print (' '); - } - - if ( isMonochron() ) - setReverse(true); - - setColor (wc.scrollbar_fg, wc.scrollbar_bg); - - for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++) - { - print() << FPoint(1, 1 + z); - - if ( isNewFont() ) - { - if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ - else - print (fc::NF_border_line_left); // ⎸ - } - - if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); - else - print (' '); - } - - if ( isMonochron() ) - setReverse(false); -} - -//---------------------------------------------------------------------- -void FScrollbar::drawHorizontalBar() -{ - int z; - setColor (wc.scrollbar_fg, wc.scrollbar_bg); - - if ( isNewFont() ) - print() << FPoint(3, 1); - else - print() << FPoint(2, 1); - - for (z = 0; z < slider_pos; z++) - { - if ( isNewFont() && max_color > 8 ) - print (fc::NF_border_line_upper); // ¯ - else if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ - else - print (' '); - } - - setColor (wc.scrollbar_bg, wc.scrollbar_fg); - - if ( isMonochron() ) - setReverse(false); - - for (z = 0; z < int(slider_length); z++) - print (' '); - - if ( isMonochron() ) - setReverse(true); - - setColor (wc.scrollbar_fg, wc.scrollbar_bg); - z = slider_pos + int(slider_length) + 1; - - for (; z <= int(bar_length); z++) - { - if ( isNewFont() && max_color > 8 ) - print (fc::NF_border_line_upper); // ¯ - else if ( isMonochron() || max_color < 16 ) - print (fc::MediumShade); // ▒ - else - print (' '); - } - - if ( isMonochron() ) - setReverse(false); -} //---------------------------------------------------------------------- void FScrollbar::drawBar() @@ -586,6 +473,111 @@ void FScrollbar::draw() drawBar(); } +//---------------------------------------------------------------------- +void FScrollbar::drawVerticalBar() +{ + int z; + setColor (wc.scrollbar_fg, wc.scrollbar_bg); + + for (z = 1; z <= slider_pos; z++) + { + print() << FPoint(1, 1 + z); + drawVerticalBackgroundLine(); + } + + setColor (wc.scrollbar_bg, wc.scrollbar_fg); + + if ( isMonochron() ) + setReverse(false); + + for (z = 1; z <= int(slider_length); z++) // Draw slider + { + print() << FPoint(1, 1 + slider_pos + z); + + if ( isNewFont() ) + print (' '); + + print (' '); + } + + if ( isMonochron() ) + setReverse(true); + + setColor (wc.scrollbar_fg, wc.scrollbar_bg); + + for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++) + { + print() << FPoint(1, 1 + z); + drawVerticalBackgroundLine(); + } + + if ( isMonochron() ) + setReverse(false); +} + +//---------------------------------------------------------------------- +inline void FScrollbar::drawVerticalBackgroundLine() +{ + if ( isNewFont() ) + { + if ( isMonochron() || max_color < 16 ) + print (fc::MediumShade); // ▒ + else + print (fc::NF_border_line_left); // ⎸ + } + + if ( isMonochron() || max_color < 16 ) + print (fc::MediumShade); // ▒ + else + print (' '); +} + +//---------------------------------------------------------------------- +void FScrollbar::drawHorizontalBar() +{ + int z; + setColor (wc.scrollbar_fg, wc.scrollbar_bg); + + if ( isNewFont() ) + print() << FPoint(3, 1); + else + print() << FPoint(2, 1); + + for (z = 0; z < slider_pos; z++) + drawHorizontalBackgroundColumn(); + + setColor (wc.scrollbar_bg, wc.scrollbar_fg); + + if ( isMonochron() ) + setReverse(false); + + for (z = 0; z < int(slider_length); z++) // Draw slider + print (' '); + + if ( isMonochron() ) + setReverse(true); + + setColor (wc.scrollbar_fg, wc.scrollbar_bg); + z = slider_pos + int(slider_length) + 1; + + for (; z <= int(bar_length); z++) + drawHorizontalBackgroundColumn(); + + if ( isMonochron() ) + setReverse(false); +} + +//---------------------------------------------------------------------- +inline void FScrollbar::drawHorizontalBackgroundColumn() +{ + if ( isNewFont() && max_color > 8 ) + print (fc::NF_border_line_upper); // ¯ + else if ( isMonochron() || max_color < 16 ) + print (fc::MediumShade); // ▒ + else + print (' '); +} + //---------------------------------------------------------------------- void FScrollbar::drawButtons() { diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 4ce682b9..168ca409 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -430,16 +430,7 @@ void FScrollView::draw() setColor(); if ( border ) - { - if ( isNewFont() ) - { - FRect box(FPoint(1, 1), getSize()); - box.scaleBy(-1, 0); - finalcut::drawBorder (this, box); - } - else - drawBorder(); - } + drawBorder(); if ( isMonochron() ) setReverse(false); @@ -457,6 +448,19 @@ void FScrollView::draw() hbar->redraw(); } +//---------------------------------------------------------------------- +void FScrollView::drawBorder() +{ + if ( isNewFont() ) + { + FRect box(FPoint(1, 1), getSize()); + box.scaleBy(-1, 0); + finalcut::drawBorder (this, box); + } + else + FWidget::drawBorder(); +} + //---------------------------------------------------------------------- void FScrollView::onKeyPress (FKeyEvent* ev) { diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 334f9b8b..215c7504 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -117,6 +117,9 @@ void FSwitch::onMouseUp (FMouseEvent* ev) //---------------------------------------------------------------------- void FSwitch::draw() { + if ( ! isVisible() ) + return; + drawLabel(); drawCheckButton(); FToggleButton::draw(); @@ -127,9 +130,6 @@ void FSwitch::draw() //---------------------------------------------------------------------- void FSwitch::drawCheckButton() { - if ( ! isVisible() ) - return; - print() << FPoint(1 + int(switch_offset_pos), 1); if ( checked ) @@ -139,7 +139,7 @@ void FSwitch::drawCheckButton() } //---------------------------------------------------------------------- -void FSwitch::drawChecked() +inline void FSwitch::drawChecked() { wchar_t on[6] = L" On "; wchar_t off[6] = L" Off "; @@ -188,7 +188,7 @@ void FSwitch::drawChecked() } //---------------------------------------------------------------------- -void FSwitch::drawUnchecked() +inline void FSwitch::drawUnchecked() { wchar_t on[6] = L" On "; wchar_t off[6] = L" Off "; diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index 400c7eb6..84d2d678 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -569,17 +569,9 @@ void FTermXTerminal::setXTerm8ColorDefaults() if ( term_detection->isPuttyTerminal() ) return; - setMouseBackground("rgb:ffff/ffff/ffff"); // white - setMouseForeground ("rgb:0000/0000/0000"); // black + setXTermDefaultsMouseCursor(); - if ( ! term_detection->isGnomeTerminal() ) - setCursorColor("rgb:ffff/ffff/ffff"); // white - - if ( xterm_default_colors - && ! (term_detection->isMinttyTerm() - || term_detection->isMltermTerminal() - || term_detection->isRxvtTerminal() - || term_detection->isScreenTerm()) ) + if ( canSetXTermBackground() ) { // mintty and rxvt can't reset these settings setBackground("rgb:2222/2222/b2b2"); // blue @@ -597,17 +589,9 @@ void FTermXTerminal::setXTerm16ColorDefaults() if ( term_detection->isPuttyTerminal() ) return; - setMouseBackground("rgb:ffff/ffff/ffff"); // white - setMouseForeground ("rgb:0000/0000/0000"); // black + setXTermDefaultsMouseCursor(); - if ( ! term_detection->isGnomeTerminal() ) - setCursorColor("rgb:ffff/ffff/ffff"); // white - - if ( xterm_default_colors - && ! (term_detection->isMinttyTerm() - || term_detection->isMltermTerminal() - || term_detection->isRxvtTerminal() - || term_detection->isScreenTerm()) ) + if ( canSetXTermBackground() ) { // mintty and rxvt can't reset these settings setBackground("rgb:8080/a4a4/ecec"); // very light blue @@ -616,6 +600,29 @@ void FTermXTerminal::setXTerm16ColorDefaults() } } +//---------------------------------------------------------------------- +inline void FTermXTerminal::setXTermDefaultsMouseCursor() +{ + setMouseBackground("rgb:ffff/ffff/ffff"); // white + setMouseForeground ("rgb:0000/0000/0000"); // black + + if ( ! term_detection->isGnomeTerminal() ) + setCursorColor("rgb:ffff/ffff/ffff"); // white +} + +//---------------------------------------------------------------------- +inline bool FTermXTerminal::canSetXTermBackground() +{ + if ( xterm_default_colors + && ! (term_detection->isMinttyTerm() + || term_detection->isMltermTerminal() + || term_detection->isRxvtTerminal() + || term_detection->isScreenTerm()) ) + return true; + else + return false; +} + //---------------------------------------------------------------------- void FTermXTerminal::resetXTermColorMap() { diff --git a/src/ftogglebutton.cpp b/src/ftogglebutton.cpp index 0e98cbb8..ecbcf5a3 100644 --- a/src/ftogglebutton.cpp +++ b/src/ftogglebutton.cpp @@ -400,6 +400,9 @@ bool FToggleButton::isCheckboxButton() const //---------------------------------------------------------------------- void FToggleButton::draw() { + if ( ! isVisible() ) + return; + if ( flags.focus && getStatusBar() ) { const auto& msg = getStatusbarMessage(); @@ -422,9 +425,6 @@ void FToggleButton::drawLabel() { wchar_t* LabelText; - if ( ! isVisible() ) - return; - if ( text.isNull() || text.isEmpty() ) return; @@ -443,7 +443,7 @@ void FToggleButton::drawLabel() FString txt = text; wchar_t* src = const_cast(txt.wc_str()); wchar_t* dest = const_cast(LabelText); - auto hotkeypos = getHotkeyPos(src, dest, length); + auto hotkeypos = finalcut::getHotkeyPos(src, dest, length); if ( hotkeypos != NOT_SET ) length--; @@ -553,31 +553,6 @@ void FToggleButton::init() } } -//---------------------------------------------------------------------- -std::size_t FToggleButton::getHotkeyPos ( wchar_t src[] - , wchar_t dest[] - , std::size_t length ) -{ - // find hotkey position in string - // + generate a new string without the '&'-sign - std::size_t pos = NOT_SET; - wchar_t* txt = src; - - for (std::size_t i = 0; i < length; i++) - { - if ( i < length && txt[i] == L'&' && pos == NOT_SET ) - { - pos = i; - i++; - src++; - } - - *dest++ = *src++; - } - - return pos; -} - //---------------------------------------------------------------------- void FToggleButton::drawText ( wchar_t LabelText[] , std::size_t hotkeypos diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 0b949af2..c832a6a2 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -2340,6 +2340,30 @@ FKey getHotkey (const FString& text) return 0; } +//---------------------------------------------------------------------- +std::size_t getHotkeyPos (wchar_t src[], wchar_t dest[], std::size_t length) +{ + // Find hotkey position in string + // + generate a new string without the '&'-sign + wchar_t* txt = src; + constexpr std::size_t NOT_SET = static_cast(-1); + std::size_t hotkeypos = NOT_SET; + + for (std::size_t i = 0; i < length; i++) + { + if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET ) + { + hotkeypos = i; + i++; + src++; + } + + *dest++ = *src++; + } + + return hotkeypos; +} + //---------------------------------------------------------------------- inline void drawBox (FWidget* w, const FRect& r) { diff --git a/src/include/final/fbutton.h b/src/include/final/fbutton.h index a2a8d055..d88792db 100644 --- a/src/include/final/fbutton.h +++ b/src/include/final/fbutton.h @@ -147,7 +147,6 @@ class FButton : public FWidget void init(); void setHotkeyAccelerator(); void detectHotkey(); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); std::size_t clickAnimationIndent (FWidget*); void clearRightMargin (FWidget*); void drawMarginLeft(); diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index f382dc2b..c5c58ae1 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -134,7 +134,6 @@ class FButtonGroup : public FScrollView // Methods void init(); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); void drawText (wchar_t[], std::size_t, std::size_t); void directFocus(); diff --git a/src/include/final/fcheckbox.h b/src/include/final/fcheckbox.h index c4a3f452..3448a4be 100644 --- a/src/include/final/fcheckbox.h +++ b/src/include/final/fcheckbox.h @@ -86,13 +86,15 @@ class FCheckBox : public FToggleButton FCheckBox& operator = (const FCheckBox&) = delete; // Accessor - const char* getClassName() const override; + const char* getClassName() const override; private: // Methods - void init(); - void draw() override; - void drawCheckButton(); + void init(); + void draw() override; + void drawCheckButton(); + void drawChecked(); + void drawUnchecked(); }; #pragma pack(pop) diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index cbcbf817..71377d55 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -174,9 +174,6 @@ class FDialog : public FWindow static constexpr std::size_t MENU_BTN = 3; static constexpr bool PRINT_WIN_NUMBER = false; // Only for debug - // Using-declaration - using FWidget::drawBorder; - // Methods void init(); void initDialogMenu(); diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index 00a90a00..50a92586 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -144,7 +144,6 @@ class FLabel : public FWidget // Methods void init(); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); void setHotkeyAccelerator(); std::size_t getAlignOffset (std::size_t); void draw() override; diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index 5363f3a1..aa1d3143 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -268,6 +268,7 @@ class FListBox : public FWidget , fc::orientation , FListBoxCallback ); void draw() override; + void drawBorder() override; void drawScrollbars(); void drawHeadline(); void drawList(); diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index fe5a838e..be8f92c9 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -394,6 +394,7 @@ class FListView : public FWidget , std::size_t , std::size_t ); void draw() override; + void drawBorder() override; void drawScrollbars(); void drawHeadlines(); void drawList(); diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index ff389650..75a19a30 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -202,7 +202,6 @@ class FMenu : public FWindow, public FMenuList bool selectPrevItem(); void keypressMenuBar (FKeyEvent*); bool hotkeyMenu (FKeyEvent*); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); void draw() override; void drawItems(); void drawSeparator (int); diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index 5d245360..c0df931e 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -131,7 +131,6 @@ class FMenuBar : public FWindow, public FMenuList bool selectNextItem(); bool selectPrevItem(); bool hotkeyMenu (FKeyEvent*&); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); void draw() override; void drawItems(); void drawItem (FMenuItem*, std::size_t&); diff --git a/src/include/final/fradiobutton.h b/src/include/final/fradiobutton.h index 473dfc63..f9ab0730 100644 --- a/src/include/final/fradiobutton.h +++ b/src/include/final/fradiobutton.h @@ -93,6 +93,8 @@ class FRadioButton : public FToggleButton void init(); void draw() override; void drawRadioButton(); + void drawChecked(); + void drawUnchecked(); }; #pragma pack(pop) diff --git a/src/include/final/fscrollbar.h b/src/include/final/fscrollbar.h index 33a2006a..93b0c34f 100644 --- a/src/include/final/fscrollbar.h +++ b/src/include/final/fscrollbar.h @@ -116,8 +116,6 @@ class FScrollbar : public FWidget void resize() override; void redraw() override; void calculateSliderValues(); - void drawVerticalBar(); - void drawHorizontalBar(); void drawBar(); // Event handlers @@ -131,6 +129,10 @@ class FScrollbar : public FWidget // Methods void init(); void draw() override; + void drawVerticalBar(); + void drawVerticalBackgroundLine(); + void drawHorizontalBar(); + void drawHorizontalBackgroundColumn(); void drawButtons(); sType getClickedScrollType (int, int); sType getVerticalClickedScrollType (int); diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index 0e16b76d..245e0931 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -133,6 +133,7 @@ class FScrollView : public FWidget void scrollTo (int, int); void scrollBy (int, int); void draw() override; + void drawBorder() override; // Event handlers void onKeyPress (FKeyEvent*) override; diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index c1911efd..f9537166 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -119,6 +119,8 @@ class FTermXTerminal final static void setXTermHighlightBackground(); static void setXTerm8ColorDefaults(); static void setXTerm16ColorDefaults(); + static void setXTermDefaultsMouseCursor(); + static bool canSetXTermBackground(); static void resetXTermColorMap(); static void resetXTermForeground(); static void resetXTermBackground(); diff --git a/src/include/final/ftogglebutton.h b/src/include/final/ftogglebutton.h index ca447281..c7ebac7f 100644 --- a/src/include/final/ftogglebutton.h +++ b/src/include/final/ftogglebutton.h @@ -157,7 +157,6 @@ class FToggleButton : public FWidget // Methods void init(); - std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); void drawText (wchar_t[], std::size_t , std::size_t); // Friend classes diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 56898d9a..83f99d30 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -522,10 +522,11 @@ class FWidget : public FVTerm, public FObject // non-member function forward declarations //---------------------------------------------------------------------- -char* createBlankArray (std::size_t); -void destroyBlankArray (char[]); -FKey getHotkey (const FString&); -void drawBorder (FWidget*, FRect); +char* createBlankArray (std::size_t); +void destroyBlankArray (char[]); +FKey getHotkey (const FString&); +std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); +void drawBorder (FWidget*, FRect); // FWidget inline functions //---------------------------------------------------------------------- diff --git a/src/include/final/fwindow.h b/src/include/final/fwindow.h index 2cf9a10d..45f1ba2c 100644 --- a/src/include/final/fwindow.h +++ b/src/include/final/fwindow.h @@ -76,7 +76,6 @@ class FWindow : public FWidget { public: // Using-declaration - using FWidget::drawBorder; using FWidget::setGeometry; // Constructor