Add the possibility to draw double lines on overlapped flat lines for the 8x16graph font

This commit is contained in:
Markus Gans 2015-06-21 23:27:10 +02:00
parent f8edb82494
commit 215f213bad
4 changed files with 132 additions and 9 deletions

View File

@ -825,6 +825,14 @@ class fc
horizontal = 1 horizontal = 1
}; };
enum sides
{
top = 0,
right = 1,
bottom = 2,
left = 3
};
enum brackets_type enum brackets_type
{ {
NoBrackets = 0, NoBrackets = 0,

View File

@ -72,6 +72,10 @@ FWidget::FWidget (FWidget* parent) : FObject(parent)
this->ymin = parent->client_ymin; this->ymin = parent->client_ymin;
this->xmax = parent->client_xmax; this->xmax = parent->client_xmax;
this->ymax = parent->client_ymax; this->ymax = parent->client_ymax;
double_flatline_mask.top.resize (width, false);
double_flatline_mask.right.resize (height, false);
double_flatline_mask.bottom.resize (width, false);
double_flatline_mask.left.resize (height, false);
} }
} }
@ -128,6 +132,11 @@ void FWidget::init()
width, height ); width, height );
adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal; adjustWidgetSizeGlobalShadow = adjustWidgetSizeGlobal;
double_flatline_mask.top.resize (width, false);
double_flatline_mask.right.resize (height, false);
double_flatline_mask.bottom.resize (width, false);
double_flatline_mask.left.resize (height, false);
// default widget colors // default widget colors
setColorTheme(); setColorTheme();
@ -1167,6 +1176,10 @@ void FWidget::resize()
} }
else else
adjustSize(); adjustSize();
double_flatline_mask.top.resize (width, false);
double_flatline_mask.right.resize (height, false);
double_flatline_mask.bottom.resize (width, false);
double_flatline_mask.left.resize (height, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1431,6 +1444,9 @@ void FWidget::setWidth (int w, bool adjust)
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
double_flatline_mask.top.resize (width, false);
double_flatline_mask.bottom.resize (width, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1449,6 +1465,9 @@ void FWidget::setHeight (int h, bool adjust)
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
double_flatline_mask.right.resize (height, false);
double_flatline_mask.left.resize (height, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1572,6 +1591,11 @@ void FWidget::setGeometry (int x, int y, int w, int h, bool adjust)
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
double_flatline_mask.top.resize (width, false);
double_flatline_mask.right.resize (height, false);
double_flatline_mask.bottom.resize (width, false);
double_flatline_mask.left.resize (height, false);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1866,26 +1890,42 @@ void FWidget::drawFlatBorder()
y2 = ypos+ymin-1+height; y2 = ypos+ymin-1+height;
setColor (wc.dialog_fg, wc.dialog_bg); setColor (wc.dialog_fg, wc.dialog_bg);
for (int y=0; y <= height-1; y++) for (int y=0; y < height; y++)
{ {
gotoxy (x1-1, y1+y+1); gotoxy (x1-1, y1+y+1);
if ( double_flatline_mask.left[y] )
print (fc::NF_rev_border_line_right); // || is not yet defined
else
print (fc::NF_rev_border_line_right); // right line (on left side) print (fc::NF_rev_border_line_right); // right line (on left side)
} }
gotoxy (x2, y1+1); gotoxy (x2, y1+1);
for (int y=1; y <= height; y++) for (int y=0; y < height; y++)
{ {
if ( double_flatline_mask.right[y] )
print (fc::NF_border_line_left); // || is not yet defined
else
print (fc::NF_border_line_left); // left line (on right side) print (fc::NF_border_line_left); // left line (on right side)
gotoxy (x2, y1+y+1); gotoxy (x2, y1+y+2);
} }
gotoxy (x1, y1); gotoxy (x1, y1);
for (int x=0; x < width; x++) for (int x=0; x < width; x++)
print (fc::NF_border_line_bottom); // top line (at bottom) {
if ( double_flatline_mask.top[x] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at top)
else
print (fc::NF_border_line_bottom); // bottom line (at top)
}
gotoxy (x1, y2); gotoxy (x1, y2);
for (int x=0; x < width; x++) for (int x=0; x < width; x++)
print (fc::NF_border_line_upper); // bottom line (at top) {
if ( double_flatline_mask.bottom[x] )
print (fc::NF_border_line_up_and_down); // top+bottom line (at bottom)
else
print (fc::NF_border_line_upper); // top line (at bottom)
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1924,6 +1964,64 @@ void FWidget::clearFlatBorder()
print (' '); // clear at top print (' '); // clear at top
} }
//----------------------------------------------------------------------
void FWidget::setDoubleFlatLine(int side, bool bit)
{
int size;
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
|| side == fc::left );
switch ( side )
{
case fc::top:
size = double_flatline_mask.top.size();
double_flatline_mask.top.assign(size, bit);
break;
case fc::right:
size = double_flatline_mask.right.size();
double_flatline_mask.right.assign(size, bit);
break;
case fc::bottom:
size = double_flatline_mask.bottom.size();
double_flatline_mask.bottom.assign(size, bit);
break;
case fc::left:
size = double_flatline_mask.left.size();
double_flatline_mask.left.assign(size, bit);
break;
}
}
//----------------------------------------------------------------------
std::vector<bool>& FWidget::doubleFlatLine_ref(int side)
{
assert ( side == fc::top
|| side == fc::right
|| side == fc::bottom
|| side == fc::left );
switch ( side )
{
case fc::top:
return double_flatline_mask.top;
case fc::right:
return double_flatline_mask.right;
case fc::bottom:
return double_flatline_mask.bottom;
case fc::left:
default:
return double_flatline_mask.left;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::drawBorder() void FWidget::drawBorder()
{ {

View File

@ -141,6 +141,14 @@ class FWidget : public FObject, public FTerm
} wc; } wc;
// widget_colors wc; // widget_colors wc;
struct dbl_line_mask
{
std::vector<bool> top;
std::vector<bool> right;
std::vector<bool> bottom;
std::vector<bool> left;
} double_flatline_mask;
protected: protected:
int xpos; int xpos;
int ypos; int ypos;
@ -355,6 +363,9 @@ class FWidget : public FObject, public FTerm
void clearShadow(); void clearShadow();
void drawFlatBorder(); void drawFlatBorder();
void clearFlatBorder(); void clearFlatBorder();
void setDoubleFlatLine(int, bool bit=true);
void unsetDoubleFlatLine(int);
std::vector<bool>& doubleFlatLine_ref(int);
virtual void drawBorder(); virtual void drawBorder();
static void quit(); static void quit();
@ -590,6 +601,10 @@ inline bool FWidget::unsetUnderline()
inline bool FWidget::isUnderline() inline bool FWidget::isUnderline()
{ return underline; } { return underline; }
//----------------------------------------------------------------------
inline void FWidget::unsetDoubleFlatLine(int side)
{ setDoubleFlatLine(side, false); }
// NewFont elements // NewFont elements
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -177,6 +177,7 @@ MyDialog::MyDialog (FWidget* parent) : FDialog(parent)
MyButton1->setStatusbarMessage("Sine function"); MyButton1->setStatusbarMessage("Sine function");
MyButton1->setNoUnderline(); MyButton1->setNoUnderline();
MyButton1->setFlat(); MyButton1->setFlat();
MyButton1->setDoubleFlatLine(fc::bottom);
FButton* MyButton2 = new FButton(this); FButton* MyButton2 = new FButton(this);
MyButton2->setGeometry(3, 5, 5, 1); MyButton2->setGeometry(3, 5, 5, 1);
@ -184,6 +185,7 @@ MyDialog::MyDialog (FWidget* parent) : FDialog(parent)
MyButton2->setStatusbarMessage("Cosine function"); MyButton2->setStatusbarMessage("Cosine function");
MyButton2->setNoUnderline(); MyButton2->setNoUnderline();
MyButton2->setFlat(); MyButton2->setFlat();
MyButton2->setDoubleFlatLine(fc::top);
FButton* MyButton3 = new FButton(this); FButton* MyButton3 = new FButton(this);
MyButton3->setGeometry(10, 3, 5, 3); MyButton3->setGeometry(10, 3, 5, 3);