From 3d0f046de92f7b7f229d4c26dd5129f9457bc797 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sat, 3 Sep 2016 15:17:48 +0200 Subject: [PATCH] clearFlatBorder() replace now a double flatline with a single flatline --- ChangeLog | 6 ++++ src/fbutton.cpp | 4 +-- src/fcharmap.h | 1 + src/fwidget.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++------ src/fwidget.h | 12 +++++-- test/ui.cpp | 2 +- 6 files changed, 105 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c1215c2..6ac3e0ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-09-03 Markus Gans + * The method clearFlatBorder() replace now a double flatline + with a single flatline + * Add the possibility to set the double_flatline_mask for + every position on all sides + 2016-09-02 Markus Gans * Method setGeometry assigns now the full widget size to the double_flatline_mask (previously, it was the adjust size) diff --git a/src/fbutton.cpp b/src/fbutton.cpp index aa7d66c5..225a5eee 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -172,8 +172,8 @@ void FButton::draw() // noshadow + indent one character to the right if ( is_Flat ) clearFlatBorder(); - - clearShadow(); + else + clearShadow(); if ( parent_widget ) setColor ( parent_widget->getForegroundColor() diff --git a/src/fcharmap.h b/src/fcharmap.h index 7d70e9ec..431fdf97 100644 --- a/src/fcharmap.h +++ b/src/fcharmap.h @@ -94,6 +94,7 @@ static uInt character[][fc::NUM_OF_ENCODINGS] = {0x1ad9, 0, 0xd9, 0}, // ( - NF_radio_button1 {0x1ada, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left {0x1adc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked + {0x1ae7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left {0x1ae8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 {0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 {0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 diff --git a/src/fwidget.cpp b/src/fwidget.cpp index fedab9ea..225e1707 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -2260,30 +2260,53 @@ void FWidget::clearFlatBorder() else setColor (wc.dialog_fg, wc.dialog_bg); + // clear on left side for (register int y=0; y < height; y++) { gotoxy (x1-1, y1+y+1); - print (' '); // clear on left side + + if ( double_flatline_mask.left[uLong(y)] ) + print (fc::NF_border_line_left); + else + print (' '); } - gotoxy (x2, y1+1); - for (register int y=1; y <= height; y++) + // clear on right side + for (register int y=0; y < height; y++) { - print (' '); // clear on right side gotoxy (x2, y1+y+1); + + if ( double_flatline_mask.right[uLong(y)] ) + print (fc::NF_rev_border_line_right); + else + print (' '); } + // clear at top gotoxy (x1, y1); - for (register int x=0; x < width; x++) - print (' '); // clear at bottom - gotoxy (x1, y2); for (register int x=0; x < width; x++) - print (' '); // clear at top + { + if ( double_flatline_mask.top[uLong(x)] ) + print (fc::NF_border_line_upper); + else + print (' '); + } + + // clear at bottom + gotoxy (x1, y2); + + for (register int x=0; x < width; x++) + { + if ( double_flatline_mask.bottom[uLong(x)] ) + print (fc::NF_border_line_bottom); + else + print (' '); + } } //---------------------------------------------------------------------- -void FWidget::setDoubleFlatLine(int side, bool bit) +void FWidget::setDoubleFlatLine (int side, bool bit) { uLong size; @@ -2320,7 +2343,60 @@ void FWidget::setDoubleFlatLine(int side, bool bit) } //---------------------------------------------------------------------- -std::vector& FWidget::doubleFlatLine_ref(int side) +void FWidget::setDoubleFlatLine (int side, int pos, bool bit) +{ + uLong size, index; + + assert ( side == fc::top + || side == fc::right + || side == fc::bottom + || side == fc::left ); + + assert ( pos >= 1 ); + + index = uLong(pos - 1); + + switch ( side ) + { + case fc::top: + size = double_flatline_mask.top.size(); + + if ( index < size ) + double_flatline_mask.top[index] = bit; + + break; + + case fc::right: + size = double_flatline_mask.right.size(); + + if ( index < size ) + double_flatline_mask.right[index] = bit; + + break; + + case fc::bottom: + size = double_flatline_mask.bottom.size(); + + if ( index < size ) + double_flatline_mask.bottom[index] = bit; + + break; + + case fc::left: + size = double_flatline_mask.left.size(); + + if ( index < size ) + double_flatline_mask.left[index] = bit; + + break; + + default: + break; + } +} + +//---------------------------------------------------------------------- +std::vector& FWidget::doubleFlatLine_ref (int side) { assert ( side == fc::top || side == fc::right diff --git a/src/fwidget.h b/src/fwidget.h index 62ce088d..85ad935d 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -532,9 +532,11 @@ class FWidget : public FObject, public FTerm void clearShadow(); void drawFlatBorder(); void clearFlatBorder(); - void setDoubleFlatLine(int, bool = true); - void unsetDoubleFlatLine(int); - std::vector& doubleFlatLine_ref(int); + void setDoubleFlatLine (int, bool = true); + void unsetDoubleFlatLine (int); + void setDoubleFlatLine (int, int, bool = true); + void unsetDoubleFlatLine (int, int); + std::vector& doubleFlatLine_ref (int); virtual void drawBorder(); static void quit(); @@ -1096,6 +1098,10 @@ inline bool FWidget::isInheritBackground() inline void FWidget::unsetDoubleFlatLine(int side) { setDoubleFlatLine(side, false); } +//---------------------------------------------------------------------- +inline void FWidget::unsetDoubleFlatLine(int side, int pos) +{ setDoubleFlatLine(side, pos, false); } + // NewFont elements //---------------------------------------------------------------------- diff --git a/test/ui.cpp b/test/ui.cpp index 0fcf0a24..7832daa8 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -347,7 +347,7 @@ MyDialog::MyDialog (FWidget* parent) MyButton2->setStatusbarMessage ("Cosine function"); MyButton2->setNoUnderline(); MyButton2->setFlat(); - MyButton2->setDoubleFlatLine(fc::top); + MyButton2->setDoubleFlatLine (fc::top); FButton* MyButton3 = new FButton (this); MyButton3->setGeometry(10, 3, 5, 3);