Print function can set the cursor position with an FPoint

This commit is contained in:
Markus Gans 2019-01-27 13:44:13 +01:00
parent c4df64c5bc
commit 96cdaa2450
34 changed files with 275 additions and 283 deletions

View File

@ -1,3 +1,8 @@
2019-01-27 Markus Gans <guru.mail@muenster.de>
* The print command can now have an FPoint object as a parameter
to set the cursor position
* Refactoring of the FProgressbar drawing methods
2019-01-24 Markus Gans <guru.mail@muenster.de>
* Refactoring of some methods in FVTerm and FDialog

View File

@ -338,9 +338,7 @@ void Calc::drawDispay()
if ( isMonochron() )
setReverse(false);
setPrintPos (FPoint(3, 3));
print(display);
print(L' ');
print() << FPoint(3, 3) << display << ' ';
setColor(wc.dialog_fg, wc.dialog_bg);
if ( isMonochron() )
@ -353,13 +351,10 @@ void Calc::drawDispay()
wchar_t top_line = finalcut::fc::NF_border_line_upper;
wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
wchar_t left_line = finalcut::fc::NF_border_line_left;
setPrintPos (FPoint(3, 2));
print (finalcut::FString(33, bottom_line));
setPrintPos (FPoint(2, 3));
print (right_line);
setPrintPos (FPoint(36, 3));
print (left_line);
setPrintPos (FPoint(3, 4));
print() << FPoint(3, 2) << finalcut::FString(33, bottom_line);
print() << FPoint(2, 3) << right_line;
print() << FPoint(36, 3) << left_line;
print() << FPoint(3, 4);
finalcut::FString top_bottom_line_5 (5, top_bottom_line);
finalcut::FString top_line_2 (2, top_line);
print ( top_bottom_line_5 + top_line_2
@ -376,8 +371,7 @@ void Calc::drawDispay()
finalcut::FString separator = finalcut::FString(vertical_and_right)
+ finalcut::FString(35, horizontal)
+ finalcut::FString(vertical_and_left);
setPrintPos (FPoint(1, 4));
print(separator);
print() << FPoint(1, 4) << separator;
}
}

View File

@ -51,6 +51,7 @@ void cb_publish (finalcut::FWidget* widget, FDataPtr data)
cbox2->unsetChecked();
cbox2->setDisable();
}
cbox2->redraw();
}

View File

@ -79,8 +79,8 @@ void Keyboard::onAccel (finalcut::FAccelEvent* ev)
//----------------------------------------------------------------------
void Keyboard::draw()
{
setPrintPos (finalcut::FPoint(1, 1));
print() << "---------------\n"
print() << finalcut::FPoint(1, 1)
<< "---------------\n"
<< "Press Q to quit\n"
<< "---------------\n";
setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);

View File

@ -92,7 +92,7 @@ void Mandelbrot::draw()
for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
{
current_line++;
setPrintPos (FPoint(xoffset, yoffset + current_line));
print() << FPoint(xoffset, yoffset + current_line);
for (x0 = x_min; x0 < x_max; x0 += dX)
{

View File

@ -131,7 +131,7 @@ void ColorChooser::draw()
for (FColor c = 0; c < 16; c++)
{
setPrintPos (FPoint(2 + (c / 8) * 3, 3 + c % 8));
print() << FPoint(2 + (c / 8) * 3, 3 + c % 8);
if ( c < 6 )
setColor (finalcut::fc::LightGray, c);
@ -245,9 +245,8 @@ void Brushes::draw()
setColor();
finalcut::FWidget::drawBorder (1, 2, 8, 4);
setColor (fg_color, bg_color);
setPrintPos (FPoint(2, 3));
print(" ");
print(finalcut::FString(3, finalcut::fc::MediumShade));
print() << FPoint(2, 3) << " "
<< finalcut::FString(3, finalcut::fc::MediumShade);
if ( brush == L' ' )
pos = 0;
@ -255,10 +254,10 @@ void Brushes::draw()
pos = 3;
setColor();
setPrintPos (FPoint(3 + pos, 2));
print(finalcut::fc::BlackDownPointingTriangle);
setPrintPos (FPoint(3 + pos, 4));
print(finalcut::fc::BlackUpPointingTriangle);
print() << FPoint(3 + pos, 2)
<< finalcut::fc::BlackDownPointingTriangle
<< FPoint(3 + pos, 4)
<< finalcut::fc::BlackUpPointingTriangle;
}
//----------------------------------------------------------------------
@ -428,26 +427,25 @@ void MouseDraw::draw()
{
for (int y = 2; y < y_max; y++)
{
setPrintPos (FPoint(10, y));
print (finalcut::fc::NF_rev_border_line_right);
print() << FPoint(10, y)
<< finalcut::fc::NF_rev_border_line_right;
}
setPrintPos (FPoint(10, y_max));
print (finalcut::fc::NF_rev_border_corner_lower_right);
print() << FPoint(10, y_max)
<< finalcut::fc::NF_rev_border_corner_lower_right;
}
else
{
setPrintPos (FPoint(10, 2));
print (finalcut::fc::BoxDrawingsDownAndHorizontal);
print() << FPoint(10, 2)
<< finalcut::fc::BoxDrawingsDownAndHorizontal;
for (int y = 3; y < y_max; y++)
{
setPrintPos (FPoint(10, y));
print (finalcut::fc::BoxDrawingsVertical);
print() << FPoint(10, y) << finalcut::fc::BoxDrawingsVertical;
}
setPrintPos (FPoint(10, y_max));
print (finalcut::fc::BoxDrawingsUpAndHorizontal);
print() << FPoint(10, y_max)
<< finalcut::fc::BoxDrawingsUpAndHorizontal;
}
drawCanvas();

View File

@ -139,7 +139,7 @@ void Scrollview::draw()
for (int y = 0; y < int(getScrollHeight()); y++)
{
setPrintPos (FPoint(1, 1 + y));
print() << FPoint(1, 1 + y);
for (int x = 0; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f));

View File

@ -273,8 +273,7 @@ void AttribDemo::printAltCharset()
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
setPrintPos (FPoint(1, 1));
print("alternate charset: ");
print() << FPoint(1, 1) << "alternate charset: ";
if ( parent->bgcolor == finalcut::fc::Default )
{
@ -440,7 +439,7 @@ void AttribDemo::draw()
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
{
setPrintPos (FPoint(1, 2 + int(y)));
print() << FPoint(1, 2 + int(y));
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
@ -452,7 +451,7 @@ void AttribDemo::draw()
if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg);
setPrintPos (FPoint(1, 15));
print() << FPoint(1, 15);
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:");
@ -461,8 +460,7 @@ void AttribDemo::draw()
else
printf ( " %d", bg);
setPrintPos (FPoint(16, 17));
print ("Change background color ->");
print() << FPoint(16, 17) << "Change background color ->";
}

View File

@ -59,8 +59,8 @@ Timer::Timer (finalcut::FWidget* parent)
//----------------------------------------------------------------------
void Timer::draw()
{
setPrintPos (finalcut::FPoint(1, 1));
print() << "---------------\n"
print() << finalcut::FPoint(1, 1)
<< "---------------\n"
<< "Press Q to quit\n"
<< "---------------\n";
setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);

View File

@ -111,8 +111,7 @@ void Transparent::draw()
for (int n = 1; n <= int(getClientHeight()); n++)
{
setPrintPos (FPoint(2, 2 + n));
print(line);
print() << FPoint(2, 2 + n) << line;
}
if ( type == shadow )
@ -242,10 +241,8 @@ void MainWindow::draw()
setReverse(true);
setColor();
setPrintPos (FPoint(2, 4));
print(line1);
setPrintPos (FPoint(2, 5));
print(line2);
print() << FPoint(2, 4) << line1;
print() << FPoint(2, 5) << line2;
if ( isMonochron() )
setReverse(false);

View File

@ -253,8 +253,7 @@ void FButton::hide()
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
{
setPrintPos (FPoint(1 - int(f), 1 + int(y - f)));
print (blank);
print() << FPoint(1 - int(f), 1 + int(y - f)) << blank;
}
destroyBlankArray (blank);
@ -491,8 +490,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
for (std::size_t y = 1; y <= getHeight(); y++)
{
setPrintPos (FPoint(1, int(y)));
print (' '); // clear one left █
print() << FPoint(1, int(y)) << ' '; // clear one left █
}
return 1;
@ -514,8 +512,7 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
if ( isMonochron() )
setReverse(true); // Light background
setPrintPos (FPoint(1 + int(getWidth()), y));
print (' '); // clear right
print() << FPoint(1 + int(getWidth()), y) << ' '; // clear right
if ( flags.active && isMonochron() )
setReverse(false); // Dark background
@ -531,7 +528,7 @@ inline void FButton::drawMarginLeft()
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (FPoint(1 + int(indent), 1 + int(y)));
print() << FPoint(1 + int(indent), 1 + int(y));
if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ►
@ -547,7 +544,7 @@ inline void FButton::drawMarginRight()
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (FPoint(int(getWidth() + indent), 1 + int(y)));
print() << FPoint(int(getWidth() + indent), 1 + int(y));
if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄
@ -566,7 +563,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = 0; y < vcenter_offset; y++)
{
setPrintPos (FPoint(2 + int(indent), 1 + int(y)));
print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █
@ -574,7 +571,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
{
setPrintPos (FPoint(2 + int(indent), 1 + int(y)));
print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █
@ -585,7 +582,7 @@ inline void FButton::drawTopBottomBackground()
inline void FButton::drawButtonTextLine (wchar_t button_text[])
{
std::size_t pos;
setPrintPos (FPoint(2 + int(indent), 1 + int(vcenter_offset)));
print() << FPoint(2 + int(indent), 1 + int(vcenter_offset));
setColor (button_fg, button_bg);
if ( getWidth() < txtlength + 1 )
@ -643,8 +640,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( txtlength >= getWidth() - 1 )
{
// Print ellipsis
setPrintPos (FPoint(int(getWidth() + indent) - 2, 1));
print (L"..");
print() << FPoint(int(getWidth() + indent) - 2, 1) << "..";
}
if ( active_focus && (isMonochron() || getMaxColor() < 16) )

View File

@ -72,7 +72,7 @@ void FCheckBox::drawCheckButton()
if ( ! isVisible() )
return;
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
setColor();
if ( isMonochron() )

View File

@ -924,24 +924,20 @@ void FDialog::drawBorder()
{
for (int y = y1; y < y2; y++)
{
setPrintPos (FPoint(x1, y));
// Border left ⎸
print (fc::NF_border_line_left);
setPrintPos (FPoint(x2, y));
// Border right⎹
print (fc::NF_rev_border_line_right);
print() << FPoint(x1, y) // Border left ⎸
<< fc::NF_border_line_left;
print() << FPoint(x2, y) // Border right⎹
<< fc::NF_rev_border_line_right;
}
setPrintPos (FPoint(x1, y2));
// Lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
print() << FPoint(x1, y2) // Lower left corner border ⎣
<< fc::NF_border_corner_lower_left;
for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom);
setPrintPos (FPoint(x2, y2));
// Lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right);
print() << FPoint(x2, y2) // Lower right corner border ⎦
<< fc::NF_rev_border_corner_lower_right;
}
else
{
@ -966,7 +962,7 @@ void FDialog::drawTitleBar()
if ( PRINT_WIN_NUMBER )
{
// Print the number of window in stack
setPrintPos (FPoint(int(getWidth()) - 2, 1));
print() << FPoint(int(getWidth()) - 2, 1);
printf ("(%d)", getWindowLayer(this));
}
#endif // DEBUG
@ -976,7 +972,7 @@ void FDialog::drawTitleBar()
void FDialog::drawBarButton()
{
// Print the title button
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( dialog_menu && dialog_menu->isShown() )
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);

View File

@ -480,7 +480,7 @@ void FLabel::drawMultiLine()
else
std::wcsncpy(dest, src, length);
setPrintPos (FPoint(1, 1 + int(y)));
print() << FPoint(1, 1 + int(y));
if ( hotkeypos != NOT_SET )
{
@ -522,7 +522,7 @@ void FLabel::drawSingleLine()
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text;

View File

@ -678,7 +678,7 @@ void FLineEdit::drawInputField()
std::size_t x;
FString show_text;
bool isActiveFocus = flags.active && flags.focus;
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( isMonochron() )
{

View File

@ -315,8 +315,7 @@ void FListBox::clear()
for (int y = 0; y < int(getHeight()) - 2; y++)
{
setPrintPos (FPoint(2, 2 + y));
print (blank);
print() << FPoint(2, 2 + y) << blank;
}
destroyBlankArray (blank);
@ -819,8 +818,8 @@ void FListBox::draw()
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (FPoint(int(getWidth()), y));
print (' '); // clear right side of the scrollbar
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
}
}
@ -854,7 +853,7 @@ void FListBox::drawHeadline()
FString txt = " " + text + " ";
std::size_t length = txt.getLength();
setPrintPos (FPoint(2, 1));
print() << FPoint(2, 1);
if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg);
@ -1060,7 +1059,7 @@ inline void FListBox::setLineAttributes ( int y
{
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
std::size_t inc_len = inc_search.getLength();
setPrintPos (FPoint(2, 2 + int(y)));
print() << FPoint(2, 2 + int(y));
if ( isLineSelected )
{

View File

@ -1469,8 +1469,8 @@ void FListView::draw()
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (FPoint(int(getWidth()), y));
print (' '); // clear right side of the scrollbar
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
}
}
@ -1543,8 +1543,7 @@ void FListView::drawHeadlines()
last = h.begin() + len;
}
setPrintPos (FPoint(2, 1));
print() << std::vector<charData>(first, last);
print() << FPoint(2, 1) << std::vector<charData>(first, last);
}
//----------------------------------------------------------------------
@ -1563,7 +1562,7 @@ void FListView::drawList()
const auto item = static_cast<FListViewItem*>(*iter);
int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
setPrintPos (FPoint(2, 2 + int(y)));
print() << FPoint(2, 2 + int(y));
// Draw one FListViewItem
drawListLine (item, flags.focus, is_current_line);
@ -1589,8 +1588,8 @@ void FListView::drawList()
// Clean empty space after last element
while ( y < uInt(getClientHeight()) )
{
setPrintPos (FPoint(2, 2 + int(y)));
print (FString(std::size_t(getClientWidth()), ' '));
print() << FPoint(2, 2 + int(y))
<< FString(std::size_t(getClientWidth()), ' ');
y++;
}
}
@ -1667,7 +1666,7 @@ void FListView::drawListLine ( const FListViewItem* item
std::size_t i;
for (i = 0; i < len; i++)
*this << element_str[i];
print() << element_str[i];
for (; i < getWidth() - nf_offset - 2; i++)
print (' ');

View File

@ -1251,7 +1251,7 @@ void FMenu::drawItems()
//----------------------------------------------------------------------
inline void FMenu::drawSeparator (int y)
{
setPrintPos (FPoint(1, 2 + y));
print() << FPoint(1, 2 + y);
setColor (wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() )
@ -1498,7 +1498,7 @@ inline void FMenu::setLineAttributes (FMenuItem* menuitem, int y)
setReverse(true);
}
setPrintPos (FPoint(2, 2 + y));
print() << FPoint(2, 2 + y);
setColor();
}

View File

@ -66,8 +66,7 @@ void FMenuBar::hide()
setColor (fg, bg);
screenWidth = getDesktopWidth();
auto blank = createBlankArray (screenWidth + 1);
setPrintPos (FPoint(1, 1));
print (blank);
print() << FPoint(1, 1) << blank;
destroyBlankArray (blank);
}
@ -501,7 +500,7 @@ void FMenuBar::drawItems()
if ( item_list.empty() )
return;
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( isMonochron() )
setReverse(true);
@ -664,14 +663,12 @@ inline void FMenuBar::drawEllipsis (const menuText& txtdata, std::size_t x)
if ( txtdata.startpos < screenWidth )
{
// Print ellipsis
setPrintPos (FPoint(int(screenWidth) - 1, 1));
print ("..");
print() << FPoint(int(screenWidth) - 1, 1) << "..";
}
else if ( txtdata.startpos - 1 <= screenWidth )
{
// Hide first character from text
setPrintPos (FPoint(int(screenWidth), 1));
print (' ');
print() << FPoint(int(screenWidth), 1) << ' ';
}
}
}

View File

@ -359,8 +359,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2);
setPrintPos (FPoint(1 + msg_x + center_x, 4));
print (headline_text);
print() << FPoint(1 + msg_x + center_x, 4) << headline_text;
head_offset = 2;
}
@ -373,8 +372,8 @@ void FMessageBox::draw()
if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2);
setPrintPos (FPoint(1 + msg_x + center_x, 4 + head_offset + i));
print(text_components[i]);
print() << FPoint(1 + msg_x + center_x, 4 + head_offset + i)
<< text_components[i];
}
if ( isMonochron() )

View File

@ -58,8 +58,8 @@ void FProgressbar::setPercentage (std::size_t percentage_value)
if ( isShown() )
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
}
updateTerminal();
@ -100,8 +100,8 @@ void FProgressbar::hide()
FWidget::hide();
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
hideSize (getSize() + shadow);
setPrintPos (FPoint(int(getWidth()) - 4, 0));
print (" "); // hide percentage
print() << FPoint(int(getWidth()) - 4, 0)
<< (" "); // hide percentage
}
//----------------------------------------------------------------------
@ -111,8 +111,8 @@ void FProgressbar::reset()
if ( isShown() )
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
}
updateTerminal();
@ -123,8 +123,8 @@ void FProgressbar::reset()
//----------------------------------------------------------------------
void FProgressbar::draw()
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
if ( flags.shadow )
drawShadow ();
@ -133,7 +133,7 @@ void FProgressbar::draw()
}
//----------------------------------------------------------------------
void FProgressbar::drawPercentage()
void FProgressbar::drawProgressLabel()
{
auto parent_widget = getParentWidget();
@ -146,7 +146,7 @@ void FProgressbar::drawPercentage()
if ( isMonochron() )
setReverse(true);
setPrintPos (FPoint(int(getWidth()) - 3, 0));
print() << FPoint(int(getWidth()) - 3, 0);
if ( percentage > 100 )
print ("--- %");
@ -158,62 +158,16 @@ void FProgressbar::drawPercentage()
}
//----------------------------------------------------------------------
void FProgressbar::drawBar()
void FProgressbar::drawProgressBar()
{
std::size_t i = 0;
double length;
setPrintPos (FPoint(1, 1));
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
std::size_t len = 0;
print() << FPoint(1, 1);
setColor (wc.progressbar_bg, wc.progressbar_fg);
if ( percentage == NOT_SET )
length = double(-0/100);
else
length = double(bar_length * percentage) / 100;
if ( percentage > 0 && percentage <= 100 )
len = drawProgressIndicator();
if ( isMonochron() )
setReverse(false);
for (; i < trunc(length); i++)
print (' ');
if ( isMonochron() )
setReverse(true);
if ( percentage > 0 && percentage <= 100 && trunc(length) < bar_length )
{
if ( round(length) > trunc(length) || getMaxColor() < 16 )
{
if ( isMonochron() )
{
setReverse(false);
print (' ');
setReverse(true);
}
else
print (' ');
}
else
{
setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌
}
i++;
}
setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 )
{
for (; i < bar_length; i++)
print (fc::MediumShade); // ▒
}
else
{
for (; i < bar_length; i++)
print (' ');
}
drawProgressBackground(len);
if ( isMonochron() )
setReverse(false);
@ -222,4 +176,56 @@ void FProgressbar::drawBar()
flush_out();
}
//----------------------------------------------------------------------
std::size_t FProgressbar::drawProgressIndicator()
{
// Draw the progress indicator
if ( isMonochron() )
setReverse(false);
double length = double(bar_length * percentage) / 100;
auto len = std::size_t(trunc(length));
print() << FString (len, L' ');
if ( isMonochron() )
setReverse(true);
if ( len >= bar_length )
return len;
if ( round(length) > len || getMaxColor() < 16 )
{
if ( isMonochron() )
setReverse(false);
print(' ');
if ( isMonochron() )
setReverse(true);
}
else
{
setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌
}
len++;
return len;
}
//----------------------------------------------------------------------
void FProgressbar::drawProgressBackground (std::size_t len)
{
// Draw the progress background
std::size_t bg_len = bar_length - len;
setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 )
print() << FString (bg_len, fc::MediumShade); // ▒
else
print() << FString (bg_len, L' ');
}
} // namespace finalcut

View File

@ -73,7 +73,7 @@ void FRadioButton::drawRadioButton()
if ( ! isVisible() )
return;
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
setColor();
if ( isMonochron() )

View File

@ -240,7 +240,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= slider_pos; z++)
{
setPrintPos (FPoint(1, 1 + z));
print() << FPoint(1, 1 + z);
if ( isNewFont() )
{
@ -263,7 +263,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= int(slider_length); z++)
{
setPrintPos (FPoint(1, 1 + slider_pos + z));
print() << FPoint(1, 1 + slider_pos + z);
if ( isNewFont() )
print (' ');
@ -278,7 +278,7 @@ void FScrollbar::drawVerticalBar()
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
{
setPrintPos (FPoint(1, 1 + z));
print() << FPoint(1, 1 + z);
if ( isNewFont() )
{
@ -305,9 +305,9 @@ void FScrollbar::drawHorizontalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
if ( isNewFont() )
setPrintPos (FPoint(3, 1));
print() << FPoint(3, 1);
else
setPrintPos (FPoint(2, 1));
print() << FPoint(2, 1);
for (z = 0; z < slider_pos; z++)
{
@ -590,43 +590,43 @@ void FScrollbar::drawButtons()
if ( isNewFont() )
{
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( bar_orientation == fc::vertical )
{
print (fc::NF_rev_up_arrow1);
print (fc::NF_rev_up_arrow2);
setPrintPos (FPoint(1, int(length)));
print (fc::NF_rev_down_arrow1);
print (fc::NF_rev_down_arrow2);
print() << fc::NF_rev_up_arrow1
<< fc::NF_rev_up_arrow2
<< FPoint(1, int(length))
<< fc::NF_rev_down_arrow1
<< fc::NF_rev_down_arrow2;
}
else // horizontal
{
print (fc::NF_rev_left_arrow1);
print (fc::NF_rev_left_arrow2);
setPrintPos (FPoint(int(length) - 1, 1));
print (fc::NF_rev_right_arrow1);
print (fc::NF_rev_right_arrow2);
print() << fc::NF_rev_left_arrow1
<< fc::NF_rev_left_arrow2
<< FPoint(int(length) - 1, 1)
<< fc::NF_rev_right_arrow1
<< fc::NF_rev_right_arrow2;
}
}
else
{
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( isMonochron() )
setReverse(true);
if ( bar_orientation == fc::vertical )
{
print (fc::BlackUpPointingTriangle); // ▲
setPrintPos (FPoint(1, int(length)));
print (fc::BlackDownPointingTriangle); // ▼
print() << fc::BlackUpPointingTriangle // ▲
<< FPoint(1, int(length))
<< fc::BlackDownPointingTriangle; // ▼
}
else // horizontal
{
print (fc::BlackLeftPointingPointer); // ◄
setPrintPos (FPoint(int(length), 1));
print (fc::BlackRightPointingPointer); // ►
print() << fc::BlackLeftPointingPointer // ◄
<< FPoint(int(length), 1)
<< fc::BlackRightPointingPointer; // ►
}
if ( isMonochron() )

View File

@ -178,8 +178,7 @@ void FStatusBar::hide()
setColor (fg, bg);
screenWidth = getDesktopWidth();
auto blank = createBlankArray(screenWidth + 1);
setPrintPos (FPoint(1, 1));
print (blank);
print() << FPoint(1, 1) << blank;
destroyBlankArray (blank);
}
@ -541,7 +540,7 @@ void FStatusBar::drawKeys()
return;
}
setPrintPos (FPoint(1, 1));
print() << FPoint(1, 1);
if ( isMonochron() )
setReverse(true);

View File

@ -127,7 +127,7 @@ void FSwitch::drawCheckButton()
if ( ! isVisible() )
return;
setPrintPos (FPoint(1 + int(switch_offset_pos), 1));
print() << FPoint(1 + int(switch_offset_pos), 1);
if ( checked )
drawChecked();

View File

@ -297,8 +297,7 @@ void FTextView::clear()
for (int y = 0; y < int(getTextHeight()); y++)
{
setPrintPos (FPoint(2, 2 - nf_offset + y));
print (blank);
print() << FPoint(2, 2 - nf_offset + y) << blank;
}
destroyBlankArray (blank);
@ -695,7 +694,7 @@ void FTextView::drawText()
{
std::size_t i;
FString line;
setPrintPos (FPoint(2, 2 - nf_offset + int(y)));
print() << FPoint(2, 2 - nf_offset + int(y));
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() );
const auto line_str = line.wc_str();

View File

@ -445,7 +445,7 @@ void FToggleButton::drawLabel()
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (FPoint(1 + int(label_offset_pos), 1));
print() << FPoint(1 + int(label_offset_pos), 1);
drawText (LabelText, hotkeypos, length);
delete[] LabelText;
}

View File

@ -87,8 +87,7 @@ void FToolTip::draw()
for (std::size_t i = 0; i < text_num_lines; i++)
{
setPrintPos (FPoint(3, 2 + int(i)));
print(text_components[i]);
print() << FPoint(3, 2 + int(i)) << text_components[i];
}
unsetBold();

View File

@ -150,14 +150,10 @@ void FVTerm::hideCursor (bool enable)
//----------------------------------------------------------------------
void FVTerm::setPrintCursor (const FPoint& pos)
{
int x = pos.getX();
int y = pos.getY();
auto win = getPrintArea();
if ( win )
if ( auto win = getPrintArea() )
{
win->cursor_x = x - win->offset_left;
win->cursor_y = y - win->offset_top;
win->cursor_x = pos.getX() - win->offset_left;
win->cursor_y = pos.getY() - win->offset_top;
}
}
@ -315,7 +311,9 @@ int FVTerm::printf (const FString format, ...)
//----------------------------------------------------------------------
int FVTerm::print (const FString& s)
{
assert ( ! s.isNull() );
if ( s.isNull() )
return -1;
auto area = getPrintArea();
if ( ! area )
@ -332,9 +330,7 @@ int FVTerm::print (const FString& s)
//----------------------------------------------------------------------
int FVTerm::print (term_area* area, const FString& s)
{
assert ( ! s.isNull() );
if ( ! area )
if ( s.isNull() || ! area )
return -1;
std::vector<charData> term_string;
@ -561,6 +557,13 @@ int FVTerm::print (term_area* area, charData& term_char)
return 1;
}
//----------------------------------------------------------------------
void FVTerm::print (const FPoint& p)
{
setPrintCursor (p);
}
// protected methods of FVTerm
//----------------------------------------------------------------------
FVTerm::term_area* FVTerm::getPrintArea()

View File

@ -1273,14 +1273,13 @@ void FWidget::clearShadow()
{
for (std::size_t y = 1; y <= getHeight(); y++)
{
setPrintPos (FPoint(w + 1, int(y)));
print (' '); // clear █
print() << FPoint(w + 1, int(y)) << ' '; // clear █
}
}
if ( h <= offset.getY2() )
{
setPrintPos (FPoint(2, h + 1));
print() << FPoint(2, h + 1);
for (std::size_t i = 1; i <= getWidth(); i++)
print (' '); // clear ▀
@ -1308,7 +1307,7 @@ void FWidget::drawFlatBorder()
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (FPoint(x1 - 1, y1 + int(y) + 1));
print() << FPoint(x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[uLong(y)] )
// left+right line (on left side)
@ -1318,7 +1317,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_rev_border_line_right);
}
setPrintPos (FPoint(x2, y1 + 1));
print() << FPoint(x2, y1 + 1);
for (std::size_t y = 0; y < getHeight(); y++)
{
@ -1329,10 +1328,10 @@ void FWidget::drawFlatBorder()
// left line (on right side)
print (fc::NF_border_line_left);
setPrintPos (FPoint(x2, y1 + int(y) + 2));
print() << FPoint(x2, y1 + int(y) + 2);
}
setPrintPos (FPoint(x1, y1));
print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1344,7 +1343,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_border_line_bottom);
}
setPrintPos (FPoint(x1, y2));
print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1376,7 +1375,7 @@ void FWidget::clearFlatBorder()
// clear on left side
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (FPoint(x1 - 1, y1 + int(y) + 1));
print() << FPoint(x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[y] )
print (fc::NF_border_line_left);
@ -1387,7 +1386,7 @@ void FWidget::clearFlatBorder()
// clear on right side
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (FPoint(x2, y1 + int(y) + 1));
print() << FPoint(x2, y1 + int(y) + 1);
if ( double_flatline_mask.right[y] )
print (fc::NF_rev_border_line_right);
@ -1396,7 +1395,7 @@ void FWidget::clearFlatBorder()
}
// clear at top
setPrintPos (FPoint(x1, y1));
print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1407,7 +1406,7 @@ void FWidget::clearFlatBorder()
}
// clear at bottom
setPrintPos (FPoint(x1, y2));
print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1646,8 +1645,7 @@ void FWidget::hideSize (const FSize& size)
for (int y = 0; y < int(size.getWidth()); y++)
{
setPrintPos (FPoint(1, 1 + y));
print (blank);
print() << FPoint(1, 1 + y) << blank;
}
destroyBlankArray (blank);
@ -2230,9 +2228,9 @@ void FWidget::drawChildren()
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
{
// transparent shadow
setPrintPos (FPoint(x2 + 1, y1));
setTransparent();
print (" ");
print() << FPoint(x2 + 1, y1) << " ";
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
@ -2240,14 +2238,12 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++)
{
setPrintPos (FPoint(x2 + 1, y1 + int(y)));
print (" ");
print() << FPoint(x2 + 1, y1 + int(y)) << " ";
}
unsetTransShadow();
setPrintPos (FPoint(x1, y2 + 1));
setTransparent();
print (" ");
print() << FPoint(x1, y2 + 1) << " ";
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
@ -2266,12 +2262,12 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
{
// non-transparent shadow
int block;
wchar_t block;
if ( ! hasShadowCharacter() )
return;
setPrintPos (FPoint(x2 + 1, y1));
print() << FPoint(x2 + 1, y1);
if ( isWindowWidget() )
{
@ -2289,11 +2285,10 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++)
{
setPrintPos (FPoint(x2 + 1, y1 + int(y)));
print (block); // █
print() << FPoint(x2 + 1, y1 + int(y)) << block; // █
}
setPrintPos (FPoint(x1 + 1, y2 + 1));
print() << FPoint(x1 + 1, y2 + 1);
if ( isWindowWidget() )
setInheritBackground();
@ -2310,8 +2305,7 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
{
// Use box-drawing characters to draw a border
setPrintPos (FPoint(x1, y1));
print (fc::BoxDrawingsDownAndRight); // ┌
print() << FPoint(x1, y1) << fc::BoxDrawingsDownAndRight; // ┌
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
@ -2320,14 +2314,13 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y < y2; y++)
{
setPrintPos (FPoint(x1, y));
print (fc::BoxDrawingsVertical); // │
setPrintPos (FPoint(x2, y));
print (fc::BoxDrawingsVertical); // │
print() << FPoint(x1, y)
<< fc::BoxDrawingsVertical // │
<< FPoint(x2, y)
<< fc::BoxDrawingsVertical; // │
}
setPrintPos (FPoint(x1, y2));
print (fc::BoxDrawingsUpAndRight); // └
print() << FPoint(x1, y2) << fc::BoxDrawingsUpAndRight; // └
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
@ -2336,10 +2329,10 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int x = x1 + 1; x < x2; x++)
{
setPrintPos (FPoint(x, y1));
print (fc::BoxDrawingsHorizontal); // ─
setPrintPos (FPoint(x, y2));
print (fc::BoxDrawingsHorizontal); // ─
print() << FPoint(x, y1)
<< fc::BoxDrawingsHorizontal // ─
<< FPoint(x, y2)
<< fc::BoxDrawingsHorizontal; // ─
}
}
@ -2348,8 +2341,8 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
{
// Use new graphical font characters to draw a border
setPrintPos (FPoint(x1, y1));
print (fc::NF_border_corner_middle_upper_left); // ┌
print() << FPoint(x1, y1)
<< fc::NF_border_corner_middle_upper_left; // ┌
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
@ -2358,14 +2351,14 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y <= y2; y++)
{
setPrintPos (FPoint(x1, y));
print (fc::NF_border_line_left); // border left ⎸
setPrintPos (FPoint(x2, y));
print (fc::NF_rev_border_line_right); // border right⎹
print() << FPoint(x1, y)
<< fc::NF_border_line_left // border left ⎸
<< FPoint(x2, y)
<< fc::NF_rev_border_line_right; // border right⎹
}
setPrintPos (FPoint(x1, y2));
print (fc::NF_border_corner_middle_lower_left); // └
print() << FPoint(x1, y2)
<< fc::NF_border_corner_middle_lower_left; // └
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─

View File

@ -251,8 +251,7 @@ void FWindow::drawBorder()
, y1 = 1
, y2 = 1 + int(getHeight()) - 1;
setPrintPos (FPoint(x1, y1));
print (fc::NF_border_corner_upper_left); // ⎡
print() << FPoint(x1, y1) << fc::NF_border_corner_upper_left; // ⎡
for (int x = x1 + 1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯
@ -261,24 +260,20 @@ void FWindow::drawBorder()
for (int y = y1 + 1; y < y2; y++)
{
setPrintPos (FPoint(x1, y));
// border left ⎸
print (fc::NF_border_line_left);
setPrintPos (FPoint(x2, y));
// border right⎹
print (fc::NF_rev_border_line_right);
print() << FPoint(x1, y) // border left ⎸
<< fc::NF_border_line_left
<< FPoint(x2, y) // border right⎹
<< fc::NF_rev_border_line_right;
}
setPrintPos (FPoint(x1, y2));
// lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
print() << FPoint(x1, y2) // lower left corner border ⎣
<< fc::NF_border_corner_lower_left;
for (std::size_t x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom);
setPrintPos (FPoint(x2, y2));
// lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right);
print() << FPoint(x2, y2) // lower right corner border ⎦
<< fc::NF_rev_border_corner_lower_right;
}
else
{

View File

@ -101,8 +101,10 @@ class FProgressbar : public FWidget
// Methods
virtual void draw() override;
void drawPercentage();
void drawBar();
void drawProgressLabel();
void drawProgressBar();
std::size_t drawProgressIndicator();
void drawProgressBackground (std::size_t);
// Data Members
std::size_t percentage{NOT_SET};

View File

@ -132,6 +132,7 @@ class FVTerm
template <typename type>
FVTerm& operator << (const type&);
FVTerm& operator << (const std::vector<charData>&);
FVTerm& operator << (const FPoint&);
// Accessors
virtual const char* getClassName() const;
@ -294,7 +295,8 @@ class FVTerm
int print (term_area*, wchar_t);
int print (charData&);
int print (term_area*, charData&);
FVTerm& print();
virtual void print (const FPoint&);
virtual FVTerm& print();
static void beep();
static void redefineDefaultColors (bool);
static char* moveCursor (int, int, int, int);
@ -550,6 +552,13 @@ inline FVTerm& FVTerm::operator << \
return *this;
}
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << (const FPoint& pos)
{
print (pos);
return *this;
}
//----------------------------------------------------------------------
inline const char* FVTerm::getClassName() const
{ return "FVTerm"; }

View File

@ -129,6 +129,7 @@ class FWidget : public FVTerm, public FObject
public:
// Using-declaration
using FVTerm::setColor;
using FVTerm::print;
struct accelerator
{
@ -325,6 +326,7 @@ class FWidget : public FVTerm, public FObject
virtual bool focusLastChild();
FPoint termToWidgetPos (const FPoint&);
void detectTermSize();
virtual void print (const FPoint& p) override;
virtual void move (const FPoint&);
void drawShadow();
void clearShadow();
@ -920,6 +922,12 @@ inline FPoint FWidget::termToWidgetPos (const FPoint& tPos)
, tPos.getY() + 1 - offset.getY1() - adjust_wsize.getY() );
}
//----------------------------------------------------------------------
inline void FWidget::print (const FPoint& pos)
{
setPrintPos (pos);
}
//----------------------------------------------------------------------
inline void FWidget::drawBorder()
{ drawBorder (1, 1, int(getWidth()), int(getHeight())); }