diff --git a/src/fenum.h b/src/fenum.h index c48f4e43..d866dd60 100644 --- a/src/fenum.h +++ b/src/fenum.h @@ -125,7 +125,7 @@ class fc NF_border_line_left = 0x1abc, // ⎸ NF_rev_up_arrow2 = 0x1abd, //⎹◣ NF_rev_down_arrow2 = 0x1abe, //⎹◤ - NF_border_corner_middle_lower_left = 0x1ac0, // └ + NF_border_corner_middle_lower_left = 0x1ac0, // └ NF_rev_up_arrow1 = 0x1ac1, // ◢⎸ NF_rev_down_arrow1 = 0x1ac2, // ◥⎸ NF_border_line_vertical_right = 0x1ac3, // ├ @@ -136,7 +136,7 @@ class fc NF_rev_right_arrow1 = 0x1ac9, // ⊏ NF_rev_menu_button1 = 0x1aca, // [ NF_rev_menu_button2 = 0x1acb, // - - NF_border_corner_middle_upper_left = 0x1acc, // ┌ + NF_border_corner_middle_upper_left = 0x1acc, // ┌ NF_shadow_box_cd = 0x1acd, // ニ NF_shadow_box_left = 0x1ace, // [ NF_border_corner_middle_lower_right = 0x1acf, // ┘ @@ -825,6 +825,14 @@ class fc horizontal = 1 }; + enum sides + { + top = 0, + right = 1, + bottom = 2, + left = 3 + }; + enum brackets_type { NoBrackets = 0, diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 4ed06ae9..579fb045 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -72,6 +72,10 @@ FWidget::FWidget (FWidget* parent) : FObject(parent) this->ymin = parent->client_ymin; this->xmax = parent->client_xmax; 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 ); 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 setColorTheme(); @@ -1167,6 +1176,10 @@ void FWidget::resize() } else 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 ) 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 ) 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 ) 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; 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); - print (fc::NF_rev_border_line_right); // right line (on left side) + 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) } gotoxy (x2, y1+1); - for (int y=1; y <= height; y++) + for (int y=0; y < height; y++) { - print (fc::NF_border_line_left); // left line (on right side) - gotoxy (x2, y1+y+1); + 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) + gotoxy (x2, y1+y+2); } gotoxy (x1, y1); 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); 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 } +//---------------------------------------------------------------------- +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& 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() { diff --git a/src/fwidget.h b/src/fwidget.h index fabe352f..29bf1c27 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -141,6 +141,14 @@ class FWidget : public FObject, public FTerm } wc; // widget_colors wc; + struct dbl_line_mask + { + std::vector top; + std::vector right; + std::vector bottom; + std::vector left; + } double_flatline_mask; + protected: int xpos; int ypos; @@ -355,6 +363,9 @@ class FWidget : public FObject, public FTerm void clearShadow(); void drawFlatBorder(); void clearFlatBorder(); + void setDoubleFlatLine(int, bool bit=true); + void unsetDoubleFlatLine(int); + std::vector& doubleFlatLine_ref(int); virtual void drawBorder(); static void quit(); @@ -590,6 +601,10 @@ inline bool FWidget::unsetUnderline() inline bool FWidget::isUnderline() { return underline; } +//---------------------------------------------------------------------- +inline void FWidget::unsetDoubleFlatLine(int side) +{ setDoubleFlatLine(side, false); } + // NewFont elements //---------------------------------------------------------------------- diff --git a/test/ui.cpp b/test/ui.cpp index 47c33afc..e4df37cf 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -177,6 +177,7 @@ MyDialog::MyDialog (FWidget* parent) : FDialog(parent) MyButton1->setStatusbarMessage("Sine function"); MyButton1->setNoUnderline(); MyButton1->setFlat(); + MyButton1->setDoubleFlatLine(fc::bottom); FButton* MyButton2 = new FButton(this); MyButton2->setGeometry(3, 5, 5, 1); @@ -184,6 +185,7 @@ MyDialog::MyDialog (FWidget* parent) : FDialog(parent) MyButton2->setStatusbarMessage("Cosine function"); MyButton2->setNoUnderline(); MyButton2->setFlat(); + MyButton2->setDoubleFlatLine(fc::top); FButton* MyButton3 = new FButton(this); MyButton3->setGeometry(10, 3, 5, 3);