2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* term-attributes.cpp - Test the video attributes of the terminal *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2020-02-02 22:34:27 +01:00
|
|
|
* Copyright 2015-2020 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2015-12-24 02:37:01 +01:00
|
|
|
|
2018-12-16 00:11:25 +01:00
|
|
|
#include <functional>
|
2019-08-06 23:45:28 +02:00
|
|
|
#include <vector>
|
2017-10-31 00:41:59 +01:00
|
|
|
#include <final/final.h>
|
|
|
|
|
2019-04-26 21:06:04 +02:00
|
|
|
namespace fc = finalcut::fc;
|
2019-01-21 03:42:18 +01:00
|
|
|
using finalcut::FPoint;
|
|
|
|
using finalcut::FSize;
|
2019-01-30 12:17:48 +01:00
|
|
|
using finalcut::FColorPair;
|
2019-01-21 03:42:18 +01:00
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class AttribDlg
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2020-04-14 23:46:42 +02:00
|
|
|
class AttribDlg final : public finalcut::FDialog
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2018-12-10 01:48:26 +01:00
|
|
|
explicit AttribDlg (finalcut::FWidget* = nullptr);
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2018-12-09 22:04:55 +01:00
|
|
|
// Disable copy constructor
|
|
|
|
AttribDlg (const AttribDlg&) = delete;
|
2018-12-24 18:11:16 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Destructor
|
2020-02-19 21:59:13 +01:00
|
|
|
~AttribDlg() override;
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2020-04-15 23:44:08 +02:00
|
|
|
// Disable copy assignment operator (=)
|
2018-12-09 22:04:55 +01:00
|
|
|
AttribDlg& operator = (const AttribDlg&) = delete;
|
|
|
|
|
2020-04-13 12:40:11 +02:00
|
|
|
// Methods
|
|
|
|
FColor getBGColor();
|
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Event handlers
|
2019-08-06 23:45:28 +02:00
|
|
|
void onKeyPress (finalcut::FKeyEvent*) override;
|
|
|
|
void onWheel (finalcut::FWheelEvent*) override;
|
|
|
|
void onClose (finalcut::FCloseEvent*) override;
|
2016-09-30 04:55:28 +02:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
// Callback methods
|
2020-04-13 12:40:11 +02:00
|
|
|
void cb_next (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr);
|
|
|
|
void cb_back (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr);
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2017-09-11 03:06:02 +02:00
|
|
|
private:
|
|
|
|
// Method
|
2019-08-06 23:45:28 +02:00
|
|
|
void adjustSize() override;
|
2016-11-02 00:37:58 +01:00
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data members
|
2020-04-19 20:38:52 +02:00
|
|
|
FColor bgcolor{getFWidgetColors().label_bg};
|
2018-12-03 03:22:36 +01:00
|
|
|
finalcut::FButton next_button{"&Next >", this};
|
|
|
|
finalcut::FButton back_button{"< &Back", this};
|
2015-12-24 02:37:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
2020-05-24 23:55:08 +02:00
|
|
|
: finalcut::FDialog{parent}
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2020-04-19 20:38:52 +02:00
|
|
|
FDialog::setText ( "A terminal attributes test ("
|
2020-05-16 22:24:36 +02:00
|
|
|
+ finalcut::FString{finalcut::FTerm::getTermType()}
|
2020-04-19 20:38:52 +02:00
|
|
|
+ ")");
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
|
|
|
, FSize{10, 1} );
|
2019-04-26 21:06:04 +02:00
|
|
|
next_button.addAccelerator (fc::Fkey_right);
|
2020-05-02 00:07:35 +02:00
|
|
|
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
|
|
|
, FSize{10, 1} );
|
2019-04-26 21:06:04 +02:00
|
|
|
back_button.addAccelerator (fc::Fkey_left);
|
2016-01-08 01:00:05 +01:00
|
|
|
|
|
|
|
// Add function callbacks
|
2018-10-03 22:23:55 +02:00
|
|
|
next_button.addCallback
|
2016-01-08 01:00:05 +01:00
|
|
|
(
|
|
|
|
"clicked",
|
2017-04-09 20:08:53 +02:00
|
|
|
F_METHOD_CALLBACK (this, &AttribDlg::cb_next)
|
2016-01-08 01:00:05 +01:00
|
|
|
);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-10-03 22:23:55 +02:00
|
|
|
back_button.addCallback
|
2016-01-08 01:00:05 +01:00
|
|
|
(
|
|
|
|
"clicked",
|
2017-04-09 20:08:53 +02:00
|
|
|
F_METHOD_CALLBACK (this, &AttribDlg::cb_back)
|
2016-01-08 01:00:05 +01:00
|
|
|
);
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
AttribDlg::~AttribDlg()
|
|
|
|
{ }
|
|
|
|
|
2020-04-13 12:40:11 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FColor AttribDlg::getBGColor()
|
|
|
|
{
|
|
|
|
return bgcolor;
|
|
|
|
}
|
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
2019-01-21 03:42:18 +01:00
|
|
|
void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2019-01-21 03:42:18 +01:00
|
|
|
if ( ! ev )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( ev->key() == 'q' )
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
finalcut::FDialog::onKeyPress(ev);
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
2016-01-10 00:56:52 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void AttribDlg::onWheel (finalcut::FWheelEvent* ev)
|
2016-01-10 00:56:52 +01:00
|
|
|
{
|
2020-02-02 22:34:27 +01:00
|
|
|
const int wheel = ev->getWheel();
|
2016-01-10 00:56:52 +01:00
|
|
|
|
2019-04-26 21:06:04 +02:00
|
|
|
if ( wheel == fc::WheelUp )
|
2016-01-10 00:56:52 +01:00
|
|
|
cb_next();
|
2019-04-26 21:06:04 +02:00
|
|
|
else if ( wheel == fc::WheelDown )
|
2016-01-10 00:56:52 +01:00
|
|
|
cb_back();
|
|
|
|
}
|
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
void AttribDlg::onClose (finalcut::FCloseEvent* ev)
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
//----------------------------------------------------------------------
|
2020-04-13 12:40:11 +02:00
|
|
|
void AttribDlg::cb_next (const finalcut::FWidget*, const FDataPtr)
|
2016-01-08 01:00:05 +01:00
|
|
|
{
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( finalcut::FTerm::isMonochron() )
|
2016-01-08 01:00:05 +01:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( bgcolor == FColor(finalcut::FTerm::getMaxColor() - 1) )
|
2019-04-26 21:06:04 +02:00
|
|
|
bgcolor = fc::Default;
|
|
|
|
else if ( bgcolor == fc::Default )
|
2018-11-07 22:06:58 +01:00
|
|
|
bgcolor = 0;
|
|
|
|
else
|
|
|
|
bgcolor++;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2020-04-13 12:40:11 +02:00
|
|
|
void AttribDlg::cb_back (const finalcut::FWidget*, const FDataPtr)
|
2016-01-08 01:00:05 +01:00
|
|
|
{
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( finalcut::FTerm::isMonochron() )
|
2016-01-08 01:00:05 +01:00
|
|
|
return;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2018-11-07 22:06:58 +01:00
|
|
|
if ( bgcolor == 0 )
|
2019-04-26 21:06:04 +02:00
|
|
|
bgcolor = fc::Default;
|
|
|
|
else if ( bgcolor == fc::Default )
|
2020-05-16 22:24:36 +02:00
|
|
|
bgcolor = FColor(finalcut::FTerm::getMaxColor() - 1);
|
2018-11-07 22:06:58 +01:00
|
|
|
else
|
|
|
|
bgcolor--;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
redraw();
|
|
|
|
}
|
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDlg::adjustSize()
|
|
|
|
{
|
2019-02-07 23:05:50 +01:00
|
|
|
int x = int((getDesktopWidth() - getWidth()) / 2);
|
|
|
|
int y = int((getDesktopHeight() - getHeight()) / 2) + 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
if ( x < 1 )
|
|
|
|
x = 1;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-17 02:57:08 +01:00
|
|
|
if ( y < 1 )
|
|
|
|
y = 1;
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
setGeometry(FPoint{x, y}, FSize{69, 21}, false);
|
|
|
|
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
|
|
|
, FSize{10, 1}, false );
|
|
|
|
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
|
|
|
, FSize{10, 1}, false );
|
2018-09-20 23:59:01 +02:00
|
|
|
finalcut::FDialog::adjustSize();
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class AttribDemo
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2020-04-14 23:46:42 +02:00
|
|
|
class AttribDemo final : public finalcut::FWidget
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Constructor
|
2018-12-10 01:48:26 +01:00
|
|
|
explicit AttribDemo (FWidget* = nullptr);
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
// Destructor
|
2020-02-19 21:59:13 +01:00
|
|
|
~AttribDemo() override
|
2017-09-11 03:06:02 +02:00
|
|
|
{ }
|
|
|
|
|
|
|
|
// Event handler
|
2019-08-06 23:45:28 +02:00
|
|
|
void onWheel (finalcut::FWheelEvent* ev) override
|
2017-09-11 03:06:02 +02:00
|
|
|
{
|
2018-12-15 00:50:09 +01:00
|
|
|
auto p = static_cast<AttribDlg*>(getParentWidget());
|
2017-09-11 03:06:02 +02:00
|
|
|
|
|
|
|
if ( p )
|
|
|
|
p->onWheel(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Methods
|
|
|
|
void printColorLine();
|
|
|
|
void printAltCharset();
|
2017-11-24 00:28:25 +01:00
|
|
|
void printDim();
|
|
|
|
void printNormal();
|
|
|
|
void printBold();
|
|
|
|
void printBoldDim();
|
|
|
|
void printItalic();
|
|
|
|
void printUnderline();
|
|
|
|
void printDblUnderline();
|
|
|
|
void printCrossesOut();
|
|
|
|
void printBlink();
|
|
|
|
void printReverse();
|
|
|
|
void printStandout();
|
|
|
|
void printInvisible();
|
|
|
|
void printProtected();
|
2019-08-06 23:45:28 +02:00
|
|
|
void draw() override;
|
2017-09-11 03:06:02 +02:00
|
|
|
|
2019-09-04 23:57:31 +02:00
|
|
|
// Data member
|
2020-05-16 22:24:36 +02:00
|
|
|
FColor last_color{FColor(finalcut::FTerm::getMaxColor())};
|
2015-12-24 02:37:01 +01:00
|
|
|
};
|
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
//----------------------------------------------------------------------
|
2018-09-20 23:59:01 +02:00
|
|
|
AttribDemo::AttribDemo (finalcut::FWidget* parent)
|
2020-05-24 23:55:08 +02:00
|
|
|
: finalcut::FWidget{parent}
|
2016-01-08 01:00:05 +01:00
|
|
|
{
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( finalcut::FTerm::isMonochron() )
|
2019-11-19 02:46:01 +01:00
|
|
|
last_color = 1;
|
|
|
|
else if ( last_color > 16 )
|
|
|
|
last_color = 16;
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
unsetFocusable();
|
|
|
|
}
|
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printColorLine()
|
|
|
|
{
|
2020-02-02 22:34:27 +01:00
|
|
|
const auto& parent = static_cast<AttribDlg*>(getParent());
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2019-11-19 02:46:01 +01:00
|
|
|
for (FColor color{0}; color < last_color; color++)
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2020-05-02 00:07:35 +02:00
|
|
|
print() << FColorPair{color, parent->getBGColor()} << " # ";
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printAltCharset()
|
|
|
|
{
|
2019-10-01 23:14:00 +02:00
|
|
|
const auto& wc = getFWidgetColors();
|
2020-02-02 22:34:27 +01:00
|
|
|
const auto& parent = static_cast<AttribDlg*>(getParent());
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( ! finalcut::FTerm::isMonochron() )
|
2016-01-08 01:00:05 +01:00
|
|
|
setColor (wc.label_fg, wc.label_bg);
|
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
print() << FPoint{1, 1} << "alternate charset: ";
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2020-04-13 12:40:11 +02:00
|
|
|
if ( parent->getBGColor() == fc::Default )
|
2016-01-08 01:00:05 +01:00
|
|
|
{
|
2019-04-26 21:06:04 +02:00
|
|
|
setColor (fc::Default, fc::Default);
|
2016-01-08 01:00:05 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-13 12:40:11 +02:00
|
|
|
if ( (parent->getBGColor() <= 8)
|
|
|
|
|| (parent->getBGColor() >= 16 && parent->getBGColor() <= 231
|
|
|
|
&& (parent->getBGColor() - 16) % 36 <= 17)
|
|
|
|
|| (parent->getBGColor() >= 232 && parent->getBGColor() <= 243) )
|
|
|
|
setColor (fc::White, parent->getBGColor());
|
2016-01-08 01:00:05 +01:00
|
|
|
else
|
2020-04-13 12:40:11 +02:00
|
|
|
setColor (fc::Black, parent->getBGColor());
|
2016-01-08 01:00:05 +01:00
|
|
|
}
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-01-08 01:00:05 +01:00
|
|
|
setAltCharset();
|
|
|
|
print("`abcdefghijklmnopqrstuvwxyz{|}~");
|
|
|
|
unsetAltCharset();
|
|
|
|
print(" ");
|
|
|
|
}
|
|
|
|
|
2017-11-24 00:28:25 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printDim()
|
|
|
|
{
|
|
|
|
print(" Dim: ");
|
|
|
|
setDim();
|
|
|
|
printColorLine();
|
|
|
|
unsetDim();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printNormal()
|
|
|
|
{
|
|
|
|
print(" Normal: ");
|
|
|
|
setNormal();
|
|
|
|
printColorLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printBold()
|
|
|
|
{
|
|
|
|
print(" Bold: ");
|
|
|
|
setBold();
|
|
|
|
printColorLine();
|
|
|
|
unsetBold();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printBoldDim()
|
|
|
|
{
|
|
|
|
print(" Bold+Dim: ");
|
|
|
|
setBold();
|
|
|
|
setDim();
|
|
|
|
printColorLine();
|
|
|
|
unsetDim();
|
|
|
|
unsetBold();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printItalic()
|
|
|
|
{
|
|
|
|
print(" Italic: ");
|
|
|
|
setItalic();
|
|
|
|
printColorLine();
|
|
|
|
unsetItalic();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printUnderline()
|
|
|
|
{
|
|
|
|
print(" Underline: ");
|
|
|
|
setUnderline();
|
|
|
|
printColorLine();
|
|
|
|
unsetUnderline();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printDblUnderline()
|
|
|
|
{
|
|
|
|
print(" Double underline: ");
|
|
|
|
setDoubleUnderline();
|
|
|
|
printColorLine();
|
|
|
|
unsetDoubleUnderline();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printCrossesOut()
|
|
|
|
{
|
|
|
|
print(" Crossed-out: ");
|
|
|
|
setCrossedOut();
|
|
|
|
printColorLine();
|
|
|
|
unsetCrossedOut();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printBlink()
|
|
|
|
{
|
|
|
|
print(" Blink: ");
|
|
|
|
setBlink();
|
|
|
|
printColorLine();
|
|
|
|
unsetBlink();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printReverse()
|
|
|
|
{
|
|
|
|
print(" Reverse: ");
|
|
|
|
setReverse();
|
|
|
|
printColorLine();
|
|
|
|
unsetReverse();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printStandout()
|
|
|
|
{
|
|
|
|
print(" Standout: ");
|
|
|
|
setStandout();
|
|
|
|
printColorLine();
|
|
|
|
unsetStandout();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printInvisible()
|
|
|
|
{
|
|
|
|
print(" Invisible: ");
|
|
|
|
setInvisible();
|
|
|
|
printColorLine();
|
|
|
|
unsetInvisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::printProtected()
|
|
|
|
{
|
|
|
|
print(" Protected: ");
|
|
|
|
setProtected();
|
|
|
|
printColorLine();
|
|
|
|
unsetProtected();
|
|
|
|
}
|
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void AttribDemo::draw()
|
|
|
|
{
|
2016-01-08 01:00:05 +01:00
|
|
|
// test alternate character set
|
2019-10-01 23:14:00 +02:00
|
|
|
const auto& wc = getFWidgetColors();
|
2016-01-08 01:00:05 +01:00
|
|
|
printAltCharset();
|
|
|
|
|
2020-02-02 22:34:27 +01:00
|
|
|
const std::vector<std::function<void()> > effect
|
2015-12-24 02:37:01 +01:00
|
|
|
{
|
2020-04-14 23:46:42 +02:00
|
|
|
[this] { printNormal(); },
|
|
|
|
[this] { printBold(); },
|
|
|
|
[this] { printBoldDim(); },
|
|
|
|
[this] { printItalic(); },
|
|
|
|
[this] { printUnderline(); },
|
|
|
|
[this] { printDblUnderline(); },
|
|
|
|
[this] { printCrossesOut(); },
|
|
|
|
[this] { printBlink(); },
|
|
|
|
[this] { printReverse(); },
|
|
|
|
[this] { printStandout(); },
|
|
|
|
[this] { printInvisible(); },
|
|
|
|
[this] { printProtected(); },
|
2018-12-16 00:11:25 +01:00
|
|
|
};
|
|
|
|
|
2019-08-25 22:16:00 +02:00
|
|
|
for (std::size_t y{0}; y < getParentWidget()->getHeight() - 7; y++)
|
2018-12-16 00:11:25 +01:00
|
|
|
{
|
2020-05-02 00:07:35 +02:00
|
|
|
print() << FPoint{1, 2 + int(y)};
|
2016-01-08 01:00:05 +01:00
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( ! finalcut::FTerm::isMonochron() )
|
2016-01-08 01:00:05 +01:00
|
|
|
setColor (wc.label_fg, wc.label_bg);
|
|
|
|
|
2018-12-16 00:11:25 +01:00
|
|
|
if ( y < effect.size() )
|
|
|
|
effect[y]();
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
2020-05-16 22:24:36 +02:00
|
|
|
if ( ! finalcut::FTerm::isMonochron() )
|
2016-01-08 01:00:05 +01:00
|
|
|
setColor(wc.label_fg, wc.label_bg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
print() << FPoint{1, 15};
|
2020-04-13 12:40:11 +02:00
|
|
|
const FColor bg = static_cast<AttribDlg*>(getParent())->getBGColor();
|
2016-01-17 02:57:08 +01:00
|
|
|
print (" Background color:");
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2019-04-26 21:06:04 +02:00
|
|
|
if ( bg == fc::Default )
|
2016-01-17 23:37:52 +01:00
|
|
|
print (" default");
|
2016-01-17 02:57:08 +01:00
|
|
|
else
|
|
|
|
printf ( " %d", bg);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
print() << FPoint{16, 17} << "Change background color ->";
|
2015-12-24 02:37:01 +01:00
|
|
|
}
|
|
|
|
|
2016-01-10 00:56:52 +01:00
|
|
|
|
2015-12-24 02:37:01 +01:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// main part
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
int main (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
// Create the application object
|
2020-05-02 00:07:35 +02:00
|
|
|
finalcut::FApplication app {argc, argv};
|
2015-12-24 02:37:01 +01:00
|
|
|
|
|
|
|
// Create a dialog box object.
|
|
|
|
// This object will be automatically deleted by
|
|
|
|
// the parent object "app" (FObject destructor).
|
2020-05-02 00:07:35 +02:00
|
|
|
AttribDlg dialog{&app};
|
2015-12-24 02:37:01 +01:00
|
|
|
|
2020-05-02 00:07:35 +02:00
|
|
|
dialog.setGeometry (FPoint{6, 2}, FSize{69, 21});
|
2018-10-03 22:23:55 +02:00
|
|
|
dialog.setShadow();
|
2015-12-24 02:37:01 +01:00
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Create the attribute demo widget as a child object from the dialog
|
2018-10-03 22:23:55 +02:00
|
|
|
AttribDemo demo(&dialog);
|
2020-05-02 00:07:35 +02:00
|
|
|
demo.setGeometry (FPoint{1, 1}, FSize{67, 19});
|
2015-12-24 02:37:01 +01:00
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Set the dialog object as main widget
|
2020-04-13 12:40:11 +02:00
|
|
|
finalcut::FWidget::setMainWidget(&dialog);
|
2015-12-24 02:37:01 +01:00
|
|
|
|
2017-09-19 06:18:03 +02:00
|
|
|
// Show and start the application
|
2018-10-03 22:23:55 +02:00
|
|
|
dialog.show();
|
2015-12-24 02:37:01 +01:00
|
|
|
return app.exec();
|
|
|
|
}
|