Converts getHotkeyPos() for sharing into a non-member function

This commit is contained in:
Markus Gans 2019-08-11 20:07:39 +02:00
parent 5a43a018cf
commit 44e157e493
34 changed files with 315 additions and 409 deletions

View File

@ -1,6 +1,7 @@
2019-08-11 Markus Gans <guru.mail@muenster.de>
* 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 <guru.mail@muenster.de>
* Pitch and duration of system speaker can now be changed

View File

@ -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)
{

View File

@ -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--;

View File

@ -445,7 +445,7 @@ void FButtonGroup::drawLabel()
wchar_t* src = const_cast<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(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

View File

@ -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,7 +85,17 @@ void FCheckBox::drawCheckButton()
}
if ( checked )
{
drawChecked();
else
drawUnchecked();
if ( isMonochron() )
setReverse(false);
}
//----------------------------------------------------------------------
inline void FCheckBox::drawChecked()
{
if ( isNewFont() )
print (CHECKBOX_ON);
else
@ -94,9 +104,11 @@ void FCheckBox::drawCheckButton()
print (fc::Times); // Times ×
print (']');
}
}
else
{
}
//----------------------------------------------------------------------
inline void FCheckBox::drawUnchecked()
{
if ( isNewFont() )
print (CHECKBOX);
else
@ -105,10 +117,6 @@ void FCheckBox::drawCheckButton()
print (' ');
print (']');
}
}
if ( isMonochron() )
setReverse(false);
}
} // namespace finalcut

View File

@ -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);
}
//----------------------------------------------------------------------

View File

@ -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<wchar_t*>(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--;

View File

@ -815,13 +815,6 @@ 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();
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()
{

View File

@ -1475,13 +1475,6 @@ 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();
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()
{

View File

@ -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--;

View File

@ -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 )
{

View File

@ -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,7 +85,17 @@ void FRadioButton::drawRadioButton()
}
if ( checked )
{
drawChecked();
else
drawUnchecked();
if ( isMonochron() )
setReverse(false);
}
//----------------------------------------------------------------------
inline void FRadioButton::drawChecked()
{
if ( isNewFont() )
print (CHECKED_RADIO_BUTTON);
else
@ -94,9 +104,11 @@ void FRadioButton::drawRadioButton()
print (fc::Bullet); // Bullet ●
print (')');
}
}
else
{
}
//----------------------------------------------------------------------
inline void FRadioButton::drawUnchecked()
{
if ( isNewFont() )
print (RADIO_BUTTON);
else
@ -105,10 +117,6 @@ void FRadioButton::drawRadioButton()
print (' ');
print (')');
}
}
if ( isMonochron() )
setReverse(false);
}
} // namespace finalcut

View File

@ -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()
{

View File

@ -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();
}
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)
{

View File

@ -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 ";

View File

@ -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()
{

View File

@ -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<wchar_t*>(txt.wc_str());
wchar_t* dest = const_cast<wchar_t*>(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

View File

@ -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<std::size_t>(-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)
{

View File

@ -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();

View File

@ -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();

View File

@ -93,6 +93,8 @@ class FCheckBox : public FToggleButton
void init();
void draw() override;
void drawCheckButton();
void drawChecked();
void drawUnchecked();
};
#pragma pack(pop)

View File

@ -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();

View File

@ -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;

View File

@ -268,6 +268,7 @@ class FListBox : public FWidget
, fc::orientation
, FListBoxCallback );
void draw() override;
void drawBorder() override;
void drawScrollbars();
void drawHeadline();
void drawList();

View File

@ -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();

View File

@ -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);

View File

@ -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&);

View File

@ -93,6 +93,8 @@ class FRadioButton : public FToggleButton
void init();
void draw() override;
void drawRadioButton();
void drawChecked();
void drawUnchecked();
};
#pragma pack(pop)

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -525,6 +525,7 @@ class FWidget : public FVTerm, public FObject
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

View File

@ -76,7 +76,6 @@ class FWindow : public FWidget
{
public:
// Using-declaration
using FWidget::drawBorder;
using FWidget::setGeometry;
// Constructor