Minor code changes

This commit is contained in:
Markus Gans 2019-09-09 19:13:38 +02:00
parent bc3afa6235
commit e15f1a344a
17 changed files with 128 additions and 154 deletions

View File

@ -59,7 +59,7 @@ case "$1" in
;;
"--fulldebug"|"fulldebug")
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args"
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args"
then
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255

View File

@ -26,9 +26,6 @@
#include <final/final.h>
// Global FVTerm object
static finalcut::FVTerm* terminal;
// Global FApplication object
static finalcut::FApplication* app{nullptr};
@ -145,7 +142,6 @@ int main (int argc, char* argv[])
finalcut::FApplication TermApp(argc, argv);
// Pointer to the global virtual terminal object
terminal = static_cast<finalcut::FVTerm*>(&TermApp);
app = &TermApp;
// Get screen dimension

View File

@ -28,9 +28,6 @@
namespace fc = finalcut::fc;
// Global FVTerm object
static finalcut::FVTerm* terminal;
// Function prototype
void tcapBoolean (const std::string&, bool);
void tcapNumeric (const std::string&, int);
@ -309,9 +306,6 @@ int main (int argc, char* argv[])
bool disable_alt_screen{true};
finalcut::FApplication TermApp (argc, argv, disable_alt_screen);
// Pointer to the global virtual terminal object
terminal = static_cast<finalcut::FVTerm*>(&TermApp);
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";

View File

@ -586,7 +586,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
setBold();
for ( std::size_t z{0}
; pos < center_offset + txtlength && z < getWidth() - 2
; pos < center_offset + txtlength && z + 2 < getWidth()
; z++, pos++)
{
if ( z == hotkeypos && getFlags().active )
@ -615,7 +615,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
}
}
if ( txtlength >= getWidth() - 1 )
if ( txtlength + 1 >= getWidth() )
{
// Print ellipsis
print() << FPoint(int(getWidth() + indent) - 2, 1) << "..";

View File

@ -284,7 +284,7 @@ void FLineEdit::setCursorPosition (std::size_t pos)
if ( cursor_pos > text.getLength() )
keyEnd();
else if ( cursor_pos >= getWidth() - 1 )
else if ( cursor_pos + 1 >= getWidth() )
text_offset = text.getLength() - getWidth() + 2;
else
text_offset = 0;
@ -534,7 +534,7 @@ void FLineEdit::onTimer (FTimerEvent*)
break;
case FLineEdit::scrollRight:
if ( len < getWidth() - 2
if ( len + 2 < getWidth()
|| text_offset == len - getWidth() + 2 )
{
drag_scroll = FLineEdit::noScroll;
@ -744,7 +744,7 @@ void FLineEdit::drawInputField()
std::size_t x = show_text.getLength();
while ( x < getWidth() - 1 )
while ( x + 1 < getWidth() )
{
print (' ');
x++;
@ -784,7 +784,7 @@ inline void FLineEdit::keyRight()
if ( cursor_pos < len )
cursor_pos++;
if ( cursor_pos - text_offset >= getWidth() - 2
if ( cursor_pos - text_offset + 2 >= getWidth()
&& text_offset <= len - getWidth() + 1 )
text_offset++;
}
@ -802,7 +802,7 @@ inline void FLineEdit::keyEnd()
std::size_t len = text.getLength();
cursor_pos = len;
if ( cursor_pos >= getWidth() - 1 )
if ( cursor_pos + 1 >= getWidth() )
text_offset = len - getWidth() + 2;
else
text_offset = 0;
@ -822,7 +822,7 @@ inline void FLineEdit::keyDel()
if ( cursor_pos >= len )
cursor_pos = len;
if ( text_offset > 0 && len - text_offset < getWidth() - 1 )
if ( text_offset > 0 && len - text_offset + 1 < getWidth() )
text_offset--;
}
@ -888,7 +888,7 @@ inline bool FLineEdit::keyInput (FKey key)
cursor_pos++;
if ( cursor_pos >= getWidth() - 1 )
if ( cursor_pos + 1 >= getWidth() )
text_offset++;
processChanged();

View File

@ -259,7 +259,7 @@ void FListBox::remove (std::size_t item)
if ( hbar->isShown() && isHorizontallyScrollable() )
hbar->hide();
int vmax = ( element_count > getHeight() - 2 )
int vmax = ( element_count + 2 > getHeight() )
? int(element_count - getHeight()) + 2
: 0;
vbar->setMaximum (vmax);
@ -721,7 +721,7 @@ void FListBox::adjustSize()
vbar->setHeight (height, false);
vbar->resize();
int hmax = ( max_line_width > width - 2 )
int hmax = ( max_line_width + 2 > width )
? int(max_line_width - width + 2)
: 0;
hbar->setMaximum (hmax);
@ -956,7 +956,7 @@ inline void FListBox::drawListLine ( int y
std::size_t inc_len = inc_search.getLength();
const FWidgetColors& wc = getFWidgetColors();
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
FString element (getString(iter).mid ( std::size_t(1 + xoffset)
FString element (getString(iter).mid ( std::size_t(xoffset) + 1
, getWidth() - nf_offset - 4 ));
const wchar_t* const& element_str = element.wc_str();
std::size_t len = element.getLength();
@ -1215,7 +1215,7 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
//----------------------------------------------------------------------
void FListBox::recalculateVerticalBar (std::size_t element_count)
{
int vmax = ( element_count > getHeight() - 2 )
int vmax = ( element_count + 2 > getHeight() )
? int(element_count - getHeight() + 2)
: 0;
vbar->setMaximum (vmax);
@ -1314,7 +1314,7 @@ void FListBox::wheelUp (int pagesize)
if ( yoffset < 0 )
{
current -= std::size_t(pagesize + yoffset);
current -= std::size_t(pagesize) + std::size_t(yoffset);
yoffset = 0;
}
else
@ -1515,7 +1515,7 @@ void FListBox::scrollToY (int val)
if ( yoffset < 0 )
yoffset = 0;
current = std::size_t(yoffset + c);
current = std::size_t(yoffset) + std::size_t(c);
if ( current < std::size_t(yoffset) )
current = std::size_t(yoffset);
@ -1700,7 +1700,7 @@ inline bool FListBox::keyInsert()
if ( current > element_count )
current = element_count;
if ( current - std::size_t(yoffset) >= getHeight() - 1 )
if ( current - std::size_t(yoffset) + 1 >= getHeight() )
yoffset++;
return true;
@ -1871,8 +1871,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
if ( scrollType >= FScrollbar::scrollStepBackward )
{
vbar->setValue (yoffset);
@ -1936,8 +1935,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
if ( scrollType >= FScrollbar::scrollStepBackward )
{
hbar->setValue (xoffset);

View File

@ -715,7 +715,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
if ( column < 1 || header.empty() || column > int(header.size()) )
return;
std::size_t size = std::size_t(column + 1);
std::size_t size = std::size_t(column) + 1;
if ( sort_type.empty() || sort_type.size() < size )
sort_type.resize(size);
@ -2010,7 +2010,7 @@ void FListView::recalculateHorizontalBar (std::size_t len)
//----------------------------------------------------------------------
void FListView::recalculateVerticalBar (std::size_t element_count)
{
int vmax = ( element_count > getHeight() - 2 )
int vmax = ( element_count + 2 > getHeight() )
? int(element_count - getHeight() + 2)
: 0;
vbar->setMaximum (vmax);
@ -2679,8 +2679,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
flush_out();
}
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
if ( scrollType >= FScrollbar::scrollStepBackward )
{
hbar->setValue (xoffset);

View File

@ -597,9 +597,7 @@ void FMenuItem::updateSuperMenuDimensions()
return;
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
menu_ptr->calculateDimensions();
}
//----------------------------------------------------------------------

View File

@ -426,7 +426,7 @@ void FMessageBox::adjustButtons()
btn_width += button[n]->getWidth() + gap;
}
if ( btn_width >= getWidth() - 4 )
if ( btn_width + 4 >= getWidth() )
{
std::size_t max_width;
auto root_widget = getRootWidget();

View File

@ -346,8 +346,8 @@ FRect operator - (const FRect& r, const FSize& s)
{
return FRect ( r.X1
, r.Y1
, std::size_t(r.X2 - r.X1 + 1) - s.getWidth()
, std::size_t(r.Y2 - r.Y1 + 1) - s.getHeight() );
, std::size_t(r.X2 - r.X1) + 1 - s.getWidth()
, std::size_t(r.Y2 - r.Y1) + 1 - s.getHeight() );
}
//----------------------------------------------------------------------

View File

@ -917,8 +917,7 @@ void FScrollView::cb_VBarChange (FWidget*, FDataPtr)
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
if ( scrollType >= FScrollbar::scrollStepBackward )
{
update_scrollbar = true;
}
@ -969,8 +968,7 @@ void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
if ( scrollType >= FScrollbar::scrollStepBackward )
{
update_scrollbar = true;
}

View File

@ -707,7 +707,7 @@ void FTextView::drawText()
{
std::size_t i{};
std::size_t n = y + std::size_t(yoffset);
std::size_t x = std::size_t(1 + xoffset);
std::size_t x = std::size_t(xoffset) + 1;
FString line(data[n].mid (x, getTextWidth()));
const auto line_str = line.wc_str();
const auto len = line.getLength();
@ -750,15 +750,10 @@ void FTextView::cb_VBarChange (FWidget*, FDataPtr)
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
if ( scrollType >= FScrollbar::scrollStepBackward )
update_scrollbar = true;
}
else
{
update_scrollbar = false;
}
switch ( scrollType )
{
@ -806,15 +801,10 @@ void FTextView::cb_HBarChange (FWidget*, FDataPtr)
int distance{1};
int wheel_distance{4};
if ( scrollType >= FScrollbar::scrollStepBackward
&& scrollType <= FScrollbar::scrollWheelDown )
{
if ( scrollType >= FScrollbar::scrollStepBackward )
update_scrollbar = true;
}
else
{
update_scrollbar = false;
}
switch ( scrollType )
{

View File

@ -687,15 +687,17 @@ void FVTerm::resizeArea ( const FRect& box
}
bool realloc_success{false};
std::size_t area_size = std::size_t((width + rsw) * (height + bsh));
std::size_t full_width = std::size_t(width) + std::size_t(rsw);
std::size_t full_height = std::size_t(height) + std::size_t(bsh);
std::size_t area_size = full_width * full_height;
if ( area->height + area->bottom_shadow != height + bsh )
if ( area->height + area->bottom_shadow != int(full_height) )
{
realloc_success = reallocateTextArea ( area
, std::size_t(height + bsh)
, full_height
, area_size );
}
else if ( area->width + area->right_shadow != width + rsw )
else if ( area->width + area->right_shadow != int(full_width) )
{
realloc_success = reallocateTextArea (area, area_size);
}
@ -713,7 +715,7 @@ void FVTerm::resizeArea ( const FRect& box
area->bottom_shadow = bsh;
area->has_changes = false;
FSize size(std::size_t(width + rsw), std::size_t(height + bsh));
FSize size(full_width, full_height);
setTextToDefault (area, size);
}
@ -827,9 +829,6 @@ void FVTerm::restoreVTerm (const FRect& box)
if ( y < 0 )
y = 0;
if ( w < 0 || h < 0 )
return;
if ( x + w > vterm->width )
w = vterm->width - x;
@ -892,8 +891,8 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
int win_y = win->offset_top;
FRect geometry ( win_x
, win_y
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
, std::size_t(win->width) + std::size_t(win->right_shadow)
, std::size_t(win->height) + std::size_t(win->bottom_shadow) );
if ( found && geometry.contains(pos) )
{
@ -1677,8 +1676,8 @@ charData FVTerm::generateCharacter (const FPoint& pos)
int win_y = win->offset_top;
FRect geometry ( win_x
, win_y
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
, std::size_t(win->width) + std::size_t(win->right_shadow)
, std::size_t(win->height) + std::size_t(win->bottom_shadow) );
// Window is visible and contains current character
if ( geometry.contains(x, y) )
@ -1778,8 +1777,8 @@ charData FVTerm::getCharacter ( character_type char_type
FRect geometry ( win->offset_left
, win->offset_top
, std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) );
, std::size_t(win->width) + std::size_t(win->right_shadow)
, std::size_t(win->height) + std::size_t(win->bottom_shadow) );
// Window visible and contains current character
if ( geometry.contains(x, y) )

View File

@ -47,7 +47,7 @@ FWidget::widgetList* FWidget::window_list{nullptr};
FWidget::widgetList* FWidget::dialog_list{nullptr};
FWidget::widgetList* FWidget::always_on_top_list{nullptr};
FWidget::widgetList* FWidget::close_widget{nullptr};
FWidgetColors FWidget::wc{};
FWidgetColors FWidget::wcolors{};
bool FWidget::init_desktop{false};
bool FWidget::hideable{false};
uInt FWidget::modal_dialog_counter{};
@ -86,7 +86,7 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
else
{
flags.visible_cursor = ! hideable;
offset = parent->client_offset;
woffset = parent->wclient_offset;
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
@ -109,7 +109,8 @@ FWidget::~FWidget() // destructor
if ( flags.focus )
{
if ( auto window = FWindow::getWindowWidget(this) )
window->setWindowFocusWidget(nullptr);
if ( window != this )
window->setWindowFocusWidget(nullptr);
}
// unset the global widget focus
@ -217,8 +218,8 @@ FWidget* FWidget::getLastFocusableWidget (FObjectList list)
FPoint FWidget::getPrintPos()
{
const auto cur = getPrintCursor();
return FPoint ( cur.getX() - offset.getX1() - getX() + 1
, cur.getY() - offset.getY1() - getY() + 1 );
return FPoint ( cur.getX() - woffset.getX1() - getX() + 1
, cur.getY() - woffset.getY1() - getY() + 1 );
}
//----------------------------------------------------------------------
@ -466,7 +467,7 @@ void FWidget::setTopPadding (int top, bool adjust)
if ( isRootWidget() )
{
auto r = rootObject;
r->client_offset.setY1 (r->padding.top);
r->wclient_offset.setY1 (r->padding.top);
adjustSizeGlobal();
}
else
@ -487,7 +488,7 @@ void FWidget::setLeftPadding (int left, bool adjust)
if ( isRootWidget() )
{
auto r = rootObject;
r->client_offset.setX1 (r->padding.left);
r->wclient_offset.setX1 (r->padding.left);
adjustSizeGlobal();
}
else
@ -508,7 +509,7 @@ void FWidget::setBottomPadding (int bottom, bool adjust)
if ( isRootWidget() )
{
auto r = rootObject;
r->client_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom);
r->wclient_offset.setY2 (int(r->getHeight()) - 1 - r->padding.bottom);
adjustSizeGlobal();
}
else
@ -529,7 +530,7 @@ void FWidget::setRightPadding (int right, bool adjust)
if ( isRootWidget() )
{
auto r = rootObject;
r->client_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right);
r->wclient_offset.setX2 (int(r->getWidth()) - 1 - r->padding.right);
adjustSizeGlobal();
}
else
@ -543,7 +544,7 @@ void FWidget::setParentOffset()
auto p = getParentWidget();
if ( p )
offset = p->client_offset;
woffset = p->wclient_offset;
}
//----------------------------------------------------------------------
@ -552,17 +553,17 @@ void FWidget::setTermOffset()
auto r = getRootWidget();
int w = int(r->getWidth());
int h = int(r->getHeight());
offset.setCoordinates (0, 0, w - 1, h - 1);
woffset.setCoordinates (0, 0, w - 1, h - 1);
}
//----------------------------------------------------------------------
void FWidget::setTermOffsetWithPadding()
{
auto r = getRootWidget();
offset.setCoordinates ( r->getLeftPadding()
, r->getTopPadding()
, int(r->getWidth()) - 1 - r->getRightPadding()
, int(r->getHeight()) - 1 - r->getBottomPadding() );
woffset.setCoordinates ( r->getLeftPadding()
, r->getTopPadding()
, int(r->getWidth()) - 1 - r->getRightPadding()
, int(r->getHeight()) - 1 - r->getBottomPadding() );
}
//----------------------------------------------------------------------
@ -614,10 +615,10 @@ void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
int term_x = getTermX();
int term_y = getTermY();
client_offset.setCoordinates ( term_x - 1 + padding.left
, term_y - 1 + padding.top
, term_x - 2 + int(getWidth()) - padding.right
, term_y - 2 + int(getHeight()) - padding.bottom );
wclient_offset.setCoordinates ( term_x - 1 + padding.left
, term_y - 1 + padding.top
, term_x - 2 + int(getWidth()) - padding.right
, term_y - 2 + int(getHeight()) - padding.bottom );
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
@ -645,17 +646,17 @@ bool FWidget::setCursorPos (const FPoint& pos)
if ( area->widget )
{
int widget_offsetX = getTermX() - area->widget->getTermX();
int widget_offsetY = getTermY() - area->widget->getTermY();
int woffsetX = getTermX() - area->widget->getTermX();
int woffsetY = getTermY() - area->widget->getTermY();
if ( isChildPrintArea() )
{
widget_offsetX += (1 - area->widget->getLeftPadding());
widget_offsetY += (1 - area->widget->getTopPadding());
woffsetX += (1 - area->widget->getLeftPadding());
woffsetY += (1 - area->widget->getTopPadding());
}
setAreaCursor ( FPoint ( widget_offsetX + pos.getX()
, widget_offsetY + pos.getY() )
setAreaCursor ( FPoint ( woffsetX + pos.getX()
, woffsetY + pos.getY() )
, flags.visible_cursor
, area );
return true;
@ -667,8 +668,8 @@ bool FWidget::setCursorPos (const FPoint& pos)
//----------------------------------------------------------------------
void FWidget::setPrintPos (const FPoint& pos)
{
FPoint p{ offset.getX1() + getX() + pos.getX() - 1,
offset.getY1() + getY() + pos.getY() - 1 };
FPoint p{ woffset.getX1() + getX() + pos.getX() - 1,
woffset.getY1() + getY() + pos.getY() - 1 };
setPrintCursor(p);
}
@ -999,7 +1000,7 @@ void FWidget::redraw()
{
startTerminalUpdate();
// clean desktop
setColor (wc.term_fg, wc.term_bg);
setColor (wcolors.term_fg, wcolors.term_bg);
clearArea (getVirtualDesktop());
}
else if ( ! isShown() )
@ -1219,8 +1220,8 @@ void FWidget::detectTermSize()
auto r = rootObject;
FTerm::detectTermSize();
r->adjust_wsize.setRect (1, 1, getDesktopWidth(), getDesktopHeight());
r->offset.setRect (0, 0, getDesktopWidth(), getDesktopHeight());
r->client_offset.setCoordinates
r->woffset.setRect (0, 0, getDesktopWidth(), getDesktopHeight());
r->wclient_offset.setCoordinates
(
r->padding.left,
r->padding.top,
@ -1277,13 +1278,13 @@ void FWidget::clearShadow()
if ( isWindowWidget() )
{
setColor (wc.shadow_fg, wc.shadow_bg);
setColor (wcolors.shadow_fg, wcolors.shadow_bg);
setInheritBackground(); // current background color will be ignored
}
else if ( auto p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
setColor (wcolors.shadow_fg, p->getBackgroundColor());
if ( w <= offset.getX2() )
if ( w <= woffset.getX2() )
{
for (std::size_t y{1}; y <= getHeight(); y++)
{
@ -1291,7 +1292,7 @@ void FWidget::clearShadow()
}
}
if ( h <= offset.getY2() )
if ( h <= woffset.getY2() )
{
print() << FPoint(2, h + 1);
@ -1315,9 +1316,9 @@ void FWidget::drawFlatBorder()
, y2 = int(getHeight()) + 1;
if ( auto p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor());
setColor (wcolors.dialog_fg, p->getBackgroundColor());
else
setColor (wc.dialog_fg, wc.dialog_bg);
setColor (wcolors.dialog_fg, wcolors.dialog_bg);
for (std::size_t y{0}; y < getHeight(); y++)
{
@ -1382,9 +1383,9 @@ void FWidget::clearFlatBorder()
, y2 = int(getHeight()) + 1;
if ( auto p = getParentWidget() )
setColor (wc.dialog_fg, p->getBackgroundColor());
setColor (wcolors.dialog_fg, p->getBackgroundColor());
else
setColor (wc.dialog_fg, wc.dialog_bg);
setColor (wcolors.dialog_fg, wcolors.dialog_bg);
// clear on left side
for (std::size_t y{0}; y < getHeight(); y++)
@ -1542,17 +1543,17 @@ void FWidget::adjustSize()
if ( ignore_padding && ! isDialogWidget() )
setTermOffset();
else
offset = rootObject->client_offset;
woffset = rootObject->wclient_offset;
}
else if ( ignore_padding && p )
{
offset.setCoordinates ( p->getTermX() - 1
woffset.setCoordinates ( p->getTermX() - 1
, p->getTermY() - 1
, p->getTermX() + int(p->getWidth()) - 2
, p->getTermY() + int(p->getHeight()) - 2 );
}
else if ( p )
offset = p->client_offset;
woffset = p->wclient_offset;
adjust_wsize = wsize;
}
@ -1561,7 +1562,7 @@ void FWidget::adjustSize()
if ( ! hasChildPrintArea() )
insufficientSpaceAdjust();
client_offset.setCoordinates
wclient_offset.setCoordinates
(
getTermX() - 1 + padding.left,
getTermY() - 1 + padding.top,
@ -1620,8 +1621,8 @@ void FWidget::hideArea (const FSize& size)
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
fg = wcolors.dialog_fg;
bg = wcolors.dialog_bg;
}
setColor (fg, bg);
@ -1965,8 +1966,8 @@ void FWidget::init()
detectTermSize();
wsize.setRect(1, 1, getDesktopWidth(), getDesktopHeight());
adjust_wsize = wsize;
offset.setRect(0, 0, getDesktopWidth(), getDesktopHeight());
client_offset = offset;
woffset.setRect(0, 0, getDesktopWidth(), getDesktopHeight());
wclient_offset = woffset;
double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false);
@ -1977,8 +1978,8 @@ void FWidget::init()
setColorTheme();
// Default foreground and background color of the desktop/terminal
foreground_color = wc.term_fg;
background_color = wc.term_bg;
foreground_color = wcolors.term_fg;
background_color = wcolors.term_bg;
init_desktop = false;
// Create the root object accelerator list
@ -2022,7 +2023,7 @@ inline void FWidget::insufficientSpaceAdjust()
return;
// move left if not enough space
while ( getTermX() + int(getWidth()) - padding.right > offset.getX2() + 2 )
while ( getTermX() + int(getWidth()) - padding.right > woffset.getX2() + 2 )
{
adjust_wsize.x1_ref()--;
adjust_wsize.x2_ref()--;
@ -2032,7 +2033,7 @@ inline void FWidget::insufficientSpaceAdjust()
}
// move up if not enough space
while ( getTermY() + int(getHeight()) - padding.bottom > offset.getY2() + 2 )
while ( getTermY() + int(getHeight()) - padding.bottom > woffset.getY2() + 2 )
{
adjust_wsize.y1_ref()--;
adjust_wsize.y2_ref()--;
@ -2042,7 +2043,7 @@ inline void FWidget::insufficientSpaceAdjust()
}
// reduce the width if not enough space
while ( offset.getX1() + int(getWidth()) - 1 > offset.getX2() )
while ( woffset.getX1() + int(getWidth()) - 1 > woffset.getX2() )
adjust_wsize.x2_ref()--;
if ( getWidth() < size_hints.min_width )
@ -2052,7 +2053,7 @@ inline void FWidget::insufficientSpaceAdjust()
adjust_wsize.setWidth(1);
// reduce the height if not enough space
while ( offset.getY1() + int(getHeight()) - 1 > offset.getY2() )
while ( woffset.getY1() + int(getHeight()) - 1 > woffset.getY2() )
adjust_wsize.y2_ref()--;
if ( getHeight() < size_hints.min_height )
@ -2228,7 +2229,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
print() << FPoint(x2 + 1, y1) << " ";
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setColor (wcolors.shadow_bg, wcolors.shadow_fg);
setTransShadow();
for (std::size_t y{1}; y < getHeight(); y++)
@ -2241,7 +2242,7 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
print() << FPoint(x1, y2 + 1) << " ";
unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg);
setColor (wcolors.shadow_bg, wcolors.shadow_fg);
setTransShadow();
for (std::size_t x{2}; x <= getWidth() + 1; x++)
@ -2266,11 +2267,11 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
if ( isWindowWidget() )
{
setColor (wc.shadow_fg, wc.shadow_bg);
setColor (wcolors.shadow_fg, wcolors.shadow_bg);
setInheritBackground(); // current background color will be ignored
}
else if ( auto p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
setColor (wcolors.shadow_fg, p->getBackgroundColor());
block = fc::FullBlock; // █
print (fc::LowerHalfBlock); // ▄
@ -2301,9 +2302,9 @@ void FWidget::setColorTheme()
// Sets the default color theme
if ( getMaxColor() < 16 ) // for 8 color mode
wc.set8ColorTheme();
wcolors.set8ColorTheme();
else
wc.set16ColorTheme();
wcolors.set16ColorTheme();
}
@ -2371,7 +2372,7 @@ std::size_t getHotkeyPos (wchar_t src[], wchar_t dest[], std::size_t length)
for (std::size_t i{0}; i < length; i++)
{
if ( i < length && txt[i] == L'&' && hotkeypos == NOT_SET )
if ( txt[i] == L'&' && hotkeypos == NOT_SET )
{
hotkeypos = i;
i++;

View File

@ -533,7 +533,7 @@ void FListBox::insert ( const ItemT& item
//----------------------------------------------------------------------
inline bool FListBox::isHorizontallyScrollable()
{ return bool( max_line_width >= getClientWidth() - 1 ); }
{ return bool( max_line_width + 1 >= getClientWidth() ); }
//----------------------------------------------------------------------
inline bool FListBox::isVerticallyScrollable()

View File

@ -138,7 +138,8 @@ typedef struct
// Attribute byte #2
uInt8 no_changes : 1; // no changes required
uInt8 printed : 1; // is printed to VTerm
uInt8 : 6; // padding bits
uInt8 char_with : 2; // Number of character cells on screen
uInt8 : 4; // padding bits
// Attribute byte #3
uInt8 : 8; // padding byte
} bit;

View File

@ -484,9 +484,9 @@ class FWidget : public FVTerm, public FObject
FRect adjust_wsize_shadow{};
FRect adjust_wsize_term_shadow{};
// widget offset
FRect offset{};
FRect woffset{};
// offset of the widget client area
FRect client_offset{};
FRect wclient_offset{};
// widget shadow size (on the right and bottom side)
FSize wshadow{0, 0};
@ -512,7 +512,7 @@ class FWidget : public FVTerm, public FObject
static widgetList* dialog_list;
static widgetList* always_on_top_list;
static widgetList* close_widget;
static FWidgetColors wc;
static FWidgetColors wcolors;
static uInt modal_dialog_counter;
static bool init_desktop;
static bool hideable;
@ -602,11 +602,11 @@ inline const FPoint FWidget::getPos() const // position relative to the widget
//----------------------------------------------------------------------
inline int FWidget::getTermX() const // x-position on terminal
{ return offset.getX1() + adjust_wsize.getX(); }
{ return woffset.getX1() + adjust_wsize.getX(); }
//----------------------------------------------------------------------
inline int FWidget::getTermY() const // y-position on terminal
{ return offset.getY1() + adjust_wsize.getY(); }
{ return woffset.getY1() + adjust_wsize.getY(); }
//----------------------------------------------------------------------
inline const FPoint FWidget::getTermPos() const // position on terminal
@ -642,19 +642,19 @@ inline int FWidget::getRightPadding() const
//----------------------------------------------------------------------
inline std::size_t FWidget::getClientWidth() const
{ return client_offset.getWidth(); }
{ return wclient_offset.getWidth(); }
//----------------------------------------------------------------------
inline std::size_t FWidget::getClientHeight() const
{ return client_offset.getHeight(); }
{ return wclient_offset.getHeight(); }
//----------------------------------------------------------------------
inline std::size_t FWidget::getMaxWidth() const
{ return offset.getWidth(); }
{ return woffset.getWidth(); }
//----------------------------------------------------------------------
inline std::size_t FWidget::getMaxHeight() const
{ return offset.getHeight(); }
{ return woffset.getHeight(); }
//----------------------------------------------------------------------
inline const FSize& FWidget::getShadow() const
@ -683,10 +683,10 @@ inline const FRect& FWidget::getTermGeometry()
{
adjust_wsize_term.setCoordinates
(
adjust_wsize.x1_ref() + offset.x1_ref(),
adjust_wsize.y1_ref() + offset.y1_ref(),
adjust_wsize.x2_ref() + offset.x1_ref(),
adjust_wsize.y2_ref() + offset.y1_ref()
adjust_wsize.x1_ref() + woffset.x1_ref(),
adjust_wsize.y1_ref() + woffset.y1_ref(),
adjust_wsize.x2_ref() + woffset.x1_ref(),
adjust_wsize.y2_ref() + woffset.y1_ref()
);
return adjust_wsize_term;
@ -697,10 +697,10 @@ inline const FRect& FWidget::getTermGeometryWithShadow()
{
adjust_wsize_term_shadow.setCoordinates
(
adjust_wsize.x1_ref() + offset.x1_ref(),
adjust_wsize.y1_ref() + offset.y1_ref(),
adjust_wsize.x2_ref() + offset.x1_ref() + int(wshadow.width_ref()),
adjust_wsize.y2_ref() + offset.y1_ref() + int(wshadow.height_ref())
adjust_wsize.x1_ref() + woffset.x1_ref(),
adjust_wsize.y1_ref() + woffset.y1_ref(),
adjust_wsize.x2_ref() + woffset.x1_ref() + int(wshadow.width_ref()),
adjust_wsize.y2_ref() + woffset.y1_ref() + int(wshadow.height_ref())
);
return adjust_wsize_term_shadow;
@ -945,8 +945,8 @@ inline void FWidget::delAccelerator()
//----------------------------------------------------------------------
inline FPoint FWidget::termToWidgetPos (const FPoint& tPos)
{
return FPoint ( tPos.getX() + 1 - offset.getX1() - adjust_wsize.getX()
, tPos.getY() + 1 - offset.getY1() - adjust_wsize.getY() );
return FPoint ( tPos.getX() + 1 - woffset.getX1() - adjust_wsize.getX()
, tPos.getY() + 1 - woffset.getY1() - adjust_wsize.getY() );
}
//----------------------------------------------------------------------
@ -963,7 +963,7 @@ inline void FWidget::drawBorder()
//----------------------------------------------------------------------
inline const FWidgetColors& FWidget::getFWidgetColors() const
{ return wc; }
{ return wcolors; }
//----------------------------------------------------------------------
inline uInt FWidget::getModalDialogCounter()
@ -983,7 +983,7 @@ inline FWidget::widgetList*& FWidget::getWidgetCloseList()
//----------------------------------------------------------------------
inline FWidgetColors& FWidget::setFWidgetColors()
{ return wc; }
{ return wcolors; }
//----------------------------------------------------------------------
inline uInt& FWidget::setModalDialogCounter()