Easier handling of fc::SpecialCharacter

This commit is contained in:
Markus Gans 2018-12-06 02:28:24 +01:00
parent 48f88fdeec
commit 9ba1b77069
23 changed files with 123 additions and 68 deletions

View File

@ -1,3 +1,6 @@
2018-12-06 Markus Gans <guru.mail@muenster.de>
* Easier handling of fc::SpecialCharacter
2018-12-01 Markus Gans <guru.mail@muenster.de>
* Switched to the language standard C++11
* Use delegated constructors and in-class default member initializers

View File

@ -75,6 +75,10 @@ AC_CONFIG_FILES([Makefile
finalcut.spec
finalcut.pc])
# Check for C++11 support
AX_CHECK_COMPILE_FLAG([[-std=c++11]],,
[AC_MSG_ERROR([compiler did not accept -std=c++11])])
# use GPM (General Purpose Mouse)
AC_ARG_WITH([gpm],
[AS_HELP_STRING([--without-gpm], [Disable GPM mouse support])],

View File

@ -345,11 +345,11 @@ void Calc::drawDispay()
if ( isNewFont() )
{
wchar_t bottom_line = wchar_t(finalcut::fc::NF_border_line_bottom);
wchar_t top_bottom_line = wchar_t(finalcut::fc::NF_border_line_up_and_down);
wchar_t top_line = wchar_t(finalcut::fc::NF_border_line_upper);
wchar_t right_line = wchar_t(finalcut::fc::NF_rev_border_line_right);
wchar_t left_line = wchar_t(finalcut::fc::NF_border_line_left);
wchar_t bottom_line = finalcut::fc::NF_border_line_bottom;
wchar_t top_bottom_line = finalcut::fc::NF_border_line_up_and_down;
wchar_t top_line = finalcut::fc::NF_border_line_upper;
wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
wchar_t left_line = finalcut::fc::NF_border_line_left;
setPrintPos (3, 2);
print (finalcut::FString(33, bottom_line));
setPrintPos (2, 3);
@ -367,9 +367,9 @@ void Calc::drawDispay()
}
else
{
wchar_t vertical_and_right = wchar_t(finalcut::fc::BoxDrawingsVerticalAndRight);
wchar_t horizontal = wchar_t(finalcut::fc::BoxDrawingsHorizontal);
wchar_t vertical_and_left = wchar_t(finalcut::fc::BoxDrawingsVerticalAndLeft);
wchar_t vertical_and_right = finalcut::fc::BoxDrawingsVerticalAndRight;
wchar_t horizontal = finalcut::fc::BoxDrawingsHorizontal;
wchar_t vertical_and_left = finalcut::fc::BoxDrawingsVerticalAndLeft;
finalcut::FString separator = finalcut::FString(vertical_and_right)
+ finalcut::FString(35, horizontal)
+ finalcut::FString(vertical_and_left);

View File

@ -85,7 +85,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
// Statusbar at the bottom
finalcut::FString separator;
separator << ' ' << wchar_t(finalcut::fc::BoxDrawingsVertical) << ' ';
separator << ' ' << finalcut::fc::BoxDrawingsVertical << ' ';
listView.setStatusbarMessage ( finalcut::FString()
<< "<Q> exit" << separator
<< "<Space> select an item" << separator
@ -170,7 +170,7 @@ void CheckList::cb_showList (finalcut::FWidget*, data_ptr)
static_cast<finalcut::FListViewItem*>(*iter);
if ( item->isChecked() )
shopping_list << wchar_t(finalcut::fc::Bullet) << ' '
shopping_list << finalcut::fc::Bullet << ' '
<< item->getText(1) << '\n';
++iter;

View File

@ -53,10 +53,10 @@ int main (int argc, char* argv[])
finalcut::FLabel label_1(&dgl);
finalcut::FLabel label_2(&dgl);
label_1 << wchar_t(finalcut::fc::BlackUpPointingTriangle)
label_1 << finalcut::fc::BlackUpPointingTriangle
<< std::wstring(L"\n")
<< wchar_t(finalcut::fc::BoxDrawingsUpAndRight)
<< finalcut::FString(2, wchar_t(finalcut::fc::BoxDrawingsHorizontal))
<< finalcut::fc::BoxDrawingsUpAndRight
<< finalcut::FString(2, finalcut::fc::BoxDrawingsHorizontal)
<< " Double click the title bar button,";
label_2 << "press Q on the keyboard,\n"
<< "or push the button below to exit\n"

View File

@ -63,7 +63,7 @@ class Menu : public finalcut::FDialog
void cb_message (finalcut::FWidget*, data_ptr);
// Data Members
finalcut::FString line{13, wchar_t(finalcut::fc::BoxDrawingsHorizontal)};
finalcut::FString line{13, finalcut::fc::BoxDrawingsHorizontal};
finalcut::FMenuBar Menubar{this};
finalcut::FMenu File{"&File", &Menubar};
finalcut::FMenu Edit{"&Edit", &Menubar};

View File

@ -242,7 +242,7 @@ void Brushes::draw()
setColor (fg_color, bg_color);
setPrintPos (2, 3);
print(" ");
print(finalcut::FString(3, wchar_t(finalcut::fc::MediumShade)));
print(finalcut::FString(3, finalcut::fc::MediumShade));
if ( brush == L' ' )
pos = 0;
@ -251,9 +251,9 @@ void Brushes::draw()
setColor();
setPrintPos (3 + pos, 2);
print(wchar_t(finalcut::fc::BlackDownPointingTriangle));
print(finalcut::fc::BlackDownPointingTriangle);
setPrintPos (3 + pos, 4);
print(wchar_t(finalcut::fc::BlackUpPointingTriangle));
print(finalcut::fc::BlackUpPointingTriangle);
}
//----------------------------------------------------------------------
@ -272,7 +272,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
}
else if ( mouse_x >= 5 && mouse_x <= 7 && mouse_y == 3 )
{
brush = wchar_t(finalcut::fc::MediumShade);
brush = finalcut::fc::MediumShade;
redraw();
}
}
@ -416,25 +416,25 @@ void MouseDraw::draw()
for (int y = 2; y < y_max; y++)
{
setPrintPos (10, y);
print (wchar_t(finalcut::fc::NF_rev_border_line_right));
print (finalcut::fc::NF_rev_border_line_right);
}
setPrintPos (10, y_max);
print (wchar_t(finalcut::fc::NF_rev_border_corner_lower_right));
print (finalcut::fc::NF_rev_border_corner_lower_right);
}
else
{
setPrintPos (10, 2);
print (wchar_t(finalcut::fc::BoxDrawingsDownAndHorizontal));
print (finalcut::fc::BoxDrawingsDownAndHorizontal);
for (int y = 3; y < y_max; y++)
{
setPrintPos (10, y);
print (wchar_t(finalcut::fc::BoxDrawingsVertical));
print (finalcut::fc::BoxDrawingsVertical);
}
setPrintPos (10, y_max);
print (wchar_t(finalcut::fc::BoxDrawingsUpAndHorizontal));
print (finalcut::fc::BoxDrawingsUpAndHorizontal);
}
drawCanvas();

View File

@ -103,7 +103,7 @@ void Transparent::draw()
else
setTransparent();
finalcut::FString line(getClientWidth(), wchar_t('.'));
finalcut::FString line(getClientWidth(), '.');
for (int n = 1; n <= int(getClientHeight()); n++)
{

View File

@ -770,7 +770,7 @@ void MyDialog::cb_noFunctionMsg (finalcut::FWidget* widget, data_ptr)
void MyDialog::cb_about (finalcut::FWidget*, data_ptr)
{
const char libver[] = F_VERSION;
finalcut::FString line(2, wchar_t(finalcut::fc::BoxDrawingsHorizontal));
finalcut::FString line(2, finalcut::fc::BoxDrawingsHorizontal);
finalcut::FMessageBox info ( "About"
, line + L" The Final Cut " + line + "\n\n"
@ -793,7 +793,7 @@ void MyDialog::cb_terminfo (finalcut::FWidget*, data_ptr)
<< " Type: " << getTermType() << "\n"
<< " Name: " << getTermFileName() << "\n"
<< " Mode: " << getEncodingString() << "\n"
<< " Size: " << x << wchar_t(finalcut::fc::Times)
<< " Size: " << x << finalcut::fc::Times
<< y << "\n"
<< "Colors: " << getMaxColor()
, finalcut::FMessageBox::Ok, 0, 0, this

View File

@ -223,7 +223,7 @@ class Window : public finalcut::FDialog
// Data Members
std::vector<win_data*> windows{};
finalcut::FString drop_down_symbol{wchar_t(finalcut::fc::BlackDownPointingTriangle)};
finalcut::FString drop_down_symbol{finalcut::fc::BlackDownPointingTriangle};
finalcut::FMenuBar Menubar{this};
finalcut::FMenu File{"&File", &Menubar};
finalcut::FDialogListMenu DglList{drop_down_symbol, &Menubar};

View File

@ -69,6 +69,13 @@ FLabel& FLabel::operator << (const FString& s)
return *this;
}
//----------------------------------------------------------------------
FLabel& FLabel::operator << (fc::SpecialCharacter c)
{
setText(text + static_cast<wchar_t>(c));
return *this;
}
//----------------------------------------------------------------------
FLabel& FLabel::operator << (const wchar_t c)
{

View File

@ -72,6 +72,13 @@ FLineEdit& FLineEdit::operator << (const FString& s)
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (fc::SpecialCharacter c)
{
setText(text + static_cast<wchar_t>(c));
return *this;
}
//----------------------------------------------------------------------
FLineEdit& FLineEdit::operator << (const wchar_t c)
{

View File

@ -1768,7 +1768,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item)
checkbox = L"[ ] ";
if ( item->isChecked() )
checkbox[1] = wchar_t(fc::Times); // Times ×
checkbox[1] = fc::Times; // Times ×
}
return checkbox;
@ -1789,12 +1789,12 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
{
if ( item->isExpand() )
{
line += wchar_t(fc::BlackDownPointingTriangle); // ▼
line += fc::BlackDownPointingTriangle; // ▼
line += L' ';
}
else
{
line += wchar_t(fc::BlackRightPointingPointer); // ►
line += fc::BlackRightPointingPointer; // ►
line += L' ';
}
}
@ -1821,9 +1821,9 @@ inline void FListView::drawSortIndicator ( std::size_t& length
length++;
if ( sort_order == fc::ascending )
headerline << wchar_t(fc::BlackUpPointingTriangle); // ▲
headerline << fc::BlackUpPointingTriangle; // ▲
else if ( sort_order == fc::descending )
headerline << wchar_t(fc::BlackDownPointingTriangle); // ▼
headerline << fc::BlackDownPointingTriangle; // ▼
if ( length < column_width )
{
@ -1836,7 +1836,7 @@ inline void FListView::drawSortIndicator ( std::size_t& length
inline void FListView::drawHeaderBorder (std::size_t length)
{
setColor();
const FString line (length, wchar_t(fc::BoxDrawingsHorizontal));
const FString line (length, fc::BoxDrawingsHorizontal);
headerline << line; // horizontal line
}

View File

@ -1278,7 +1278,7 @@ inline void FMenu::drawSeparator (int y)
{
print (fc::NF_border_line_vertical_right);
FString line ( std::size_t(getWidth()) - 2
, wchar_t(fc::BoxDrawingsHorizontal) );
, fc::BoxDrawingsHorizontal );
print (line);
print (fc::NF_rev_border_line_vertical_left);
}
@ -1286,7 +1286,7 @@ inline void FMenu::drawSeparator (int y)
{
print (fc::BoxDrawingsVerticalAndRight);
FString line ( std::size_t(getWidth()) - 2
, wchar_t(fc::BoxDrawingsHorizontal));
, fc::BoxDrawingsHorizontal);
print (line);
print (fc::BoxDrawingsVerticalAndLeft);
}
@ -1447,9 +1447,9 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
if ( len > 0 )
{
// Print filling blank spaces
print (FString(len, wchar_t(' ')));
print (FString(len, L' '));
// Print BlackRightPointingPointer ►
print (wchar_t(fc::BlackRightPointingPointer));
print (fc::BlackRightPointingPointer);
startpos = max_item_width - (c + 2);
}
}
@ -1465,7 +1465,7 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
if ( len > 0 )
{
// Print filling blank spaces + accelerator key name
FString spaces (len, wchar_t(' '));
FString spaces (len, L' ');
print (spaces + accel_name);
startpos = max_item_width - (c + 2);
}

View File

@ -62,20 +62,6 @@ FString::FString (std::size_t len, wchar_t c)
*--pe = c;
}
//----------------------------------------------------------------------
FString::FString (std::size_t len, char c)
{
wchar_t* ps;
wchar_t* pe;
initLength(len);
ps = string;
pe = string + len;
while ( pe != ps )
*--pe = wchar_t(c);
}
//----------------------------------------------------------------------
FString::FString (const FString& s) // copy constructor
{
@ -119,6 +105,18 @@ FString::FString (const char s[])
}
}
//----------------------------------------------------------------------
FString::FString (fc::SpecialCharacter c)
{
if ( c )
{
wchar_t s[2];
s[0] = static_cast<wchar_t>(c);
s[1] = L'\0';
_assign (s);
}
}
//----------------------------------------------------------------------
FString::FString (const wchar_t c)
{
@ -207,6 +205,14 @@ FString& FString::operator << (const FString& s)
return *this;
}
//----------------------------------------------------------------------
FString& FString::operator << (fc::SpecialCharacter c)
{
FString s(static_cast<wchar_t>(c));
_insert (length, s.length, s.string);
return *this;
}
//----------------------------------------------------------------------
FString& FString::operator << (const wchar_t c)
{

View File

@ -451,7 +451,7 @@ int FVTerm::print (term_area* area, const std::vector<charData>& term_string)
}
//----------------------------------------------------------------------
int FVTerm::print (int c)
int FVTerm::print (wchar_t c)
{
term_area* area = getPrintArea();
@ -467,14 +467,14 @@ int FVTerm::print (int c)
}
//----------------------------------------------------------------------
int FVTerm::print (term_area* area, int c)
int FVTerm::print (term_area* area, wchar_t c)
{
charData nc; // next character
if ( ! area )
return -1;
nc.code = c;
nc.code = wchar_t(c);
nc.fg_color = next_attribute.fg_color;
nc.bg_color = next_attribute.bg_color;
nc.attr.byte[0] = next_attribute.attr.byte[0];

View File

@ -82,6 +82,7 @@ class FLabel : public FWidget
// Overloaded operators
FLabel& operator = (const FString&);
FLabel& operator << (const FString&);
FLabel& operator << (fc::SpecialCharacter);
FLabel& operator << (const wchar_t);
FLabel& operator << (const uInt);
FLabel& operator << (const int);

View File

@ -85,6 +85,7 @@ class FLineEdit : public FWidget
// Overloaded operators
FLineEdit& operator = (const FString&);
FLineEdit& operator << (const FString&);
FLineEdit& operator << (fc::SpecialCharacter);
FLineEdit& operator << (const wchar_t);
FLineEdit& operator << (const uInt);
FLineEdit& operator << (const int);

View File

@ -77,9 +77,9 @@ class FOptiAttr
// Typedefs
typedef struct
{
int code; // character code
FColor fg_color; // foreground color
FColor bg_color; // background color
wchar_t code; // character code
FColor fg_color; // foreground color
FColor bg_color; // background color
union attribute
{

View File

@ -56,6 +56,7 @@
#include <string>
#include <vector>
#include "final/fc.h"
#include "final/ftypes.h"
namespace finalcut
@ -86,14 +87,14 @@ class FString
explicit FString (int);
explicit FString (std::size_t);
FString (std::size_t, wchar_t);
FString (std::size_t, char);
FString (const FString&); // implicit conversion copy constructor
FString (const std::wstring&); // implicit conversion constructor
FString (const wchar_t[]); // implicit conversion constructor
FString (const std::string&); // implicit conversion constructor
FString (const char[]); // implicit conversion constructor
FString (const wchar_t); // implicit conversion constructor
FString (const char); // implicit conversion constructor
FString (const FString&); // implicit conversion copy constructor
FString (const std::wstring&); // implicit conversion constructor
FString (const wchar_t[]); // implicit conversion constructor
FString (const std::string&); // implicit conversion constructor
FString (const char[]); // implicit conversion constructor
FString (fc::SpecialCharacter); // implicit conversion constructor
FString (const wchar_t); // implicit conversion constructor
FString (const char); // implicit conversion constructor
// Destructor
virtual ~FString ();
@ -108,6 +109,7 @@ class FString
const FString operator + (const char);
FString& operator << (const FString&);
FString& operator << (fc::SpecialCharacter);
FString& operator << (const wchar_t);
FString& operator << (const char);
FString& operator << (const sInt16);

View File

@ -579,4 +579,24 @@ inline void FTerm::changeTermSizeFinished()
} // namespace finalcut
namespace
{
//----------------------------------------------------------------------
inline std::ostream& operator << ( std::ostream& os
, finalcut::fc::SpecialCharacter c )
{
return os << static_cast<char>(c);
}
//----------------------------------------------------------------------
inline std::wostream& operator << ( std::wostream& os
, finalcut::fc::SpecialCharacter c )
{
return os << static_cast<wchar_t>(c);
}
} // namespace
#endif // FTERM_H

View File

@ -287,8 +287,8 @@ class FVTerm
int print (term_area*, const FString&);
int print (const std::vector<charData>&);
int print (term_area*, const std::vector<charData>&);
int print (int);
int print (term_area*, int);
int print (wchar_t);
int print (term_area*, wchar_t);
int print (charData&);
int print (term_area*, charData&);
FVTerm& print();

View File

@ -823,6 +823,10 @@ void FStringTest::streamInsertionTest()
out << const_cast<char*>("ABC");
CPPUNIT_ASSERT ( out == L"ABC" );
out.clear();
out << finalcut::fc::Euro;
CPPUNIT_ASSERT ( out == L"" );
out.clear();
out << wchar_t(L'A');
CPPUNIT_ASSERT ( out == L"A" );