Do not draw shadows on a linux console if not all characters are available

This commit is contained in:
Markus Gans 2016-11-13 22:08:40 +01:00
parent 04a483526f
commit fc8ee51e72
11 changed files with 91 additions and 144 deletions

View File

@ -1,3 +1,7 @@
2016-11-13 Markus Gans <guru.mail@muenster.de>
* Do not draw shadows on a linux console if not
all characters are available
2016-11-12 Markus Gans <guru.mail@muenster.de>
* Better support for Linux terminals with 8 colors
* Optimized input cursor positioning for terminals without hidden cursor

View File

@ -596,8 +596,6 @@ void FButton::draw()
if ( isMonochron() && (is_Active || is_Focus) )
setReverse(false);
if ( is_Flat )
{
if ( margin == 1 )
{
setColor (getForegroundColor(), button_bg);
@ -609,27 +607,8 @@ void FButton::draw()
}
}
if ( ! button_down )
if ( is_Flat && ! button_down )
drawFlatBorder();
}
else if ( ! isMonochron() )
{
if ( parent_widget )
setColor (button_bg, parent_widget->getBackgroundColor());
for (int y=0; y < getHeight(); y++)
{
setPrintPos (1+d, 1+y);
// Cygwin terminal use IBM Codepage 850
if ( isCygwinTerminal() )
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
}
if ( ! button_down
&& ! isNewFont()

View File

@ -489,7 +489,7 @@ void FFileDialog::init()
FDialog::setText("Open file");
filename = new FLineEdit(this);
filename->setLabelText("File&name:");
filename->setLabelText("File&name");
filename->setText(filter_pattern);
filename->setGeometry(11, 1, 28, 1);
filename->setFocus();

View File

@ -664,7 +664,7 @@ void FLineEdit::adjustLabel()
break;
case label_left:
label->setGeometry(getX()-label_length, getY(), label_length, 1);
label->setGeometry(getX()-label_length-1, getY(), label_length, 1);
break;
}
}
@ -742,12 +742,11 @@ void FLineEdit::draw()
//----------------------------------------------------------------------
void FLineEdit::drawInputField()
{
bool isActiveFocus, isActive, isShadow;
bool isActiveFocus, isShadow;
int x;
FString show_text;
int active_focus = fc::active + fc::focus;
isActiveFocus = ((flags & active_focus) == active_focus);
isActive = ((flags & fc::active) != 0);
isShadow = ((flags & fc::shadow) != 0 );
updateVTerm(false);
@ -763,44 +762,15 @@ void FLineEdit::drawInputField()
else
setUnderline(true);
}
else if ( isActiveFocus )
{
setColor (wc.inputfield_active_focus_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
else if ( isActive )
{
setColor (wc.inputfield_active_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
else // isInactive
{
setColor (wc.inputfield_inactive_bg, wc.dialog_bg);
if ( isCygwinTerminal() ) // IBM Codepage 850
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
setColor();
print (' ');
}
if ( isActiveFocus && getMaxColor() < 16 )
setBold();
setColor();
show_text = text.mid(uInt(1+text_offset), uInt(getWidth()-2));
if ( isUTF8_linux_terminal() )

View File

@ -185,53 +185,9 @@ void FProgressbar::drawPercentage()
//----------------------------------------------------------------------
void FProgressbar::drawBar()
{
int i = 1;
int i = 0;
float length = float(bar_length * percentage) / 100;
setPrintPos (1,1);
if ( isMonochron() )
{
if ( round(length) >= 1)
{
setReverse(false);
print (' ');
setReverse(true);
}
else
print (fc::MediumShade); // ▒
}
else if ( getMaxColor() < 16 )
{
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
if ( round(length) >= 1)
print (' ');
else
print (fc::MediumShade);
}
if ( getParentWidget() )
{
if ( round(length) >= 1)
setColor ( wc.progressbar_fg
, getParentWidget()->getBackgroundColor() );
else
setColor ( wc.progressbar_bg
, getParentWidget()->getBackgroundColor() );
}
if ( ! isMonochron() && getMaxColor() >= 16 )
{
// Cygwin terminal use IBM Codepage 850
if ( isCygwinTerminal() )
print (fc::FullBlock); // █
else if ( isTeraTerm() )
print (0xdb);
else
print (fc::RightHalfBlock); // ▐
}
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
@ -244,7 +200,7 @@ void FProgressbar::drawBar()
if ( isMonochron() )
setReverse(true);
if ( trunc(length) >= 1 && trunc(length) < bar_length )
if ( percentage > 0.0f && trunc(length) < bar_length )
{
if ( round(length) > trunc(length)
|| isCygwinTerminal()

View File

@ -687,9 +687,15 @@ void FStatusBar::drawKeys()
if ( isMonochron() )
setReverse(false);
if ( no_half_block_character )
print (' ');
else
{
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
x++;
print (fc::LeftHalfBlock); // ▐
}
x++;
if ( isMonochron() )
setReverse(true);

View File

@ -58,6 +58,8 @@ bool FTerm::vt100_console;
bool FTerm::ascii_console;
bool FTerm::NewFont;
bool FTerm::VGAFont;
bool FTerm::no_shadow_character;
bool FTerm::no_half_block_character;
bool FTerm::cursor_optimisation;
bool FTerm::xterm_default_colors;
termios FTerm::term_init;
@ -1482,6 +1484,8 @@ int FTerm::UTF8decode(char* utf8)
//----------------------------------------------------------------------
void FTerm::init_consoleCharMap()
{
uInt c1, c2, c3, c4, c5;
if ( NewFont || VGAFont )
return;
@ -1504,6 +1508,26 @@ void FTerm::init_consoleCharMap()
character[i][fc::PC] = character[i][fc::ASCII];
}
}
c1 = fc::UpperHalfBlock;
c2 = fc::LowerHalfBlock;
c3 = fc::FullBlock;
if ( charEncode(c1, fc::PC) == charEncode(c1, fc::ASCII)
|| charEncode(c2, fc::PC) == charEncode(c2, fc::ASCII)
|| charEncode(c3, fc::PC) == charEncode(c3, fc::ASCII) )
{
no_shadow_character = true;
}
c4 = fc::RightHalfBlock;
c5 = fc::LeftHalfBlock;
if ( charEncode(c4, fc::PC) == charEncode(c4, fc::ASCII)
|| charEncode(c5, fc::PC) == charEncode(c5, fc::ASCII) )
{
no_half_block_character = true;
}
}
//----------------------------------------------------------------------
@ -2956,9 +2980,10 @@ void FTerm::init()
vt100_console = \
NewFont = \
VGAFont = \
no_shadow_character = \
no_half_block_character = \
ascii_console = \
mouse_support = \
force_vt100 = \
tera_terminal = \
kterm_terminal = \

View File

@ -250,6 +250,8 @@ class FTerm
static int stdout_no;
static bool NewFont;
static bool VGAFont;
static bool no_shadow_character;
static bool no_half_block_character;
static bool cursor_optimisation;
static bool xterm_default_colors;
static fc::encoding Encoding;

View File

@ -1092,13 +1092,15 @@ void FWidget::show()
if ( ! visible )
return;
// Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized
if ( getMainWidget() == this )
{
// Important: Do not use setNewFont() or setVGAFont() after
// the console character mapping has been initialized
init_consoleCharMap();
// set xterm underline cursor
setXTermCursorStyle(fc::blinking_underline);
// set xterm color settings to defaults
setXTermDefaults();
}
@ -1326,6 +1328,10 @@ void FWidget::drawShadow()
{
// non-transparent shadow
int block;
if ( no_shadow_character )
return;
setPrintPos (x2+1, y1);
if ( isWindowWidget() )
@ -1336,7 +1342,6 @@ void FWidget::drawShadow()
else if ( FWidget* p = getParentWidget() )
setColor (wc.shadow_fg, p->getBackgroundColor());
if ( isTeraTerm() )
{
block = 0xdb; // █

View File

@ -58,12 +58,12 @@ int main (int argc, char* argv[])
FLineEdit* st_field = new FLineEdit(&dgl);
FLineEdit* c_field = new FLineEdit(&dgl);
name_field->setLabelText(L"&Name:");
email_field->setLabelText(L"&Email:");
org_field->setLabelText(L"Or&ganization:");
city_field->setLabelText(L"&City:");
st_field->setLabelText(L"&State:");
c_field->setLabelText(L"&Country:");
name_field->setLabelText(L"&Name");
email_field->setLabelText(L"&Email");
org_field->setLabelText(L"Or&ganization");
city_field->setLabelText(L"&City");
st_field->setLabelText(L"&State");
c_field->setLabelText(L"&Country");
name_field->setGeometry(15, 1, 19, 1);
email_field->setGeometry(15, 3, 19, 1);

View File

@ -467,7 +467,7 @@ MyDialog::MyDialog (FWidget* parent)
myLineEdit = new FLineEdit (this);
myLineEdit->setGeometry(22, 1, 10, 1);
myLineEdit->setText (FString("EnTry").toLower());
myLineEdit->setLabelText (L"&Input:");
myLineEdit->setLabelText (L"&Input");
myLineEdit->setStatusbarMessage ("Press Enter to set the title");
// Buttons