commit
cd5f7ae16e
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
engines:
|
||||
duplication:
|
||||
enabled: true
|
||||
exclude_paths:
|
||||
- 'fonts/**'
|
||||
- 'test/**'
|
||||
exclude_paths:
|
||||
- 'debian/**'
|
||||
- 'doc/**'
|
||||
- 'icon/**'
|
||||
- 'logo/**'
|
||||
- 'm4/**'
|
||||
- 'scripts/**'
|
||||
|
|
@ -38,6 +38,7 @@ examples/.deps/
|
|||
examples/.libs/
|
||||
examples/calculator
|
||||
examples/dialog
|
||||
examples/event-log
|
||||
examples/string-operations
|
||||
examples/background-color
|
||||
examples/opti-move
|
||||
|
|
|
@ -75,12 +75,12 @@ matrix:
|
|||
- whoami
|
||||
- echo -n | openssl s_client -CApath /etc/ssl/certs/ -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
|
||||
script:
|
||||
- cat /home/travis/build/gansm/finalcut/cov-int/scm_log.txt
|
||||
- cat /home/travis/build/gansm/finalcut/cov-int/scm_log.txt || echo
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
|
||||
- make V=1 -j10
|
||||
- make check
|
||||
- cat test/*.log
|
||||
- cat test/*.log || echo
|
||||
|
||||
#
|
||||
# Coveralls + Codecov
|
||||
|
|
35
ChangeLog
35
ChangeLog
|
@ -1,3 +1,38 @@
|
|||
2020-05-30 Markus Gans <guru.mail@muenster.de>
|
||||
* With the two new methods FApplication::setDarkTheme() and
|
||||
FApplication::setDefaultTheme() you can now change the theme
|
||||
within an application. An example can be found in examples/ui
|
||||
via the menu items "View" -> "Dark mode".
|
||||
|
||||
2020-05-29 Markus Gans <guru.mail@muenster.de>
|
||||
* Adding a dark theme. Can be activated with the --dark-theme parameter.
|
||||
|
||||
2020-05-28 Markus Gans <guru.mail@muenster.de>
|
||||
* FColorPalette now also uses polymorphism, so you can now
|
||||
easily create your own color palette theme
|
||||
|
||||
2020-05-26 Markus Gans <guru.mail@muenster.de>
|
||||
* FWidgetColors now uses polymorphism, so you can now easily
|
||||
create your own widget color theme
|
||||
* FApplication has got the new virtual method processExternalUserEvent()
|
||||
for user code
|
||||
|
||||
2020-05-24 Markus Gans <guru.mail@muenster.de>
|
||||
* New class FStringStream implements input and output operations
|
||||
on FString based streams
|
||||
* Fixed memory leak in FString move assignment operator
|
||||
|
||||
2020-05-21 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixed the event queue in FApplication
|
||||
|
||||
2020-05-16 Markus Gans <guru.mail@muenster.de>
|
||||
* More direct access to the static FTerm functions
|
||||
|
||||
2020-05-13 Markus Gans <guru.mail@muenster.de>
|
||||
* The new class FLogger for logging, which can be redirected
|
||||
to different I/O channels
|
||||
* Adding the event-log example to show the logging functionality
|
||||
|
||||
2020-05-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Transfer of all termcap functions into the FTermcap class
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ Table of Contents
|
|||
- [Event handler reimplementation](#event-handler-reimplementation)
|
||||
- [Signals and Callbacks](#signals-and-callbacks)
|
||||
- [Default signals](#the-final-cut-widgets-emit-the-following-default-signals)
|
||||
- [Callback function](#example-of-a-callback-function)
|
||||
- [Callback lambda expression](#example-of-an-lambda-expression-callback)
|
||||
- [Callback method](#example-of-a-callback-function)
|
||||
- [Custom signals](#send-custom-signals)
|
||||
- [Callback function](#example-of-a-callback-function)
|
||||
- [Callback lambda expression](#example-of-an-lambda-expression-callback)
|
||||
- [Callback method](#example-of-a-callback-function)
|
||||
- [Custom signals](#send-custom-signals)
|
||||
- [Widget layout](#widget-layout)
|
||||
- [Coordinates](#coordinates)
|
||||
- [Lengths](#lengths)
|
||||
|
@ -69,8 +69,8 @@ int main (int argc, char* argv[])
|
|||
finalcut::FApplication app(argc, argv);
|
||||
finalcut::FDialog dialog(&app);
|
||||
dialog.setText ("A dialog");
|
||||
const finalcut::FPoint position(25, 5);
|
||||
const finalcut::FSize size(30, 10);
|
||||
const finalcut::FPoint position{25, 5};
|
||||
const finalcut::FSize size{30, 10};
|
||||
dialog.setGeometry (position, size);
|
||||
finalcut::FWidget::setMainWidget(&dialog);
|
||||
dialog.show();
|
||||
|
@ -126,8 +126,8 @@ dialog.setText ("A dialog");
|
|||
The title bar of the dialog box gets the text "A dialog".
|
||||
|
||||
```cpp
|
||||
finalcut::FPoint position(25, 5);
|
||||
finalcut::FSize size(30, 10);
|
||||
finalcut::FPoint position{25, 5};
|
||||
finalcut::FSize size{30, 10};
|
||||
dialog.setGeometry (position, size);
|
||||
```
|
||||
The dialog window gets a width of 30 and a height of 10 characters.
|
||||
|
@ -206,11 +206,11 @@ int main (int argc, char* argv[])
|
|||
// The object dialog is managed by app
|
||||
FDialog* dialog = new FDialog(&app);
|
||||
dialog->setText ("Window Title");
|
||||
dialog->setGeometry (FPoint(25, 5), FSize(40, 8));
|
||||
dialog->setGeometry (FPoint{25, 5}, FSize{40, 8});
|
||||
|
||||
// The object input is managed by dialog
|
||||
FLineEdit* input = new FLineEdit("predefined text", dialog);
|
||||
input->setGeometry(FPoint(8, 2), FSize(29, 1));
|
||||
input->setGeometry(FPoint{8, 2}, FSize{29, 1});
|
||||
input->setLabelText (L"&Input");
|
||||
|
||||
// The object label is managed by dialog
|
||||
|
@ -218,7 +218,7 @@ int main (int argc, char* argv[])
|
|||
"adipiscing elit, sed do eiusmod tempor "
|
||||
"incididunt ut labore et dolore magna aliqua."
|
||||
, dialog );
|
||||
label->setGeometry (FPoint(2, 4), FSize(36, 1));
|
||||
label->setGeometry (FPoint{2, 4}, FSize{36, 1});
|
||||
FWidget::setMainWidget(dialog);
|
||||
dialog->show();
|
||||
return app.exec();
|
||||
|
@ -322,13 +322,13 @@ class dialogWidget : public FDialog
|
|||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint(25, 5), FSize(23, 4));
|
||||
label.setGeometry (FPoint(1, 1), FSize(10, 1));
|
||||
setGeometry (FPoint{25, 5}, FSize{23, 4});
|
||||
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
|
||||
label.setAlignment (fc::alignRight);
|
||||
value.setGeometry (FPoint(11, 1), FSize(10, 1));
|
||||
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
|
||||
id = addTimer(100);
|
||||
}
|
||||
|
||||
|
@ -500,14 +500,14 @@ int main (int argc, char* argv[])
|
|||
FApplication app(argc, argv);
|
||||
FDialog dialog(&app);
|
||||
dialog.setText ("A dialog with callback function");
|
||||
dialog.setGeometry (FRect(25, 5, 45, 9));
|
||||
dialog.setGeometry (FRect{25, 5, 45, 9});
|
||||
FLabel label (&dialog);
|
||||
label = "The button has never been pressed before";
|
||||
label.setGeometry (FPoint(2, 2), FSize(41, 1));
|
||||
label.setGeometry (FPoint{2, 2}, FSize{41, 1});
|
||||
FButton button (&dialog);
|
||||
// Character follows '&' will be used as the accelerator key
|
||||
button = "&Click me";
|
||||
button.setGeometry (FPoint(15, 5), FSize(14, 1));
|
||||
button.setGeometry (FPoint{15, 5}, FSize{14, 1});
|
||||
|
||||
// Connect the button signal "clicked" with the callback function
|
||||
button.addCallback
|
||||
|
@ -553,9 +553,9 @@ int main (int argc, char* argv[])
|
|||
FApplication app(argc, argv);
|
||||
FDialog dialog(&app);
|
||||
dialog.setText ("Lambda expression as callback");
|
||||
dialog.setGeometry (FRect(25, 5, 45, 9));
|
||||
dialog.setGeometry (FRect{25, 5, 45, 9});
|
||||
FButton button ("&bottom", &dialog);
|
||||
button.setGeometry (FPoint(15, 5), FSize(14, 1));
|
||||
button.setGeometry (FPoint{15, 5}, FSize{14, 1});
|
||||
|
||||
// Connect the button signal "clicked" with the lambda expression
|
||||
button.addCallback
|
||||
|
@ -567,12 +567,12 @@ int main (int argc, char* argv[])
|
|||
|
||||
if ( button.getY() != 2 )
|
||||
{
|
||||
button.setPos (FPoint(15, 2));
|
||||
button.setPos (FPoint{15, 2});
|
||||
button.setText("&top");
|
||||
}
|
||||
else
|
||||
{
|
||||
button.setPos (FPoint(15, 5));
|
||||
button.setPos (FPoint{15, 5});
|
||||
button.setText("&bottom");
|
||||
}
|
||||
|
||||
|
@ -616,11 +616,11 @@ class dialogWidget : public FDialog
|
|||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Callback method");
|
||||
setGeometry (FPoint(25, 5), FSize(25, 7));
|
||||
button.setGeometry (FPoint(7, 3), FSize(10, 1));
|
||||
setGeometry (FPoint{25, 5}, FSize{25, 7});
|
||||
button.setGeometry (FPoint{7, 3}, FSize{10, 1});
|
||||
|
||||
// Connect the button signal "clicked" with the callback method
|
||||
button.addCallback
|
||||
|
@ -678,16 +678,16 @@ class dialogWidget : public FDialog
|
|||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setGeometry (FPoint(25, 5), FSize(22, 7));
|
||||
setGeometry (FPoint{25, 5}, FSize{22, 7});
|
||||
setText ("Emit signal");
|
||||
const FSize size(5, 1);
|
||||
label.setGeometry (FPoint(8, 1), size);
|
||||
const FSize size{5, 1};
|
||||
label.setGeometry (FPoint{8, 1}, size);
|
||||
label.setAlignment (fc::alignRight);
|
||||
label.setForegroundColor (fc::Black);
|
||||
plus.setGeometry (FPoint(3, 3), size);
|
||||
minus.setGeometry (FPoint(13, 3), size);
|
||||
plus.setGeometry (FPoint{3, 3}, size);
|
||||
minus.setGeometry (FPoint{13, 3}, size);
|
||||
plus.setNoUnderline();
|
||||
minus.setNoUnderline();
|
||||
|
||||
|
@ -987,15 +987,15 @@ class dialogWidget : public FDialog
|
|||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setResizeable();
|
||||
button.setGeometry (FPoint(1, 1), FSize(12, 1), false);
|
||||
input.setGeometry (FPoint(2, 3), FSize(12, 1), false);
|
||||
button.setGeometry (FPoint{1, 1}, FSize{12, 1}, false);
|
||||
input.setGeometry (FPoint{2, 3}, FSize{12, 1}, false);
|
||||
// Set dialog geometry and calling adjustSize()
|
||||
setGeometry (FPoint(25, 5), FSize(40, 12));
|
||||
setMinimumSize (FSize(25, 9));
|
||||
setGeometry (FPoint{25, 5}), FSize{40, 12});
|
||||
setMinimumSize (FSize{25, 9});
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1011,14 +1011,14 @@ class dialogWidget : public FDialog
|
|||
auto y = int((getDesktopHeight() - getHeight()) / 2);
|
||||
checkMinValue(x);
|
||||
checkMinValue(y);
|
||||
setPos (FPoint(x, y), false);
|
||||
setPos (FPoint{x, y}, false);
|
||||
}
|
||||
|
||||
void adjustWidgets()
|
||||
{
|
||||
const auto bx = int(getWidth() - button.getWidth() - 3);
|
||||
const auto by = int(getHeight() - 4);
|
||||
button.setPos (FPoint(bx, by), false);
|
||||
button.setPos (FPoint{bx, by}, false);
|
||||
input.setWidth (getWidth() - 4);
|
||||
const auto ly = int(getHeight() / 2) - 1;
|
||||
input.setY (ly, false);
|
||||
|
@ -1046,10 +1046,10 @@ class dialogWidget : public FDialog
|
|||
// Calling super class method draw()
|
||||
FDialog::draw();
|
||||
|
||||
print() << FPoint (3, 3)
|
||||
<< FColorPair (fc::Black, fc::White)
|
||||
print() << FPoint{3, 3}
|
||||
<< FColorPair{fc::Black, fc::White}
|
||||
<< "Text on "
|
||||
<< FColorPair (fc::Blue, fc::Yellow)
|
||||
<< FColorPair{fc::Blue, fc::Yellow}
|
||||
<< "top";
|
||||
}
|
||||
|
||||
|
@ -1129,12 +1129,12 @@ class dialogWidget : public FDialog
|
|||
{
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint(28, 2), FSize(24, 21));
|
||||
scrollview.setGeometry(FPoint(1, 1), FSize(22, 11));
|
||||
scrollview.setScrollSize(FSize(60, 27));
|
||||
setGeometry (FPoint{28, 2}, FSize{24, 21});
|
||||
scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11});
|
||||
scrollview.setScrollSize(FSize{60, 27});
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
scrollview.clearArea();
|
||||
|
@ -1144,25 +1144,25 @@ class dialogWidget : public FDialog
|
|||
|
||||
static std::vector<direction> d
|
||||
{
|
||||
{"NW", FPoint(3, 13), FPoint(1, 1), black},
|
||||
{"N", FPoint(10, 13), FPoint(21, 1), red},
|
||||
{"NE", FPoint(17, 13), FPoint(41, 1), black},
|
||||
{"W", FPoint(3, 15), FPoint(1, 10), black},
|
||||
{"*", FPoint(10, 15), FPoint(21, 10), black},
|
||||
{"E", FPoint(17, 15), FPoint(41, 10), black},
|
||||
{"SW", FPoint(3, 17), FPoint(1, 19), black},
|
||||
{"S", FPoint(10, 17), FPoint(21, 19), cyan},
|
||||
{"SE", FPoint(17, 17), FPoint(41, 19), black}
|
||||
{"NW", FPoint{3, 13}, FPoint{1, 1}, black},
|
||||
{"N", FPoint{10, 13}, FPoint{21, 1}, red},
|
||||
{"NE", FPoint{17, 13}, FPoint{41, 1}, black},
|
||||
{"W", FPoint{3, 15}, FPoint{1, 10}, black},
|
||||
{"*", FPoint{10, 15}, FPoint{21, 10}, black},
|
||||
{"E", FPoint{17, 15}, FPoint{41, 10}, black},
|
||||
{"SW", FPoint{3, 17}, FPoint{1, 19}, black},
|
||||
{"S", FPoint{10, 17}, FPoint{21, 19}, cyan},
|
||||
{"SE", FPoint{17, 17}, FPoint{41, 19}, black}
|
||||
};
|
||||
|
||||
for (auto&& b : d)
|
||||
{
|
||||
scrollview.print() << std::get<2>(b) + FPoint(10, 5)
|
||||
scrollview.print() << std::get<2>(b) + FPoint{10, 5}
|
||||
<< std::get<3>(b) << std::get<0>(b);
|
||||
auto edit = new FLineEdit("direction " + std::get<0>(b), &scrollview);
|
||||
edit->setGeometry(std::get<2>(b) + FPoint(1, 1), FSize(17, 1));
|
||||
edit->setGeometry(std::get<2>(b) + FPoint{1, 1}, FSize{17, 1});
|
||||
auto btn = new FButton(std::get<0>(b), this);
|
||||
btn->setGeometry(std::get<1>(b), FSize(4, 1));
|
||||
btn->setGeometry(std::get<1>(b), FSize{4, 1});
|
||||
btn->unsetShadow();
|
||||
btn->addCallback
|
||||
(
|
||||
|
|
|
@ -74,7 +74,7 @@ class SegmentView final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
|
|
@ -11,6 +11,7 @@ noinst_PROGRAMS = \
|
|||
hello \
|
||||
dialog \
|
||||
input-dialog \
|
||||
event-log \
|
||||
fullwidth-character \
|
||||
7segment \
|
||||
choice \
|
||||
|
@ -39,6 +40,7 @@ noinst_PROGRAMS = \
|
|||
hello_SOURCES = hello.cpp
|
||||
dialog_SOURCES = dialog.cpp
|
||||
input_dialog_SOURCES = input-dialog.cpp
|
||||
event_log_SOURCES = event-log.cpp
|
||||
fullwidth_character_SOURCES = fullwidth-character.cpp
|
||||
7segment_SOURCES = 7segment.cpp
|
||||
choice_SOURCES = choice.cpp
|
||||
|
|
|
@ -92,7 +92,7 @@ class Background final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Background::Background (finalcut::FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
@ -211,7 +211,6 @@ void Background::cb_choice (const finalcut::FWidget*, const FDataPtr)
|
|||
updateTerminal();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -62,7 +62,7 @@ class Button final : public finalcut::FButton
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Button::Button (finalcut::FWidget* parent)
|
||||
: finalcut::FButton(parent)
|
||||
: finalcut::FButton{parent}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -81,10 +81,10 @@ void Button::setChecked (bool enable)
|
|||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setBackgroundColor(wc.button_active_bg);
|
||||
setFocusForegroundColor(wc.button_active_focus_fg);
|
||||
setFocusBackgroundColor(wc.button_active_focus_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setBackgroundColor(wc->button_active_bg);
|
||||
setFocusForegroundColor(wc->button_active_focus_fg);
|
||||
setFocusBackgroundColor(wc->button_active_focus_bg);
|
||||
}
|
||||
|
||||
redraw();
|
||||
|
@ -245,7 +245,7 @@ class Calc final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Calc::Calc (FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
@ -278,7 +278,7 @@ Calc::Calc (FWidget* parent)
|
|||
btn->setDoubleFlatLine(fc::top);
|
||||
btn->setDoubleFlatLine(fc::bottom);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
btn->unsetClickAnimation();
|
||||
|
||||
btn->addCallback
|
||||
|
@ -421,18 +421,18 @@ void Calc::drawDispay()
|
|||
if ( error )
|
||||
display = " Error ";
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FColorPair{fc::Black, fc::LightGray}
|
||||
<< FPoint{3, 3} << display << ' '
|
||||
<< FColorPair{wc.dialog_fg, wc.dialog_bg};
|
||||
<< FColorPair{wc->dialog_fg, wc->dialog_bg};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
{
|
||||
const wchar_t bottom_line {fc::NF_border_line_bottom};
|
||||
const wchar_t top_bottom_line {fc::NF_border_line_up_and_down};
|
||||
|
|
|
@ -73,13 +73,13 @@ class CheckList final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
CheckList::CheckList (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText (L"Shopping list");
|
||||
const std::size_t nf_offset = ( isNewFont() ) ? 1 : 0;
|
||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||
FDialog::setGeometry ( FPoint{int(1 + (parent->getWidth() - 28) / 2), 5}
|
||||
, FSize{28 + nf_offset, 13} );
|
||||
setShadow();
|
||||
|
|
|
@ -0,0 +1,350 @@
|
|||
/***********************************************************************
|
||||
* event-log.cpp - Logs events in a dialog box *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FSize;
|
||||
|
||||
class EventLog; // class forward declaration
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class EventLog::EventLog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class EventDialog final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventDialog (finalcut::FWidget* = nullptr);
|
||||
|
||||
// Disable copy constructor
|
||||
EventDialog (const EventDialog&) = delete;
|
||||
|
||||
// Destructor
|
||||
~EventDialog();
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
EventDialog& operator = (const EventDialog&) = delete;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
finalcut::FString getMouseButtonName (int);
|
||||
void logMouseEvent ( const finalcut::FString&
|
||||
, const finalcut::FMouseEvent& );
|
||||
|
||||
// Event handlers
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
void onMouseMove (finalcut::FMouseEvent*) override;
|
||||
void onMouseUp (finalcut::FMouseEvent*) override;
|
||||
void onMouseDoubleClick (finalcut::FMouseEvent* ev) override;
|
||||
void onWindowActive (finalcut::FEvent*) override;
|
||||
void onWindowInactive (finalcut::FEvent*) override;
|
||||
void onWindowRaised (finalcut::FEvent*) override;
|
||||
void onWindowLowered (finalcut::FEvent*) override;
|
||||
|
||||
// Data members
|
||||
finalcut::FLog& log{*finalcut::FApplication::getLog()};
|
||||
finalcut::FLabel label{this};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventDialog::EventDialog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event dialog");
|
||||
FDialog::setGeometry (FPoint{15, 2}, FSize{53, 12});
|
||||
setShadow();
|
||||
label.setText("\n\nUse the keyboard or mouse\n"
|
||||
"in this dialog to create events");
|
||||
label.setAlignment(finalcut::fc::alignCenter);
|
||||
label.setGeometry (FPoint(1, 1), getClientSize(), false);
|
||||
addTimer(60000); // Starts the timer every minute
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventDialog::~EventDialog() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
finalcut::FString EventDialog::getMouseButtonName (int btn_state)
|
||||
{
|
||||
switch ( btn_state )
|
||||
{
|
||||
case finalcut::fc::LeftButton:
|
||||
return "left";
|
||||
|
||||
case finalcut::fc::RightButton:
|
||||
return "right";
|
||||
|
||||
case finalcut::fc::MiddleButton:
|
||||
return "middle";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::logMouseEvent ( const finalcut::FString& state
|
||||
, const finalcut::FMouseEvent& ev )
|
||||
{
|
||||
const int mouse_x = ev.getX();
|
||||
const int mouse_y = ev.getY();
|
||||
|
||||
log << finalcut::FLog::Info
|
||||
<< getMouseButtonName(ev.getButton())
|
||||
<< " mouse button " << state << " at ("
|
||||
<< mouse_x << ", " << mouse_y << ")" << std::flush;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onClose (finalcut::FCloseEvent* ev)
|
||||
{
|
||||
log.info("The event dialog was closed");
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onShow (finalcut::FShowEvent*)
|
||||
{
|
||||
log.info("The event dialog is now displayed");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onTimer (finalcut::FTimerEvent*)
|
||||
{
|
||||
log.info("-- minute marker --");
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const FKey key_id = ev->key();
|
||||
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
|
||||
|
||||
if ( key_name.isEmpty() )
|
||||
key_name = wchar_t(key_id);
|
||||
|
||||
log << finalcut::FLog::Info
|
||||
<< "Key " << key_name << " (id " << key_id << ")" << std::flush;
|
||||
|
||||
finalcut::FDialog::onKeyPress(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
logMouseEvent("down", *ev);
|
||||
finalcut::FDialog::onMouseDown(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onMouseMove (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
logMouseEvent("move", *ev);
|
||||
finalcut::FDialog::onMouseMove(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onMouseUp (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
logMouseEvent("up", *ev);
|
||||
finalcut::FDialog::onMouseUp(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onMouseDoubleClick (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
logMouseEvent("double click", *ev);
|
||||
finalcut::FDialog::onMouseDoubleClick(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onWindowActive (finalcut::FEvent* ev)
|
||||
{
|
||||
log.info("The Event dialog is now active");
|
||||
finalcut::FDialog::onWindowActive(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onWindowInactive (finalcut::FEvent* ev)
|
||||
{
|
||||
log.info("The Event dialog is now inactive");
|
||||
finalcut::FDialog::onWindowInactive(ev);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onWindowRaised (finalcut::FEvent* ev)
|
||||
{
|
||||
log.info("The dialog was raised");
|
||||
finalcut::FDialog::onWindowRaised(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onWindowLowered (finalcut::FEvent* ev)
|
||||
{
|
||||
log.info("The dialog was lowered");
|
||||
finalcut::FDialog::onWindowLowered(ev);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class EventLog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventLog (finalcut::FWidget* = nullptr);
|
||||
|
||||
// Disable copy constructor
|
||||
EventLog (const EventLog&) = delete;
|
||||
|
||||
// Destructor
|
||||
~EventLog();
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
EventLog& operator = (const EventLog&) = delete;
|
||||
|
||||
// Event handlers
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
finalcut::FTextView scrollText{this};
|
||||
EventDialog* event_dialog{new EventDialog(this)};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventLog::EventLog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event log");
|
||||
FDialog::setGeometry (FPoint{4, 16}, FSize{75, 8});
|
||||
FDialog::setResizeable();
|
||||
setMinimumSize (FSize{75, 5});
|
||||
setShadow();
|
||||
scrollText.ignorePadding();
|
||||
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
event_dialog->setFocus();
|
||||
addTimer(250); // Starts the timer every 250 milliseconds
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventLog::~EventLog() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::onTimer (finalcut::FTimerEvent*)
|
||||
{
|
||||
if ( ! str().empty() )
|
||||
{
|
||||
scrollText.append(str());
|
||||
str("");
|
||||
scrollText.scrollToEnd();
|
||||
redraw();
|
||||
updateTerminal();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::onClose (finalcut::FCloseEvent* ev)
|
||||
{
|
||||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::adjustSize()
|
||||
{
|
||||
finalcut::FDialog::adjustSize();
|
||||
scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
int main (int argc, char* argv[])
|
||||
{
|
||||
finalcut::FApplication app(argc, argv);
|
||||
EventLog dialog(&app);
|
||||
|
||||
// Get the global logger object
|
||||
finalcut::FLog& log = *finalcut::FApplication::getLog();
|
||||
|
||||
// Set the line endings (default = CRLF)
|
||||
log.setLineEnding (finalcut::FLog::LF);
|
||||
|
||||
// Write a timestamp before each output line
|
||||
log.enableTimestamp();
|
||||
|
||||
// Set the dialog object as output stream
|
||||
log.setOutputStream(dialog);
|
||||
|
||||
// ----------------------------------------------
|
||||
// Remove the comment characters in the following
|
||||
// two lines to log the output to a file.
|
||||
// ----------------------------------------------
|
||||
//std::ofstream file_stream("test.log", std::ofstream::out | std::ofstream::app);
|
||||
//log.setOutputStream(file_stream);
|
||||
|
||||
// Sets the dialog as main widget
|
||||
finalcut::FWidget::setMainWidget(&dialog);
|
||||
|
||||
// Show the dialog
|
||||
dialog.show();
|
||||
|
||||
// Run the application
|
||||
return app.exec();
|
||||
}
|
||||
|
|
@ -44,17 +44,17 @@ class Keyboard final : public finalcut::FWidget
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Keyboard::Keyboard (finalcut::FWidget* parent)
|
||||
: finalcut::FWidget(parent)
|
||||
: finalcut::FWidget{parent}
|
||||
{
|
||||
setFWidgetColors().term_fg = finalcut::fc::Default;
|
||||
setFWidgetColors().term_bg = finalcut::fc::Default;
|
||||
getColorTheme()->term_fg = finalcut::fc::Default;
|
||||
getColorTheme()->term_bg = finalcut::fc::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const FKey key_id = ev->key();
|
||||
finalcut::FString key_name = getKeyName(key_id);
|
||||
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
|
||||
bool is_last_line{false};
|
||||
|
||||
if ( key_name.isEmpty() )
|
||||
|
|
|
@ -105,7 +105,7 @@ class Listbox final : public FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Listbox::Listbox (FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
auto temp = std::make_shared<FString>();
|
||||
temp_str = temp;
|
||||
|
|
|
@ -68,7 +68,7 @@ class Listview final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Listview::Listview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listView.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
|
|
|
@ -53,7 +53,7 @@ class Mandelbrot final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Mandelbrot::Mandelbrot (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Mandelbrot set");
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ class Menu final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Menu::Menu (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Menu bar itms
|
||||
File.setStatusbarMessage ("File management commands");
|
||||
|
|
|
@ -72,7 +72,7 @@ class ColorChooser final : public finalcut::FWidget
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 12});
|
||||
setFixedSize (FSize{8, 12});
|
||||
|
@ -226,7 +226,7 @@ class Brushes final : public finalcut::FWidget
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Brushes::Brushes (finalcut::FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 4});
|
||||
setFixedSize (FSize{8, 4});
|
||||
|
@ -379,7 +379,7 @@ class MouseDraw final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
MouseDraw::MouseDraw (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Drawing with the mouse");
|
||||
c_chooser.setPos (FPoint{1, 1});
|
||||
|
@ -447,7 +447,7 @@ void MouseDraw::draw()
|
|||
finalcut::FDialog::draw();
|
||||
setColor();
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
{
|
||||
for (int y{2}; y < y_max; y++)
|
||||
{
|
||||
|
|
|
@ -132,6 +132,40 @@ void move (int xold, int yold, int xnew, int ynew)
|
|||
<< std::right << std::setw(10) << byte << "\r\n";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
class DirectLogger : public finalcut::FLog
|
||||
{
|
||||
public:
|
||||
void info (const std::string& entry) override
|
||||
{
|
||||
output << entry << "\r" << std::endl;
|
||||
}
|
||||
|
||||
void warn (const std::string&) override
|
||||
{ }
|
||||
|
||||
void error (const std::string&) override
|
||||
{ }
|
||||
|
||||
void debug (const std::string&) override
|
||||
{ }
|
||||
|
||||
void setOutputStream (const std::ostream& os) override
|
||||
{ output.rdbuf(os.rdbuf()); }
|
||||
|
||||
void setLineEnding (LineEnding) override
|
||||
{ }
|
||||
|
||||
void enableTimestamp() override
|
||||
{ }
|
||||
|
||||
void disableTimestamp() override
|
||||
{ }
|
||||
|
||||
private:
|
||||
// Data member
|
||||
std::ostream output{std::cerr.rdbuf()};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
@ -157,7 +191,7 @@ int main (int argc, char* argv[])
|
|||
TermApp.clearArea();
|
||||
|
||||
// Show the determined terminal name and text resolution
|
||||
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";
|
||||
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
||||
std::cout << " Columns: 0.." << xmax << "\r\n";
|
||||
std::cout << " Lines: 0.." << ymax << "\r\n";
|
||||
|
||||
|
@ -189,7 +223,11 @@ int main (int argc, char* argv[])
|
|||
keyPressed();
|
||||
|
||||
// Show terminal speed and milliseconds for all cursor movement sequence
|
||||
std::cout << "\r" << line;
|
||||
std::cout << "\r" << line << std::flush;
|
||||
// Generation of a logger in a shared_ptr via a pointer
|
||||
finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
|
||||
// Get the shared_ptr with the base class
|
||||
std::shared_ptr<finalcut::FLog> log = finalcut::FApplication::getLog();
|
||||
const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ class RotoZoomer final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l)
|
||||
: finalcut::FDialog(parent)
|
||||
, benchmark(b)
|
||||
, loops(l)
|
||||
: finalcut::FDialog{parent}
|
||||
, benchmark{b}
|
||||
, loops{l}
|
||||
{
|
||||
FDialog::setText ("Rotozoomer effect");
|
||||
|
||||
|
@ -179,11 +179,11 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
|
|||
//----------------------------------------------------------------------
|
||||
void RotoZoomer::generateReport()
|
||||
{
|
||||
finalcut::FString term_type = getTermType();
|
||||
finalcut::FString term_type = finalcut::FTerm::getTermType();
|
||||
finalcut::FString dimension_str{};
|
||||
finalcut::FString time_str{};
|
||||
finalcut::FString fps_str{};
|
||||
std::wostringstream rep;
|
||||
finalcut::FStringStream rep;
|
||||
dimension_str << getDesktopWidth()
|
||||
<< "x" << getDesktopHeight();
|
||||
int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
|
||||
|
|
|
@ -72,7 +72,7 @@ class Scrollview final : public finalcut::FScrollView
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Scrollview::Scrollview (finalcut::FWidget* parent)
|
||||
: finalcut::FScrollView(parent)
|
||||
: finalcut::FScrollView{parent}
|
||||
{
|
||||
// Sets the navigation button geometry
|
||||
go_east.setGeometry (FPoint{1, 1}, FSize{5, 1});
|
||||
|
@ -128,11 +128,11 @@ void Scrollview::setScrollSize (const FSize& size)
|
|||
//----------------------------------------------------------------------
|
||||
void Scrollview::draw()
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_inactive_fg, wc.dialog_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->label_inactive_fg, wc->dialog_bg);
|
||||
clearArea();
|
||||
|
||||
for (int y{0}; y < int(getScrollHeight()); y++)
|
||||
|
@ -143,7 +143,7 @@ void Scrollview::draw()
|
|||
print (32 + ((x + y) % 0x5f));
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
FScrollView::draw();
|
||||
|
@ -214,7 +214,7 @@ class Scrollviewdemo final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19});
|
||||
FDialog::setText ("Scrolling viewport example");
|
||||
|
|
|
@ -224,17 +224,17 @@ void streamToInterger()
|
|||
finalcut::FString("-321") >> stream_int;
|
||||
std::cout << "stream out: " << stream_int << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,17 +248,17 @@ void streamToUnsignedInterger()
|
|||
finalcut::FString("123") >> stream_uint;
|
||||
std::cout << "stream out: " << stream_uint << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,17 +272,17 @@ void streamToDouble()
|
|||
finalcut::FString("0.123456e+2") >> stream_double;
|
||||
std::cout << "stream out: " << stream_double << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -296,17 +296,17 @@ void streamToFloat()
|
|||
finalcut::FString("0.123e-3") >> stream_float;
|
||||
std::cout << "stream out: " << stream_float << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,17 +496,17 @@ void convertToNumberExample()
|
|||
const uLong ulong_num = finalcut::FString("123456789").toULong();
|
||||
std::cout << " toULong: " << ulong_num << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
|
||||
// Test: convert a string to a signed long interger
|
||||
|
@ -515,17 +515,17 @@ void convertToNumberExample()
|
|||
const long long_num = finalcut::FString("-9876543210").toLong();
|
||||
std::cout << " toLong: " << long_num << std::endl;
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
|
||||
// Test: convert a string to a double value
|
||||
|
@ -540,17 +540,17 @@ void convertToNumberExample()
|
|||
<< double_num << std::endl;
|
||||
std::cout.flags(save_flags);
|
||||
}
|
||||
catch (const std::underflow_error& ex)
|
||||
catch (const std::underflow_error&)
|
||||
{
|
||||
std::cerr << "underflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Underflow");
|
||||
}
|
||||
catch (const std::overflow_error& ex)
|
||||
catch (const std::overflow_error&)
|
||||
{
|
||||
std::cerr << "overflow: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Overflow");
|
||||
}
|
||||
catch (const std::invalid_argument& ex)
|
||||
catch (const std::invalid_argument&)
|
||||
{
|
||||
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Arithmetic error");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,9 +640,9 @@ void insertExample()
|
|||
std::cout << " insert: "
|
||||
<< insert_str.insert("changed ", 7) << std::endl;
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Out of Range");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,14 +655,14 @@ void indexExample()
|
|||
|
||||
try
|
||||
{
|
||||
index[0] = L'I'; // write a wide character at position 0
|
||||
index[0] = L'I'; // Write a wide character at position 0
|
||||
printf ( " index: [0] = %c ; [4] = %c\n"
|
||||
, char(index[0])
|
||||
, char(index[4]) );
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
finalcut::FApplication::getLog()->error("Out of Range");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,17 +66,17 @@ class AttribDlg final : public finalcut::FDialog
|
|||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
FColor bgcolor{getFWidgetColors().label_bg};
|
||||
FColor bgcolor{getColorTheme()->label_bg};
|
||||
finalcut::FButton next_button{"&Next >", this};
|
||||
finalcut::FButton back_button{"< &Back", this};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ( "A terminal attributes test ("
|
||||
+ finalcut::FString{getTermType()}
|
||||
+ finalcut::FString{finalcut::FTerm::getTermType()}
|
||||
+ ")");
|
||||
|
||||
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
||||
|
@ -145,10 +145,10 @@ void AttribDlg::onClose (finalcut::FCloseEvent* ev)
|
|||
//----------------------------------------------------------------------
|
||||
void AttribDlg::cb_next (const finalcut::FWidget*, const FDataPtr)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
return;
|
||||
|
||||
if ( bgcolor == FColor(getMaxColor() - 1) )
|
||||
if ( bgcolor == FColor(finalcut::FTerm::getMaxColor() - 1) )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = 0;
|
||||
|
@ -161,13 +161,13 @@ void AttribDlg::cb_next (const finalcut::FWidget*, const FDataPtr)
|
|||
//----------------------------------------------------------------------
|
||||
void AttribDlg::cb_back (const finalcut::FWidget*, const FDataPtr)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
return;
|
||||
|
||||
if ( bgcolor == 0 )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = FColor(getMaxColor() - 1);
|
||||
bgcolor = FColor(finalcut::FTerm::getMaxColor() - 1);
|
||||
else
|
||||
bgcolor--;
|
||||
|
||||
|
@ -238,14 +238,14 @@ class AttribDemo final : public finalcut::FWidget
|
|||
void draw() override;
|
||||
|
||||
// Data member
|
||||
FColor last_color{FColor(getMaxColor())};
|
||||
FColor last_color{FColor(finalcut::FTerm::getMaxColor())};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
AttribDemo::AttribDemo (finalcut::FWidget* parent)
|
||||
: finalcut::FWidget(parent)
|
||||
: finalcut::FWidget{parent}
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
last_color = 1;
|
||||
else if ( last_color > 16 )
|
||||
last_color = 16;
|
||||
|
@ -267,11 +267,11 @@ void AttribDemo::printColorLine()
|
|||
//----------------------------------------------------------------------
|
||||
void AttribDemo::printAltCharset()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
const auto& parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
if ( ! isMonochron() )
|
||||
setColor (wc.label_fg, wc.label_bg);
|
||||
if ( ! finalcut::FTerm::isMonochron() )
|
||||
setColor (wc->label_fg, wc->label_bg);
|
||||
|
||||
print() << FPoint{1, 1} << "alternate charset: ";
|
||||
|
||||
|
@ -418,7 +418,7 @@ void AttribDemo::printProtected()
|
|||
void AttribDemo::draw()
|
||||
{
|
||||
// test alternate character set
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
printAltCharset();
|
||||
|
||||
const std::vector<std::function<void()> > effect
|
||||
|
@ -441,15 +441,15 @@ void AttribDemo::draw()
|
|||
{
|
||||
print() << FPoint{1, 2 + int(y)};
|
||||
|
||||
if ( ! isMonochron() )
|
||||
setColor (wc.label_fg, wc.label_bg);
|
||||
if ( ! finalcut::FTerm::isMonochron() )
|
||||
setColor (wc->label_fg, wc->label_bg);
|
||||
|
||||
if ( y < effect.size() )
|
||||
effect[y]();
|
||||
}
|
||||
|
||||
if ( ! isMonochron() )
|
||||
setColor(wc.label_fg, wc.label_bg);
|
||||
if ( ! finalcut::FTerm::isMonochron() )
|
||||
setColor(wc->label_fg, wc->label_bg);
|
||||
|
||||
print() << FPoint{1, 15};
|
||||
const FColor bg = static_cast<AttribDlg*>(getParent())->getBGColor();
|
||||
|
|
|
@ -300,7 +300,7 @@ int main (int argc, char* argv[])
|
|||
finalcut::FApplication TermApp {argc, argv, disable_alt_screen};
|
||||
|
||||
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
|
||||
std::cout << "Terminal: " << TermApp.getTermType() << "\r\n";
|
||||
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
|
||||
|
||||
debug (TermApp);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class Timer final : public finalcut::FWidget
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Timer::Timer (finalcut::FWidget* parent)
|
||||
: finalcut::FWidget(parent)
|
||||
: finalcut::FWidget{parent}
|
||||
{
|
||||
addTimer (60000); // 1-minute timer
|
||||
const int id = addTimer (50); // 50-millisecond timer
|
||||
|
@ -54,8 +54,8 @@ Timer::Timer (finalcut::FWidget* parent)
|
|||
delTimer (id);
|
||||
addTimer (250); // 250-millisecond timer
|
||||
|
||||
setFWidgetColors().term_fg = fc::Default;
|
||||
setFWidgetColors().term_bg = fc::Default;
|
||||
getColorTheme()->term_fg = fc::Default;
|
||||
getColorTheme()->term_bg = fc::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -71,8 +71,8 @@ class Transparent final : public finalcut::FDialog
|
|||
//----------------------------------------------------------------------
|
||||
Transparent::Transparent ( finalcut::FWidget* parent
|
||||
, Transparent::trans_type tt )
|
||||
: finalcut::FDialog(parent)
|
||||
, type(tt)
|
||||
: finalcut::FDialog{parent}
|
||||
, type{tt}
|
||||
{
|
||||
// Set statusbar text for this window
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
@ -89,18 +89,18 @@ void Transparent::draw()
|
|||
{
|
||||
finalcut::FDialog::draw();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( type == shadow )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
print() << FColorPair {wc.shadow_bg, wc.shadow_fg}
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FColorPair {wc->shadow_bg, wc->shadow_fg}
|
||||
<< FStyle {fc::ColorOverlay};
|
||||
}
|
||||
else if ( type == inherit_background )
|
||||
{
|
||||
if ( getMaxColor() > 8 )
|
||||
if ( finalcut::FTerm::getMaxColor() > 8 )
|
||||
print() << FColorPair {fc::Blue, fc::Black};
|
||||
else
|
||||
print() << FColorPair {fc::Green, fc::Black};
|
||||
|
@ -191,7 +191,7 @@ class MainWindow final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
MainWindow::MainWindow (finalcut::FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// The memory allocation for the following three sub windows occurs
|
||||
// with the operator new. The lifetime of the generated widget
|
||||
|
@ -228,14 +228,14 @@ void MainWindow::draw()
|
|||
{
|
||||
finalcut::FDialog::draw();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor();
|
||||
print() << FPoint{2, 4} << line1;
|
||||
print() << FPoint{2, 5} << line2;
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
updateTerminal();
|
||||
|
|
|
@ -326,7 +326,7 @@ Treeview::TreeItem Treeview::oceania[] =
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
Treeview::Treeview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listView.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||
|
|
|
@ -76,7 +76,7 @@ class ProgressDialog final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
@ -218,7 +218,7 @@ class TextWindow final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
TextWindow::TextWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
scrollText.ignorePadding();
|
||||
scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
|
@ -301,6 +301,7 @@ class MyDialog final : public finalcut::FDialog
|
|||
void cb_copyClipboard (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_pasteClipboard (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_clearInput (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_switchTheme (const finalcut::FWidget*, const FDataPtr);
|
||||
void cb_input2buttonText (finalcut::FWidget*, FDataPtr);
|
||||
void cb_setTitlebar (finalcut::FWidget*, const FDataPtr);
|
||||
void cb_showProgressBar (const finalcut::FWidget*, const FDataPtr);
|
||||
|
@ -339,6 +340,8 @@ class MyDialog final : public finalcut::FDialog
|
|||
// "View" menu items
|
||||
finalcut::FMenuItem Env{"&Terminal...", &View};
|
||||
finalcut::FMenuItem Drive{"&Drive symbols...", &View};
|
||||
finalcut::FMenuItem Line3{&View};
|
||||
finalcut::FCheckMenuItem Theme{"Dark &mode", &View};
|
||||
// Statusbar
|
||||
finalcut::FStatusBar Statusbar{this};
|
||||
finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar};
|
||||
|
@ -369,7 +372,7 @@ class MyDialog final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
MyDialog::MyDialog (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -422,6 +425,10 @@ void MyDialog::initMenu()
|
|||
// "View" menu items
|
||||
Env.setStatusbarMessage ("Informations about this terminal");
|
||||
Drive.setStatusbarMessage ("Show drive symbols");
|
||||
Line3.setSeparator();
|
||||
|
||||
if ( finalcut::FStartOptions::getFStartOptions().dark_theme )
|
||||
Theme.setChecked();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -517,6 +524,12 @@ void MyDialog::initViewMenuCallbacks()
|
|||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &MyDialog::cb_drives)
|
||||
);
|
||||
|
||||
Theme.addCallback
|
||||
(
|
||||
"clicked",
|
||||
F_METHOD_CALLBACK (this, &MyDialog::cb_switchTheme)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -810,12 +823,12 @@ void MyDialog::cb_terminfo (const finalcut::FWidget*, const FDataPtr)
|
|||
(
|
||||
"Environment"
|
||||
, finalcut::FString{}
|
||||
<< " Type: " << getTermType() << "\n"
|
||||
<< " Name: " << getTermFileName() << "\n"
|
||||
<< " Mode: " << getEncodingString() << "\n"
|
||||
<< " Type: " << finalcut::FTerm::getTermType() << "\n"
|
||||
<< " Name: " << finalcut::FTerm::getTermFileName() << "\n"
|
||||
<< " Mode: " << finalcut::FTerm::getEncodingString() << "\n"
|
||||
<< " Size: " << x << fc::Times
|
||||
<< y << "\n"
|
||||
<< "Colors: " << getMaxColor()
|
||||
<< "Colors: " << finalcut::FTerm::getMaxColor()
|
||||
, finalcut::FMessageBox::Ok, 0, 0, this
|
||||
);
|
||||
info1.setHeadline("Terminal:");
|
||||
|
@ -834,7 +847,7 @@ void MyDialog::cb_drives (const finalcut::FWidget*, const FDataPtr)
|
|||
, finalcut::FMessageBox::Ok, 0, 0, this
|
||||
);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
{
|
||||
finalcut::FLabel drive {finalcut::NF_Drive, &info2};
|
||||
drive.setGeometry (FPoint{11, 2}, FSize{4, 1});
|
||||
|
@ -853,7 +866,7 @@ void MyDialog::cb_drives (const finalcut::FWidget*, const FDataPtr)
|
|||
finalcut::FLabel cd {" CD ", &info2};
|
||||
cd.setGeometry (FPoint{11, 6}, FSize{4, 1});
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
{
|
||||
net.setReverseMode();
|
||||
drive.setReverseMode();
|
||||
|
@ -902,6 +915,21 @@ void MyDialog::cb_clearInput (const finalcut::FWidget*, const FDataPtr)
|
|||
myLineEdit.redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_switchTheme (const finalcut::FWidget* widget, const FDataPtr)
|
||||
{
|
||||
const auto& check_menu = *(static_cast<const finalcut::FCheckMenuItem*>(widget));
|
||||
|
||||
if ( check_menu.isChecked() )
|
||||
finalcut::FApplication::setDarkTheme();
|
||||
else
|
||||
finalcut::FApplication::setDefaultTheme();
|
||||
|
||||
auto root_widget = getRootWidget();
|
||||
root_widget->resetColors();
|
||||
root_widget->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_input2buttonText (finalcut::FWidget* widget, FDataPtr data)
|
||||
{
|
||||
|
@ -917,7 +945,7 @@ void MyDialog::cb_setTitlebar (finalcut::FWidget* widget, const FDataPtr)
|
|||
auto& lineedit = *(static_cast<finalcut::FLineEdit*>(widget));
|
||||
finalcut::FString title{};
|
||||
lineedit >> title;
|
||||
setTermTitle (title);
|
||||
finalcut::FTerm::setTermTitle (title);
|
||||
setText (title);
|
||||
redraw();
|
||||
}
|
||||
|
@ -981,7 +1009,7 @@ void MyDialog::cb_view (const finalcut::FWidget*, FDataPtr data)
|
|||
int(getRootWidget()->getHeight() / 6) }
|
||||
, FSize{60, getRootWidget()->getHeight() * 3 / 4} );
|
||||
view->setResizeable();
|
||||
std::string line = "";
|
||||
std::string line{""};
|
||||
std::ifstream infile;
|
||||
infile.open(file);
|
||||
|
||||
|
@ -1021,17 +1049,17 @@ int main (int argc, char* argv[])
|
|||
// Create the application object app
|
||||
finalcut::FApplication app{argc, argv};
|
||||
app.setNonBlockingRead();
|
||||
app.redefineDefaultColors(true);
|
||||
app.setTermTitle (title);
|
||||
finalcut::FTerm::redefineDefaultColors(true);
|
||||
finalcut::FTerm::setTermTitle (title);
|
||||
|
||||
// Force vt100 encoding
|
||||
//app.setEncoding(finalcut::fc::VT100);
|
||||
//finalcut::FTerm::setEncoding(finalcut::fc::VT100);
|
||||
|
||||
// Sets the terminal size to 94×30
|
||||
//app.setTermSize(94,30);
|
||||
//finalcut::FTerm::setTermSize(FSize{94, 30});
|
||||
|
||||
// Enable the final cut graphical font
|
||||
//app.setNewFont();
|
||||
//finalcut::FTerm::setNewFont();
|
||||
|
||||
// Create main dialog object d
|
||||
MyDialog d{&app};
|
||||
|
|
|
@ -73,7 +73,7 @@ class Watch final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Watch::Watch (FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
|
|
|
@ -66,32 +66,32 @@ class SmallWindow final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
const wchar_t arrow_up = fc::BlackUpPointingTriangle;
|
||||
const wchar_t arrow_down = fc::BlackDownPointingTriangle;
|
||||
|
||||
left_arrow = arrow_up;
|
||||
left_arrow.setForegroundColor (wc.label_inactive_fg);
|
||||
left_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
left_arrow.setEmphasis();
|
||||
left_arrow.ignorePadding();
|
||||
left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1});
|
||||
|
||||
right_arrow = arrow_up;
|
||||
right_arrow.setForegroundColor (wc.label_inactive_fg);
|
||||
right_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
right_arrow.setEmphasis();
|
||||
right_arrow.ignorePadding();
|
||||
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
|
||||
|
||||
top_left_label = "menu";
|
||||
top_left_label.setForegroundColor (wc.label_inactive_fg);
|
||||
top_left_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_left_label.setEmphasis();
|
||||
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
|
||||
|
||||
top_right_label = "zoom";
|
||||
top_right_label.setAlignment (fc::alignRight);
|
||||
top_right_label.setForegroundColor (wc.label_inactive_fg);
|
||||
top_right_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_right_label.setEmphasis();
|
||||
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
|
||||
|
||||
|
@ -100,7 +100,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
|||
bottom_label_text += arrow_down;
|
||||
bottom_label = bottom_label_text;
|
||||
bottom_label.setAlignment (fc::alignRight);
|
||||
bottom_label.setForegroundColor (wc.label_inactive_fg);
|
||||
bottom_label.setForegroundColor (wc->label_inactive_fg);
|
||||
bottom_label.setEmphasis();
|
||||
bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3});
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ class Window final : public finalcut::FDialog
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
Window::Window (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog(parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Menu bar item
|
||||
File.setStatusbarMessage ("File management commands");
|
||||
|
|
|
@ -10,6 +10,7 @@ lib_LTLIBRARIES = libfinal.la
|
|||
|
||||
libfinal_la_SOURCES = \
|
||||
fstring.cpp \
|
||||
fstringstream.cpp \
|
||||
fpoint.cpp \
|
||||
fsize.cpp \
|
||||
frect.cpp \
|
||||
|
@ -25,6 +26,8 @@ libfinal_la_SOURCES = \
|
|||
flabel.cpp \
|
||||
flistbox.cpp \
|
||||
flistview.cpp \
|
||||
flog.cpp \
|
||||
flogger.cpp \
|
||||
fmenu.cpp \
|
||||
fmouse.cpp \
|
||||
fsystem.cpp \
|
||||
|
@ -67,6 +70,7 @@ libfinal_la_SOURCES = \
|
|||
foptimove.cpp \
|
||||
ftermbuffer.cpp \
|
||||
fapplication.cpp \
|
||||
fcolorpalette.cpp \
|
||||
fwidgetcolors.cpp \
|
||||
fwidget.cpp \
|
||||
fwidget_functions.cpp \
|
||||
|
@ -98,6 +102,8 @@ finalcutinclude_HEADERS = \
|
|||
include/final/flineedit.h \
|
||||
include/final/flistbox.h \
|
||||
include/final/flistview.h \
|
||||
include/final/flog.h \
|
||||
include/final/flogger.h \
|
||||
include/final/fmenu.h \
|
||||
include/final/fmouse.h \
|
||||
include/final/fkeyboard.h \
|
||||
|
@ -126,6 +132,7 @@ finalcutinclude_HEADERS = \
|
|||
include/final/fstartoptions.h \
|
||||
include/final/fstatusbar.h \
|
||||
include/final/fstring.h \
|
||||
include/final/fstringstream.h \
|
||||
include/final/fsystem.h \
|
||||
include/final/fsystemimpl.h \
|
||||
include/final/ftermcap.h \
|
||||
|
|
|
@ -25,6 +25,8 @@ INCLUDE_HEADERS = \
|
|||
flineedit.h \
|
||||
flistbox.h \
|
||||
flistview.h \
|
||||
flog.h \
|
||||
flogger.h \
|
||||
fmenu.h \
|
||||
fdialoglistmenu.h \
|
||||
fmenubar.h \
|
||||
|
@ -49,6 +51,7 @@ INCLUDE_HEADERS = \
|
|||
fcombobox.h \
|
||||
fstatusbar.h \
|
||||
fstring.h \
|
||||
fstringstream.h \
|
||||
fmouse.h \
|
||||
fkeyboard.h \
|
||||
fstartoptions.h \
|
||||
|
@ -83,6 +86,7 @@ RM = rm -f
|
|||
LIB = libfinal.so
|
||||
OBJS = \
|
||||
fstring.o \
|
||||
fstringstream.o \
|
||||
fpoint.o \
|
||||
fsize.o \
|
||||
frect.o \
|
||||
|
@ -98,6 +102,8 @@ OBJS = \
|
|||
flabel.o \
|
||||
flistbox.o \
|
||||
flistview.o \
|
||||
flog.o \
|
||||
flogger.o \
|
||||
fmenu.o \
|
||||
fdialoglistmenu.o \
|
||||
fmenubar.o \
|
||||
|
@ -139,6 +145,7 @@ OBJS = \
|
|||
foptimove.o \
|
||||
ftermbuffer.o \
|
||||
fapplication.o \
|
||||
fcolorpalette.o \
|
||||
fwidgetcolors.o \
|
||||
fwidget.o \
|
||||
fwidget_functions.o \
|
||||
|
|
|
@ -25,6 +25,8 @@ INCLUDE_HEADERS = \
|
|||
flineedit.h \
|
||||
flistbox.h \
|
||||
flistview.h \
|
||||
flog.h \
|
||||
flogger.h \
|
||||
fmenu.h \
|
||||
fdialoglistmenu.h \
|
||||
fmenubar.h \
|
||||
|
@ -49,6 +51,7 @@ INCLUDE_HEADERS = \
|
|||
fcombobox.h \
|
||||
fstatusbar.h \
|
||||
fstring.h \
|
||||
fstringstream.h \
|
||||
fmouse.h \
|
||||
fkeyboard.h \
|
||||
fstartoptions.h \
|
||||
|
@ -83,6 +86,7 @@ RM = rm -f
|
|||
LIB = libfinal.so
|
||||
OBJS = \
|
||||
fstring.o \
|
||||
fstringstream.o \
|
||||
fpoint.o \
|
||||
fsize.o \
|
||||
frect.o \
|
||||
|
@ -98,6 +102,8 @@ OBJS = \
|
|||
flabel.o \
|
||||
flistbox.o \
|
||||
flistview.o \
|
||||
flog.o \
|
||||
flogger.o \
|
||||
fmenu.o \
|
||||
fdialoglistmenu.o \
|
||||
fmenubar.o \
|
||||
|
@ -139,6 +145,7 @@ OBJS = \
|
|||
foptimove.o \
|
||||
ftermbuffer.o \
|
||||
fapplication.o \
|
||||
fcolorpalette.o \
|
||||
fwidgetcolors.o \
|
||||
fwidget.o \
|
||||
fwidget_functions.o \
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/flogger.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmessagebox.h"
|
||||
|
@ -69,7 +71,7 @@ bool FApplication::quit_now {false};
|
|||
FApplication::FApplication ( const int& _argc
|
||||
, char* _argv[]
|
||||
, bool disable_alt_screen )
|
||||
: FWidget(processParameters(_argc, _argv), disable_alt_screen)
|
||||
: FWidget{processParameters(_argc, _argv), disable_alt_screen}
|
||||
, app_argc{_argc}
|
||||
, app_argv{_argv}
|
||||
{
|
||||
|
@ -98,6 +100,11 @@ FApplication::FApplication ( const int& _argc
|
|||
FApplication::~FApplication() // destructor
|
||||
{
|
||||
app_object = nullptr;
|
||||
|
||||
if ( eventInQueue() )
|
||||
event_queue.clear();
|
||||
|
||||
destroyLog();
|
||||
}
|
||||
|
||||
|
||||
|
@ -108,6 +115,24 @@ FApplication* FApplication::getApplicationObject()
|
|||
return app_object;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FApplication::FLogPtr& FApplication::getLog()
|
||||
{
|
||||
// Global logger object
|
||||
static FLogPtr* logger = new FLogPtr();
|
||||
|
||||
if ( logger && logger->get() == nullptr )
|
||||
*logger = std::make_shared<FLogger>();
|
||||
|
||||
return *logger;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setLog (const FLogPtr& logger)
|
||||
{
|
||||
getLog() = logger;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::isQuit()
|
||||
{
|
||||
|
@ -167,25 +192,27 @@ void FApplication::quit()
|
|||
//----------------------------------------------------------------------
|
||||
bool FApplication::sendEvent (FObject* receiver, FEvent* event )
|
||||
{
|
||||
if ( quit_now || app_exit_loop || ! receiver )
|
||||
if ( quit_now || app_exit_loop || ! (bool(receiver) && bool(event)) )
|
||||
return false;
|
||||
|
||||
if ( ! isEventProcessable (receiver, event) )
|
||||
return false;
|
||||
|
||||
// Sends the event event directly to receiver
|
||||
return receiver->event(event);
|
||||
bool ret = receiver->event(event);
|
||||
event->send = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::queueEvent (FObject* receiver, FEvent* event)
|
||||
{
|
||||
if ( ! receiver )
|
||||
if ( ! (bool(receiver) && bool(event)) )
|
||||
return;
|
||||
|
||||
// queue this event
|
||||
eventPair send_event (receiver, std::make_shared<FEvent>(*event));
|
||||
event_queue.push_back(send_event);
|
||||
event->queued = true;
|
||||
event_queue.emplace_back (receiver, event);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -193,8 +220,9 @@ void FApplication::sendQueuedEvents()
|
|||
{
|
||||
while ( eventInQueue() )
|
||||
{
|
||||
sendEvent( event_queue.front().first,
|
||||
event_queue.front().second.get() );
|
||||
const EventPair& event_pair = event_queue.front();
|
||||
event_pair.second->queued = false;
|
||||
sendEvent(event_pair.first, event_pair.second);
|
||||
event_queue.pop_front();
|
||||
}
|
||||
}
|
||||
|
@ -234,6 +262,12 @@ bool FApplication::removeQueuedEvent (const FObject* receiver)
|
|||
return retval;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::processExternalUserEvent()
|
||||
{
|
||||
// This method can be overloaded and replaced by own code
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||
{
|
||||
|
@ -248,6 +282,37 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setDefaultTheme()
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default8ColorPalette>(&FTerm::setPalette);
|
||||
|
||||
setColorTheme<default8ColorTheme>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default16ColorPalette>(&FTerm::setPalette);
|
||||
|
||||
setColorTheme<default16ColorTheme>();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::setDarkTheme()
|
||||
{
|
||||
if ( getStartOptions().color_change )
|
||||
FTerm::setColorPaletteTheme<default16DarkColorPalette>(&FTerm::setPalette);
|
||||
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorDarkTheme>();
|
||||
else
|
||||
setColorTheme<default16ColorDarkTheme>();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::showParameterUsage()
|
||||
{
|
||||
|
@ -277,6 +342,8 @@ void FApplication::showParameterUsage()
|
|||
<< " Set the standard vga 8x16 font\n"
|
||||
<< " --newfont "
|
||||
<< " Enables the graphical font\n"
|
||||
<< " --dark-theme "
|
||||
<< " Enables the dark theme\n"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
<< "\n"
|
||||
|
@ -322,7 +389,7 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
|||
void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
||||
{
|
||||
// Initialize keyboard
|
||||
keyboard = FVTerm::getFKeyboard();
|
||||
keyboard = FTerm::getFKeyboard();
|
||||
|
||||
// Set the keyboard keypress timeout
|
||||
if ( keyboard )
|
||||
|
@ -340,7 +407,7 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
|||
}
|
||||
|
||||
// Initialize mouse control
|
||||
mouse = FVTerm::getFMouseControl();
|
||||
mouse = FTerm::getFMouseControl();
|
||||
|
||||
// Set stdin number for a gpm-mouse
|
||||
if ( mouse )
|
||||
|
@ -349,6 +416,9 @@ void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
|
|||
// Set the default double click interval
|
||||
if ( mouse )
|
||||
mouse->setDblclickInterval (dblclick_time);
|
||||
|
||||
// Initialize logging
|
||||
getLog()->setLineEnding(FLog::CRLF);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -369,6 +439,7 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
|||
{"no-sgr-optimizer", no_argument, nullptr, 0 },
|
||||
{"vgafont", no_argument, nullptr, 0 },
|
||||
{"newfont", no_argument, nullptr, 0 },
|
||||
{"dark-theme", no_argument, nullptr, 0 },
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
{"no-esc-for-alt-meta", no_argument, nullptr, 0 },
|
||||
|
@ -405,8 +476,8 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
|||
else if ( encoding.includes("help") )
|
||||
showParameterUsage();
|
||||
else
|
||||
exitWithMessage ( "Unknown encoding "
|
||||
+ std::string(encoding.c_str()) );
|
||||
FTerm::exitWithMessage ( "Unknown encoding "
|
||||
+ std::string(encoding.c_str()) );
|
||||
}
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
|
||||
|
@ -433,6 +504,9 @@ void FApplication::cmd_options (const int& argc, char* argv[])
|
|||
if ( std::strcmp(long_options[idx].name, "newfont") == 0 )
|
||||
getStartOptions().newfont = true;
|
||||
|
||||
if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 )
|
||||
getStartOptions().dark_theme = true;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 )
|
||||
getStartOptions().meta_sends_escape = false;
|
||||
|
@ -453,6 +527,13 @@ inline FStartOptions& FApplication::getStartOptions()
|
|||
return FStartOptions::getFStartOptions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::destroyLog()
|
||||
{
|
||||
const FLogPtr* logger = &(getLog());
|
||||
delete logger;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::findKeyboardWidget()
|
||||
{
|
||||
|
@ -985,7 +1066,7 @@ void FApplication::sendMouseMiddleClickEvent ( const FPoint& widgetMousePos
|
|||
sendEvent (clicked, &m_down_ev);
|
||||
|
||||
// gnome-terminal sends no released on middle click
|
||||
if ( isGnomeTerminal() )
|
||||
if ( FTerm::isGnomeTerminal() )
|
||||
setClickedWidget(nullptr);
|
||||
}
|
||||
else if ( mouse->isMiddleButtonReleased() )
|
||||
|
@ -1057,7 +1138,7 @@ void FApplication::processMouseEvent()
|
|||
//----------------------------------------------------------------------
|
||||
void FApplication::processResizeEvent()
|
||||
{
|
||||
if ( ! hasChangedTermSize() )
|
||||
if ( ! FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
if ( mouse )
|
||||
|
@ -1070,7 +1151,7 @@ void FApplication::processResizeEvent()
|
|||
sendEvent(app_object, &r_ev);
|
||||
|
||||
if ( r_ev.isAccepted() )
|
||||
changeTermSizeFinished();
|
||||
FTerm::changeTermSizeFinished();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1094,6 +1175,17 @@ void FApplication::processCloseWidget()
|
|||
setTerminalUpdates (FVTerm::start_terminal_updates);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::processLogger()
|
||||
{
|
||||
// Synchronizing the stream buffer with the logging output
|
||||
|
||||
auto logger = getLog();
|
||||
|
||||
if ( ! logger->str().empty() )
|
||||
logger->pubsync();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processNextEvent()
|
||||
{
|
||||
|
@ -1104,6 +1196,8 @@ bool FApplication::processNextEvent()
|
|||
processResizeEvent();
|
||||
processTerminalUpdate();
|
||||
processCloseWidget();
|
||||
processLogger();
|
||||
processExternalUserEvent();
|
||||
|
||||
sendQueuedEvents();
|
||||
num_events += processTimerEvent();
|
||||
|
@ -1118,7 +1212,8 @@ void FApplication::performTimerAction (FObject* receiver, FEvent* event)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::isEventProcessable (const FObject* receiver, const FEvent* event )
|
||||
bool FApplication::isEventProcessable ( const FObject* receiver
|
||||
, const FEvent* event )
|
||||
{
|
||||
if ( ! receiver->isWidget() ) // No restrictions for non-widgets
|
||||
return true;
|
||||
|
@ -1139,7 +1234,7 @@ bool FApplication::isEventProcessable (const FObject* receiver, const FEvent* ev
|
|||
&& ! window->getFlags().modal
|
||||
&& ! window->isMenuWidget() )
|
||||
{
|
||||
switch ( uInt(event->type()) )
|
||||
switch ( uInt(event->getType()) )
|
||||
{
|
||||
case fc::KeyPress_Event:
|
||||
case fc::KeyUp_Event:
|
||||
|
@ -1163,8 +1258,8 @@ bool FApplication::isEventProcessable (const FObject* receiver, const FEvent* ev
|
|||
}
|
||||
|
||||
// Throw away mouse events for disabled widgets
|
||||
if ( event->type() >= fc::MouseDown_Event
|
||||
&& event->type() <= fc::MouseMove_Event
|
||||
if ( event->getType() >= fc::MouseDown_Event
|
||||
&& event->getType() <= fc::MouseMove_Event
|
||||
&& ! widget->isEnabled() )
|
||||
return false;
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FButton::FButton(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FButton::FButton (const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
{
|
||||
init();
|
||||
|
@ -127,6 +127,20 @@ void FButton::setInactiveBackgroundColor (FColor color)
|
|||
updateButtonColor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->button_active_fg);
|
||||
setBackgroundColor (wc->button_active_bg);
|
||||
setHotkeyForegroundColor (wc->button_hotkey_fg);
|
||||
setFocusForegroundColor (wc->button_active_focus_fg);
|
||||
setFocusBackgroundColor (wc->button_active_focus_bg);
|
||||
setInactiveForegroundColor (wc->button_inactive_fg);
|
||||
setInactiveBackgroundColor (wc->button_inactive_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FButton::setNoUnderline (bool enable)
|
||||
{
|
||||
|
@ -165,8 +179,8 @@ bool FButton::setFlat (bool enable)
|
|||
bool FButton::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
|
@ -218,9 +232,9 @@ void FButton::hide()
|
|||
}
|
||||
else
|
||||
{
|
||||
auto wc = getFWidgetColors();
|
||||
fg = wc.dialog_fg;
|
||||
bg = wc.dialog_bg;
|
||||
const auto& wc = getColorTheme();
|
||||
fg = wc->dialog_fg;
|
||||
bg = wc->dialog_bg;
|
||||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
|
@ -387,9 +401,9 @@ void FButton::onFocusOut (FFocusEvent*)
|
|||
//----------------------------------------------------------------------
|
||||
void FButton::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.button_active_fg);
|
||||
setBackgroundColor (wc.button_active_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->button_active_fg);
|
||||
setBackgroundColor (wc->button_active_bg);
|
||||
setShadow();
|
||||
|
||||
if ( ! text.isEmpty() )
|
||||
|
@ -439,7 +453,7 @@ inline std::size_t FButton::clickAnimationIndent (const FWidget* parent_widget)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FButton::clearRightMargin (const FWidget* parent_widget)
|
||||
{
|
||||
if ( button_down || isNewFont() )
|
||||
if ( button_down || FTerm::isNewFont() )
|
||||
return;
|
||||
|
||||
// Restore the right background after button down
|
||||
|
@ -449,12 +463,12 @@ inline void FButton::clearRightMargin (const FWidget* parent_widget)
|
|||
|
||||
for (int y{1}; y <= int(getHeight()); y++)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
print() << FPoint{1 + int(getWidth()), y} << ' '; // clear right
|
||||
|
||||
if ( getFlags().active && isMonochron() )
|
||||
if ( getFlags().active && FTerm::isMonochron() )
|
||||
setReverse(false); // Dark background
|
||||
}
|
||||
}
|
||||
|
@ -470,7 +484,7 @@ inline void FButton::drawMarginLeft()
|
|||
{
|
||||
print() << FPoint{1 + int(indent), 1 + int(y)};
|
||||
|
||||
if ( isMonochron() && active_focus && y == vcenter_offset )
|
||||
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (space_char); // full block █
|
||||
|
@ -486,7 +500,7 @@ inline void FButton::drawMarginRight()
|
|||
{
|
||||
print() << FPoint{int(getWidth() + indent), 1 + int(y)};
|
||||
|
||||
if ( isMonochron() && active_focus && y == vcenter_offset )
|
||||
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
else
|
||||
print (space_char); // full block █
|
||||
|
@ -543,10 +557,10 @@ inline void FButton::drawButtonTextLine (const FString& button_text)
|
|||
setCursorPos ({ 2 + int(center_offset + hotkeypos)
|
||||
, 1 + int(vcenter_offset) }); // hotkey
|
||||
|
||||
if ( ! getFlags().active && isMonochron() )
|
||||
if ( ! getFlags().active && FTerm::isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
if ( active_focus && (isMonochron() || getMaxColor() < 16) )
|
||||
if ( active_focus && (FTerm::isMonochron() || FTerm::getMaxColor() < 16) )
|
||||
setBold();
|
||||
|
||||
while ( pos < center_offset + column_width && columns + 2 < getWidth() )
|
||||
|
@ -555,7 +569,7 @@ inline void FButton::drawButtonTextLine (const FString& button_text)
|
|||
{
|
||||
setColor (button_hotkey_fg, button_bg);
|
||||
|
||||
if ( ! active_focus && getMaxColor() < 16 )
|
||||
if ( ! active_focus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( ! getFlags().no_underline )
|
||||
|
@ -563,7 +577,7 @@ inline void FButton::drawButtonTextLine (const FString& button_text)
|
|||
|
||||
print (button_text[z]);
|
||||
|
||||
if ( ! active_focus && getMaxColor() < 16 )
|
||||
if ( ! active_focus && FTerm::getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
|
||||
if ( ! getFlags().no_underline )
|
||||
|
@ -588,7 +602,7 @@ inline void FButton::drawButtonTextLine (const FString& button_text)
|
|||
print() << FPoint{int(getWidth() + indent) - 2, 1} << "..";
|
||||
}
|
||||
|
||||
if ( active_focus && (isMonochron() || getMaxColor() < 16) )
|
||||
if ( active_focus && (FTerm::isMonochron() || FTerm::getMaxColor() < 16) )
|
||||
unsetBold();
|
||||
|
||||
for (pos = center_offset + column_width; pos < getWidth() - 2; pos++)
|
||||
|
@ -604,7 +618,7 @@ void FButton::draw()
|
|||
space_char = int(' ');
|
||||
active_focus = getFlags().active && getFlags().focus;
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true); // Light background
|
||||
|
||||
// Click animation preprocessing
|
||||
|
@ -613,10 +627,10 @@ void FButton::draw()
|
|||
// Clear right margin after animation
|
||||
clearRightMargin (parent_widget);
|
||||
|
||||
if ( ! getFlags().active && isMonochron() )
|
||||
if ( ! getFlags().active && FTerm::isMonochron() )
|
||||
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
|
||||
|
||||
if ( isMonochron() && (getFlags().active || getFlags().focus) )
|
||||
if ( FTerm::isMonochron() && (getFlags().active || getFlags().focus) )
|
||||
setReverse(false); // Dark background
|
||||
|
||||
if ( getFlags().flat && ! button_down )
|
||||
|
@ -648,7 +662,7 @@ void FButton::draw()
|
|||
if ( ! getFlags().flat && getFlags().shadow && ! button_down )
|
||||
drawShadow(this);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false); // Dark background
|
||||
|
||||
updateStatusBar();
|
||||
|
|
|
@ -39,14 +39,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FButtonGroup::FButtonGroup(FWidget* parent)
|
||||
: FScrollView(parent)
|
||||
: FScrollView{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FButtonGroup::FButtonGroup (const FString& txt, FWidget* parent)
|
||||
: FScrollView(parent)
|
||||
: FScrollView{parent}
|
||||
, text{txt}
|
||||
{
|
||||
init();
|
||||
|
@ -196,9 +196,9 @@ void FButtonGroup::hide()
|
|||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
fg = wc.dialog_fg;
|
||||
bg = wc.dialog_bg;
|
||||
const auto& wc = getColorTheme();
|
||||
fg = wc->dialog_fg;
|
||||
bg = wc->dialog_bg;
|
||||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
|
@ -380,13 +380,13 @@ void FButtonGroup::setHotkeyAccelerator()
|
|||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::draw()
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
clearArea();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
FScrollView::draw();
|
||||
|
@ -427,9 +427,6 @@ bool FButtonGroup::isRadioButton (const FToggleButton* button) const
|
|||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.label_fg);
|
||||
setBackgroundColor (wc.label_bg);
|
||||
setMinimumSize (FSize{7, 3});
|
||||
buttonlist.clear(); // no buttons yet
|
||||
}
|
||||
|
@ -438,7 +435,7 @@ void FButtonGroup::init()
|
|||
void FButtonGroup::drawText ( const FString& label_text
|
||||
, std::size_t hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
const std::size_t column_width = getColumnWidth(label_text);
|
||||
std::size_t length = label_text.getLength();
|
||||
bool ellipsis{false};
|
||||
|
@ -451,19 +448,19 @@ void FButtonGroup::drawText ( const FString& label_text
|
|||
ellipsis = true;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isEnabled() )
|
||||
setColor(wc.label_emphasis_fg, wc.label_bg);
|
||||
setColor(wc->label_emphasis_fg, wc->label_bg);
|
||||
else
|
||||
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
setColor(wc->label_inactive_fg, wc->label_inactive_bg);
|
||||
|
||||
for (std::size_t z{0}; z < length; z++)
|
||||
{
|
||||
if ( (z == hotkeypos) && getFlags().active )
|
||||
{
|
||||
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
|
||||
setColor (wc->label_hotkey_fg, wc->label_hotkey_bg);
|
||||
|
||||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
@ -473,16 +470,16 @@ void FButtonGroup::drawText ( const FString& label_text
|
|||
if ( ! getFlags().no_underline )
|
||||
unsetUnderline();
|
||||
|
||||
setColor (wc.label_emphasis_fg, wc.label_bg);
|
||||
setColor (wc->label_emphasis_fg, wc->label_bg);
|
||||
}
|
||||
else
|
||||
print (label_text[z]);
|
||||
}
|
||||
|
||||
if ( ellipsis ) // Print ellipsis
|
||||
print() << FColorPair {wc.label_ellipsis_fg, wc.label_bg} << "..";
|
||||
print() << FColorPair {wc->label_ellipsis_fg, wc->label_bg} << "..";
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FCheckBox::FCheckBox(FWidget* parent)
|
||||
: FToggleButton(parent)
|
||||
: FToggleButton{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCheckBox::FCheckBox (const FString& txt, FWidget* parent)
|
||||
: FToggleButton(txt, parent)
|
||||
: FToggleButton{txt, parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ void FCheckBox::draw()
|
|||
void FCheckBox::drawCheckButton()
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
setReverse(false);
|
||||
|
@ -89,14 +89,14 @@ void FCheckBox::drawCheckButton()
|
|||
else
|
||||
drawUnchecked();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FCheckBox::drawChecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (CHECKBOX_ON);
|
||||
else
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ inline void FCheckBox::drawChecked()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FCheckBox::drawUnchecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (CHECKBOX);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -34,14 +34,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FCheckMenuItem::FCheckMenuItem (FWidget* parent)
|
||||
: FMenuItem(parent)
|
||||
: FMenuItem{parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent)
|
||||
: FMenuItem(txt, parent)
|
||||
: FMenuItem{txt, parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,201 @@
|
|||
/***********************************************************************
|
||||
* fcolorpalette.cpp - Define RGB color value for a palette entry *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fcolorpalette.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FColorPalette::FColorPalette (const FSetPalette& f)
|
||||
: set_palette{f}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FColorPalette::~FColorPalette() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// protected methods of FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void FColorPalette::setPalette (FColor index, int r, int g, int b)
|
||||
{
|
||||
set_palette (index, r, g, b);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FColorPalette::setVGAdefaultPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x00, 0x00, 0xaa);
|
||||
setPalette (fc::Green, 0x00, 0xaa, 0x00);
|
||||
setPalette (fc::Cyan, 0x00, 0x55, 0xaa);
|
||||
setPalette (fc::Red, 0xaa, 0x00, 0x00);
|
||||
setPalette (fc::Magenta, 0xaa, 0x00, 0xaa);
|
||||
setPalette (fc::Brown, 0xaa, 0xaa, 0x00);
|
||||
setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa);
|
||||
setPalette (fc::DarkGray, 0x55, 0x55, 0x55);
|
||||
setPalette (fc::LightBlue, 0x55, 0x55, 0xff);
|
||||
setPalette (fc::LightGreen, 0x55, 0xff, 0x55);
|
||||
setPalette (fc::LightCyan, 0x55, 0xff, 0xff);
|
||||
setPalette (fc::LightRed, 0xff, 0x55, 0x55);
|
||||
setPalette (fc::LightMagenta, 0xff, 0x55, 0xff);
|
||||
setPalette (fc::Yellow, 0xff, 0xff, 0x55);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorPalette::default8ColorPalette (const FSetPalette& f)
|
||||
: FColorPalette(f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorPalette::~default8ColorPalette()
|
||||
{ }
|
||||
|
||||
// public methods of default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default8ColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::Red, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0);
|
||||
// The same colors again...
|
||||
setPalette (fc::DarkGray, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::LightBlue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::LightGreen, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::LightRed, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::LightMagenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Yellow, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::White, 0xe0, 0xe0, 0xe0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void default8ColorPalette::resetColorPalette()
|
||||
{
|
||||
setVGAdefaultPalette();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default16ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorPalette::default16ColorPalette (const FSetPalette& f)
|
||||
: FColorPalette(f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorPalette::~default16ColorPalette()
|
||||
{ }
|
||||
|
||||
// public methods of default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default16ColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x55, 0x6a, 0xcf);
|
||||
setPalette (fc::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc);
|
||||
setPalette (fc::DarkGray, 0x50, 0x50, 0x50);
|
||||
setPalette (fc::LightBlue, 0x80, 0xa4, 0xec);
|
||||
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (fc::LightRed, 0xee, 0x44, 0x44);
|
||||
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void default16ColorPalette::resetColorPalette()
|
||||
{
|
||||
setVGAdefaultPalette();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default16DarkColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default16DarkColorPalette::default16DarkColorPalette (const FSetPalette& f)
|
||||
: FColorPalette(f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16DarkColorPalette::~default16DarkColorPalette()
|
||||
{ }
|
||||
|
||||
// public methods of default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default16DarkColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x41, 0x58, 0xb3);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x4e, 0x66, 0x72);
|
||||
setPalette (fc::Red, 0xa5, 0x40, 0x40);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xd2, 0xd2, 0xd2);
|
||||
setPalette (fc::DarkGray, 0x27, 0x33, 0x39);
|
||||
setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8);
|
||||
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (fc::LightRed, 0xdd, 0x51, 0x45);
|
||||
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void default16DarkColorPalette::resetColorPalette()
|
||||
{
|
||||
setVGAdefaultPalette();
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "final/flabel.h"
|
||||
#include "final/flineedit.h"
|
||||
#include "final/flistbox.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmouse.h"
|
||||
#include "final/fpoint.h"
|
||||
#include "final/fsize.h"
|
||||
|
@ -43,7 +44,7 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FDropDownListBox::FDropDownListBox (FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ void FDropDownListBox::setGeometry ( const FPoint& pos, const FSize& size
|
|||
{
|
||||
FWindow::setGeometry (pos, size, adjust);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
FSize new_size{size};
|
||||
new_size.scaleBy(-1, 0);
|
||||
|
@ -123,25 +124,25 @@ void FDropDownListBox::init()
|
|||
void FDropDownListBox::draw()
|
||||
{
|
||||
// Fill the background
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_active_fg, wc.menu_active_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_active_fg, wc->menu_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
clearArea();
|
||||
drawShadow();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDropDownListBox::drawShadow()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
finalcut::drawShadow(this);
|
||||
setColor (wc.shadow_fg, wc.shadow_bg);
|
||||
setColor (wc->shadow_fg, wc->shadow_bg);
|
||||
print() << FPoint{int(getWidth()) + 1, 1} << fc::FullBlock; // █
|
||||
}
|
||||
|
||||
|
@ -168,7 +169,7 @@ bool FDropDownListBox::containsWidget (const FPoint& p)
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FComboBox::FComboBox (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -218,8 +219,8 @@ bool FComboBox::setFocus (bool enable)
|
|||
bool FComboBox::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
|
@ -494,7 +495,7 @@ void FComboBox::init()
|
|||
adjustSize();
|
||||
initCallbacks();
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
nf = 1;
|
||||
}
|
||||
|
||||
|
@ -532,22 +533,22 @@ void FComboBox::initCallbacks()
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::draw()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
const FColorPair button_color = [this, &wc] ()
|
||||
{
|
||||
if ( list_window.isEmpty() )
|
||||
return FColorPair { wc.scrollbar_button_inactive_fg
|
||||
, wc.scrollbar_button_inactive_bg };
|
||||
return FColorPair { wc->scrollbar_button_inactive_fg
|
||||
, wc->scrollbar_button_inactive_bg };
|
||||
else
|
||||
return FColorPair { wc.scrollbar_button_fg
|
||||
, wc.scrollbar_button_bg };
|
||||
return FColorPair { wc->scrollbar_button_fg
|
||||
, wc->scrollbar_button_bg };
|
||||
}();
|
||||
|
||||
print() << FPoint{int(getWidth()) - nf, 1}
|
||||
<< button_color;
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print() << NF_button_arrow_down;
|
||||
else
|
||||
print() << fc::BlackDownPointingTriangle; // ▼
|
||||
|
@ -605,9 +606,9 @@ void FComboBox::passEventToListWindow (FMouseEvent* const& ev)
|
|||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,7 +644,7 @@ void FComboBox::cb_closeComboBox (const FWidget*, const FDataPtr)
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldSwitch (const FWidget*, const FDataPtr)
|
||||
{
|
||||
const auto& mouse = getFMouseControl();
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( mouse && ! mouse->isLeftButtonPressed() )
|
||||
return;
|
||||
|
@ -675,7 +676,7 @@ void FComboBox::cb_inputFieldSwitch (const FWidget*, const FDataPtr)
|
|||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldHandOver (const FWidget*, const FDataPtr)
|
||||
{
|
||||
const auto& mouse = getFMouseControl();
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( ! mouse || list_window.isHidden() )
|
||||
return;
|
||||
|
@ -692,9 +693,9 @@ void FComboBox::cb_inputFieldHandOver (const FWidget*, const FDataPtr)
|
|||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
103
src/fdialog.cpp
103
src/fdialog.cpp
|
@ -42,15 +42,15 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FDialog::FDialog (FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FDialog::FDialog (const FString& txt, FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, tb_text(txt)
|
||||
: FWindow{parent}
|
||||
, tb_text{txt}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ bool FDialog::setModal (bool enable)
|
|||
if ( enable )
|
||||
{
|
||||
setModalDialogCounter()++;
|
||||
getFKeyboard()->clearKeyBuffer();
|
||||
FTerm::getFKeyboard()->clearKeyBuffer();
|
||||
}
|
||||
else
|
||||
setModalDialogCounter()--;
|
||||
|
@ -136,6 +136,15 @@ bool FDialog::setBorder (bool enable)
|
|||
return (setFlags().no_border = ! enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FDialog::setResizeable (bool enable)
|
||||
{
|
||||
|
@ -752,7 +761,7 @@ void FDialog::draw()
|
|||
// Fill the background
|
||||
setColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
clearArea();
|
||||
|
@ -763,14 +772,14 @@ void FDialog::draw()
|
|||
if ( getFlags().shadow )
|
||||
drawDialogShadow();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::drawDialogShadow()
|
||||
{
|
||||
if ( isMonochron() && ! getFlags().trans_shadow )
|
||||
if ( FTerm::isMonochron() && ! getFlags().trans_shadow )
|
||||
return;
|
||||
|
||||
drawShadow(this);
|
||||
|
@ -800,9 +809,7 @@ void FDialog::init()
|
|||
addDialog(this);
|
||||
setActiveWindow(this);
|
||||
setTransparentShadow();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
resetColors();
|
||||
auto old_focus = FWidget::getFocusWidget();
|
||||
|
||||
if ( old_focus )
|
||||
|
@ -824,9 +831,9 @@ void FDialog::initDialogMenu()
|
|||
{
|
||||
dialog_menu = new FMenu ("-", this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMenu");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -854,9 +861,9 @@ void FDialog::initMoveSizeMenuItem (FMenu* menu)
|
|||
{
|
||||
move_size_item = new FMenuItem (menu);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMenuItem");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -877,9 +884,9 @@ void FDialog::initZoomMenuItem (FMenu* menu)
|
|||
{
|
||||
zoom_item = new FMenuItem (menu);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMenuItem");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -900,9 +907,9 @@ void FDialog::initCloseMenuItem (FMenu* menu)
|
|||
{
|
||||
close_item = new FMenuItem ("&Close", menu);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMenuItem");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -924,13 +931,13 @@ void FDialog::drawBorder()
|
|||
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() )
|
||||
&& ! isZoomed() )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.dialog_resize_fg, getBackgroundColor());
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->dialog_resize_fg, getBackgroundColor());
|
||||
}
|
||||
else
|
||||
setColor();
|
||||
|
||||
if ( isNewFont() ) // Draw a newfont U-shaped frame
|
||||
if ( FTerm::isNewFont() ) // Draw a newfont U-shaped frame
|
||||
{
|
||||
const FRect r{FPoint{1, 1}, getSize()};
|
||||
|
||||
|
@ -965,7 +972,7 @@ void FDialog::drawTitleBar()
|
|||
// Draw the zoom/unzoom button
|
||||
drawZoomButton();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
#if DEBUG
|
||||
|
@ -983,14 +990,14 @@ void FDialog::drawBarButton()
|
|||
{
|
||||
// Print the title button
|
||||
print() << FPoint{1, 1};
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( dialog_menu && dialog_menu->isShown() )
|
||||
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
|
||||
setColor (wc->titlebar_button_focus_fg, wc->titlebar_button_focus_bg);
|
||||
else
|
||||
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
|
||||
setColor (wc->titlebar_button_fg, wc->titlebar_button_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
if ( isWindowActive() )
|
||||
setReverse(false);
|
||||
|
@ -998,11 +1005,11 @@ void FDialog::drawBarButton()
|
|||
setReverse(true);
|
||||
}
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print (finalcut::NF_menu_button);
|
||||
}
|
||||
else if ( isMonochron() )
|
||||
else if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
|
||||
|
@ -1034,12 +1041,12 @@ void FDialog::drawZoomButton()
|
|||
if ( ! isResizeable() )
|
||||
return;
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( zoom_button_pressed )
|
||||
setColor (wc.titlebar_button_focus_fg, wc.titlebar_button_focus_bg);
|
||||
setColor (wc->titlebar_button_focus_fg, wc->titlebar_button_focus_bg);
|
||||
else
|
||||
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
|
||||
setColor (wc->titlebar_button_fg, wc->titlebar_button_bg);
|
||||
|
||||
if ( isZoomed() )
|
||||
drawRestoreSizeButton();
|
||||
|
@ -1050,13 +1057,13 @@ void FDialog::drawZoomButton()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FDialog::drawRestoreSizeButton()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print (finalcut::NF_button_down);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
print (fc::BlackDownPointingTriangle); // ▼
|
||||
|
@ -1074,13 +1081,13 @@ inline void FDialog::drawRestoreSizeButton()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FDialog::drawZoomedButton()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print (finalcut::NF_button_up);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
print (fc::BlackUpPointingTriangle); // ▲
|
||||
|
@ -1101,15 +1108,15 @@ void FDialog::drawTextBar()
|
|||
// Fill with spaces (left of the title)
|
||||
std::size_t center_offset{0};
|
||||
std::size_t x{1};
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
if ( FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( isWindowActive() || (dialog_menu && dialog_menu->isShown()) )
|
||||
setColor (wc.titlebar_active_fg, wc.titlebar_active_bg);
|
||||
setColor (wc->titlebar_active_fg, wc->titlebar_active_bg);
|
||||
else
|
||||
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
|
||||
setColor (wc->titlebar_inactive_fg, wc->titlebar_inactive_bg);
|
||||
|
||||
const auto width = getWidth();
|
||||
const auto zoom_btn = getZoomButtonWidth();
|
||||
|
@ -1138,7 +1145,7 @@ void FDialog::drawTextBar()
|
|||
for ( ; x + 1 + length < width - zoom_btn - 1; x++)
|
||||
print (' ');
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
if ( FTerm::getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1274,7 @@ inline std::size_t FDialog::getZoomButtonWidth()
|
|||
{
|
||||
if ( ! isResizeable() )
|
||||
return 0;
|
||||
else if ( isNewFont() )
|
||||
else if ( FTerm::isNewFont() )
|
||||
return 2;
|
||||
else
|
||||
return 3;
|
||||
|
@ -1358,9 +1365,9 @@ inline void FDialog::passEventToSubMenu ( const mouseStates& ms
|
|||
setClickedWidget(dialog_menu);
|
||||
dialog_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1632,12 +1639,12 @@ void FDialog::cb_move (const FWidget*, const FDataPtr)
|
|||
|
||||
setMoveSizeWidget(this);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
drawBorder();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
save_geometry = getGeometry();
|
||||
|
@ -1646,15 +1653,15 @@ void FDialog::cb_move (const FWidget*, const FDataPtr)
|
|||
{
|
||||
tooltip = new FToolTip(this);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FToolTip");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isResizeable() )
|
||||
{
|
||||
if ( isLinuxTerm() )
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
tooltip->setText ( " Arrow keys: Move\n"
|
||||
"Shift + Arrow keys: Resize\n"
|
||||
" Enter: Done\n"
|
||||
|
|
|
@ -33,14 +33,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FDialogListMenu::FDialogListMenu(FWidget* parent)
|
||||
: FMenu(parent)
|
||||
: FMenu{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FDialogListMenu::FDialogListMenu (const FString& txt, FWidget* parent)
|
||||
: FMenu(txt, parent)
|
||||
: FMenu{txt, parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -36,16 +36,24 @@ FEvent::FEvent (fc::events ev_type) // constructor
|
|||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fc::events FEvent::type() const
|
||||
fc::events FEvent::getType() const
|
||||
{ return t; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FEvent::isQueued() const
|
||||
{ return queued; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FEvent::wasSent() const
|
||||
{ return send; }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FKeyEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, k{key_num}
|
||||
{ }
|
||||
|
||||
|
@ -78,7 +86,7 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
|||
, const FPoint& pos
|
||||
, const FPoint& termPos
|
||||
, int button )
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, p{pos}
|
||||
, tp{termPos}
|
||||
, b{button}
|
||||
|
@ -88,7 +96,7 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
|||
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, int button )
|
||||
: FMouseEvent(ev_type, pos, FPoint{}, button)
|
||||
: FMouseEvent{ev_type, pos, FPoint{}, button}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -132,7 +140,7 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
|||
, const FPoint& pos
|
||||
, const FPoint& termPos
|
||||
, int wheel )
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, p{pos}
|
||||
, tp{termPos}
|
||||
, w{wheel}
|
||||
|
@ -142,7 +150,7 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
|||
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, int wheel )
|
||||
: FWheelEvent(ev_type, pos, FPoint{}, wheel)
|
||||
: FWheelEvent{ev_type, pos, FPoint{}, wheel}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -183,7 +191,7 @@ int FWheelEvent::getWheel() const
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FFocusEvent::FFocusEvent (fc::events ev_type) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -193,13 +201,13 @@ FFocusEvent::~FFocusEvent() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
bool FFocusEvent::gotFocus() const
|
||||
{
|
||||
return ( type() == fc::FocusIn_Event );
|
||||
return ( getType() == fc::FocusIn_Event );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FFocusEvent::lostFocus() const
|
||||
{
|
||||
return ( type() == fc::FocusOut_Event );
|
||||
return ( getType() == fc::FocusOut_Event );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -228,7 +236,7 @@ void FFocusEvent::ignore()
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FAccelEvent::FAccelEvent (fc::events ev_type, void* focused) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, focus_widget{focused}
|
||||
{ }
|
||||
|
||||
|
@ -258,7 +266,7 @@ void FAccelEvent::ignore()
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FResizeEvent::FResizeEvent (fc::events ev_type) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -283,7 +291,7 @@ void FResizeEvent::ignore()
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FShowEvent::FShowEvent (fc::events ev_type) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -296,7 +304,7 @@ FShowEvent::~FShowEvent() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FHideEvent::FHideEvent (fc::events ev_type) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -309,7 +317,7 @@ FHideEvent::~FHideEvent() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FCloseEvent::FCloseEvent (fc::events ev_type) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -334,7 +342,7 @@ void FCloseEvent::ignore()
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, id{timer_id}
|
||||
{ }
|
||||
|
||||
|
@ -352,7 +360,7 @@ int FTimerEvent::getTimerId() const
|
|||
//----------------------------------------------------------------------
|
||||
|
||||
FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor
|
||||
: FEvent(ev_type)
|
||||
: FEvent{ev_type}
|
||||
, uid{user_event_id}
|
||||
{ }
|
||||
|
||||
|
|
|
@ -99,14 +99,14 @@ FSystem* FFileDialog::fsystem{nullptr};
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FFileDialog::FFileDialog (FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FFileDialog::FFileDialog (const FFileDialog& fdlg)
|
||||
: FDialog(fdlg.getParentWidget())
|
||||
: FDialog{fdlg.getParentWidget()}
|
||||
{
|
||||
if ( fdlg.directory )
|
||||
setPath(fdlg.directory);
|
||||
|
@ -119,9 +119,9 @@ FFileDialog::FFileDialog ( const FString& dirname
|
|||
, const FString& filter
|
||||
, DialogType type
|
||||
, FWidget* parent )
|
||||
: FDialog(parent)
|
||||
, filter_pattern(filter)
|
||||
, dlg_type(type)
|
||||
: FDialog{parent}
|
||||
, filter_pattern{filter}
|
||||
, dlg_type{type}
|
||||
{
|
||||
if ( ! dirname.isNull() )
|
||||
setPath(dirname);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "final/fcolorpair.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flabel.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fstatusbar.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -39,15 +40,15 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLabel::FLabel(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLabel::FLabel (const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, text(txt)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
{
|
||||
init();
|
||||
setText(txt);
|
||||
|
@ -173,9 +174,9 @@ void FLabel::onMouseDown (FMouseEvent* ev)
|
|||
std::make_shared<FMouseEvent>(fc::MouseDown_Event, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -245,20 +246,7 @@ void FLabel::cb_accelWidgetDestroyed (const FWidget*, const FDataPtr)
|
|||
//----------------------------------------------------------------------
|
||||
void FLabel::init()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
unsetFocusable();
|
||||
|
||||
if ( parent_widget )
|
||||
{
|
||||
setForegroundColor (parent_widget->getForegroundColor());
|
||||
setBackgroundColor (parent_widget->getBackgroundColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -302,7 +290,9 @@ void FLabel::draw()
|
|||
if ( text.isEmpty() )
|
||||
return;
|
||||
|
||||
if ( isMonochron() )
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
setReverse(true);
|
||||
|
||||
|
@ -321,7 +311,7 @@ void FLabel::draw()
|
|||
else
|
||||
drawSingleLine();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
setReverse(false);
|
||||
|
||||
|
@ -406,7 +396,7 @@ void FLabel::printLine (FString& line)
|
|||
for (std::size_t z{0}; z < to_char; z++)
|
||||
{
|
||||
if ( ! std::iswprint(std::wint_t(line[z]))
|
||||
&& ! isNewFont()
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( line[z] < fc::NF_rev_left_arrow2
|
||||
|| line[z] > fc::NF_check_mark ) )
|
||||
{
|
||||
|
@ -415,8 +405,8 @@ void FLabel::printLine (FString& line)
|
|||
|
||||
if ( z == hotkeypos && getFlags().active )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->label_hotkey_fg, wc->label_hotkey_bg);
|
||||
|
||||
if ( ! getFlags().no_underline )
|
||||
setUnderline();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flabel.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/flineedit.h"
|
||||
#include "final/fpoint.h"
|
||||
#include "final/fsize.h"
|
||||
|
@ -41,7 +42,7 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLineEdit::FLineEdit (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
, label{new FLabel("", parent)}
|
||||
{
|
||||
init();
|
||||
|
@ -49,8 +50,8 @@ FLineEdit::FLineEdit (FWidget* parent)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, text(txt)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
, label{new FLabel("", parent)}
|
||||
{
|
||||
init();
|
||||
|
@ -61,7 +62,7 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
|
|||
FLineEdit::~FLineEdit() // destructor
|
||||
{
|
||||
if ( ! insert_mode )
|
||||
setInsertCursor();
|
||||
FTerm::setInsertCursor();
|
||||
}
|
||||
|
||||
// FLineEdit operators
|
||||
|
@ -98,28 +99,8 @@ const FLineEdit& FLineEdit::operator >> (FString& s)
|
|||
//----------------------------------------------------------------------
|
||||
bool FLineEdit::setEnable (bool enable)
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
FWidget::setEnable(enable);
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc.inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_fg);
|
||||
setBackgroundColor (wc.inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.inputfield_inactive_fg);
|
||||
setBackgroundColor (wc.inputfield_inactive_bg);
|
||||
}
|
||||
|
||||
resetColors();
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
@ -127,23 +108,7 @@ bool FLineEdit::setEnable (bool enable)
|
|||
bool FLineEdit::setFocus (bool enable)
|
||||
{
|
||||
FWidget::setFocus(enable);
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc.inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_fg);
|
||||
setBackgroundColor (wc.inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
|
||||
resetColors();
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
@ -151,8 +116,8 @@ bool FLineEdit::setFocus (bool enable)
|
|||
bool FLineEdit::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
|
@ -254,6 +219,34 @@ void FLineEdit::setLabelOrientation (const label_o o)
|
|||
adjustLabel();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() ) // active
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc->inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->inputfield_active_fg);
|
||||
setBackgroundColor (wc->inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->inputfield_inactive_fg);
|
||||
setBackgroundColor (wc->inputfield_inactive_bg);
|
||||
}
|
||||
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
|
@ -575,7 +568,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
|
|||
void FLineEdit::onHide (FHideEvent*)
|
||||
{
|
||||
if ( ! insert_mode && ! isReadOnly() )
|
||||
setInsertCursor();
|
||||
FTerm::setInsertCursor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -584,9 +577,9 @@ void FLineEdit::onFocusIn (FFocusEvent*)
|
|||
if ( ! isReadOnly() )
|
||||
{
|
||||
if ( insert_mode )
|
||||
setInsertCursor();
|
||||
FTerm::setInsertCursor();
|
||||
else
|
||||
unsetInsertCursor();
|
||||
FTerm::unsetInsertCursor();
|
||||
}
|
||||
|
||||
if ( getStatusBar() )
|
||||
|
@ -607,7 +600,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
|
|||
}
|
||||
|
||||
if ( ! insert_mode && ! isReadOnly() )
|
||||
setInsertCursor();
|
||||
FTerm::setInsertCursor();
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,34 +647,14 @@ void FLineEdit::adjustSize()
|
|||
//----------------------------------------------------------------------
|
||||
void FLineEdit::init()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
label->setAccelWidget(this);
|
||||
setShadow();
|
||||
resetColors();
|
||||
|
||||
if ( isReadOnly() )
|
||||
unsetVisibleCursor();
|
||||
else
|
||||
setVisibleCursor();
|
||||
|
||||
setShadow();
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_focus_fg);
|
||||
setBackgroundColor (wc.inputfield_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.inputfield_active_fg);
|
||||
setBackgroundColor (wc.inputfield_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc.inputfield_inactive_fg);
|
||||
setBackgroundColor (wc.inputfield_inactive_bg);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -723,7 +696,7 @@ void FLineEdit::drawInputField()
|
|||
const bool isActiveFocus = getFlags().active && getFlags().focus;
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
setReverse(true);
|
||||
print (' ');
|
||||
|
@ -739,7 +712,7 @@ void FLineEdit::drawInputField()
|
|||
print (' ');
|
||||
}
|
||||
|
||||
if ( isActiveFocus && getMaxColor() < 16 )
|
||||
if ( isActiveFocus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
const std::size_t text_offset_column = [this] ()
|
||||
|
@ -765,10 +738,10 @@ void FLineEdit::drawInputField()
|
|||
x_pos++;
|
||||
}
|
||||
|
||||
if ( isActiveFocus && getMaxColor() < 16 )
|
||||
if ( isActiveFocus && FTerm::getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
setReverse(false);
|
||||
setUnderline(false);
|
||||
|
@ -860,7 +833,8 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
if ( input_width >= char_width )
|
||||
|
@ -883,7 +857,8 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -918,7 +893,8 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
idx++;
|
||||
|
@ -951,7 +927,8 @@ void FLineEdit::adjustTextOffset()
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -963,7 +940,8 @@ void FLineEdit::adjustTextOffset()
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,9 +1054,9 @@ inline void FLineEdit::switchInsertMode()
|
|||
insert_mode = ! insert_mode;
|
||||
|
||||
if ( insert_mode )
|
||||
setInsertCursor(); // Insert mode
|
||||
FTerm::setInsertCursor(); // Insert mode
|
||||
else
|
||||
unsetInsertCursor(); // Overtype mode
|
||||
FTerm::unsetInsertCursor(); // Overtype mode
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1092,7 +1070,7 @@ inline bool FLineEdit::keyInput (FKey key)
|
|||
{
|
||||
if ( text.getLength() >= max_length )
|
||||
{
|
||||
beep();
|
||||
FTerm::beep();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
114
src/flistbox.cpp
114
src/flistbox.cpp
|
@ -45,16 +45,16 @@ FListBoxItem::FListBoxItem()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FListBoxItem::FListBoxItem (const FListBoxItem& item)
|
||||
: text(item.text)
|
||||
, data_pointer(item.data_pointer)
|
||||
, brackets(item.brackets)
|
||||
, selected(item.selected)
|
||||
: text{item.text}
|
||||
, data_pointer{item.data_pointer}
|
||||
, brackets{item.brackets}
|
||||
, selected{item.selected}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListBoxItem::FListBoxItem (const FString& txt, FDataPtr data)
|
||||
: text(txt)
|
||||
, data_pointer(data)
|
||||
: text{txt}
|
||||
, data_pointer{data}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -87,7 +87,7 @@ FListBoxItem& FListBoxItem::operator = (const FListBoxItem& item)
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListBox::FListBox (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -274,8 +274,8 @@ void FListBox::clear()
|
|||
hbar->hide();
|
||||
|
||||
// clear list from screen
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
const std::size_t size = getWidth() - 2;
|
||||
drawBorder();
|
||||
drawHeadline();
|
||||
|
@ -655,10 +655,7 @@ void FListBox::init()
|
|||
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange);
|
||||
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
nf_offset = isNewFont() ? 1 : 0;
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
|
@ -722,14 +719,15 @@ void FListBox::draw()
|
|||
if ( current < 1 )
|
||||
current = 1;
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
drawBorder();
|
||||
|
||||
if ( isNewFont() && ! vbar->isShown() )
|
||||
if ( FTerm::isNewFont() && ! vbar->isShown() )
|
||||
{
|
||||
setColor();
|
||||
|
||||
|
@ -742,7 +740,7 @@ void FListBox::draw()
|
|||
|
||||
drawHeadline();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
drawScrollbars();
|
||||
|
@ -792,12 +790,12 @@ void FListBox::drawHeadline()
|
|||
const FString txt{" " + text + " "};
|
||||
const auto column_width = getColumnWidth(txt);
|
||||
print() << FPoint{2, 1};
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() )
|
||||
setColor(wc.label_emphasis_fg, wc.label_bg);
|
||||
setColor(wc->label_emphasis_fg, wc->label_bg);
|
||||
else
|
||||
setColor(wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
setColor(wc->label_inactive_fg, wc->label_inactive_bg);
|
||||
|
||||
if ( column_width <= getClientWidth() )
|
||||
print (txt);
|
||||
|
@ -805,7 +803,7 @@ void FListBox::drawHeadline()
|
|||
{
|
||||
// Print ellipsis
|
||||
print() << getColumnSubString (text, 1, getClientWidth() - 2)
|
||||
<< FColorPair {wc.label_ellipsis_fg, wc.label_bg} << "..";
|
||||
<< FColorPair {wc->label_ellipsis_fg, wc->label_bg} << "..";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,32 +868,32 @@ inline void FListBox::drawListLine ( int y
|
|||
, bool serach_mark )
|
||||
{
|
||||
const std::size_t inc_len = inc_search.getLength();
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
const bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
const std::size_t first = std::size_t(xoffset) + 1;
|
||||
const std::size_t max_width = getWidth() - nf_offset - 4;
|
||||
const FString element(getColumnSubString (getString(iter), first, max_width));
|
||||
std::size_t column_width = getColumnWidth(element);
|
||||
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
|
||||
if ( serach_mark )
|
||||
setColor ( wc.current_inc_search_element_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_inc_search_element_fg
|
||||
, wc->current_element_focus_bg );
|
||||
|
||||
for (std::size_t i{0}; i < element.getLength(); i++)
|
||||
{
|
||||
if ( serach_mark && i == inc_len && getFlags().focus )
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
|
||||
print (element[i]);
|
||||
}
|
||||
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
column_width++;
|
||||
|
@ -928,7 +926,7 @@ inline void FListBox::drawListBracketsLine ( int y
|
|||
const std::size_t inc_len = inc_search.getLength();
|
||||
const bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
|
@ -945,17 +943,17 @@ inline void FListBox::drawListBracketsLine ( int y
|
|||
std::size_t column_width = getColumnWidth(element);
|
||||
const std::size_t text_width = getColumnWidth(getString(iter));
|
||||
std::size_t i{0};
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
for (; i < element.getLength(); i++)
|
||||
{
|
||||
if ( serach_mark && i == 0 )
|
||||
setColor ( wc.current_inc_search_element_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_inc_search_element_fg
|
||||
, wc->current_element_focus_bg );
|
||||
|
||||
if ( serach_mark && i == inc_len )
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
|
||||
print (element[i]);
|
||||
}
|
||||
|
@ -964,14 +962,14 @@ inline void FListBox::drawListBracketsLine ( int y
|
|||
&& std::size_t(xoffset) <= text_width )
|
||||
{
|
||||
if ( serach_mark && i == inc_len )
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
|
||||
printRightBracket (iter->brackets);
|
||||
column_width++;
|
||||
}
|
||||
|
||||
if ( isMonochron() && isCurrentLine && getFlags().focus )
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
column_width++;
|
||||
|
@ -990,51 +988,51 @@ inline void FListBox::setLineAttributes ( int y
|
|||
const bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
const std::size_t inc_len = inc_search.getLength();
|
||||
const std::size_t inc_width = getColumnWidth(inc_search);
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FPoint{2, 2 + int(y)};
|
||||
|
||||
if ( isLineSelected )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setBold();
|
||||
else
|
||||
setColor (wc.selected_list_fg, wc.selected_list_bg);
|
||||
setColor (wc->selected_list_fg, wc->selected_list_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
unsetBold();
|
||||
else
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
}
|
||||
|
||||
if ( isCurrentLine )
|
||||
{
|
||||
if ( getFlags().focus && getMaxColor() < 16 )
|
||||
if ( getFlags().focus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( isLineSelected )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setBold();
|
||||
else if ( getFlags().focus )
|
||||
setColor ( wc.selected_current_element_focus_fg
|
||||
, wc.selected_current_element_focus_bg );
|
||||
setColor ( wc->selected_current_element_focus_fg
|
||||
, wc->selected_current_element_focus_bg );
|
||||
else
|
||||
setColor ( wc.selected_current_element_fg
|
||||
, wc.selected_current_element_bg );
|
||||
setColor ( wc->selected_current_element_fg
|
||||
, wc->selected_current_element_bg );
|
||||
|
||||
setCursorPos ({3, 2 + int(y)}); // first character
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
unsetBold();
|
||||
|
||||
if ( getFlags().focus )
|
||||
{
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
const int b = ( lineHasBrackets ) ? 1: 0;
|
||||
|
||||
if ( inc_len > 0 ) // incremental search
|
||||
|
@ -1047,18 +1045,18 @@ inline void FListBox::setLineAttributes ( int y
|
|||
setCursorPos ({3 + b, 2 + int(y)}); // first character
|
||||
}
|
||||
else
|
||||
setColor ( wc.current_element_fg
|
||||
, wc.current_element_bg );
|
||||
setColor ( wc->current_element_fg
|
||||
, wc->current_element_bg );
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
else if ( getFlags().focus && getMaxColor() < 16 )
|
||||
else if ( getFlags().focus && FTerm::getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
}
|
||||
}
|
||||
|
@ -1066,7 +1064,7 @@ inline void FListBox::setLineAttributes ( int y
|
|||
//----------------------------------------------------------------------
|
||||
inline void FListBox::unsetAttributes()
|
||||
{
|
||||
if ( isMonochron() ) // unset for the last element
|
||||
if ( FTerm::isMonochron() ) // unset for the last element
|
||||
setReverse(false);
|
||||
|
||||
unsetBold();
|
||||
|
@ -1719,7 +1717,7 @@ void FListBox::processChanged()
|
|||
//----------------------------------------------------------------------
|
||||
void FListBox::changeOnResize()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
vbar->setGeometry (FPoint{int(getWidth()), 2}, FSize{2, getHeight() - 2});
|
||||
hbar->setGeometry (FPoint{1, int(getHeight())}, FSize{getWidth() - 2, 1});
|
||||
|
|
|
@ -170,9 +170,9 @@ bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs)
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListViewItem::FListViewItem (const FListViewItem& item)
|
||||
: FObject(item.getParent())
|
||||
, column_list(item.column_list)
|
||||
, data_pointer(item.data_pointer)
|
||||
: FObject{item.getParent()}
|
||||
, column_list{item.column_list}
|
||||
, data_pointer{item.data_pointer}
|
||||
{
|
||||
auto parent = getParent();
|
||||
|
||||
|
@ -191,7 +191,7 @@ FListViewItem::FListViewItem (const FListViewItem& item)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewItem::FListViewItem (iterator parent_iter)
|
||||
: FObject((*parent_iter)->getParent())
|
||||
: FObject{(*parent_iter)->getParent()}
|
||||
{
|
||||
insert (this, parent_iter);
|
||||
}
|
||||
|
@ -200,9 +200,9 @@ FListViewItem::FListViewItem (iterator parent_iter)
|
|||
FListViewItem::FListViewItem ( const FStringList& cols
|
||||
, FDataPtr data
|
||||
, iterator parent_iter )
|
||||
: FObject(nullptr)
|
||||
, column_list(cols)
|
||||
, data_pointer(data)
|
||||
: FObject{nullptr}
|
||||
, column_list{cols}
|
||||
, data_pointer{data}
|
||||
{
|
||||
if ( cols.empty() )
|
||||
return;
|
||||
|
@ -496,7 +496,7 @@ FListViewIterator::FListViewIterator()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (iterator iter)
|
||||
: node(iter)
|
||||
: node{iter}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -505,16 +505,16 @@ FListViewIterator::~FListViewIterator() // destructor
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (const FListViewIterator& i)
|
||||
: iter_path(i.iter_path) // copy constructor
|
||||
, node(i.node)
|
||||
, position(i.position)
|
||||
: iter_path{i.iter_path} // copy constructor
|
||||
, node{i.node}
|
||||
, position{i.position}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (FListViewIterator&& i) noexcept
|
||||
: iter_path(std::move(i.iter_path)) // move constructor
|
||||
, node(std::move(i.node))
|
||||
, position(std::move(i.position))
|
||||
: iter_path{std::move(i.iter_path)} // move constructor
|
||||
, node{std::move(i.node)}
|
||||
, position{std::move(i.position)}
|
||||
{ }
|
||||
|
||||
// FListViewIterator operators
|
||||
|
@ -683,7 +683,7 @@ void FListViewIterator::parentElement()
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListView::FListView (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -910,9 +910,9 @@ FObject::iterator FListView::insert ( const FStringList& cols
|
|||
{
|
||||
item = new FListViewItem (cols, d, getNullIterator());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FListViewItem");
|
||||
return getNullIterator();
|
||||
}
|
||||
|
||||
|
@ -1523,10 +1523,7 @@ void FListView::init()
|
|||
root = selflist.begin();
|
||||
getNullIterator() = selflist.end();
|
||||
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
nf_offset = isNewFont() ? 1 : 0;
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
|
@ -1637,14 +1634,14 @@ void FListView::draw()
|
|||
if ( current_iter.getPosition() < 1 )
|
||||
current_iter = itemlist.begin();
|
||||
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
drawBorder();
|
||||
|
||||
if ( isNewFont() && ! vbar->isShown() )
|
||||
if ( FTerm::isNewFont() && ! vbar->isShown() )
|
||||
{
|
||||
setColor();
|
||||
|
||||
|
@ -1657,7 +1654,7 @@ void FListView::draw()
|
|||
|
||||
drawHeadlines();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
drawScrollbars();
|
||||
|
@ -1773,7 +1770,7 @@ void FListView::drawList()
|
|||
// Reset color
|
||||
setColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
// Clean empty space after last element
|
||||
|
@ -1876,8 +1873,8 @@ void FListView::clearList()
|
|||
{
|
||||
// Clear list from terminal screen
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
const std::size_t size = getWidth() - 2;
|
||||
drawBorder();
|
||||
drawHeadlines();
|
||||
|
@ -1897,34 +1894,34 @@ void FListView::clearList()
|
|||
inline void FListView::setLineAttributes ( bool is_current
|
||||
, bool is_focus )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.list_fg, wc.list_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->list_fg, wc->list_bg);
|
||||
|
||||
if ( is_current )
|
||||
{
|
||||
if ( is_focus && getMaxColor() < 16 )
|
||||
if ( is_focus && FTerm::getMaxColor() < 16 )
|
||||
setBold();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
unsetBold();
|
||||
|
||||
if ( is_focus )
|
||||
{
|
||||
setColor ( wc.current_element_focus_fg
|
||||
, wc.current_element_focus_bg );
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
}
|
||||
else
|
||||
setColor ( wc.current_element_fg
|
||||
, wc.current_element_bg );
|
||||
setColor ( wc->current_element_fg
|
||||
, wc->current_element_bg );
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
else if ( is_focus && getMaxColor() < 16 )
|
||||
else if ( is_focus && FTerm::getMaxColor() < 16 )
|
||||
unsetBold();
|
||||
}
|
||||
}
|
||||
|
@ -1934,7 +1931,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item)
|
|||
{
|
||||
FString checkbox{""};
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
checkbox = ( item->isChecked() ) ? CHECKBOX_ON : CHECKBOX;
|
||||
checkbox += L' ';
|
||||
|
@ -2039,12 +2036,12 @@ void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter)
|
|||
const headerItems::const_iterator first = header.begin();
|
||||
const int column = int(std::distance(first, iter)) + 1;
|
||||
const bool has_sort_indicator( sort_column == column && ! hide_sort_indicator );
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() )
|
||||
setColor (wc.label_emphasis_fg, wc.label_bg);
|
||||
setColor (wc->label_emphasis_fg, wc->label_bg);
|
||||
else
|
||||
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
setColor (wc->label_inactive_fg, wc->label_inactive_bg);
|
||||
|
||||
if ( has_sort_indicator && column_width >= column_max - 1 && column_width > 1 )
|
||||
{
|
||||
|
@ -2169,11 +2166,11 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
|
|||
// Print label ellipsis
|
||||
static constexpr int ellipsis_length = 2;
|
||||
const int width = iter->width;
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
headerline << ' '
|
||||
<< getColumnSubString (text, 1, uInt(width - ellipsis_length))
|
||||
<< FColorPair {wc.label_ellipsis_fg, wc.label_bg}
|
||||
<< FColorPair {wc->label_ellipsis_fg, wc->label_bg}
|
||||
<< "..";
|
||||
|
||||
if ( iter == header.end() - 1 ) // Last element
|
||||
|
@ -2516,7 +2513,7 @@ void FListView::processChanged()
|
|||
//----------------------------------------------------------------------
|
||||
void FListView::changeOnResize()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
vbar->setGeometry (FPoint{int(getWidth()), 2}, FSize{2, getHeight() - 2});
|
||||
hbar->setGeometry (FPoint{1, int(getHeight())}, FSize{getWidth() - 2, 1});
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/***********************************************************************
|
||||
* flog.cpp - Interface of the FINAL CUT logger *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/flog.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FLog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLog::FLog()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLog::~FLog() // destructor
|
||||
{
|
||||
FLog::sync();
|
||||
}
|
||||
|
||||
|
||||
// public methods of FLog
|
||||
//----------------------------------------------------------------------
|
||||
FLog& FLog::operator << (LogLevel l)
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
sync();
|
||||
|
||||
switch ( l )
|
||||
{
|
||||
case Info:
|
||||
current_log = std::bind(&FLog::info, this, _1);
|
||||
break;
|
||||
|
||||
case Warn:
|
||||
current_log = std::bind(&FLog::warn, this, _1);
|
||||
break;
|
||||
|
||||
case Error:
|
||||
current_log = std::bind(&FLog::error, this, _1);
|
||||
break;
|
||||
|
||||
case Debug:
|
||||
current_log = std::bind(&FLog::debug, this, _1);
|
||||
break;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// protected methods of FLog
|
||||
//----------------------------------------------------------------------
|
||||
int FLog::sync()
|
||||
{
|
||||
if ( ! str().empty() )
|
||||
{
|
||||
current_log (str());
|
||||
str("");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/***********************************************************************
|
||||
* flogger.cpp - The FINAL CUT text logger *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/flogger.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FLogger
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLogger::FLogger()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLogger::~FLogger() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// private methods of FLogger
|
||||
//----------------------------------------------------------------------
|
||||
void FLogger::newlineReplace ( std::string& str
|
||||
, const std::string& replace_str )
|
||||
{
|
||||
std::size_t pos{0};
|
||||
std::size_t npos{std::string::npos};
|
||||
|
||||
while ( (pos = str.find("\n", pos)) != npos
|
||||
&& pos + 1 < str.length() )
|
||||
{
|
||||
str.replace(pos, 1, replace_str);
|
||||
pos += replace_str.length();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const std::string FLogger::getTimeString()
|
||||
{
|
||||
char str[100];
|
||||
const auto& now = std::chrono::system_clock::now();
|
||||
const auto& t = std::chrono::system_clock::to_time_t(now);
|
||||
// Print RFC 2822 date
|
||||
struct tm time{};
|
||||
localtime_r (&t, &time);
|
||||
std::strftime (str, sizeof(str), "%a, %d %b %Y %T %z", &time);
|
||||
return std::string(str);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const std::string FLogger::getEOL()
|
||||
{
|
||||
if ( getEnding() == FLog::LF )
|
||||
return "\n";
|
||||
else if ( getEnding() == FLog::CR )
|
||||
return "\r";
|
||||
else if ( getEnding() == FLog::CRLF )
|
||||
return "\r\n";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLogger::printLogLine (const std::string& msg)
|
||||
{
|
||||
const std::string& log_level = [this] ()
|
||||
{
|
||||
switch ( getLevel() )
|
||||
{
|
||||
case Info:
|
||||
return "INFO";
|
||||
|
||||
case Warn:
|
||||
return "WARNING";
|
||||
|
||||
case Error:
|
||||
return "ERROR";
|
||||
|
||||
case Debug:
|
||||
return "DEBUG";
|
||||
}
|
||||
|
||||
return "";
|
||||
}();
|
||||
|
||||
const std::string prefix = [this, &log_level] ()
|
||||
{
|
||||
if ( timestamp )
|
||||
return getTimeString() + " [" + log_level + "] ";
|
||||
else
|
||||
return "[" + log_level + "] ";
|
||||
}();
|
||||
|
||||
std::string message{msg};
|
||||
const std::string& eol = getEOL();
|
||||
const std::string replace_str = eol + prefix;
|
||||
newlineReplace (message, replace_str);
|
||||
output << prefix << message << eol;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
#include "final/fcolorpair.h"
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenuitem.h"
|
||||
|
@ -44,15 +45,15 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMenu::FMenu(FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init(parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMenu::FMenu (const FString& txt, FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, menuitem(txt, parent)
|
||||
: FWindow{parent}
|
||||
, menuitem{txt, parent}
|
||||
{
|
||||
init(parent);
|
||||
}
|
||||
|
@ -82,6 +83,15 @@ void FMenu::setStatusbarMessage (const FString& msg)
|
|||
menuitem.setStatusbarMessage(msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::show()
|
||||
{
|
||||
|
@ -457,10 +467,7 @@ void FMenu::init(FWidget* parent)
|
|||
setTransparentShadow();
|
||||
setMenuWidget();
|
||||
hide();
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
resetColors();
|
||||
menuitem.setMenu(this);
|
||||
|
||||
if ( parent )
|
||||
|
@ -517,7 +524,7 @@ void FMenu::calculateDimensions()
|
|||
}
|
||||
else if ( accel_key )
|
||||
{
|
||||
const std::size_t accel_len = getKeyName(accel_key).getLength();
|
||||
const std::size_t accel_len = FTerm::getKeyName(accel_key).getLength();
|
||||
item_width += accel_len + 2;
|
||||
}
|
||||
|
||||
|
@ -941,9 +948,9 @@ void FMenu::passEventToSubMenu (FMouseEvent* const& ev)
|
|||
setClickedWidget(opened_sub_menu);
|
||||
opened_sub_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -965,9 +972,9 @@ void FMenu::passEventToSuperMenu (FMouseEvent* const& ev)
|
|||
setClickedWidget(smenu);
|
||||
smenu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,9 +997,9 @@ void FMenu::passEventToMenuBar (FMouseEvent* const& ev)
|
|||
mbar.mouse_down = true;
|
||||
mbar.onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1208,10 +1215,10 @@ bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
|||
void FMenu::draw()
|
||||
{
|
||||
// Fill the background
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_active_fg, wc.menu_active_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_active_fg, wc->menu_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
clearArea();
|
||||
|
@ -1219,7 +1226,7 @@ void FMenu::draw()
|
|||
drawItems();
|
||||
drawShadow(this);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -1242,14 +1249,14 @@ void FMenu::drawItems()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawSeparator (int y)
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FPoint{1, 2 + y}
|
||||
<< FColorPair{wc.menu_active_fg, wc.menu_active_bg};
|
||||
<< FColorPair{wc->menu_active_fg, wc->menu_active_bg};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print (fc::NF_border_line_vertical_right);
|
||||
FString line { std::size_t(getWidth()) - 2
|
||||
|
@ -1266,7 +1273,7 @@ inline void FMenu::drawSeparator (int y)
|
|||
print (fc::BoxDrawingsVerticalAndLeft);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -1313,7 +1320,7 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
|||
if ( is_selected )
|
||||
drawTrailingSpaces (column_width);
|
||||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
if ( FTerm::isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
|
@ -1333,14 +1340,14 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
|
|||
{
|
||||
if ( is_radio_btn )
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (fc::NF_Bullet); // NF_Bullet ●
|
||||
else
|
||||
print (fc::BlackCircle); // BlackCircle ●
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (fc::NF_check_mark); // NF_check_mark ✓
|
||||
else
|
||||
print (fc::SquareRoot); // SquareRoot √
|
||||
|
@ -1348,10 +1355,10 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
|
|||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_inactive_fg, getBackgroundColor());
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_inactive_fg, getBackgroundColor());
|
||||
|
||||
if ( getEncoding() == fc::ASCII )
|
||||
if ( FTerm::getEncoding() == fc::ASCII )
|
||||
print ('-');
|
||||
else
|
||||
print (fc::SmallBullet); // ·
|
||||
|
@ -1371,18 +1378,18 @@ inline void FMenu::drawMenuText (menuText& data)
|
|||
for (std::size_t z{0}; z < data.text.getLength(); z++)
|
||||
{
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z]))
|
||||
&& ! isNewFont()
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark )
|
||||
&& ! charEncodable(wchar_t(data.text[z])) )
|
||||
&& ! FTerm::charEncodable(wchar_t(data.text[z])) )
|
||||
{
|
||||
data.text[z] = L' ';
|
||||
}
|
||||
|
||||
if ( z == data.hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_hotkey_fg, wc->menu_hotkey_bg);
|
||||
|
||||
if ( ! data.no_underline )
|
||||
setUnderline();
|
||||
|
@ -1418,7 +1425,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
|
|||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
|
||||
{
|
||||
const FString accel_name {getKeyName(accel_key)};
|
||||
const FString accel_name {FTerm::getKeyName(accel_key)};
|
||||
const std::size_t c = ( has_checkable_items ) ? 1 : 0;
|
||||
const std::size_t accel_len = accel_name.getLength();
|
||||
const std::size_t len = max_item_width - (startpos + accel_len + c + 2);
|
||||
|
@ -1447,33 +1454,33 @@ inline void FMenu::setLineAttributes (const FMenuItem* m_item, int y)
|
|||
{
|
||||
const bool is_enabled = m_item->isEnabled();
|
||||
const bool is_selected = m_item->isSelected();
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( is_enabled )
|
||||
{
|
||||
if ( is_selected )
|
||||
{
|
||||
setForegroundColor (wc.menu_active_focus_fg);
|
||||
setBackgroundColor (wc.menu_active_focus_bg);
|
||||
setForegroundColor (wc->menu_active_focus_fg);
|
||||
setBackgroundColor (wc->menu_active_focus_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.menu_inactive_fg);
|
||||
setBackgroundColor (wc.menu_inactive_bg);
|
||||
setForegroundColor (wc->menu_inactive_fg);
|
||||
setBackgroundColor (wc->menu_inactive_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenuitem.h"
|
||||
|
@ -41,7 +42,7 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMenuBar::FMenuBar(FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -54,6 +55,15 @@ FMenuBar::~FMenuBar() // destructor
|
|||
|
||||
|
||||
// public methods of FMenuBar
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::resetMenu()
|
||||
{
|
||||
|
@ -64,9 +74,9 @@ void FMenuBar::resetMenu()
|
|||
//----------------------------------------------------------------------
|
||||
void FMenuBar::hide()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
FColor fg = wc.term_fg;
|
||||
FColor bg = wc.term_bg;
|
||||
const auto& wc = getColorTheme();
|
||||
FColor fg = wc->term_fg;
|
||||
FColor bg = wc->term_bg;
|
||||
setColor (fg, bg);
|
||||
print() << FPoint{1, 1} << FString{getDesktopWidth(), L' '};
|
||||
updateTerminal();
|
||||
|
@ -248,9 +258,7 @@ void FMenuBar::init()
|
|||
|
||||
addAccelerator (fc::Fkey_f10);
|
||||
addAccelerator (fc::Fckey_space);
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
resetColors();
|
||||
unsetFocusable();
|
||||
}
|
||||
|
||||
|
@ -477,7 +485,7 @@ void FMenuBar::drawItems()
|
|||
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
std::size_t x{1};
|
||||
|
@ -489,7 +497,7 @@ void FMenuBar::drawItems()
|
|||
for (; x <= getDesktopWidth(); x++)
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -528,10 +536,10 @@ inline void FMenuBar::drawItem (FMenuItem* menuitem, std::size_t& x)
|
|||
drawEllipsis (txtdata, x);
|
||||
drawTrailingSpace (x);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_active_fg, wc.menu_active_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_active_fg, wc->menu_active_bg);
|
||||
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
if ( FTerm::isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
|
@ -540,28 +548,28 @@ inline void FMenuBar::setLineAttributes (const FMenuItem* menuitem)
|
|||
{
|
||||
bool is_enabled = menuitem->isEnabled();
|
||||
bool is_selected = menuitem->isSelected();
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( is_enabled )
|
||||
{
|
||||
if ( is_selected )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
setForegroundColor (wc.menu_active_focus_fg);
|
||||
setBackgroundColor (wc.menu_active_focus_bg);
|
||||
setForegroundColor (wc->menu_active_focus_fg);
|
||||
setBackgroundColor (wc->menu_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.menu_active_fg);
|
||||
setBackgroundColor (wc.menu_active_bg);
|
||||
setForegroundColor (wc->menu_active_fg);
|
||||
setBackgroundColor (wc->menu_active_bg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.menu_inactive_fg);
|
||||
setBackgroundColor (wc.menu_inactive_bg);
|
||||
setForegroundColor (wc->menu_inactive_fg);
|
||||
setBackgroundColor (wc->menu_inactive_bg);
|
||||
}
|
||||
|
||||
setColor();
|
||||
|
@ -597,7 +605,7 @@ inline void FMenuBar::drawMenuText (menuText& data)
|
|||
break;
|
||||
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z]))
|
||||
&& ! isNewFont()
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark ) )
|
||||
{
|
||||
|
@ -606,8 +614,8 @@ inline void FMenuBar::drawMenuText (menuText& data)
|
|||
|
||||
if ( z == data.hotkeypos )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_hotkey_fg, wc->menu_hotkey_bg);
|
||||
|
||||
if ( ! data.no_underline )
|
||||
setUnderline();
|
||||
|
@ -944,9 +952,9 @@ void FMenuBar::passEventToMenu (const FMouseEvent* const& ev)
|
|||
setClickedWidget(menu);
|
||||
menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "final/fapplication.h"
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmenu.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenulist.h"
|
||||
|
@ -41,24 +42,24 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMenuItem::FMenuItem (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMenuItem::FMenuItem (const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, text(txt)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMenuItem::FMenuItem (FKey k, const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, text(txt)
|
||||
, accel_key(k)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
, accel_key{k}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
@ -614,9 +615,9 @@ void FMenuItem::createDialogList (FMenu* winmenu)
|
|||
// create a new dialog list item
|
||||
win_item = new FMenuItem (name, winmenu);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMenuItem");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -663,9 +664,9 @@ void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev
|
|||
{
|
||||
_ev = std::make_shared<FMouseEvent>(ev_type, p2, t, b);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fbutton.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmessagebox.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -49,7 +50,7 @@ static const char* const button_text[] =
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::FMessageBox (FWidget* parent)
|
||||
: FDialog(parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setTitlebarText("Message for you");
|
||||
init(FMessageBox::Ok, 0, 0);
|
||||
|
@ -57,15 +58,15 @@ FMessageBox::FMessageBox (FWidget* parent)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::FMessageBox (const FMessageBox& mbox)
|
||||
: FDialog(mbox.getParentWidget())
|
||||
, headline_text(mbox.headline_text)
|
||||
, text(mbox.text)
|
||||
, text_components(mbox.text_components)
|
||||
, max_line_width(mbox.max_line_width)
|
||||
, emphasis_color(mbox.emphasis_color)
|
||||
, num_buttons(mbox.num_buttons)
|
||||
, text_num_lines(mbox.text_num_lines)
|
||||
, center_text(mbox.center_text)
|
||||
: FDialog{mbox.getParentWidget()}
|
||||
, headline_text{mbox.headline_text}
|
||||
, text{mbox.text}
|
||||
, text_components{mbox.text_components}
|
||||
, max_line_width{mbox.max_line_width}
|
||||
, emphasis_color{mbox.emphasis_color}
|
||||
, num_buttons{mbox.num_buttons}
|
||||
, text_num_lines{mbox.text_num_lines}
|
||||
, center_text{mbox.center_text}
|
||||
{
|
||||
setTitlebarText (mbox.getTitlebarText());
|
||||
init ( mbox.button_digit[0]
|
||||
|
@ -80,8 +81,8 @@ FMessageBox::FMessageBox ( const FString& caption
|
|||
, int button1
|
||||
, int button2
|
||||
, FWidget* parent )
|
||||
: FDialog(parent)
|
||||
, text(message)
|
||||
: FDialog{parent}
|
||||
, text{message}
|
||||
{
|
||||
setTitlebarText(caption);
|
||||
init(button0, button1, button2);
|
||||
|
@ -256,9 +257,9 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
|
|||
button[2]->setHeight(1, false);
|
||||
}
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FButton");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +348,7 @@ void FMessageBox::draw()
|
|||
// center the whole block
|
||||
const int msg_x = int((getWidth() - max_line_width) / 2);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( ! headline_text.isEmpty() )
|
||||
|
@ -376,7 +377,7 @@ void FMessageBox::draw()
|
|||
y++;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ bool FMouse::isDblclickTimeout (const timeval* time)
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMouseGPM::FMouseGPM()
|
||||
: FMouse()
|
||||
: FMouse{}
|
||||
{
|
||||
gpm_ev.x = -1;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ const FString* fc::emptyFString::empty_string{nullptr};
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FObject::FObject (FObject* parent)
|
||||
: parent_obj(parent)
|
||||
: parent_obj{parent}
|
||||
{
|
||||
if ( parent ) // add object to parent
|
||||
{
|
||||
|
@ -60,9 +60,9 @@ FObject::FObject (FObject* parent)
|
|||
{
|
||||
timer_list = new FTimerList;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTimerList");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -191,19 +191,18 @@ bool FObject::event (FEvent* ev)
|
|||
{
|
||||
// Receives events on this object
|
||||
|
||||
if ( ev->type() == fc::Timer_Event )
|
||||
if ( ev->getType() == fc::Timer_Event )
|
||||
{
|
||||
onTimer ( static_cast<FTimerEvent*>(ev) );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ev->type() == fc::User_Event )
|
||||
else if ( ev->getType() == fc::User_Event )
|
||||
{
|
||||
onUserEvent ( static_cast<FUserEvent*>(ev) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/foptimove.h"
|
||||
#include "final/ftermcap.h"
|
||||
|
||||
|
@ -36,7 +38,7 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FOptiMove::FOptiMove (int baud)
|
||||
: baudrate(baud)
|
||||
: baudrate{baud}
|
||||
{
|
||||
assert ( baud >= 0 );
|
||||
|
||||
|
@ -1105,42 +1107,43 @@ void FOptiMove::moveByMethod ( int method
|
|||
//----------------------------------------------------------------------
|
||||
void printDurations (const FOptiMove& om)
|
||||
{
|
||||
std::cout << " speed: "
|
||||
<< om.baudrate << " baud\r\n";
|
||||
std::cout << " char_duration: "
|
||||
<< om.char_duration << " ms\r\n";
|
||||
std::cout << " cursor_home: "
|
||||
<< om.F_cursor_home.duration << " ms\r\n";
|
||||
std::cout << " cursor_to_ll: "
|
||||
<< om.F_cursor_to_ll.duration << " ms\r\n";
|
||||
std::cout << " carriage_return: "
|
||||
<< om.F_carriage_return.duration << " ms\r\n";
|
||||
std::cout << " tab: "
|
||||
<< om.F_tab.duration << " ms\r\n";
|
||||
std::cout << " back_tab: "
|
||||
<< om.F_back_tab.duration << " ms\r\n";
|
||||
std::cout << " cursor_up: "
|
||||
<< om.F_cursor_up.duration << " ms\r\n";
|
||||
std::cout << " cursor_down: "
|
||||
<< om.F_cursor_down.duration << " ms\r\n";
|
||||
std::cout << " cursor_left: "
|
||||
<< om.F_cursor_left.duration << " ms\r\n";
|
||||
std::cout << " cursor_right: "
|
||||
<< om.F_cursor_right.duration << " ms\r\n";
|
||||
std::cout << " cursor_address: "
|
||||
<< om.F_cursor_address.duration << " ms\r\n";
|
||||
std::cout << " column_address: "
|
||||
<< om.F_column_address.duration << " ms\r\n";
|
||||
std::cout << " row_address: "
|
||||
<< om.F_row_address.duration << " ms\r\n";
|
||||
std::cout << " parm_up_cursor: "
|
||||
<< om.F_parm_up_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_down_cursor: "
|
||||
<< om.F_parm_down_cursor.duration << " ms\r\n";
|
||||
std::cout << " parm_left_cursor: "
|
||||
<< om.F_parm_left_cursor.duration << " ms\r\n";
|
||||
std::cout << "parm_right_cursor: "
|
||||
<< om.F_parm_right_cursor.duration << " ms\r\n";
|
||||
finalcut::FLog& log = *FApplication::getLog();
|
||||
log << " speed: "
|
||||
<< om.baudrate << " baud" << std::flush;
|
||||
log << " char_duration: "
|
||||
<< om.char_duration << " ms" << std::flush;
|
||||
log << " cursor_home: "
|
||||
<< om.F_cursor_home.duration << " ms" << std::flush;
|
||||
log << " cursor_to_ll: "
|
||||
<< om.F_cursor_to_ll.duration << " ms" << std::flush;
|
||||
log << " carriage_return: "
|
||||
<< om.F_carriage_return.duration << " ms" << std::flush;
|
||||
log << " tab: "
|
||||
<< om.F_tab.duration << " ms" << std::flush;
|
||||
log << " back_tab: "
|
||||
<< om.F_back_tab.duration << " ms" << std::flush;
|
||||
log << " cursor_up: "
|
||||
<< om.F_cursor_up.duration << " ms" << std::flush;
|
||||
log << " cursor_down: "
|
||||
<< om.F_cursor_down.duration << " ms" << std::flush;
|
||||
log << " cursor_left: "
|
||||
<< om.F_cursor_left.duration << " ms" << std::flush;
|
||||
log << " cursor_right: "
|
||||
<< om.F_cursor_right.duration << " ms" << std::flush;
|
||||
log << " cursor_address: "
|
||||
<< om.F_cursor_address.duration << " ms" << std::flush;
|
||||
log << " column_address: "
|
||||
<< om.F_column_address.duration << " ms" << std::flush;
|
||||
log << " row_address: "
|
||||
<< om.F_row_address.duration << " ms" << std::flush;
|
||||
log << " parm_up_cursor: "
|
||||
<< om.F_parm_up_cursor.duration << " ms" << std::flush;
|
||||
log << " parm_down_cursor: "
|
||||
<< om.F_parm_down_cursor.duration << " ms" << std::flush;
|
||||
log << " parm_left_cursor: "
|
||||
<< om.F_parm_left_cursor.duration << " ms" << std::flush;
|
||||
log << "parm_right_cursor: "
|
||||
<< om.F_parm_right_cursor.duration << " ms" << std::flush;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FProgressbar::FProgressbar(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
unsetFocusable();
|
||||
setShadow();
|
||||
|
@ -92,8 +92,8 @@ void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
|
|||
bool FProgressbar::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
|
@ -148,20 +148,10 @@ void FProgressbar::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FProgressbar::drawProgressLabel()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
|
||||
if ( parent_widget )
|
||||
setColor ( parent_widget->getForegroundColor()
|
||||
, parent_widget->getBackgroundColor() );
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.dialog_fg, wc.dialog_bg);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
useParentWidgetColor();
|
||||
print() << FPoint{int(getWidth()) - 3, 0};
|
||||
|
||||
if ( percentage > 100 )
|
||||
|
@ -169,7 +159,7 @@ void FProgressbar::drawProgressLabel()
|
|||
else
|
||||
printf ("%3zu %%", percentage);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -184,7 +174,7 @@ void FProgressbar::drawProgressBar()
|
|||
|
||||
drawProgressBackground(len);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
updateTerminal();
|
||||
|
@ -196,31 +186,31 @@ std::size_t FProgressbar::drawProgressIndicator()
|
|||
{
|
||||
// Draw the progress indicator
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
const double length = double(bar_length * percentage) / 100;
|
||||
auto len = std::size_t(trunc(length));
|
||||
print() << FColorPair {wc.progressbar_fg, wc.progressbar_fg}
|
||||
print() << FColorPair {wc->progressbar_fg, wc->progressbar_fg}
|
||||
<< FString {len, fc::FullBlock}; // █
|
||||
|
||||
if ( len >= bar_length )
|
||||
return len;
|
||||
|
||||
if ( round(length) > len || getMaxColor() < 16 )
|
||||
if ( round(length) > len || FTerm::getMaxColor() < 16 )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
print(' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
print() << FColorPair{wc.progressbar_fg, wc.progressbar_bg}
|
||||
print() << FColorPair{wc->progressbar_fg, wc->progressbar_bg}
|
||||
<< fc::LeftHalfBlock; // ▌
|
||||
}
|
||||
|
||||
|
@ -234,10 +224,10 @@ void FProgressbar::drawProgressBackground (std::size_t len)
|
|||
// Draw the progress background
|
||||
|
||||
const std::size_t bg_len = bar_length - len;
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.progressbar_fg, wc.progressbar_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->progressbar_fg, wc->progressbar_bg);
|
||||
|
||||
if ( getMaxColor() < 16 )
|
||||
if ( FTerm::getMaxColor() < 16 )
|
||||
print() << FString {bg_len, fc::MediumShade}; // ▒
|
||||
else
|
||||
print() << FString {bg_len, L' '};
|
||||
|
|
|
@ -33,14 +33,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FRadioButton::FRadioButton(FWidget* parent)
|
||||
: FToggleButton(parent)
|
||||
: FToggleButton{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRadioButton::FRadioButton (const FString& txt, FWidget* parent)
|
||||
: FToggleButton(txt, parent)
|
||||
: FToggleButton{txt, parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -74,9 +74,9 @@ void FRadioButton::draw()
|
|||
void FRadioButton::drawRadioButton()
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
setColor();
|
||||
useParentWidgetColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
setReverse(false);
|
||||
|
@ -89,14 +89,14 @@ void FRadioButton::drawRadioButton()
|
|||
else
|
||||
drawUnchecked();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FRadioButton::drawChecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (CHECKED_RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ inline void FRadioButton::drawChecked()
|
|||
//----------------------------------------------------------------------
|
||||
inline void FRadioButton::drawUnchecked()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (RADIO_BUTTON);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2019 Markus Gans *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -34,14 +34,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FRadioMenuItem::FRadioMenuItem (FWidget* parent)
|
||||
: FMenuItem(parent)
|
||||
: FMenuItem{parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent)
|
||||
: FMenuItem(txt, parent)
|
||||
: FMenuItem{txt, parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
|
|
@ -36,18 +36,18 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FRect::FRect (const FPoint& p, const FSize& s)
|
||||
: X1(p.getX())
|
||||
, Y1(p.getY())
|
||||
, X2(p.getX() + int(s.getWidth()) - 1)
|
||||
, Y2(p.getY() + int(s.getHeight()) - 1)
|
||||
: X1{p.getX()}
|
||||
, Y1{p.getY()}
|
||||
, X2{p.getX() + int(s.getWidth()) - 1}
|
||||
, Y2{p.getY() + int(s.getHeight()) - 1}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRect::FRect (const FPoint& p1, const FPoint& p2)
|
||||
: X1(p1.getX())
|
||||
, Y1(p1.getY())
|
||||
, X2(p2.getX())
|
||||
, Y2(p2.getY())
|
||||
: X1{p1.getX()}
|
||||
, Y1{p1.getY()}
|
||||
, X2{p2.getX()}
|
||||
, Y2{p2.getY()}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::FScrollbar(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
// The default scrollbar orientation is vertical
|
||||
setGeometry(FPoint{1, 1}, FSize{1, length}, false);
|
||||
|
@ -46,7 +46,7 @@ FScrollbar::FScrollbar(FWidget* parent)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::FScrollbar(fc::orientation o, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
setOrientation (o);
|
||||
init();
|
||||
|
@ -184,7 +184,7 @@ void FScrollbar::redraw()
|
|||
//----------------------------------------------------------------------
|
||||
void FScrollbar::calculateSliderValues()
|
||||
{
|
||||
if ( isNewFont() && bar_orientation == fc::horizontal )
|
||||
if ( FTerm::isNewFont() && bar_orientation == fc::horizontal )
|
||||
bar_length = ( length > 2 ) ? length - 4 : 1;
|
||||
else
|
||||
bar_length = ( length > 2 ) ? length - 2 : 1;
|
||||
|
@ -276,7 +276,7 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
|
|||
slider_click_stop_pos = mouse_y - 2;
|
||||
else
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
slider_click_stop_pos = mouse_x - 3;
|
||||
else
|
||||
slider_click_stop_pos = mouse_x - 2;
|
||||
|
@ -459,8 +459,8 @@ void FScrollbar::draw()
|
|||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawVerticalBar()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->scrollbar_fg, wc->scrollbar_bg);
|
||||
|
||||
for (int z{1}; z <= slider_pos; z++)
|
||||
{
|
||||
|
@ -468,25 +468,25 @@ void FScrollbar::drawVerticalBar()
|
|||
drawVerticalBackgroundLine();
|
||||
}
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
setColor (wc->scrollbar_bg, wc->scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (int z{1}; z <= int(slider_length); z++) // Draw slider
|
||||
{
|
||||
print() << FPoint{1, 1 + slider_pos + z};
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print (' ');
|
||||
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
setColor (wc->scrollbar_fg, wc->scrollbar_bg);
|
||||
|
||||
for (int z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
|
||||
{
|
||||
|
@ -494,25 +494,25 @@ void FScrollbar::drawVerticalBar()
|
|||
drawVerticalBackgroundLine();
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FScrollbar::drawVerticalBackgroundLine()
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (fc::NF_border_line_left); // ⎸
|
||||
}
|
||||
|
||||
if ( isMonochron() || max_color < 16 )
|
||||
if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else if ( isNewFont() )
|
||||
print (fc::NF_rev_border_line_right); // ⎹
|
||||
else if ( FTerm::isNewFont() )
|
||||
print (fc::NF_rev_border_line_right); //⎹
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
|
@ -520,10 +520,10 @@ inline void FScrollbar::drawVerticalBackgroundLine()
|
|||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawHorizontalBar()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->scrollbar_fg, wc->scrollbar_bg);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
print() << FPoint{3, 1};
|
||||
else
|
||||
print() << FPoint{2, 1};
|
||||
|
@ -531,33 +531,33 @@ void FScrollbar::drawHorizontalBar()
|
|||
for (int z{0}; z < slider_pos; z++)
|
||||
drawHorizontalBackgroundColumn();
|
||||
|
||||
setColor (wc.scrollbar_bg, wc.scrollbar_fg);
|
||||
setColor (wc->scrollbar_bg, wc->scrollbar_fg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
for (int z{0}; z < int(slider_length); z++) // Draw slider
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
setColor (wc.scrollbar_fg, wc.scrollbar_bg);
|
||||
setColor (wc->scrollbar_fg, wc->scrollbar_bg);
|
||||
int z = slider_pos + int(slider_length) + 1;
|
||||
|
||||
for (; z <= int(bar_length); z++)
|
||||
drawHorizontalBackgroundColumn();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FScrollbar::drawHorizontalBackgroundColumn()
|
||||
{
|
||||
if ( isNewFont() && max_color > 8 )
|
||||
if ( FTerm::isNewFont() && max_color > 8 )
|
||||
print (fc::NF_border_line_up_and_down); // ニ
|
||||
else if ( isMonochron() || max_color < 16 )
|
||||
else if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
|
@ -566,10 +566,10 @@ inline void FScrollbar::drawHorizontalBackgroundColumn()
|
|||
//----------------------------------------------------------------------
|
||||
void FScrollbar::drawButtons()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.scrollbar_button_fg, wc.scrollbar_button_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->scrollbar_button_fg, wc->scrollbar_button_bg);
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
|
@ -590,7 +590,7 @@ void FScrollbar::drawButtons()
|
|||
{
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
|
@ -606,7 +606,7 @@ void FScrollbar::drawButtons()
|
|||
<< fc::BlackRightPointingPointer; // ►
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y)
|
|||
//----------------------------------------------------------------------
|
||||
FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x)
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
if ( x == 1 || x == 2 )
|
||||
{
|
||||
|
@ -707,7 +707,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y)
|
|||
}
|
||||
else // horizontal bar orientation
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
if ( mouse_x > slider_pos + 2
|
||||
&& mouse_x <= slider_pos + int(slider_length) + 2 )
|
||||
|
@ -741,7 +741,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
|
|||
}
|
||||
else // horizontal
|
||||
{
|
||||
const int nf = isNewFont() ? 1 : 0;
|
||||
const int nf = FTerm::isNewFont() ? 1 : 0;
|
||||
|
||||
if ( x > 1 + nf && x < int(getWidth()) - nf )
|
||||
{
|
||||
|
@ -769,7 +769,7 @@ void FScrollbar::jumpToClickPos (int pos)
|
|||
jumpToClickPos (0, pos + 2);
|
||||
else
|
||||
{
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
jumpToClickPos (pos + 3, 0);
|
||||
else
|
||||
jumpToClickPos (pos + 2, 0);
|
||||
|
@ -807,7 +807,7 @@ void FScrollbar::changeOnResize()
|
|||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
{
|
||||
setWidth(isNewFont() ? 2 : 1);
|
||||
setWidth(FTerm::isNewFont() ? 2 : 1);
|
||||
setHeight(length);
|
||||
}
|
||||
else // horizontal
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FScrollView::FScrollView (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init(parent);
|
||||
}
|
||||
|
@ -293,6 +293,15 @@ bool FScrollView::setViewportPrint (bool enable)
|
|||
return (use_own_print_area = ! enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FScrollView::setBorder (bool enable)
|
||||
{
|
||||
|
@ -416,7 +425,7 @@ void FScrollView::draw()
|
|||
{
|
||||
unsetViewportPrint();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( const auto& p = getParentWidget() )
|
||||
|
@ -427,7 +436,7 @@ void FScrollView::draw()
|
|||
if ( hasBorder() )
|
||||
drawBorder();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
setViewportPrint();
|
||||
|
@ -712,14 +721,12 @@ void FScrollView::init (const FWidget* parent)
|
|||
initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange);
|
||||
mapKeyFunctions();
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
resetColors();
|
||||
setGeometry (FPoint{1, 1}, FSize{4, 4});
|
||||
setMinimumSize (FSize{4, 4});
|
||||
const int xoffset_end = int(getScrollWidth() - getViewportWidth());
|
||||
const int yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
nf_offset = isNewFont() ? 1 : 0;
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding (1 - getScrollY());
|
||||
setLeftPadding (1 - getScrollX());
|
||||
setBottomPadding (1 - (yoffset_end - getScrollY()));
|
||||
|
@ -769,7 +776,7 @@ void FScrollView::calculateScrollbarPos()
|
|||
const std::size_t width = getWidth();
|
||||
const std::size_t height = getHeight();
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
vbar->setGeometry (FPoint{int(width), 2}, FSize{2, height - 2});
|
||||
hbar->setGeometry (FPoint{1, int(height)}, FSize{width - 2, 1});
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace finalcut
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSpinBox::FSpinBox (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ bool FSpinBox::setFocus (bool enable)
|
|||
bool FSpinBox::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& getEncoding() != fc::VT100
|
||||
&& getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
|
@ -326,26 +326,26 @@ void FSpinBox::init()
|
|||
//----------------------------------------------------------------------
|
||||
void FSpinBox::draw()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
const FColorPair inc_button_color = [this, &wc] ()
|
||||
{
|
||||
if ( value == max )
|
||||
return FColorPair { wc.scrollbar_button_inactive_fg
|
||||
, wc.scrollbar_button_inactive_bg };
|
||||
return FColorPair { wc->scrollbar_button_inactive_fg
|
||||
, wc->scrollbar_button_inactive_bg };
|
||||
else
|
||||
return FColorPair { wc.scrollbar_button_fg
|
||||
, wc.scrollbar_button_bg };
|
||||
return FColorPair { wc->scrollbar_button_fg
|
||||
, wc->scrollbar_button_bg };
|
||||
}();
|
||||
|
||||
const FColorPair dec_button_color = [this, &wc] ()
|
||||
{
|
||||
if ( value == min )
|
||||
return FColorPair { wc.scrollbar_button_inactive_fg
|
||||
, wc.scrollbar_button_inactive_bg };
|
||||
return FColorPair { wc->scrollbar_button_inactive_fg
|
||||
, wc->scrollbar_button_inactive_bg };
|
||||
else
|
||||
return FColorPair { wc.scrollbar_button_fg
|
||||
, wc.scrollbar_button_bg };
|
||||
return FColorPair { wc->scrollbar_button_fg
|
||||
, wc->scrollbar_button_bg };
|
||||
}();
|
||||
|
||||
print() << FPoint{int(getWidth()) - 1, 1}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fstartoptions.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -49,6 +51,7 @@ FStartOptions::FStartOptions()
|
|||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
, meta_sends_escape{true}
|
||||
#endif
|
||||
, dark_theme{false}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -65,9 +68,9 @@ FStartOptions& FStartOptions::getFStartOptions()
|
|||
{
|
||||
start_options = new FStartOptions;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FStartOptions");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,16 +36,16 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FStatusKey::FStatusKey(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStatusKey::FStatusKey (FKey k, const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
, text(txt)
|
||||
, key(k)
|
||||
: FWidget{parent}
|
||||
, text{txt}
|
||||
, key{k}
|
||||
{
|
||||
init (parent);
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ void FStatusKey::processActivate()
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FStatusBar::FStatusBar(FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -158,6 +158,15 @@ void FStatusBar::setMessage (const FString& mgs)
|
|||
text.setString(mgs);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStatusBar::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->statusbar_fg);
|
||||
setBackgroundColor (wc->statusbar_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FStatusBar::hasActivatedKey() const
|
||||
{
|
||||
|
@ -174,9 +183,9 @@ bool FStatusBar::hasActivatedKey() const
|
|||
//----------------------------------------------------------------------
|
||||
void FStatusBar::hide()
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const FColor fg = wc.term_fg;
|
||||
const FColor bg = wc.term_bg;
|
||||
const auto& wc = getColorTheme();
|
||||
const FColor fg = wc->term_fg;
|
||||
const FColor bg = wc->term_bg;
|
||||
setColor (fg, bg);
|
||||
print() << FPoint{1, 1} << FString{getDesktopWidth(), L' '};
|
||||
updateTerminal();
|
||||
|
@ -210,11 +219,11 @@ void FStatusBar::drawMessage()
|
|||
if ( isLastActiveFocus )
|
||||
space_offset = 0;
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->statusbar_fg, wc->statusbar_bg);
|
||||
setPrintPos ({x, 1});
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( x + space_offset + 3 < int(termWidth) && text )
|
||||
|
@ -249,7 +258,7 @@ void FStatusBar::drawMessage()
|
|||
for (int i = x; i <= int(termWidth); i++)
|
||||
print (' ');
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -513,16 +522,14 @@ void FStatusBar::init()
|
|||
if ( getRootWidget() )
|
||||
getRootWidget()->setBottomPadding(1, true);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.statusbar_fg);
|
||||
setBackgroundColor (wc.statusbar_bg);
|
||||
resetColors();
|
||||
unsetFocusable();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FStatusBar::getKeyNameWidth (const FStatusKey* key)
|
||||
{
|
||||
const FString& key_name = getKeyName(key->getKey());
|
||||
const FString& key_name = FTerm::getKeyName(key->getKey());
|
||||
return int(getColumnWidth(key_name));
|
||||
}
|
||||
|
||||
|
@ -554,7 +561,7 @@ void FStatusBar::drawKeys()
|
|||
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
auto iter = key_list.begin();
|
||||
|
@ -573,8 +580,8 @@ void FStatusBar::drawKeys()
|
|||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->statusbar_fg, wc->statusbar_bg);
|
||||
|
||||
for (; x <= int(screenWidth); x++)
|
||||
print (' ');
|
||||
|
@ -583,7 +590,7 @@ void FStatusBar::drawKeys()
|
|||
++iter;
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
x_msg = x;
|
||||
|
@ -595,13 +602,13 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
|||
// Draw not active key
|
||||
|
||||
const auto item = *iter;
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.statusbar_hotkey_fg, wc.statusbar_hotkey_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->statusbar_hotkey_fg, wc->statusbar_hotkey_bg);
|
||||
x++;
|
||||
print (' ');
|
||||
x += keyname_len;
|
||||
print (getKeyName(item->getKey()));
|
||||
setColor (wc.statusbar_fg, wc.statusbar_bg);
|
||||
print (FTerm::getKeyName(item->getKey()));
|
||||
setColor (wc->statusbar_fg, wc->statusbar_bg);
|
||||
x++;
|
||||
print ('-');
|
||||
const auto column_width = getColumnWidth (item->getText());
|
||||
|
@ -622,12 +629,12 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
|||
&& x + getKeyNameWidth(*(iter + 1)) + 3 < int(screenWidth) )
|
||||
{
|
||||
// Next element is active
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
if ( hasHalfBlockCharacter() )
|
||||
if ( FTerm::hasHalfBlockCharacter() )
|
||||
{
|
||||
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
|
||||
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
|
||||
print (fc::LeftHalfBlock); // ▐
|
||||
}
|
||||
else
|
||||
|
@ -635,13 +642,13 @@ void FStatusBar::drawKey (keyList::const_iterator iter)
|
|||
|
||||
x++;
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
else if ( iter + 1 != key_list.end() && x < int(screenWidth) )
|
||||
{
|
||||
// Not the last element
|
||||
setColor (wc.statusbar_separator_fg, wc.statusbar_bg);
|
||||
setColor (wc->statusbar_separator_fg, wc->statusbar_bg);
|
||||
x++;
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
}
|
||||
|
@ -654,17 +661,17 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
|||
|
||||
const auto& item = *iter;
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor ( wc.statusbar_active_hotkey_fg
|
||||
, wc.statusbar_active_hotkey_bg );
|
||||
const auto& wc = getColorTheme();
|
||||
setColor ( wc->statusbar_active_hotkey_fg
|
||||
, wc->statusbar_active_hotkey_bg );
|
||||
x++;
|
||||
print (' ');
|
||||
x += keyname_len;
|
||||
print (getKeyName(item->getKey()));
|
||||
setColor (wc.statusbar_active_fg, wc.statusbar_active_bg);
|
||||
print (FTerm::getKeyName(item->getKey()));
|
||||
setColor (wc->statusbar_active_fg, wc->statusbar_active_bg);
|
||||
x++;
|
||||
print ('-');
|
||||
const auto column_width = getColumnWidth (item->getText());
|
||||
|
@ -674,6 +681,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
|||
{
|
||||
print (item->getText());
|
||||
x++;
|
||||
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
|
||||
print (fc::RightHalfBlock); // ▌
|
||||
}
|
||||
else
|
||||
|
@ -684,7 +692,7 @@ void FStatusBar::drawActiveKey (keyList::const_iterator iter)
|
|||
<< "..";
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
}
|
||||
|
||||
|
|
114
src/fstring.cpp
114
src/fstring.cpp
|
@ -25,6 +25,8 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fstring.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -43,21 +45,21 @@ const wchar_t FString::const_null_char{L'\0'};
|
|||
FString::FString (int len)
|
||||
{
|
||||
if ( len > 0 )
|
||||
initLength(std::size_t(len));
|
||||
_initLength(std::size_t(len));
|
||||
else
|
||||
initLength(0);
|
||||
_initLength(0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (std::size_t len)
|
||||
{
|
||||
initLength(len);
|
||||
_initLength(len);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (std::size_t len, wchar_t c)
|
||||
{
|
||||
initLength(len);
|
||||
_initLength(len);
|
||||
const wchar_t* ps = string;
|
||||
wchar_t* pe = string + len;
|
||||
|
||||
|
@ -74,12 +76,12 @@ FString::FString (const FString& s) // copy constructor
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (FString&& s) noexcept // move constructor
|
||||
: string{std::move(s.string)}
|
||||
, length{s.length}
|
||||
, bufsize{s.bufsize}
|
||||
, c_string{std::move(s.c_string)}
|
||||
{
|
||||
if ( ! s.isNull() )
|
||||
_assign (std::move(s.string));
|
||||
else
|
||||
s.string = nullptr;
|
||||
|
||||
s.string = nullptr;
|
||||
s.length = 0;
|
||||
s.bufsize = 0;
|
||||
s.c_string = nullptr;
|
||||
|
@ -104,7 +106,7 @@ FString::FString (const std::string& s)
|
|||
{
|
||||
if ( ! s.empty() )
|
||||
{
|
||||
const wchar_t* wc_string = c_to_wc_str(s.c_str());
|
||||
const wchar_t* wc_string = _to_wcstring(s.c_str());
|
||||
_assign(wc_string);
|
||||
delete[] wc_string;
|
||||
}
|
||||
|
@ -115,7 +117,7 @@ FString::FString (const char s[])
|
|||
{
|
||||
if ( s )
|
||||
{
|
||||
const wchar_t* wc_string = c_to_wc_str(s);
|
||||
const wchar_t* wc_string = _to_wcstring(s);
|
||||
_assign( wc_string );
|
||||
delete[] wc_string;
|
||||
}
|
||||
|
@ -172,14 +174,34 @@ FString::~FString() // destructor
|
|||
//----------------------------------------------------------------------
|
||||
FString& FString::operator = (const FString& s)
|
||||
{
|
||||
_assign (s.string);
|
||||
if ( &s != this )
|
||||
_assign (s.string);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator = (FString&& s) noexcept
|
||||
{
|
||||
_assign (std::move(s.string));
|
||||
if ( &s != this )
|
||||
{
|
||||
if ( string )
|
||||
delete[](string);
|
||||
|
||||
if ( c_string )
|
||||
delete[](c_string);
|
||||
|
||||
string = std::move(s.string);
|
||||
length = s.length;
|
||||
bufsize = s.bufsize;
|
||||
c_string = std::move(s.c_string);
|
||||
|
||||
s.string = nullptr;
|
||||
s.length = 0;
|
||||
s.bufsize = 0;
|
||||
s.c_string = nullptr;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -399,9 +421,9 @@ const char* FString::c_str() const
|
|||
// Returns a constant c-string
|
||||
|
||||
if ( length > 0 )
|
||||
return wc_to_c_str (string);
|
||||
return _to_cstring(string);
|
||||
else if ( string )
|
||||
return const_cast<const char*>("");
|
||||
return "";
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -412,7 +434,7 @@ char* FString::c_str()
|
|||
// Returns a c-string
|
||||
|
||||
if ( length > 0 )
|
||||
return wc_to_c_str (string);
|
||||
return const_cast<char*>(_to_cstring(string));
|
||||
else if ( string )
|
||||
return const_cast<char*>("");
|
||||
else
|
||||
|
@ -759,12 +781,12 @@ FStringList FString::split (const FString& delimiter)
|
|||
return string_list;
|
||||
|
||||
wchar_t* rest{nullptr};
|
||||
const wchar_t* token = extractToken(&rest, s.string, delimiter.wc_str());
|
||||
const wchar_t* token = _extractToken(&rest, s.string, delimiter.wc_str());
|
||||
|
||||
while ( token )
|
||||
{
|
||||
string_list.push_back (FString{token});
|
||||
token = extractToken (&rest, nullptr, delimiter.wc_str());
|
||||
token = _extractToken (&rest, nullptr, delimiter.wc_str());
|
||||
}
|
||||
|
||||
return string_list;
|
||||
|
@ -1219,7 +1241,7 @@ bool FString::includes (const FString& s) const
|
|||
|
||||
// private methods of FString
|
||||
//----------------------------------------------------------------------
|
||||
inline void FString::initLength (std::size_t len)
|
||||
inline void FString::_initLength (std::size_t len)
|
||||
{
|
||||
if ( len == 0 )
|
||||
return;
|
||||
|
@ -1232,9 +1254,9 @@ inline void FString::initLength (std::size_t len)
|
|||
string = new wchar_t[bufsize]();
|
||||
std::wmemset (string, L'\0', bufsize);
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[bufsize]");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1263,9 +1285,9 @@ void FString::_assign (const wchar_t s[])
|
|||
{
|
||||
string = new wchar_t[bufsize]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[bufsize]");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1291,9 +1313,9 @@ void FString::_insert (std::size_t len, const wchar_t s[])
|
|||
{
|
||||
string = new wchar_t[bufsize]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[bufsize]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1338,9 +1360,9 @@ void FString::_insert ( std::size_t pos
|
|||
{
|
||||
sptr = new wchar_t[bufsize](); // generate new string
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[bufsize]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1382,9 +1404,9 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
|||
{
|
||||
sptr = new wchar_t[bufsize](); // generate new string
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[bufsize]");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1404,7 +1426,7 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
||||
inline const char* FString::_to_cstring (const wchar_t s[]) const
|
||||
{
|
||||
if ( ! s ) // handle NULL string
|
||||
return nullptr;
|
||||
|
@ -1416,9 +1438,9 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
|||
// Generate a empty string ("")
|
||||
c_string = new char[1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("char[1]");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1441,9 +1463,9 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
|||
// pre-initialiaze the whole string with '\0'
|
||||
std::memset (c_string, '\0', std::size_t(dest_size));
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("char[std::size_t(dest_size)]");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1454,14 +1476,14 @@ inline char* FString::wc_to_c_str (const wchar_t s[]) const
|
|||
{
|
||||
delete[](c_string);
|
||||
c_string = nullptr;
|
||||
return const_cast<char*>("");
|
||||
return "";
|
||||
}
|
||||
|
||||
return c_string;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
||||
inline const wchar_t* FString::_to_wcstring (const char s[]) const
|
||||
{
|
||||
if ( ! s ) // handle NULL string
|
||||
return nullptr;
|
||||
|
@ -1473,9 +1495,9 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
|||
// Generate a empty wide string (L"")
|
||||
return new wchar_t[1]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[1]");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1493,9 +1515,9 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
|||
// pre-initialiaze the whole string with '\0'
|
||||
std::wmemset (dest, L'\0', std::size_t(size));
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << " " << ex.what() << std::endl;
|
||||
badAllocOutput ("wchar_t[std::size_t(size)]");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1526,9 +1548,9 @@ inline wchar_t* FString::c_to_wc_str (const char s[]) const
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline wchar_t* FString::extractToken ( wchar_t* rest[]
|
||||
, const wchar_t s[]
|
||||
, const wchar_t delim[] )
|
||||
inline const wchar_t* FString::_extractToken ( wchar_t* rest[]
|
||||
, const wchar_t s[]
|
||||
, const wchar_t delim[] )
|
||||
{
|
||||
wchar_t* token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
|
||||
|
||||
|
@ -1641,12 +1663,12 @@ std::ostream& operator << (std::ostream& outstr, const FString& s)
|
|||
|
||||
if ( s.length > 0 )
|
||||
{
|
||||
outstr << s.wc_to_c_str(s.string);
|
||||
outstr << s._to_cstring(s.string);
|
||||
}
|
||||
else if ( width > 0 )
|
||||
{
|
||||
const FString fill_str{width, wchar_t(outstr.fill())};
|
||||
outstr << s.wc_to_c_str(fill_str.string);
|
||||
outstr << s._to_cstring(fill_str.string);
|
||||
}
|
||||
|
||||
return outstr;
|
||||
|
@ -1657,7 +1679,7 @@ std::istream& operator >> (std::istream& instr, FString& s)
|
|||
{
|
||||
char buf[FString::INPBUFFER + 1]{};
|
||||
instr.getline (buf, FString::INPBUFFER);
|
||||
const wchar_t* wc_str = s.c_to_wc_str(buf);
|
||||
const wchar_t* wc_str = s._to_wcstring(buf);
|
||||
|
||||
if ( wc_str )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/***********************************************************************
|
||||
* fstringstream.cpp - I/O operations on FString based streams *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fstring.h"
|
||||
#include "final/fstringstream.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FStringStream
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream::FStringStream (openmode mode)
|
||||
: std::wiostream{&buffer}
|
||||
, buffer{mode}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream::FStringStream (const FString& str, openmode mode)
|
||||
: std::wiostream{&buffer}
|
||||
, buffer{str.wc_str(), mode}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream::FStringStream (FStringStream&& sstream) noexcept
|
||||
: std::wiostream{std::move(sstream)}
|
||||
, buffer{std::move(sstream.buffer)}
|
||||
{
|
||||
std::wiostream::set_rdbuf(&buffer);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream::~FStringStream() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FStringStream
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream& FStringStream::operator = (FStringStream&& sstream) noexcept
|
||||
{
|
||||
std::wiostream::operator = (std::move(sstream));
|
||||
buffer = std::move(sstream.buffer);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStringStream::swap (FStringStream& sstream) noexcept
|
||||
{
|
||||
std::wiostream::swap(sstream);
|
||||
buffer.swap(sstream.buffer);
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
@ -35,14 +35,14 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSwitch::FSwitch(FWidget* parent)
|
||||
: FToggleButton(parent)
|
||||
: FToggleButton{parent}
|
||||
{
|
||||
setButtonWidth(11);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSwitch::FSwitch (const FString& txt, FWidget* parent)
|
||||
: FToggleButton(txt, parent)
|
||||
: FToggleButton{txt, parent}
|
||||
, switch_offset_pos(txt.getLength() + 1)
|
||||
{
|
||||
setButtonWidth(11);
|
||||
|
@ -143,46 +143,46 @@ inline void FSwitch::drawChecked()
|
|||
{
|
||||
wchar_t on[6]{L" On "};
|
||||
const wchar_t off[6]{L" Off "};
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( hasFocus() && ! button_pressed )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
std::wcsncpy (on, L" <On>", 6);
|
||||
setBold(true);
|
||||
}
|
||||
else if ( getMaxColor() < 16 )
|
||||
else if ( FTerm::getMaxColor() < 16 )
|
||||
{
|
||||
setBold(true);
|
||||
setColor (wc.button_active_focus_fg, wc.button_active_focus_bg);
|
||||
setColor (wc->button_active_focus_fg, wc->button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_focus_bg);
|
||||
setColor (wc->button_hotkey_fg, wc->button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
setColor (wc.button_active_focus_fg, wc.button_active_bg);
|
||||
if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 )
|
||||
setColor (wc->button_active_focus_fg, wc->button_active_bg);
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_bg);
|
||||
setColor (wc->button_hotkey_fg, wc->button_active_bg);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
print (on);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 )
|
||||
setBold(false);
|
||||
|
||||
print() << FColorPair{wc.button_inactive_fg, wc.button_inactive_bg}
|
||||
print() << FColorPair{wc->button_inactive_fg, wc->button_inactive_bg}
|
||||
<< off;
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
setCursorPos ({3 + int(switch_offset_pos), 1});
|
||||
|
@ -194,43 +194,43 @@ inline void FSwitch::drawUnchecked()
|
|||
const wchar_t on[6]{L" On "};
|
||||
wchar_t off[6]{L" Off "};
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->button_inactive_fg, wc->button_inactive_bg);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
print (on);
|
||||
|
||||
if ( hasFocus() && ! button_pressed )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
std::wcsncpy (off, L"<Off>", 6);
|
||||
setBold(true);
|
||||
}
|
||||
else if ( getMaxColor() < 16 )
|
||||
else if ( FTerm::getMaxColor() < 16 )
|
||||
{
|
||||
setBold(true);
|
||||
setColor (wc.button_active_focus_fg, wc.button_active_focus_bg);
|
||||
setColor (wc->button_active_focus_fg, wc->button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_focus_bg);
|
||||
setColor (wc->button_hotkey_fg, wc->button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
setColor (wc.button_active_focus_fg, wc.button_active_bg);
|
||||
if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 )
|
||||
setColor (wc->button_active_focus_fg, wc->button_active_bg);
|
||||
else
|
||||
setColor (wc.button_hotkey_fg, wc.button_active_bg);
|
||||
setColor (wc->button_hotkey_fg, wc->button_active_bg);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
|
||||
print (off);
|
||||
|
||||
if ( isMonochron() || getMaxColor() < 16 )
|
||||
if ( FTerm::isMonochron() || FTerm::getMaxColor() < 16 )
|
||||
setBold(false);
|
||||
|
||||
setCursorPos ({7 + int(switch_offset_pos), 1});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -42,6 +42,7 @@ FSystemImpl::FSystemImpl()
|
|||
FSystemImpl::~FSystemImpl() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FSystemImpl
|
||||
//----------------------------------------------------------------------
|
||||
int FSystemImpl::getpwuid_r ( uid_t uid, struct passwd* pwd
|
||||
, char* buf, size_t buflen
|
||||
|
|
151
src/fterm.cpp
151
src/fterm.cpp
|
@ -28,9 +28,9 @@
|
|||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/fcolorpalette.h"
|
||||
#include "final/fkey_map.h"
|
||||
#include "final/fkeyboard.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmouse.h"
|
||||
#include "final/foptiattr.h"
|
||||
#include "final/foptimove.h"
|
||||
|
@ -180,6 +180,13 @@ int FTerm::getMaxColor()
|
|||
return FTermcap::max_color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTerm::FColorPalettePtr& FTerm::getColorPaletteTheme()
|
||||
{
|
||||
static FColorPalettePtr* color_theme = new FColorPalettePtr();
|
||||
return *color_theme;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermData* FTerm::getFTermData()
|
||||
{
|
||||
|
@ -189,9 +196,9 @@ FTermData* FTerm::getFTermData()
|
|||
{
|
||||
data = new FTermData;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermData");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -208,9 +215,9 @@ FSystem* FTerm::getFSystem()
|
|||
{
|
||||
fsys = new FSystemImpl;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermData");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -227,9 +234,9 @@ FOptiMove* FTerm::getFOptiMove()
|
|||
{
|
||||
opti_move = new FOptiMove;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FOptiMove");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -246,9 +253,9 @@ FOptiAttr* FTerm::getFOptiAttr()
|
|||
{
|
||||
opti_attr = new FOptiAttr;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FOptiAttr");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -265,9 +272,9 @@ FTermDetection* FTerm::getFTermDetection()
|
|||
{
|
||||
term_detection = new FTermDetection;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermDetection");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -284,9 +291,9 @@ FTermXTerminal* FTerm::getFTermXTerminal()
|
|||
{
|
||||
xterm = new FTermXTerminal;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermXTerminal");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -303,9 +310,9 @@ FKeyboard* FTerm::getFKeyboard()
|
|||
{
|
||||
keyboard = new FKeyboard;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FKeyboard");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -322,9 +329,9 @@ FMouseControl* FTerm::getFMouseControl()
|
|||
{
|
||||
mouse = new FMouseControl;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseControl");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -342,9 +349,9 @@ FTermLinux* FTerm::getFTermLinux()
|
|||
{
|
||||
linux = new FTermLinux;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermLinux");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -362,9 +369,9 @@ FTermFreeBSD* FTerm::getFTermFreeBSD()
|
|||
{
|
||||
freebsd = new FTermFreeBSD;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermFreeBSD");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -382,9 +389,9 @@ FTermOpenBSD* FTerm::getFTermOpenBSD()
|
|||
{
|
||||
openbsd = new FTermOpenBSD;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermOpenBSD");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -403,9 +410,9 @@ FTermDebugData& FTerm::getFTermDebugData()
|
|||
{
|
||||
debug_data = new FTermDebugData;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermDebugData");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -624,7 +631,7 @@ void FTerm::redefineDefaultColors (bool enable)
|
|||
if ( isNewFont() ) // NewFont need the reverse-video attribute
|
||||
return;
|
||||
|
||||
xterm->redefineDefaultColors (enable);
|
||||
getFTermXTerminal()->redefineDefaultColors (enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -665,7 +672,7 @@ bool FTerm::setVGAFont()
|
|||
{
|
||||
data->setVGAFont(true);
|
||||
// Set font in xterm to vga
|
||||
xterm->setFont("vga");
|
||||
getFTermXTerminal()->setFont("vga");
|
||||
data->setNewFont(false);
|
||||
}
|
||||
#if defined(__linux__)
|
||||
|
@ -700,7 +707,7 @@ bool FTerm::setNewFont()
|
|||
{
|
||||
data->setNewFont(true);
|
||||
// Set font in xterm to 8x16graph
|
||||
xterm->setFont("8x16graph");
|
||||
getFTermXTerminal()->setFont("8x16graph");
|
||||
}
|
||||
#if defined(__linux__)
|
||||
else if ( isLinuxTerm() )
|
||||
|
@ -739,12 +746,12 @@ bool FTerm::setOldFont()
|
|||
if ( font.getLength() > 2 )
|
||||
{
|
||||
// restore saved xterm font
|
||||
xterm->setFont(font);
|
||||
getFTermXTerminal()->setFont(font);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set font in xterm to vga
|
||||
xterm->setFont("vga");
|
||||
getFTermXTerminal()->setFont("vga");
|
||||
}
|
||||
|
||||
retval = true;
|
||||
|
@ -914,7 +921,7 @@ void FTerm::setTermSize (const FSize& size)
|
|||
{
|
||||
// Set xterm size
|
||||
|
||||
xterm->setTermSize (size);
|
||||
getFTermXTerminal()->setTermSize (size);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -922,7 +929,7 @@ void FTerm::setTermTitle (const FString& title)
|
|||
{
|
||||
// Set the xterm window title
|
||||
|
||||
xterm->setTitle (title);
|
||||
getFTermXTerminal()->setTitle (title);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1268,10 +1275,10 @@ void FTerm::initScreenSettings()
|
|||
#endif
|
||||
|
||||
// set xterm underline cursor
|
||||
xterm->setCursorStyle (fc::blinking_underline);
|
||||
getFTermXTerminal()->setCursorStyle (fc::blinking_underline);
|
||||
|
||||
// set xterm color settings to defaults
|
||||
xterm->setDefaults();
|
||||
getFTermXTerminal()->setDefaults();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1297,7 +1304,7 @@ void FTerm::exitWithMessage (const FString& message)
|
|||
std::fflush (stdout);
|
||||
|
||||
if ( ! message.isEmpty() )
|
||||
std::cerr << "Warning: " << message << std::endl;
|
||||
FApplication::getLog()->warn(message.c_str());
|
||||
|
||||
std::exit (EXIT_FAILURE);
|
||||
}
|
||||
|
@ -1322,7 +1329,7 @@ void FTerm::init_global_values (bool disable_alt_screen)
|
|||
data->useAlternateScreen(! disable_alt_screen);
|
||||
|
||||
// Initialize xterm object
|
||||
xterm->init();
|
||||
getFTermXTerminal()->init();
|
||||
|
||||
if ( ! getStartOptions().terminal_detection )
|
||||
term_detection->setTerminalDetection (false);
|
||||
|
@ -1845,9 +1852,9 @@ void FTerm::init_captureFontAndTitle()
|
|||
if ( ! FStartOptions::getFStartOptions().terminal_data_request )
|
||||
return;
|
||||
|
||||
xterm->captureFontAndTitle();
|
||||
const auto& font = xterm->getFont();
|
||||
const auto& title = xterm->getTitle();
|
||||
getFTermXTerminal()->captureFontAndTitle();
|
||||
const auto& font = getFTermXTerminal()->getFont();
|
||||
const auto& title = getFTermXTerminal()->getTitle();
|
||||
|
||||
if ( ! font.isEmpty() )
|
||||
data->setXtermFont(font);
|
||||
|
@ -1875,38 +1882,41 @@ void FTerm::redefineColorPalette()
|
|||
{
|
||||
// Redefine the color palette
|
||||
|
||||
if ( ! canChangeColorPalette() )
|
||||
if ( ! (canChangeColorPalette() && getStartOptions().color_change) )
|
||||
return;
|
||||
|
||||
resetColorMap();
|
||||
saveColorMap();
|
||||
|
||||
if ( getMaxColor() >= 16 )
|
||||
FColorPalette::set16ColorPalette (FTerm::setPalette);
|
||||
else // 8 colors
|
||||
FColorPalette::set8ColorPalette (FTerm::setPalette);
|
||||
if ( getStartOptions().dark_theme )
|
||||
{
|
||||
setColorPaletteTheme<default16DarkColorPalette>(&FTerm::setPalette);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( getMaxColor() >= 16 )
|
||||
setColorPaletteTheme<default16ColorPalette>(&FTerm::setPalette);
|
||||
else // 8 colors
|
||||
setColorPaletteTheme<default8ColorPalette>(&FTerm::setPalette);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::restoreColorPalette()
|
||||
{
|
||||
if ( ! canChangeColorPalette() )
|
||||
if ( ! (canChangeColorPalette() && getStartOptions().color_change) )
|
||||
return;
|
||||
|
||||
// Reset screen settings
|
||||
if ( getMaxColor() >= 16 )
|
||||
FColorPalette::reset16ColorPalette (FTerm::setPalette);
|
||||
else // 8 colors
|
||||
FColorPalette::reset8ColorPalette (FTerm::setPalette);
|
||||
|
||||
xterm->resetColorMap();
|
||||
getColorPaletteTheme()->resetColorPalette();
|
||||
getFTermXTerminal()->resetColorMap();
|
||||
resetColorMap();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::setInsertCursorStyle()
|
||||
{
|
||||
xterm->setCursorStyle (fc::blinking_underline);
|
||||
getFTermXTerminal()->setCursorStyle (fc::blinking_underline);
|
||||
setKDECursor(fc::UnderlineCursor);
|
||||
|
||||
#if defined(__linux__)
|
||||
|
@ -1916,13 +1926,13 @@ void FTerm::setInsertCursorStyle()
|
|||
#endif
|
||||
|
||||
if ( isUrxvtTerminal() )
|
||||
xterm->setCursorColor ("rgb:ffff/ffff/ffff");
|
||||
getFTermXTerminal()->setCursorColor ("rgb:ffff/ffff/ffff");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::setOverwriteCursorStyle()
|
||||
{
|
||||
xterm->setCursorStyle (fc::steady_block);
|
||||
getFTermXTerminal()->setCursorStyle (fc::steady_block);
|
||||
setKDECursor(fc::BlockCursor);
|
||||
|
||||
#if defined(__linux__)
|
||||
|
@ -1932,7 +1942,7 @@ void FTerm::setOverwriteCursorStyle()
|
|||
#endif
|
||||
|
||||
if ( isUrxvtTerminal() )
|
||||
xterm->setCursorColor ("rgb:eeee/0000/0000");
|
||||
getFTermXTerminal()->setCursorColor ("rgb:eeee/0000/0000");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -2250,7 +2260,7 @@ void FTerm::init (bool disable_alt_screen)
|
|||
|
||||
// Activate meta key sends escape
|
||||
if ( isXTerminal() )
|
||||
xterm->metaSendsESC(true);
|
||||
getFTermXTerminal()->metaSendsESC(true);
|
||||
|
||||
// switch to application escape key mode
|
||||
enableApplicationEscKey();
|
||||
|
@ -2271,8 +2281,7 @@ void FTerm::init (bool disable_alt_screen)
|
|||
initTermspecifics();
|
||||
|
||||
// Redefine the color palette
|
||||
if ( getStartOptions().color_change )
|
||||
redefineColorPalette();
|
||||
redefineColorPalette();
|
||||
|
||||
// Set 220 Hz beep (100 ms)
|
||||
setBeep(220, 100);
|
||||
|
@ -2429,14 +2438,13 @@ void FTerm::finish()
|
|||
}
|
||||
|
||||
// Reset xterm color settings to default values
|
||||
xterm->resetDefaults();
|
||||
getFTermXTerminal()->resetDefaults();
|
||||
|
||||
// Set xterm full block cursor
|
||||
xterm->setCursorStyle (fc::steady_block);
|
||||
getFTermXTerminal()->setCursorStyle (fc::steady_block);
|
||||
|
||||
// Restore the color palette
|
||||
if ( getStartOptions().color_change )
|
||||
restoreColorPalette();
|
||||
restoreColorPalette();
|
||||
|
||||
// Switch to normal escape key mode
|
||||
disableApplicationEscKey();
|
||||
|
@ -2454,7 +2462,7 @@ void FTerm::finish()
|
|||
|
||||
// Deactivate meta key sends escape
|
||||
if ( isXTerminal() )
|
||||
xterm->metaSendsESC(false);
|
||||
getFTermXTerminal()->metaSendsESC(false);
|
||||
|
||||
// Switch to the normal screen
|
||||
useNormalScreenBuffer();
|
||||
|
@ -2471,7 +2479,7 @@ void FTerm::finish()
|
|||
const auto& exit_message = data->getExitMessage();
|
||||
|
||||
if ( ! exit_message.isEmpty() )
|
||||
std::cerr << exit_message << std::endl;
|
||||
FApplication::getLog()->info(exit_message.c_str());
|
||||
|
||||
deallocationValues();
|
||||
}
|
||||
|
@ -2497,6 +2505,13 @@ void FTerm::finish_encoding()
|
|||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::destroyColorPaletteTheme()
|
||||
{
|
||||
const FColorPalettePtr* theme = &(getColorPaletteTheme());
|
||||
delete theme;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTerm::setSignalHandler()
|
||||
{
|
||||
|
@ -2546,9 +2561,11 @@ void FTerm::signal_handler (int signum)
|
|||
init_term_object->finish();
|
||||
std::fflush (stderr);
|
||||
std::fflush (stdout);
|
||||
std::cerr << "\nProgram stopped: signal "
|
||||
<< signum
|
||||
<< " (" << strsignal(signum) << ")" << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "\nProgram stopped: signal "
|
||||
<< signum
|
||||
<< " (" << strsignal(signum) << ")"
|
||||
<< std::endl;
|
||||
std::terminate();
|
||||
|
||||
default:
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermbuffer.h"
|
||||
|
||||
|
@ -451,7 +453,8 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
|||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::cerr << "Out of Range error: " << ex.what() << std::endl;
|
||||
*FApplication::getLog() << FLog::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void FTermcap::termcap()
|
|||
std::vector<std::string> terminals{};
|
||||
static constexpr int success = 1;
|
||||
static constexpr int uninitialized = -2;
|
||||
static char term_buffer[2048]{};
|
||||
static char term_buffer[BUF_SIZE]{};
|
||||
int status = uninitialized;
|
||||
const bool color256 = term_detection->canDisplay256Colors();
|
||||
|
||||
|
@ -116,9 +116,6 @@ void FTermcap::termcap()
|
|||
++iter;
|
||||
}
|
||||
|
||||
if ( std::strncmp(termtype, "ansi", 4) == 0 )
|
||||
term_detection->setAnsiTerminal (true);
|
||||
|
||||
termcapError (status);
|
||||
termcapVariables();
|
||||
}
|
||||
|
@ -129,19 +126,23 @@ void FTermcap::termcapError (int status)
|
|||
static constexpr int no_entry = 0;
|
||||
static constexpr int db_not_found = -1;
|
||||
static constexpr int uninitialized = -2;
|
||||
finalcut::FLog& log = *FApplication::getLog();
|
||||
|
||||
if ( status == no_entry || status == uninitialized )
|
||||
{
|
||||
const char* termtype = fterm_data->getTermType();
|
||||
std::cerr << "Unknown terminal: " << termtype << "\n"
|
||||
<< "Check the TERM environment variable\n"
|
||||
<< "Also make sure that the terminal\n"
|
||||
<< "is defined in the termcap/terminfo database.\n";
|
||||
log << FLog::Error
|
||||
<< "Unknown terminal: \"" << termtype << "\". "
|
||||
<< "Check the TERM environment variable. "
|
||||
<< "Also make sure that the terminal "
|
||||
<< "is defined in the termcap/terminfo database."
|
||||
<< std::endl;
|
||||
std::abort();
|
||||
}
|
||||
else if ( status == db_not_found )
|
||||
{
|
||||
std::cerr << "The termcap/terminfo database could not be found.\n";
|
||||
log << "The termcap/terminfo database could not be found."
|
||||
<< std::endl;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
#endif
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
|
@ -377,6 +379,8 @@ void FTermDetection::detectTerminal()
|
|||
if ( ! new_termtype && std::strlen(termtype) == 5 )
|
||||
new_termtype = "xterm-16color";
|
||||
}
|
||||
else if ( std::strncmp(termtype, "ansi", 4) == 0 ) // ANSI detection
|
||||
terminal_type.ansi = true;
|
||||
|
||||
// set the new environment variable TERM
|
||||
if ( new_termtype )
|
||||
|
@ -587,9 +591,9 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
|||
{
|
||||
answer_back = new FString(getAnswerbackMsg());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FString");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -657,9 +661,9 @@ const char* FTermDetection::parseSecDA (const char current_termtype[])
|
|||
// Secondary device attributes (SEC_DA) <- decTerminalID string
|
||||
sec_da = new FString(getSecDA());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FString");
|
||||
return current_termtype;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -20,13 +20,24 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermdata.h"
|
||||
#include "final/ftermfreebsd.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
#define initCheck(ret_value) \
|
||||
if ( ! isInitialized() ) \
|
||||
{ \
|
||||
warnNotInitialized(); \
|
||||
return ret_value; \
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
|
@ -58,12 +69,14 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
|||
{
|
||||
// Set cursor style in a BSD console
|
||||
|
||||
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
|
||||
return false;
|
||||
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
initCheck(false);
|
||||
|
||||
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
|
||||
return false;
|
||||
|
||||
cursor_style = style;
|
||||
|
||||
if ( fterm_data->isCursorHidden() )
|
||||
|
@ -177,6 +190,16 @@ void FTermFreeBSD::finish()
|
|||
|
||||
|
||||
// private methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::warnNotInitialized()
|
||||
{
|
||||
*FApplication::getLog() << FLog::Warn
|
||||
<< "The FTermFreeBSD object has "
|
||||
<< "not yet been initialized! "
|
||||
<< "Please call the init() method first."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::saveFreeBSDAltKey()
|
||||
{
|
||||
|
@ -185,9 +208,8 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
initCheck(false);
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
@ -205,9 +227,8 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
|||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
|
||||
if ( fsystem )
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
initCheck(false);
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
return false;
|
||||
|
@ -241,6 +262,8 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||
{
|
||||
initCheck(false);
|
||||
|
||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||
return true;
|
||||
else
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fcharmap.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermcap.h"
|
||||
|
@ -200,7 +202,7 @@ void FTermLinux::init()
|
|||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "can not open the console.\n";
|
||||
FApplication::getLog()->error("Can not open the console.");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
@ -290,6 +292,9 @@ bool FTermLinux::loadVGAFont()
|
|||
|
||||
if ( vga_font )
|
||||
{
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -336,6 +341,9 @@ bool FTermLinux::loadNewFont()
|
|||
|
||||
if ( new_font )
|
||||
{
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
fterm_data->supportShadowCharacter (true);
|
||||
fterm_data->supportHalfBlockCharacter (true);
|
||||
}
|
||||
|
@ -553,9 +561,9 @@ bool FTermLinux::getScreenFont()
|
|||
static constexpr std::size_t data_size = 4 * 32 * 512;
|
||||
font.data = new uChar[data_size]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FString");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -605,9 +613,9 @@ bool FTermLinux::getUnicodeMap()
|
|||
{
|
||||
screen_unicode_map.entries = new struct unipair[count]();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("unipair[count]");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -683,9 +691,9 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count
|
|||
{
|
||||
font.data = new uChar[data_size](); // Initialize with 0
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("uChar[data_size]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1286,6 +1294,9 @@ inline void FTermLinux::initSpecialCharacter()
|
|||
const wchar_t c2 = fc::LowerHalfBlock;
|
||||
const wchar_t c3 = fc::FullBlock;
|
||||
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII)
|
||||
|| FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII)
|
||||
|| FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) )
|
||||
|
@ -1322,6 +1333,10 @@ void FTermLinux::characterFallback ( wchar_t ucs
|
|||
, std::vector<wchar_t> fallback )
|
||||
{
|
||||
constexpr sInt16 NOT_FOUND = -1;
|
||||
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
charSubstitution& sub_map = fterm_data->getCharSubstitutionMap();
|
||||
|
||||
if ( fallback.size() < 2 || ucs != fallback[0] )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -20,10 +20,21 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fsystem.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermopenbsd.h"
|
||||
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
|
||||
#define initCheck(ret_value) \
|
||||
if ( ! isInitialized() ) \
|
||||
{ \
|
||||
warnNotInitialized(); \
|
||||
return ret_value; \
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
|
@ -86,6 +97,8 @@ void FTermOpenBSD::init()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermOpenBSD::finish()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( ! isBSDConsole() )
|
||||
return;
|
||||
|
||||
|
@ -96,6 +109,8 @@ void FTermOpenBSD::finish()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::setBeep (int Hz, int ms)
|
||||
{
|
||||
initCheck(false);
|
||||
|
||||
if ( ! isBSDConsole() )
|
||||
return false;
|
||||
|
||||
|
@ -122,6 +137,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::resetBeep()
|
||||
{
|
||||
initCheck(false);
|
||||
wskbd_bell_data default_bell;
|
||||
|
||||
// Gets the default setting for the bell
|
||||
|
@ -141,6 +157,16 @@ bool FTermOpenBSD::resetBeep()
|
|||
|
||||
|
||||
// private methods of FTermOpenBSD
|
||||
//----------------------------------------------------------------------
|
||||
void FTermOpenBSD::warnNotInitialized()
|
||||
{
|
||||
*FApplication::getLog() << FLog::Warn
|
||||
<< "The FTermOpenBSD object has "
|
||||
<< "not yet been initialized! "
|
||||
<< "Please call the init() method first."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermOpenBSD::saveBSDConsoleEncoding()
|
||||
{
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
#include "final/fconfig.h" // includes _GNU_SOURCE for fd_set
|
||||
#endif
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermcap.h"
|
||||
|
@ -34,6 +36,13 @@
|
|||
#include "final/ftermxterminal.h"
|
||||
#include "final/fsize.h"
|
||||
|
||||
#define initCheck(ret_value) \
|
||||
if ( ! isInitialized() ) \
|
||||
{ \
|
||||
warnNotInitialized(); \
|
||||
return ret_value; \
|
||||
}
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
|
@ -256,6 +265,8 @@ void FTermXTerminal::resetHighlightBackground()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::resetDefaults()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
|
@ -280,6 +291,8 @@ void FTermXTerminal::resetDefaults()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::captureFontAndTitle()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( ( term_detection->isXTerminal()
|
||||
|| term_detection->isUrxvtTerminal() )
|
||||
&& ! term_detection->isRxvtTerminal() )
|
||||
|
@ -293,6 +306,16 @@ void FTermXTerminal::captureFontAndTitle()
|
|||
|
||||
|
||||
// private methods of FTermXTerminal
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::warnNotInitialized()
|
||||
{
|
||||
*FApplication::getLog() << FLog::Warn
|
||||
<< "The FTermXTerminal object has "
|
||||
<< "not yet been initialized! "
|
||||
<< "Please call the init() method first."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setXTermCursorStyle()
|
||||
{
|
||||
|
@ -303,6 +326,8 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
return;
|
||||
#endif
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isGnomeTerminal()
|
||||
&& ! term_detection->hasSetCursorStyleSupport() )
|
||||
return;
|
||||
|
@ -325,6 +350,7 @@ void FTermXTerminal::setXTermCursorStyle()
|
|||
void FTermXTerminal::setXTermTitle()
|
||||
{
|
||||
// Set the xterm title
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|
@ -343,6 +369,8 @@ void FTermXTerminal::setXTermTitle()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::setXTermSize()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal() )
|
||||
{
|
||||
FTerm::putstringf ( CSI "8;%lu;%lut"
|
||||
|
@ -357,6 +385,8 @@ void FTermXTerminal::setXTermFont()
|
|||
{
|
||||
// Change the XTerm font (needs the allowFontOps resource)
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isUrxvtTerminal()
|
||||
|
@ -373,6 +403,8 @@ void FTermXTerminal::setXTermForeground()
|
|||
{
|
||||
// Set the XTerm text foreground color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isMinttyTerm()
|
||||
|
@ -391,6 +423,8 @@ void FTermXTerminal::setXTermBackground()
|
|||
{
|
||||
// Set the XTerm text background color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isMinttyTerm()
|
||||
|
@ -409,6 +443,8 @@ void FTermXTerminal::setXTermCursorColor()
|
|||
{
|
||||
// Set the text cursor color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isMinttyTerm()
|
||||
|
@ -427,6 +463,8 @@ void FTermXTerminal::setXTermMouseForeground()
|
|||
{
|
||||
// Set the mouse foreground color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isUrxvtTerminal()
|
||||
|
@ -444,6 +482,8 @@ void FTermXTerminal::setXTermMouseBackground()
|
|||
{
|
||||
// Set the mouse background color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| FTermcap::osc_support )
|
||||
|
@ -460,6 +500,8 @@ void FTermXTerminal::setXTermHighlightBackground()
|
|||
{
|
||||
// Set the highlight background color
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| term_detection->isUrxvtTerminal()
|
||||
|
@ -478,6 +520,8 @@ void FTermXTerminal::setXTerm8ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 8 color theme
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
|
@ -498,6 +542,8 @@ void FTermXTerminal::setXTerm16ColorDefaults()
|
|||
// Redefinition of the XTerm default colors
|
||||
// for the final cut 16 color theme
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
|
@ -518,6 +564,8 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
|||
setMouseBackground("rgb:ffff/ffff/ffff"); // white
|
||||
setMouseForeground ("rgb:0000/0000/0000"); // black
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( ! term_detection->isGnomeTerminal() )
|
||||
setCursorColor("rgb:ffff/ffff/ffff"); // white
|
||||
}
|
||||
|
@ -525,6 +573,8 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
|
|||
//----------------------------------------------------------------------
|
||||
inline bool FTermXTerminal::canSetXTermBackground()
|
||||
{
|
||||
initCheck(false);
|
||||
|
||||
if ( xterm_default_colors
|
||||
&& ! (term_detection->isMinttyTerm()
|
||||
|| term_detection->isMltermTerminal()
|
||||
|
@ -540,6 +590,8 @@ void FTermXTerminal::resetXTermColorMap()
|
|||
{
|
||||
// Reset the entire color table
|
||||
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isMinttyTerm() )
|
||||
{
|
||||
FTerm::putstring (ESC "c"); // Full Reset (RIS)
|
||||
|
@ -640,6 +692,8 @@ void FTermXTerminal::resetXTermHighlightBackground()
|
|||
//----------------------------------------------------------------------
|
||||
bool FTermXTerminal::canResetColor()
|
||||
{
|
||||
initCheck(false);
|
||||
|
||||
if ( term_detection->isGnomeTerminal()
|
||||
&& term_detection->getGnomeTerminalID() < 3502 )
|
||||
return false;
|
||||
|
@ -659,6 +713,8 @@ bool FTermXTerminal::canResetColor()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPrefix()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isTmuxTerm() )
|
||||
{
|
||||
// tmux device control string
|
||||
|
@ -674,6 +730,8 @@ void FTermXTerminal::oscPrefix()
|
|||
//----------------------------------------------------------------------
|
||||
void FTermXTerminal::oscPostfix()
|
||||
{
|
||||
initCheck();
|
||||
|
||||
if ( term_detection->isScreenTerm()
|
||||
|| term_detection->isTmuxTerm() )
|
||||
{
|
||||
|
@ -685,6 +743,8 @@ void FTermXTerminal::oscPostfix()
|
|||
//----------------------------------------------------------------------
|
||||
const FString FTermXTerminal::captureXTermFont()
|
||||
{
|
||||
initCheck(FString{});
|
||||
|
||||
if ( term_detection->isXTerminal()
|
||||
|| term_detection->isScreenTerm()
|
||||
|| FTermcap::osc_support )
|
||||
|
@ -727,6 +787,8 @@ const FString FTermXTerminal::captureXTermFont()
|
|||
//----------------------------------------------------------------------
|
||||
const FString FTermXTerminal::captureXTermTitle()
|
||||
{
|
||||
initCheck(FString{});
|
||||
|
||||
if ( term_detection->isKdeTerminal() )
|
||||
return FString{};
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTextView::FTextView(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -104,6 +104,15 @@ void FTextView::setGeometry ( const FPoint& pos, const FSize& size
|
|||
changeOnResize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::setText (const FString& str)
|
||||
{
|
||||
|
@ -178,6 +187,18 @@ void FTextView::scrollTo (int x, int y)
|
|||
updateTerminal();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::scrollToBegin()
|
||||
{
|
||||
scrollToY (0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::scrollToEnd()
|
||||
{
|
||||
scrollToY (int(getRows() - getTextHeight()));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTextView::hide()
|
||||
{
|
||||
|
@ -202,7 +223,7 @@ void FTextView::insert (const FString& str, int pos)
|
|||
if ( str.isEmpty() )
|
||||
s = "\n";
|
||||
else
|
||||
s = FString{str}.rtrim().expandTabs(getTabstop());
|
||||
s = FString{str}.rtrim().expandTabs(FTerm::getTabstop());
|
||||
|
||||
|
||||
auto text_split = s.split("\r\n");
|
||||
|
@ -363,9 +384,9 @@ void FTextView::onMouseDown (FMouseEvent* ev)
|
|||
std::make_shared<FMouseEvent>(fc::MouseDown_Event, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -392,9 +413,9 @@ void FTextView::onMouseUp (FMouseEvent* ev)
|
|||
std::make_shared<FMouseEvent>(fc::MouseUp_Event, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -425,9 +446,9 @@ void FTextView::onMouseMove (FMouseEvent* ev)
|
|||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -557,10 +578,8 @@ void FTextView::init()
|
|||
{
|
||||
initScrollbar (vbar, fc::vertical, this, &FTextView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FTextView::cb_hbarChange);
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.dialog_fg);
|
||||
setBackgroundColor (wc.dialog_bg);
|
||||
nf_offset = isNewFont() ? 1 : 0;
|
||||
resetColors();
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
setLeftPadding(1);
|
||||
setBottomPadding(1);
|
||||
|
@ -577,8 +596,8 @@ inline void FTextView::mapKeyFunctions()
|
|||
key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
|
||||
key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getTextHeight())); };
|
||||
key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getTextHeight())); };
|
||||
key_map[fc::Fkey_home] = [this] { scrollToY (0); };
|
||||
key_map[fc::Fkey_end] = [this] { scrollToY (int(getRows() - getTextHeight())); };
|
||||
key_map[fc::Fkey_home] = [this] { scrollToBegin(); };
|
||||
key_map[fc::Fkey_end] = [this] { scrollToEnd(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -611,13 +630,13 @@ void FTextView::drawBorder()
|
|||
{
|
||||
if ( ! useFDialogBorder() )
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const FRect box{FPoint{1, 1}, getSize()};
|
||||
finalcut::drawListBorder (this, box);
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
}
|
||||
|
@ -649,7 +668,7 @@ void FTextView::drawText()
|
|||
|
||||
setColor();
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
for (std::size_t y{0}; y < num; y++) // Line loop
|
||||
|
@ -678,7 +697,7 @@ void FTextView::drawText()
|
|||
print() << FString{trailing_whitespace, L' '};
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -707,7 +726,7 @@ inline bool FTextView::isPrintable (wchar_t ch)
|
|||
{
|
||||
// Check for printable characters
|
||||
|
||||
const bool utf8 = ( getEncoding() == fc::UTF8 ) ? true : false;
|
||||
const bool utf8 = ( FTerm::getEncoding() == fc::UTF8 ) ? true : false;
|
||||
|
||||
if ( (utf8 && std::iswprint(std::wint_t(ch)))
|
||||
|| (!utf8 && std::isprint(ch)) )
|
||||
|
@ -728,7 +747,7 @@ void FTextView::changeOnResize()
|
|||
const std::size_t width = getWidth();
|
||||
const std::size_t height = getHeight();
|
||||
|
||||
if ( isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
vbar->setGeometry (FPoint{int(width), 1}, FSize{2, height - 1});
|
||||
hbar->setGeometry (FPoint{1, int(height)}, FSize{width - 2, 1});
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FToggleButton::FToggleButton (FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
|
||||
|
@ -55,7 +55,7 @@ FToggleButton::FToggleButton (FWidget* parent)
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
FToggleButton::FToggleButton (const FString& txt, FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FToggleButton::setText(txt); // call own method
|
||||
init();
|
||||
|
@ -111,6 +111,33 @@ void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
|
|||
FWidget::setGeometry (pos, size, adjust);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToggleButton::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() ) // active
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc->toggle_button_active_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc->label_inactive_fg);
|
||||
setBackgroundColor (wc->label_inactive_bg);
|
||||
}
|
||||
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FToggleButton::setNoUnderline (bool enable)
|
||||
{
|
||||
|
@ -121,7 +148,7 @@ bool FToggleButton::setNoUnderline (bool enable)
|
|||
bool FToggleButton::setEnable (bool enable)
|
||||
{
|
||||
FWidget::setEnable(enable);
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
|
@ -129,20 +156,20 @@ bool FToggleButton::setEnable (bool enable)
|
|||
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc.toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_focus_bg);
|
||||
setForegroundColor (wc->toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.toggle_button_active_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_bg);
|
||||
setForegroundColor (wc->toggle_button_active_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delAccelerator();
|
||||
setForegroundColor (wc.toggle_button_inactive_fg);
|
||||
setBackgroundColor (wc.toggle_button_inactive_bg);
|
||||
setForegroundColor (wc->toggle_button_inactive_fg);
|
||||
setBackgroundColor (wc->toggle_button_inactive_bg);
|
||||
}
|
||||
|
||||
return enable;
|
||||
|
@ -155,20 +182,20 @@ bool FToggleButton::setFocus (bool enable)
|
|||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( enable )
|
||||
{
|
||||
if ( isRadioButton() )
|
||||
focus_inside_group = false;
|
||||
|
||||
setForegroundColor (wc.toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_focus_bg);
|
||||
setForegroundColor (wc->toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.toggle_button_active_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_bg);
|
||||
setForegroundColor (wc->toggle_button_active_fg);
|
||||
setBackgroundColor (wc->toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -497,46 +524,27 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
|
|||
void FToggleButton::init()
|
||||
{
|
||||
setGeometry (FPoint{1, 1}, FSize{4, 1}, false); // initialize geometry values
|
||||
const auto& wc = getFWidgetColors();
|
||||
|
||||
if ( isEnabled() )
|
||||
{
|
||||
if ( hasFocus() )
|
||||
{
|
||||
setForegroundColor (wc.toggle_button_active_focus_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_focus_bg);
|
||||
}
|
||||
else
|
||||
{
|
||||
setForegroundColor (wc.toggle_button_active_fg);
|
||||
setBackgroundColor (wc.toggle_button_active_bg);
|
||||
}
|
||||
}
|
||||
else // inactive
|
||||
{
|
||||
setForegroundColor (wc.label_inactive_fg);
|
||||
setBackgroundColor (wc.label_inactive_bg);
|
||||
}
|
||||
resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
const auto& wc = getFWidgetColors();
|
||||
const auto& wc = getColorTheme();
|
||||
|
||||
if ( isEnabled() )
|
||||
setColor (wc.label_fg, wc.label_bg);
|
||||
setColor (wc->label_fg, wc->label_bg);
|
||||
else
|
||||
setColor (wc.label_inactive_fg, wc.label_inactive_bg);
|
||||
setColor (wc->label_inactive_fg, wc->label_inactive_bg);
|
||||
|
||||
for (std::size_t z{0}; z < label_text.getLength(); z++)
|
||||
{
|
||||
if ( (z == hotkeypos) && flags.active )
|
||||
{
|
||||
setColor (wc.label_hotkey_fg, wc.label_hotkey_bg);
|
||||
setColor (wc->label_hotkey_fg, wc->label_hotkey_bg);
|
||||
|
||||
if ( ! flags.no_underline )
|
||||
setUnderline();
|
||||
|
@ -546,13 +554,13 @@ void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos)
|
|||
if ( ! flags.no_underline )
|
||||
unsetUnderline();
|
||||
|
||||
setColor (wc.label_fg, wc.label_bg);
|
||||
setColor (wc->label_fg, wc->label_bg);
|
||||
}
|
||||
else
|
||||
print (label_text[z]);
|
||||
}
|
||||
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,15 +34,15 @@ namespace finalcut
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FToolTip::FToolTip (FWidget* parent)
|
||||
: FWindow(parent)
|
||||
: FWindow{parent}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FToolTip::FToolTip (const FString& txt, FWidget* parent)
|
||||
: FWindow(parent)
|
||||
, text(txt)
|
||||
: FWindow{parent}
|
||||
, text{txt}
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -73,6 +73,15 @@ void FToolTip::setText (const FString& txt)
|
|||
calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FToolTip::resetColors()
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->tooltip_fg);
|
||||
setBackgroundColor (wc->tooltip_bg);
|
||||
FWidget::resetColors();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FToolTip::setBorder (bool enable)
|
||||
{
|
||||
|
@ -107,9 +116,7 @@ void FToolTip::init()
|
|||
// initialize geometry values
|
||||
setGeometry (FPoint{1, 1}, FSize{3, 3}, false);
|
||||
setMinimumSize (FSize{3, 3});
|
||||
const auto& wc = getFWidgetColors();
|
||||
setForegroundColor (wc.tooltip_fg);
|
||||
setBackgroundColor (wc.tooltip_bg);
|
||||
resetColors();
|
||||
calculateDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "final/fcharmap.h"
|
||||
#include "final/fcolorpair.h"
|
||||
#include "final/fkeyboard.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/foptiattr.h"
|
||||
#include "final/foptimove.h"
|
||||
#include "final/fstyle.h"
|
||||
|
@ -122,8 +123,8 @@ void FVTerm::setTermXY (int x, int y)
|
|||
if ( term_pos->getX() == x && term_pos->getY() == y )
|
||||
return;
|
||||
|
||||
const int term_width = int(getColumnNumber());
|
||||
const int term_height = int(getLineNumber());
|
||||
const int term_width = int(FTerm::getColumnNumber());
|
||||
const int term_height = int(FTerm::getLineNumber());
|
||||
|
||||
if ( x >= term_width && term_width > 0 )
|
||||
{
|
||||
|
@ -412,7 +413,7 @@ int FVTerm::print (const std::vector<FChar>& term_string)
|
|||
int FVTerm::print (FTermArea* area, const std::vector<FChar>& term_string)
|
||||
{
|
||||
int len{0};
|
||||
const uInt tabstop = uInt(getTabstop());
|
||||
const uInt tabstop = uInt(FTerm::getTabstop());
|
||||
|
||||
if ( ! area )
|
||||
return -1;
|
||||
|
@ -446,7 +447,7 @@ int FVTerm::print (FTermArea* area, const std::vector<FChar>& term_string)
|
|||
break;
|
||||
|
||||
case '\a':
|
||||
beep();
|
||||
FTerm::beep();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -690,9 +691,9 @@ void FVTerm::createArea ( const FRect& box
|
|||
{
|
||||
area = new FTermArea;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTermArea");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1383,9 +1384,9 @@ inline bool FVTerm::reallocateTextArea ( FTermArea* area
|
|||
area->changes = new FLineChanges[height];
|
||||
area->data = new FChar[size];
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FLineChanges[height] or FChar[size]");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1404,9 +1405,9 @@ inline bool FVTerm::reallocateTextArea (FTermArea* area, std::size_t size)
|
|||
{
|
||||
area->data = new FChar[size];
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FChar[size]");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1909,9 +1910,9 @@ void FVTerm::init (bool disable_alt_screen)
|
|||
term_pos = new FPoint(-1, -1);
|
||||
output_buffer = new std::queue<int>;
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FTerm, FPoint, or std::queue<int>");
|
||||
std::abort();
|
||||
}
|
||||
|
||||
|
@ -1928,7 +1929,7 @@ void FVTerm::init (bool disable_alt_screen)
|
|||
std::memcpy (&next_attribute, &term_attribute, sizeof(next_attribute));
|
||||
|
||||
// Create virtual terminal
|
||||
FRect term_geometry {0, 0, getColumnNumber(), getLineNumber()};
|
||||
FRect term_geometry {0, 0, FTerm::getColumnNumber(), FTerm::getLineNumber()};
|
||||
createVTerm (term_geometry.getSize());
|
||||
|
||||
// Create virtual desktop area
|
||||
|
@ -2120,7 +2121,7 @@ bool FVTerm::clearTerm (int fillchar)
|
|||
{
|
||||
term_pos->setPoint(-1, -1);
|
||||
|
||||
for (int i{0}; i < int(getLineNumber()); i++)
|
||||
for (int i{0}; i < int(FTerm::getLineNumber()); i++)
|
||||
{
|
||||
setTermXY (0, i);
|
||||
appendOutputBuffer (cb);
|
||||
|
@ -2753,7 +2754,7 @@ void FVTerm::printPaddingCharacter (FTermArea* area, const FChar& term_char)
|
|||
// Copy character to padding character
|
||||
std::memcpy (&pc, &term_char, sizeof(pc));
|
||||
|
||||
if ( getEncoding() == fc::UTF8 )
|
||||
if ( FTerm::getEncoding() == fc::UTF8 )
|
||||
{
|
||||
pc.ch = 0;
|
||||
pc.attr.bit.fullwidth_padding = true;
|
||||
|
@ -2862,7 +2863,7 @@ bool FVTerm::isInsideTerminal (const FPoint& pos)
|
|||
{
|
||||
// Check whether the coordinates are within the virtual terminal
|
||||
|
||||
const FRect term_geometry {0, 0, getColumnNumber(), getLineNumber()};
|
||||
const FRect term_geometry {0, 0, FTerm::getColumnNumber(), FTerm::getLineNumber()};
|
||||
|
||||
if ( term_geometry.contains(pos) )
|
||||
return true;
|
||||
|
@ -2910,7 +2911,7 @@ inline void FVTerm::markAsPrinted (uInt from, uInt to, uInt line)
|
|||
inline void FVTerm::newFontChanges (FChar*& next_char)
|
||||
{
|
||||
// NewFont special cases
|
||||
if ( ! isNewFont() )
|
||||
if ( ! FTerm::isNewFont() )
|
||||
return;
|
||||
|
||||
if ( next_char->ch == fc::LowerHalfBlock )
|
||||
|
@ -2928,7 +2929,7 @@ inline void FVTerm::charsetChanges (FChar*& next_char)
|
|||
const wchar_t& ch = next_char->ch;
|
||||
next_char->encoded_char = ch;
|
||||
|
||||
if ( getEncoding() == fc::UTF8 )
|
||||
if ( FTerm::getEncoding() == fc::UTF8 )
|
||||
return;
|
||||
|
||||
const wchar_t ch_enc = FTerm::charEncode(ch);
|
||||
|
@ -2944,18 +2945,18 @@ inline void FVTerm::charsetChanges (FChar*& next_char)
|
|||
|
||||
next_char->encoded_char = ch_enc;
|
||||
|
||||
if ( getEncoding() == fc::VT100 )
|
||||
if ( FTerm::getEncoding() == fc::VT100 )
|
||||
next_char->attr.bit.alt_charset = true;
|
||||
else if ( getEncoding() == fc::PC )
|
||||
else if ( FTerm::getEncoding() == fc::PC )
|
||||
{
|
||||
next_char->attr.bit.pc_charset = true;
|
||||
|
||||
if ( isPuttyTerminal() )
|
||||
if ( FTerm::isPuttyTerminal() )
|
||||
return;
|
||||
|
||||
if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f
|
||||
if ( FTerm::isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f
|
||||
{
|
||||
if ( hasUTF8() )
|
||||
if ( FTerm::hasUTF8() )
|
||||
next_char->encoded_char = int(FTerm::charEncode(ch, fc::ASCII));
|
||||
else
|
||||
{
|
||||
|
@ -3027,8 +3028,8 @@ int FVTerm::appendLowerRight (FChar*& screen_char)
|
|||
const auto& ip = TCAP(fc::t_insert_padding);
|
||||
const auto& ic = TCAP(fc::t_insert_character);
|
||||
|
||||
const int x = int(getColumnNumber()) - 2;
|
||||
const int y = int(getLineNumber()) - 1;
|
||||
const int x = int(FTerm::getColumnNumber()) - 2;
|
||||
const int y = int(FTerm::getLineNumber()) - 1;
|
||||
setTermXY (x, y);
|
||||
appendChar (screen_char);
|
||||
term_pos->x_ref()++;
|
||||
|
|
103
src/fwidget.cpp
103
src/fwidget.cpp
|
@ -24,7 +24,9 @@
|
|||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fstartoptions.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fstring.h"
|
||||
#include "final/ftermdata.h"
|
||||
|
@ -47,7 +49,6 @@ FWidget::FWidgetList* FWidget::window_list{nullptr};
|
|||
FWidget::FWidgetList* FWidget::dialog_list{nullptr};
|
||||
FWidget::FWidgetList* FWidget::always_on_top_list{nullptr};
|
||||
FWidget::FWidgetList* FWidget::close_widget{nullptr};
|
||||
FWidgetColors FWidget::wcolors{};
|
||||
bool FWidget::init_desktop{false};
|
||||
bool FWidget::hideable{false};
|
||||
uInt FWidget::modal_dialog_counter{};
|
||||
|
@ -59,8 +60,8 @@ uInt FWidget::modal_dialog_counter{};
|
|||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
|
||||
: FVTerm( ! (bool(parent) || root_widget), disable_alt_screen)
|
||||
, FObject(parent)
|
||||
: FVTerm{ ! (bool(parent) || root_widget), disable_alt_screen}
|
||||
, FObject{parent}
|
||||
{
|
||||
// init bit field with 0
|
||||
memset (&flags, 0, sizeof(flags));
|
||||
|
@ -304,6 +305,42 @@ bool FWidget::setFocus (bool enable)
|
|||
return (flags.focus = enable);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::resetColors()
|
||||
{
|
||||
if ( ! hasChildren() )
|
||||
return;
|
||||
|
||||
for (auto&& child : getChildren())
|
||||
{
|
||||
if ( child->isWidget() )
|
||||
{
|
||||
auto widget = static_cast<FWidget*>(child);
|
||||
widget->resetColors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::useParentWidgetColor()
|
||||
{
|
||||
const auto& parent_widget = getParentWidget();
|
||||
|
||||
if ( parent_widget )
|
||||
{
|
||||
setForegroundColor (parent_widget->getForegroundColor());
|
||||
setBackgroundColor (parent_widget->getBackgroundColor());
|
||||
}
|
||||
else // Fallback
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setForegroundColor (wc->dialog_fg);
|
||||
setBackgroundColor (wc->dialog_bg);
|
||||
}
|
||||
|
||||
setColor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setColor()
|
||||
{
|
||||
|
@ -537,7 +574,7 @@ void FWidget::setTermSize (const FSize& size)
|
|||
{
|
||||
// Set xterm size to width x height
|
||||
|
||||
if ( isXTerminal() )
|
||||
if ( FTerm::isXTerminal() )
|
||||
{
|
||||
root_widget->wsize.setRect(FPoint{1, 1}, size);
|
||||
root_widget->adjust_wsize = root_widget->wsize;
|
||||
|
@ -938,7 +975,8 @@ void FWidget::redraw()
|
|||
{
|
||||
startTerminalUpdate();
|
||||
// clean desktop
|
||||
setColor (wcolors.term_fg, wcolors.term_bg);
|
||||
auto color_theme = getColorTheme();
|
||||
setColor (color_theme->term_fg, color_theme->term_bg);
|
||||
clearArea (getVirtualDesktop());
|
||||
}
|
||||
else if ( ! isShown() )
|
||||
|
@ -1000,7 +1038,7 @@ void FWidget::show()
|
|||
if ( ! init_desktop )
|
||||
{
|
||||
// Sets the initial screen settings
|
||||
initScreenSettings();
|
||||
FTerm::initScreenSettings();
|
||||
// Initializing vdesktop
|
||||
const auto& r = getRootWidget();
|
||||
setColor(r->getForegroundColor(), r->getBackgroundColor());
|
||||
|
@ -1369,8 +1407,9 @@ void FWidget::hideArea (const FSize& size)
|
|||
}
|
||||
else
|
||||
{
|
||||
fg = wcolors.dialog_fg;
|
||||
bg = wcolors.dialog_bg;
|
||||
auto color_theme = getColorTheme();
|
||||
fg = color_theme->dialog_fg;
|
||||
bg = color_theme->dialog_bg;
|
||||
}
|
||||
|
||||
setColor (fg, bg);
|
||||
|
@ -1514,7 +1553,7 @@ bool FWidget::focusPrevChild()
|
|||
//----------------------------------------------------------------------
|
||||
bool FWidget::event (FEvent* ev)
|
||||
{
|
||||
switch ( uInt(ev->type()) )
|
||||
switch ( uInt(ev->getType()) )
|
||||
{
|
||||
case fc::KeyPress_Event:
|
||||
KeyPressEvent (static_cast<FKeyEvent*>(ev));
|
||||
|
@ -1590,12 +1629,8 @@ bool FWidget::event (FEvent* ev)
|
|||
onClose (static_cast<FCloseEvent*>(ev));
|
||||
break;
|
||||
|
||||
case fc::Timer_Event:
|
||||
onTimer (static_cast<FTimerEvent*>(ev));
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
return FObject::event(ev);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1689,13 +1724,13 @@ void FWidget::initRootWidget()
|
|||
always_on_top_list = new FWidgetList();
|
||||
close_widget = new FWidgetList();
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FWidgetList");
|
||||
return;
|
||||
}
|
||||
|
||||
hideable = isCursorHideable();
|
||||
hideable = FTerm::isCursorHideable();
|
||||
flags.visible_cursor = ! hideable;
|
||||
|
||||
// Determine width and height of the terminal
|
||||
|
@ -1711,11 +1746,12 @@ void FWidget::initRootWidget()
|
|||
double_flatline_mask.left.resize (getHeight(), false);
|
||||
|
||||
// Initialize default widget colors
|
||||
setColorTheme();
|
||||
initColorTheme();
|
||||
|
||||
// Default foreground and background color of the desktop/terminal
|
||||
foreground_color = wcolors.term_fg;
|
||||
background_color = wcolors.term_bg;
|
||||
auto color_theme = getColorTheme();
|
||||
foreground_color = color_theme->term_fg;
|
||||
background_color = color_theme->term_bg;
|
||||
init_desktop = false;
|
||||
}
|
||||
|
||||
|
@ -1745,6 +1781,8 @@ void FWidget::finish()
|
|||
delete window_list;
|
||||
window_list = nullptr;
|
||||
}
|
||||
|
||||
destroyColorTheme();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -1987,14 +2025,31 @@ void FWidget::drawChildren()
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::setColorTheme()
|
||||
void FWidget::initColorTheme()
|
||||
{
|
||||
// Sets the default color theme
|
||||
|
||||
if ( getMaxColor() < 16 ) // for 8 color mode
|
||||
wcolors.set8ColorTheme();
|
||||
if ( FStartOptions::getFStartOptions().dark_theme )
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorDarkTheme>();
|
||||
else
|
||||
setColorTheme<default16ColorDarkTheme>();
|
||||
}
|
||||
else
|
||||
wcolors.set16ColorTheme();
|
||||
{
|
||||
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
|
||||
setColorTheme<default8ColorTheme>();
|
||||
else
|
||||
setColorTheme<default16ColorTheme>();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidget::destroyColorTheme()
|
||||
{
|
||||
const FWidgetColorsPtr* theme = &(getColorTheme());
|
||||
delete theme;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -138,11 +138,11 @@ void setHotkeyViaString (FWidget* w, const FString& text)
|
|||
//----------------------------------------------------------------------
|
||||
void drawShadow (FWidget* w)
|
||||
{
|
||||
if ( w->isMonochron() && ! w->flags.trans_shadow )
|
||||
if ( FTerm::isMonochron() && ! w->flags.trans_shadow )
|
||||
return;
|
||||
|
||||
if ( (w->getEncoding() == fc::VT100 && ! w->flags.trans_shadow)
|
||||
|| (w->getEncoding() == fc::ASCII && ! w->flags.trans_shadow) )
|
||||
if ( (FTerm::getEncoding() == fc::VT100 && ! w->flags.trans_shadow)
|
||||
|| (FTerm::getEncoding() == fc::ASCII && ! w->flags.trans_shadow) )
|
||||
{
|
||||
clearShadow(w);
|
||||
return;
|
||||
|
@ -161,12 +161,12 @@ void drawTransparentShadow (FWidget* w)
|
|||
|
||||
const std::size_t width = w->getWidth();
|
||||
const std::size_t height = w->getHeight();
|
||||
const auto& wcolors = FWidget::wcolors;
|
||||
const auto& wc = FWidget::getColorTheme();
|
||||
w->print() << FStyle {fc::Transparent}
|
||||
<< FPoint {int(width) + 1, 1}
|
||||
<< " "
|
||||
<< FStyle {fc::Reset}
|
||||
<< FColorPair {wcolors.shadow_bg, wcolors.shadow_fg}
|
||||
<< FColorPair {wc->shadow_bg, wc->shadow_fg}
|
||||
<< FStyle {fc::ColorOverlay};
|
||||
|
||||
for (std::size_t y{1}; y < height; y++)
|
||||
|
@ -178,12 +178,12 @@ void drawTransparentShadow (FWidget* w)
|
|||
<< FPoint {1, int(height) + 1}
|
||||
<< " "
|
||||
<< FStyle {fc::Reset}
|
||||
<< FColorPair {wcolors.shadow_bg, wcolors.shadow_fg}
|
||||
<< FColorPair {wc->shadow_bg, wc->shadow_fg}
|
||||
<< FStyle {fc::ColorOverlay}
|
||||
<< FString {width, L' '}
|
||||
<< FStyle {fc::Reset};
|
||||
|
||||
if ( w->isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
w->setReverse(false);
|
||||
}
|
||||
|
||||
|
@ -192,21 +192,21 @@ void drawBlockShadow (FWidget* w)
|
|||
{
|
||||
// non-transparent shadow
|
||||
|
||||
if ( ! w->hasShadowCharacter() )
|
||||
if ( ! FTerm::hasShadowCharacter() )
|
||||
return;
|
||||
|
||||
const std::size_t width = w->getWidth();
|
||||
const std::size_t height = w->getHeight();
|
||||
const auto& wcolors = FWidget::wcolors;
|
||||
const auto& wc = FWidget::getColorTheme();
|
||||
w->print() << FPoint {int(width) + 1, 1};
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
{
|
||||
w->print() << FColorPair {wcolors.shadow_fg, wcolors.shadow_bg}
|
||||
w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg}
|
||||
<< FStyle {fc::InheritBackground}; // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = w->getParentWidget() )
|
||||
w->print() << FColorPair {wcolors.shadow_fg, p->getBackgroundColor()};
|
||||
w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()};
|
||||
|
||||
w->print (fc::LowerHalfBlock); // ▄
|
||||
|
||||
|
@ -233,20 +233,20 @@ void drawBlockShadow (FWidget* w)
|
|||
//----------------------------------------------------------------------
|
||||
void clearShadow (FWidget* w)
|
||||
{
|
||||
if ( w->isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
return;
|
||||
|
||||
const std::size_t width = w->getWidth();
|
||||
const std::size_t height = w->getHeight();
|
||||
const auto& wcolors = FWidget::wcolors;
|
||||
const auto& wc = FWidget::getColorTheme();
|
||||
|
||||
if ( w->isWindowWidget() )
|
||||
{
|
||||
w->print() << FColorPair {wcolors.shadow_fg, wcolors.shadow_bg}
|
||||
w->print() << FColorPair {wc->shadow_fg, wc->shadow_bg}
|
||||
<< FStyle {fc::InheritBackground}; // current background color will be ignored
|
||||
}
|
||||
else if ( auto p = w->getParentWidget() )
|
||||
w->print() << FColorPair {wcolors.shadow_fg, p->getBackgroundColor()};
|
||||
w->print() << FColorPair {wc->shadow_fg, p->getBackgroundColor()};
|
||||
|
||||
if ( int(width) <= w->woffset.getX2() )
|
||||
{
|
||||
|
@ -270,17 +270,17 @@ void clearShadow (FWidget* w)
|
|||
//----------------------------------------------------------------------
|
||||
void drawFlatBorder (FWidget* w)
|
||||
{
|
||||
if ( ! w->isNewFont() )
|
||||
if ( ! FTerm::isNewFont() )
|
||||
return;
|
||||
|
||||
const std::size_t width = w->getWidth();
|
||||
const std::size_t height = w->getHeight();
|
||||
const auto& wcolors = FWidget::wcolors;
|
||||
const auto& wc = FWidget::getColorTheme();
|
||||
|
||||
if ( auto p = w->getParentWidget() )
|
||||
w->setColor (wcolors.dialog_fg, p->getBackgroundColor());
|
||||
w->setColor (wc->dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
w->setColor (wcolors.dialog_fg, wcolors.dialog_bg);
|
||||
w->setColor (wc->dialog_fg, wc->dialog_bg);
|
||||
|
||||
for (std::size_t y{0}; y < height; y++)
|
||||
{
|
||||
|
@ -331,17 +331,17 @@ void drawFlatBorder (FWidget* w)
|
|||
//----------------------------------------------------------------------
|
||||
void clearFlatBorder (FWidget* w)
|
||||
{
|
||||
if ( ! w->isNewFont() )
|
||||
if ( ! FTerm::isNewFont() )
|
||||
return;
|
||||
|
||||
const std::size_t width = w->getWidth();
|
||||
const std::size_t height = w->getHeight();
|
||||
const auto& wcolors = FWidget::wcolors;
|
||||
const auto& wc = FWidget::getColorTheme();
|
||||
|
||||
if ( auto p = w->getParentWidget() )
|
||||
w->setColor (wcolors.dialog_fg, p->getBackgroundColor());
|
||||
w->setColor (wc->dialog_fg, p->getBackgroundColor());
|
||||
else
|
||||
w->setColor (wcolors.dialog_fg, wcolors.dialog_bg);
|
||||
w->setColor (wc->dialog_fg, wc->dialog_bg);
|
||||
|
||||
for (std::size_t y{0}; y < height; y++)
|
||||
{
|
||||
|
@ -413,7 +413,7 @@ void drawBorder (FWidget* w, const FRect& r)
|
|||
FRect rect = r;
|
||||
checkBorder (w, rect);
|
||||
|
||||
if ( w->isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
drawNewFontBox (w, rect);
|
||||
else
|
||||
drawBox (w, rect);
|
||||
|
@ -425,7 +425,7 @@ void drawListBorder (FWidget* w, const FRect& r)
|
|||
FRect rect = r;
|
||||
checkBorder (w, rect);
|
||||
|
||||
if ( w->isNewFont() )
|
||||
if ( FTerm::isNewFont() )
|
||||
drawNewFontListBox (w, rect);
|
||||
else
|
||||
drawBox (w, rect);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2019 Markus Gans *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* *
|
||||
* The Final Cut is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Lesser General Public License *
|
||||
|
@ -31,9 +31,34 @@ namespace finalcut
|
|||
// class FWidgetColors
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FWidgetColors
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
void FWidgetColors::set8ColorTheme()
|
||||
FWidgetColors::FWidgetColors()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidgetColors::~FWidgetColors()
|
||||
{ }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default8ColorTheme
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorTheme::default8ColorTheme()
|
||||
{
|
||||
default8ColorTheme::setColorTheme();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorTheme::~default8ColorTheme()
|
||||
{ }
|
||||
|
||||
// public methods of default8ColorTheme
|
||||
//----------------------------------------------------------------------
|
||||
void default8ColorTheme::setColorTheme()
|
||||
{
|
||||
term_fg = fc::Black;
|
||||
term_bg = fc::Blue;
|
||||
|
@ -123,8 +148,25 @@ void FWidgetColors::set8ColorTheme()
|
|||
progressbar_bg = fc::LightGray;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FWidgetColors::set16ColorTheme()
|
||||
// class default16ColorTheme
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorTheme::default16ColorTheme()
|
||||
{
|
||||
default16ColorTheme::setColorTheme();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorTheme::~default16ColorTheme()
|
||||
{ }
|
||||
|
||||
// public methods of default16ColorTheme
|
||||
//----------------------------------------------------------------------
|
||||
void default16ColorTheme::setColorTheme()
|
||||
{
|
||||
term_fg = fc::Black;
|
||||
term_bg = fc::LightBlue;
|
||||
|
@ -217,4 +259,219 @@ void FWidgetColors::set16ColorTheme()
|
|||
term_bg = fc::SkyBlue2;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default8ColorDarkTheme
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorDarkTheme::default8ColorDarkTheme()
|
||||
{
|
||||
default8ColorDarkTheme::setColorTheme();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorDarkTheme::~default8ColorDarkTheme()
|
||||
{ }
|
||||
|
||||
// public methods of default8ColorDarkTheme
|
||||
//----------------------------------------------------------------------
|
||||
void default8ColorDarkTheme::setColorTheme()
|
||||
{
|
||||
term_fg = fc::LightGray;
|
||||
term_bg = fc::Cyan;
|
||||
list_fg = fc::Black;
|
||||
list_bg = fc::LightGray;
|
||||
selected_list_fg = fc::Cyan;
|
||||
selected_list_bg = fc::LightGray;
|
||||
dialog_fg = fc::Black;
|
||||
dialog_resize_fg = fc::Blue;
|
||||
dialog_emphasis_fg = fc::Blue;
|
||||
dialog_bg = fc::LightGray;
|
||||
error_box_fg = fc::LightGray;
|
||||
error_box_emphasis_fg = fc::Black;
|
||||
error_box_bg = fc::Red;
|
||||
tooltip_fg = fc::LightGray;
|
||||
tooltip_bg = fc::Black;
|
||||
shadow_fg = fc::Black;
|
||||
shadow_bg = fc::LightGray; // only for transparent shadow
|
||||
current_element_focus_fg = fc::LightGray;
|
||||
current_element_focus_bg = fc::Cyan;
|
||||
current_element_fg = fc::Black;
|
||||
current_element_bg = fc::Cyan;
|
||||
current_inc_search_element_fg = fc::Red;
|
||||
selected_current_element_focus_fg = fc::Cyan;
|
||||
selected_current_element_focus_bg = fc::Cyan;
|
||||
selected_current_element_fg = fc::Blue;
|
||||
selected_current_element_bg = fc::Cyan;
|
||||
label_fg = fc::Black;
|
||||
label_bg = fc::LightGray;
|
||||
label_inactive_fg = fc::Cyan;
|
||||
label_inactive_bg = fc::LightGray;
|
||||
label_hotkey_fg = fc::Red;
|
||||
label_hotkey_bg = fc::LightGray;
|
||||
label_emphasis_fg = fc::Blue;
|
||||
label_ellipsis_fg = fc::Cyan;
|
||||
inputfield_active_focus_fg = fc::LightGray;
|
||||
inputfield_active_focus_bg = fc::Cyan;
|
||||
inputfield_active_fg = fc::LightGray;
|
||||
inputfield_active_bg = fc::Cyan;
|
||||
inputfield_inactive_fg = fc::Cyan;
|
||||
inputfield_inactive_bg = fc::LightGray;
|
||||
toggle_button_active_focus_fg = fc::LightGray;
|
||||
toggle_button_active_focus_bg = fc::Cyan;
|
||||
toggle_button_active_fg = fc::Black;
|
||||
toggle_button_active_bg = fc::LightGray;
|
||||
toggle_button_inactive_fg = fc::Cyan;
|
||||
toggle_button_inactive_bg = fc::LightGray;
|
||||
button_active_focus_fg = fc::LightGray;
|
||||
button_active_focus_bg = fc::Cyan;
|
||||
button_active_fg = fc::LightGray;
|
||||
button_active_bg = fc::Black;
|
||||
button_inactive_fg = fc::Black;
|
||||
button_inactive_bg = fc::Cyan;
|
||||
button_hotkey_fg = fc::LightGray;
|
||||
titlebar_active_fg = fc::LightGray;
|
||||
titlebar_active_bg = fc::Black;
|
||||
titlebar_inactive_fg = fc::Black;
|
||||
titlebar_inactive_bg = fc::LightGray;
|
||||
titlebar_button_fg = fc::Black;
|
||||
titlebar_button_bg = fc::LightGray;
|
||||
titlebar_button_focus_fg = fc::LightGray;
|
||||
titlebar_button_focus_bg = fc::Black;
|
||||
menu_active_focus_fg = fc::LightGray;
|
||||
menu_active_focus_bg = fc::Blue;
|
||||
menu_active_fg = fc::LightGray;
|
||||
menu_active_bg = fc::Black;
|
||||
menu_inactive_fg = fc::LightGray;
|
||||
menu_inactive_bg = fc::Black;
|
||||
menu_hotkey_fg = fc::Red;
|
||||
menu_hotkey_bg = fc::Black;
|
||||
statusbar_fg = fc::LightGray;
|
||||
statusbar_bg = fc::Black;
|
||||
statusbar_hotkey_fg = fc::Red;
|
||||
statusbar_hotkey_bg = fc::Black;
|
||||
statusbar_separator_fg = fc::LightGray;
|
||||
statusbar_active_fg = fc::LightGray;
|
||||
statusbar_active_bg = fc::Blue;
|
||||
statusbar_active_hotkey_fg = fc::Red;
|
||||
statusbar_active_hotkey_bg = fc::Blue;
|
||||
scrollbar_fg = fc::Cyan;
|
||||
scrollbar_bg = fc::LightGray;
|
||||
scrollbar_button_fg = fc::Black;
|
||||
scrollbar_button_bg = fc::LightGray;
|
||||
scrollbar_button_inactive_fg = fc::Cyan;
|
||||
scrollbar_button_inactive_bg = fc::LightGray;
|
||||
progressbar_fg = fc::Cyan;
|
||||
progressbar_bg = fc::LightGray;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class default16ColorDarkTheme
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorDarkTheme::default16ColorDarkTheme()
|
||||
{
|
||||
default16ColorDarkTheme::setColorTheme();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorDarkTheme::~default16ColorDarkTheme()
|
||||
{ }
|
||||
|
||||
// public methods of default16ColorDarkTheme
|
||||
//----------------------------------------------------------------------
|
||||
void default16ColorDarkTheme::setColorTheme()
|
||||
{
|
||||
term_fg = fc::White;
|
||||
term_bg = fc::Cyan;
|
||||
list_fg = fc::Black;
|
||||
list_bg = fc::LightGray;
|
||||
selected_list_fg = fc::Red;
|
||||
selected_list_bg = fc::LightGray;
|
||||
dialog_fg = fc::Black;
|
||||
dialog_resize_fg = fc::LightBlue;
|
||||
dialog_emphasis_fg = fc::Blue;
|
||||
dialog_bg = fc::LightGray;
|
||||
error_box_fg = fc::White;
|
||||
error_box_emphasis_fg = fc::Yellow;
|
||||
error_box_bg = fc::Red;
|
||||
tooltip_fg = fc::White;
|
||||
tooltip_bg = fc::Black;
|
||||
shadow_fg = fc::Black;
|
||||
shadow_bg = fc::LightGray; // only for transparent shadow
|
||||
current_element_focus_fg = fc::White;
|
||||
current_element_focus_bg = fc::Cyan;
|
||||
current_element_fg = fc::LightBlue;
|
||||
current_element_bg = fc::Cyan;
|
||||
current_inc_search_element_fg = fc::LightRed;
|
||||
selected_current_element_focus_fg = fc::LightRed;
|
||||
selected_current_element_focus_bg = fc::Cyan;
|
||||
selected_current_element_fg = fc::Red;
|
||||
selected_current_element_bg = fc::Cyan;
|
||||
label_fg = fc::Black;
|
||||
label_bg = fc::LightGray;
|
||||
label_inactive_fg = fc::DarkGray;
|
||||
label_inactive_bg = fc::LightGray;
|
||||
label_hotkey_fg = fc::Red;
|
||||
label_hotkey_bg = fc::LightGray;
|
||||
label_emphasis_fg = fc::Blue;
|
||||
label_ellipsis_fg = fc::DarkGray;
|
||||
inputfield_active_focus_fg = fc::White;
|
||||
inputfield_active_focus_bg = fc::Cyan;
|
||||
inputfield_active_fg = fc::White;
|
||||
inputfield_active_bg = fc::DarkGray;
|
||||
inputfield_inactive_fg = fc::DarkGray;
|
||||
inputfield_inactive_bg = fc::LightGray;
|
||||
toggle_button_active_focus_fg = fc::White;
|
||||
toggle_button_active_focus_bg = fc::Cyan;
|
||||
toggle_button_active_fg = fc::Black;
|
||||
toggle_button_active_bg = fc::LightGray;
|
||||
toggle_button_inactive_fg = fc::DarkGray;
|
||||
toggle_button_inactive_bg = fc::LightGray;
|
||||
button_active_focus_fg = fc::LightGray;
|
||||
button_active_focus_bg = fc::Cyan;
|
||||
button_active_fg = fc::LightGray;
|
||||
button_active_bg = fc::DarkGray;
|
||||
button_inactive_fg = fc::DarkGray;
|
||||
button_inactive_bg = fc::LightBlue;
|
||||
button_hotkey_fg = fc::White;
|
||||
titlebar_active_fg = fc::White;
|
||||
titlebar_active_bg = fc::DarkGray;
|
||||
titlebar_inactive_fg = fc::DarkGray;
|
||||
titlebar_inactive_bg = fc::LightBlue;
|
||||
titlebar_button_fg = fc::DarkGray;
|
||||
titlebar_button_bg = fc::LightBlue;
|
||||
titlebar_button_focus_fg = fc::LightGray;
|
||||
titlebar_button_focus_bg = fc::Black;
|
||||
menu_active_focus_fg = fc::White;
|
||||
menu_active_focus_bg = fc::Blue;
|
||||
menu_active_fg = fc::White;
|
||||
menu_active_bg = fc::DarkGray;
|
||||
menu_inactive_fg = fc::LightGray;
|
||||
menu_inactive_bg = fc::DarkGray;
|
||||
menu_hotkey_fg = fc::LightRed;
|
||||
menu_hotkey_bg = fc::DarkGray;
|
||||
statusbar_fg = fc::White;
|
||||
statusbar_bg = fc::DarkGray;
|
||||
statusbar_hotkey_fg = fc::LightRed;
|
||||
statusbar_hotkey_bg = fc::DarkGray;
|
||||
statusbar_separator_fg = fc::LightGray;
|
||||
statusbar_active_fg = fc::White;
|
||||
statusbar_active_bg = fc::Blue;
|
||||
statusbar_active_hotkey_fg = fc::LightRed;
|
||||
statusbar_active_hotkey_bg = fc::Blue;
|
||||
scrollbar_fg = fc::DarkGray;
|
||||
scrollbar_bg = fc::LightBlue;
|
||||
scrollbar_button_fg = fc::Black;
|
||||
scrollbar_button_bg = fc::LightBlue;
|
||||
scrollbar_button_inactive_fg = fc::DarkGray;
|
||||
scrollbar_button_inactive_bg = fc::LightGray;
|
||||
progressbar_fg = fc::DarkGray;
|
||||
progressbar_bg = fc::LightBlue;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
|
|
@ -44,7 +44,7 @@ FWindow* FWindow::previous_window{nullptr};
|
|||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FWindow::FWindow(FWidget* parent)
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
setWindowWidget();
|
||||
FRect geometry {getTermGeometry()};
|
||||
|
@ -184,7 +184,7 @@ bool FWindow::setTransparentShadow (bool enable)
|
|||
//----------------------------------------------------------------------
|
||||
bool FWindow::setShadow (bool enable)
|
||||
{
|
||||
if ( isMonochron() )
|
||||
if ( FTerm::isMonochron() )
|
||||
return false;
|
||||
|
||||
if ( enable )
|
||||
|
@ -239,7 +239,7 @@ bool FWindow::isWindowHidden() const
|
|||
//----------------------------------------------------------------------
|
||||
void FWindow::drawBorder()
|
||||
{
|
||||
if ( isNewFont() ) // Draw a newfont outer frame
|
||||
if ( FTerm::isNewFont() ) // Draw a newfont outer frame
|
||||
{
|
||||
const FRect r{FPoint{1, 1}, getSize()};
|
||||
print() << r.getUpperLeftPos()
|
||||
|
@ -786,7 +786,7 @@ void FWindow::adjustSize()
|
|||
//----------------------------------------------------------------------
|
||||
bool FWindow::event (FEvent* ev)
|
||||
{
|
||||
switch ( uInt(ev->type()) )
|
||||
switch ( uInt(ev->getType()) )
|
||||
{
|
||||
case fc::WindowActive_Event:
|
||||
onWindowActive (ev);
|
||||
|
@ -882,7 +882,8 @@ void closeDropDown (FWidget* widget, const FPoint& mouse_position)
|
|||
if ( ! openmenu )
|
||||
return;
|
||||
|
||||
if ( openmenu->isInstanceOf("FMenu") )
|
||||
if ( openmenu->isInstanceOf("FMenu")
|
||||
|| openmenu->isInstanceOf("FDialogListMenu") )
|
||||
{
|
||||
bool contains_menu_structure;
|
||||
auto menu = static_cast<FMenu*>(openmenu);
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
/* Standalone class
|
||||
* ════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ emptyFString ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
#ifndef EMPTYFSTRING_H
|
||||
#define EMPTYFSTRING_H
|
||||
|
||||
|
@ -27,6 +35,8 @@
|
|||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include "final/fapplication.h"
|
||||
#include "final/flog.h"
|
||||
#include "final/fstring.h"
|
||||
|
||||
namespace finalcut
|
||||
|
@ -51,6 +61,7 @@ public:
|
|||
// Disable copy assignment operator (=)
|
||||
emptyFString& operator = (const emptyFString&) = delete;
|
||||
|
||||
static const FString getClassName();
|
||||
static bool isNull();
|
||||
static const FString& get();
|
||||
static void clear();
|
||||
|
@ -61,6 +72,10 @@ private:
|
|||
};
|
||||
|
||||
// emptyFString inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString emptyFString::getClassName()
|
||||
{ return "emptyFString"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool emptyFString::isNull()
|
||||
{
|
||||
|
@ -76,9 +91,9 @@ inline const FString& emptyFString::get()
|
|||
{
|
||||
empty_string = new FString("");
|
||||
}
|
||||
catch (const std::bad_alloc& ex)
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
std::cerr << bad_alloc_str << ex.what() << std::endl;
|
||||
badAllocOutput ("FString");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,11 +68,12 @@ namespace finalcut
|
|||
{
|
||||
|
||||
// class forward declaration
|
||||
class FEvent;
|
||||
class FAccelEvent;
|
||||
class FCloseEvent;
|
||||
class FEvent;
|
||||
class FFocusEvent;
|
||||
class FKeyEvent;
|
||||
class FLog;
|
||||
class FMouseEvent;
|
||||
class FStartOptions;
|
||||
class FTimerEvent;
|
||||
|
@ -89,6 +90,9 @@ class FObject;
|
|||
class FApplication : public FWidget
|
||||
{
|
||||
public:
|
||||
// Typedef
|
||||
typedef std::shared_ptr<FLog> FLogPtr;
|
||||
|
||||
// Constructor
|
||||
FApplication (const int&, char*[], bool = false);
|
||||
|
||||
|
@ -106,6 +110,10 @@ class FApplication : public FWidget
|
|||
int getArgc() const;
|
||||
char** getArgv() const;
|
||||
static FApplication* getApplicationObject();
|
||||
static FLogPtr& getLog();
|
||||
|
||||
// Mutator
|
||||
static void setLog (const FLogPtr&);
|
||||
|
||||
// Inquiry
|
||||
static bool isQuit();
|
||||
|
@ -118,10 +126,13 @@ class FApplication : public FWidget
|
|||
void quit();
|
||||
static bool sendEvent (FObject*, FEvent*);
|
||||
void queueEvent (FObject*, FEvent*);
|
||||
void sendQueuedEvents ();
|
||||
void sendQueuedEvents();
|
||||
bool eventInQueue();
|
||||
bool removeQueuedEvent (const FObject*);
|
||||
virtual void processExternalUserEvent();
|
||||
static FWidget* processParameters (const int&, char*[]);
|
||||
static void setDefaultTheme();
|
||||
static void setDarkTheme();
|
||||
static void showParameterUsage ()
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
__attribute__((noreturn))
|
||||
|
@ -134,13 +145,14 @@ class FApplication : public FWidget
|
|||
|
||||
private:
|
||||
// Typedefs
|
||||
typedef std::pair<FObject*, std::shared_ptr<FEvent> > eventPair;
|
||||
typedef std::deque<eventPair> FEventQueue;
|
||||
typedef std::pair<FObject*, FEvent*> EventPair;
|
||||
typedef std::deque<EventPair> FEventQueue;
|
||||
|
||||
// Methods
|
||||
void init (uInt64, uInt64);
|
||||
static void cmd_options (const int&, char*[]);
|
||||
static FStartOptions& getStartOptions();
|
||||
void destroyLog();
|
||||
void findKeyboardWidget();
|
||||
bool isKeyPressed() const;
|
||||
void keyPressed();
|
||||
|
@ -177,6 +189,7 @@ class FApplication : public FWidget
|
|||
void processMouseEvent();
|
||||
void processResizeEvent();
|
||||
void processCloseWidget();
|
||||
void processLogger();
|
||||
bool processNextEvent();
|
||||
void performTimerAction (FObject*, FEvent*) override;
|
||||
static bool isEventProcessable (const FObject*, const FEvent*);
|
||||
|
|
|
@ -88,6 +88,7 @@ class FButton : public FWidget
|
|||
void setFocusBackgroundColor (FColor);
|
||||
void setInactiveForegroundColor (FColor);
|
||||
void setInactiveBackgroundColor (FColor);
|
||||
void resetColors() override;
|
||||
bool setNoUnderline(bool);
|
||||
bool setNoUnderline();
|
||||
bool unsetNoUnderline();
|
||||
|
@ -157,13 +158,13 @@ class FButton : public FWidget
|
|||
bool click_animation{true};
|
||||
int click_time{150};
|
||||
int space_char{int(' ')};
|
||||
FColor button_fg{getFWidgetColors().button_active_fg};
|
||||
FColor button_bg{getFWidgetColors().button_active_bg};
|
||||
FColor button_hotkey_fg{getFWidgetColors().button_hotkey_fg};
|
||||
FColor button_focus_fg{getFWidgetColors().button_active_focus_fg};
|
||||
FColor button_focus_bg{getFWidgetColors().button_active_focus_bg};
|
||||
FColor button_inactive_fg{getFWidgetColors().button_inactive_fg};
|
||||
FColor button_inactive_bg{getFWidgetColors().button_inactive_bg};
|
||||
FColor button_fg{getColorTheme()->button_active_fg};
|
||||
FColor button_bg{getColorTheme()->button_active_bg};
|
||||
FColor button_hotkey_fg{getColorTheme()->button_hotkey_fg};
|
||||
FColor button_focus_fg{getColorTheme()->button_active_focus_fg};
|
||||
FColor button_focus_bg{getColorTheme()->button_active_focus_bg};
|
||||
FColor button_inactive_fg{getColorTheme()->button_inactive_fg};
|
||||
FColor button_inactive_bg{getColorTheme()->button_inactive_bg};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
std::size_t indent{0};
|
||||
std::size_t center_offset{0};
|
||||
|
|
|
@ -46,27 +46,32 @@ namespace finalcut
|
|||
// class FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class FColorPalette final
|
||||
class FColorPalette
|
||||
{
|
||||
public:
|
||||
// Typedef
|
||||
typedef std::function<void(FColor, int, int, int)> FSetPalette;
|
||||
|
||||
// Constructor
|
||||
FColorPalette() = default;
|
||||
explicit FColorPalette (const FSetPalette&);
|
||||
|
||||
// Destructor
|
||||
~FColorPalette();
|
||||
virtual ~FColorPalette();
|
||||
|
||||
// Accessor
|
||||
const FString getClassName() const;
|
||||
virtual const FString getClassName() const;
|
||||
|
||||
// Methods
|
||||
template<typename funcT>
|
||||
static void set8ColorPalette (funcT);
|
||||
template<typename funcT>
|
||||
static void set16ColorPalette (funcT);
|
||||
template<typename funcT>
|
||||
static void reset8ColorPalette (funcT);
|
||||
template<typename funcT>
|
||||
static void reset16ColorPalette (funcT);
|
||||
virtual void setColorPalette() = 0;
|
||||
virtual void resetColorPalette() = 0;
|
||||
|
||||
protected:
|
||||
void setPalette (FColor, int, int, int);
|
||||
void setVGAdefaultPalette();
|
||||
|
||||
private:
|
||||
// Data members
|
||||
FSetPalette set_palette;
|
||||
};
|
||||
|
||||
// FColorPalette inline functions
|
||||
|
@ -74,85 +79,112 @@ class FColorPalette final
|
|||
inline const FString FColorPalette::getClassName() const
|
||||
{ return "FColorPalette"; }
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
inline FColorPalette::~FColorPalette() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
template<typename funcT>
|
||||
void FColorPalette::set8ColorPalette (funcT set_palette)
|
||||
{
|
||||
set_palette (fc::Black, 0x00, 0x00, 0x00);
|
||||
set_palette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
set_palette (fc::Green, 0x18, 0x78, 0x18);
|
||||
set_palette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
set_palette (fc::Red, 0xb2, 0x18, 0x18);
|
||||
set_palette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
set_palette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
set_palette (fc::LightGray, 0xe0, 0xe0, 0xe0);
|
||||
// The same colors again...
|
||||
set_palette (fc::DarkGray, 0x00, 0x00, 0x00);
|
||||
set_palette (fc::LightBlue, 0x10, 0x3b, 0x9e);
|
||||
set_palette (fc::LightGreen, 0x18, 0x78, 0x18);
|
||||
set_palette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
set_palette (fc::LightRed, 0xb2, 0x18, 0x18);
|
||||
set_palette (fc::LightMagenta, 0xb2, 0x18, 0xb2);
|
||||
set_palette (fc::Yellow, 0xe8, 0x87, 0x1f);
|
||||
set_palette (fc::White, 0xe0, 0xe0, 0xe0);
|
||||
}
|
||||
/* Inheritance diagram
|
||||
* ═══════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ FColorPalette ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
* ▲
|
||||
* │
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ default8ColorPalette ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
template<typename funcT>
|
||||
void FColorPalette::set16ColorPalette (funcT set_palette)
|
||||
// class default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class default8ColorPalette final : public FColorPalette
|
||||
{
|
||||
set_palette (fc::Black, 0x00, 0x00, 0x00);
|
||||
set_palette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
set_palette (fc::Green, 0x18, 0x78, 0x18);
|
||||
set_palette (fc::Cyan, 0x55, 0x6a, 0xcf);
|
||||
set_palette (fc::Red, 0xba, 0x1a, 0x1a);
|
||||
set_palette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
set_palette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
set_palette (fc::LightGray, 0xbc, 0xbc, 0xbc);
|
||||
set_palette (fc::DarkGray, 0x50, 0x50, 0x50);
|
||||
set_palette (fc::LightBlue, 0x80, 0xa4, 0xec);
|
||||
set_palette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
set_palette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
set_palette (fc::LightRed, 0xee, 0x44, 0x44);
|
||||
set_palette (fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
set_palette (fc::Yellow, 0xfb, 0xe8, 0x67);
|
||||
set_palette (fc::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
public:
|
||||
// Constructor
|
||||
explicit default8ColorPalette (const FSetPalette&);
|
||||
|
||||
// Destructor
|
||||
~default8ColorPalette();
|
||||
|
||||
// Accessor
|
||||
const FString getClassName() const override;
|
||||
|
||||
// Methods
|
||||
void setColorPalette() override;
|
||||
void resetColorPalette() override;
|
||||
};
|
||||
|
||||
// default8ColorPalette inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString default8ColorPalette::getClassName() const
|
||||
{ return "default8ColorPalette"; }
|
||||
|
||||
|
||||
/* Inheritance diagram
|
||||
* ═══════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ FColorPalette ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
* ▲
|
||||
* │
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ default16ColorPalette ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
template<typename funcT>
|
||||
void FColorPalette::reset8ColorPalette (funcT set_palette)
|
||||
// class default16ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class default16ColorPalette final : public FColorPalette
|
||||
{
|
||||
reset16ColorPalette(set_palette);
|
||||
}
|
||||
public:
|
||||
// Constructor
|
||||
explicit default16ColorPalette (const FSetPalette&);
|
||||
|
||||
// Destructor
|
||||
~default16ColorPalette();
|
||||
|
||||
// Accessor
|
||||
const FString getClassName() const override;
|
||||
|
||||
// Methods
|
||||
void setColorPalette() override;
|
||||
void resetColorPalette() override;
|
||||
};
|
||||
|
||||
// default16ColorPalette inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString default16ColorPalette::getClassName() const
|
||||
{ return "default16ColorPalette"; }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
template<typename funcT>
|
||||
void FColorPalette::reset16ColorPalette (funcT set_palette)
|
||||
// class default16DarkColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class default16DarkColorPalette final : public FColorPalette
|
||||
{
|
||||
set_palette (fc::Black, 0x00, 0x00, 0x00);
|
||||
set_palette (fc::Blue, 0x00, 0x00, 0xaa);
|
||||
set_palette (fc::Green, 0x00, 0xaa, 0x00);
|
||||
set_palette (fc::Cyan, 0x00, 0x55, 0xaa);
|
||||
set_palette (fc::Red, 0xaa, 0x00, 0x00);
|
||||
set_palette (fc::Magenta, 0xaa, 0x00, 0xaa);
|
||||
set_palette (fc::Brown, 0xaa, 0xaa, 0x00);
|
||||
set_palette (fc::LightGray, 0xaa, 0xaa, 0xaa);
|
||||
set_palette (fc::DarkGray, 0x55, 0x55, 0x55);
|
||||
set_palette (fc::LightBlue, 0x55, 0x55, 0xff);
|
||||
set_palette (fc::LightGreen, 0x55, 0xff, 0x55);
|
||||
set_palette (fc::LightCyan, 0x55, 0xff, 0xff);
|
||||
set_palette (fc::LightRed, 0xff, 0x55, 0x55);
|
||||
set_palette (fc::LightMagenta, 0xff, 0x55, 0xff);
|
||||
set_palette (fc::Yellow, 0xff, 0xff, 0x55);
|
||||
set_palette (fc::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
public:
|
||||
// Constructor
|
||||
explicit default16DarkColorPalette (const FSetPalette&);
|
||||
|
||||
// Destructor
|
||||
~default16DarkColorPalette();
|
||||
|
||||
// Accessor
|
||||
const FString getClassName() const override;
|
||||
|
||||
// Methods
|
||||
void setColorPalette() override;
|
||||
void resetColorPalette() override;
|
||||
};
|
||||
|
||||
// default16ColorPalette inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString default16DarkColorPalette::getClassName() const
|
||||
{ return "default16DarkColorPalette"; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ class FDialog : public FWindow
|
|||
bool setBorder (bool);
|
||||
bool setBorder();
|
||||
bool unsetBorder();
|
||||
void resetColors() override;
|
||||
virtual void setText (const FString&);
|
||||
|
||||
// Inquiries
|
||||
|
|
|
@ -99,10 +99,18 @@ class FEvent // event base class
|
|||
public:
|
||||
FEvent() = default;
|
||||
explicit FEvent(fc::events);
|
||||
fc::events type() const;
|
||||
fc::events getType() const;
|
||||
bool isQueued() const;
|
||||
bool wasSent() const;
|
||||
|
||||
private:
|
||||
// Data members
|
||||
fc::events t{fc::None_Event};
|
||||
bool queued{false};
|
||||
bool send{false};
|
||||
|
||||
// Friend class
|
||||
friend class FApplication;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,8 @@
|
|||
#include <final/flineedit.h>
|
||||
#include <final/flistbox.h>
|
||||
#include <final/flistview.h>
|
||||
#include <final/flog.h>
|
||||
#include <final/flogger.h>
|
||||
#include <final/fmenubar.h>
|
||||
#include <final/fmenu.h>
|
||||
#include <final/fmenuitem.h>
|
||||
|
|
|
@ -145,8 +145,8 @@ class FLabel : public FWidget
|
|||
std::size_t align_offset{0};
|
||||
std::size_t hotkeypos{NOT_SET};
|
||||
std::size_t column_width{0};
|
||||
FColor emphasis_color{getFWidgetColors().label_emphasis_fg};
|
||||
FColor ellipsis_color{getFWidgetColors().label_ellipsis_fg};
|
||||
FColor emphasis_color{getColorTheme()->label_emphasis_fg};
|
||||
FColor ellipsis_color{getColorTheme()->label_ellipsis_fg};
|
||||
bool multiline{false};
|
||||
bool emphasis{false};
|
||||
bool reverse_mode{false};
|
||||
|
|
|
@ -120,6 +120,7 @@ class FLineEdit : public FWidget
|
|||
void setInputType (const inputType);
|
||||
void setLabelOrientation (const label_o);
|
||||
void setLabelAssociatedWidget (FWidget*);
|
||||
void resetColors() override;
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
void setGeometry ( const FPoint&, const FSize&
|
||||
, bool = true ) override;
|
||||
|
|
|
@ -350,7 +350,7 @@ inline FListBox::FListBox ( Iterator first
|
|||
, Iterator last
|
||||
, InsertConverter convert
|
||||
, FWidget* parent )
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
|
||||
|
@ -366,7 +366,7 @@ template <typename Container, typename LazyConverter>
|
|||
inline FListBox::FListBox ( Container container
|
||||
, LazyConverter convert
|
||||
, FWidget* parent )
|
||||
: FWidget(parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
init();
|
||||
insert (container, convert);
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
/***********************************************************************
|
||||
* flog.h - Interface of the FINAL CUT logger *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
/* Inheritance diagram
|
||||
* ═══════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ std::stringbuf ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
* ▲
|
||||
* │
|
||||
* ▕▔▔▔▔▔▔▏
|
||||
* ▕ FLog ▏
|
||||
* ▕▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
#ifndef FLOG_H
|
||||
#define FLOG_H
|
||||
|
||||
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
||||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <final/fstring.h>
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FLog
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class FLog : public std::stringbuf
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FLogPrint = std::function<void(const std::string&)>;
|
||||
using IOManip = std::ostream& (*)(std::ostream&);
|
||||
|
||||
// Enumerations
|
||||
enum LogLevel
|
||||
{
|
||||
Info, Warn, Error, Debug
|
||||
};
|
||||
|
||||
enum LineEnding
|
||||
{
|
||||
LF, CR, CRLF
|
||||
};
|
||||
|
||||
// Constructor
|
||||
FLog();
|
||||
|
||||
// Destructor
|
||||
~FLog() override;
|
||||
|
||||
template <typename T>
|
||||
FLog& operator << (const T& s);
|
||||
FLog& operator << (IOManip);
|
||||
FLog& operator << (LogLevel);
|
||||
|
||||
virtual const FString getClassName() const;
|
||||
virtual void info (const std::string&) = 0;
|
||||
virtual void warn (const std::string&) = 0;
|
||||
virtual void error (const std::string&) = 0;
|
||||
virtual void debug (const std::string&) = 0;
|
||||
virtual void setOutputStream (const std::ostream&) = 0;
|
||||
virtual void setLineEnding (LineEnding) = 0;
|
||||
virtual void enableTimestamp() = 0;
|
||||
virtual void disableTimestamp() = 0;
|
||||
|
||||
protected:
|
||||
int sync() override;
|
||||
const LogLevel& getLevel();
|
||||
LogLevel& setLevel();
|
||||
const LineEnding& getEnding();
|
||||
LineEnding& setEnding();
|
||||
|
||||
private:
|
||||
// Data member
|
||||
LogLevel level{Info};
|
||||
LineEnding end_of_line{CRLF};
|
||||
FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
|
||||
std::ostream stream{this};
|
||||
};
|
||||
|
||||
// FLog inline functions
|
||||
//----------------------------------------------------------------------
|
||||
template <typename T>
|
||||
inline FLog& FLog::operator << (const T& s)
|
||||
{
|
||||
stream << s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FLog& FLog::operator << (IOManip pf)
|
||||
{
|
||||
pf(stream);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString FLog::getClassName() const
|
||||
{ return "FLog"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FLog::LogLevel& FLog::getLevel()
|
||||
{ return level; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FLog::LogLevel& FLog::setLevel()
|
||||
{ return level; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const FLog::LineEnding& FLog::getEnding()
|
||||
{ return end_of_line; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FLog::LineEnding& FLog::setEnding()
|
||||
{ return end_of_line; }
|
||||
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // FLOG_H
|
|
@ -0,0 +1,148 @@
|
|||
/***********************************************************************
|
||||
* flogger.h - The FINAL CUT text logger *
|
||||
* *
|
||||
* This file is part of the Final Cut widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* *
|
||||
* 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/>. *
|
||||
***********************************************************************/
|
||||
|
||||
/* Inheritance diagram
|
||||
* ═══════════════════
|
||||
*
|
||||
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ std::stringbuf ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
|
||||
* ▲
|
||||
* │
|
||||
* ▕▔▔▔▔▔▔▏
|
||||
* ▕ FLog ▏
|
||||
* ▕▁▁▁▁▁▁▏
|
||||
* ▲
|
||||
* │
|
||||
* ▕▔▔▔▔▔▔▔▔▔▏
|
||||
* ▕ FLogger ▏
|
||||
* ▕▁▁▁▁▁▁▁▁▁▏
|
||||
*/
|
||||
|
||||
#ifndef FLOGGER_H
|
||||
#define FLOGGER_H
|
||||
|
||||
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
||||
#error "Only <final/final.h> can be included directly."
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
|
||||
#include "final/flog.h"
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FLogger
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
class FLogger : public FLog
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
FLogger();
|
||||
|
||||
// Destructor
|
||||
~FLogger() override;
|
||||
|
||||
// Methods
|
||||
const FString getClassName() const override;
|
||||
void info (const std::string&) override;
|
||||
void warn (const std::string&) override;
|
||||
void error (const std::string&) override;
|
||||
void debug (const std::string&) override;
|
||||
void setOutputStream (const std::ostream&) override;
|
||||
void setLineEnding (LineEnding) override;
|
||||
void enableTimestamp() override;
|
||||
void disableTimestamp() override;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void newlineReplace (std::string&, const std::string&);
|
||||
const std::string getTimeString();
|
||||
const std::string getEOL();
|
||||
void printLogLine (const std::string&);
|
||||
|
||||
// Data member
|
||||
bool timestamp{false};
|
||||
std::ostream output{std::cerr.rdbuf()};
|
||||
};
|
||||
|
||||
// FLogger inline functions
|
||||
//----------------------------------------------------------------------
|
||||
inline const FString FLogger::getClassName() const
|
||||
{ return "FLogger"; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::info (const std::string& msg)
|
||||
{
|
||||
setLevel() = Info;
|
||||
printLogLine (msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::warn (const std::string& msg)
|
||||
{
|
||||
setLevel() = Warn;
|
||||
printLogLine (msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::error (const std::string& msg)
|
||||
{
|
||||
setLevel() = Error;
|
||||
printLogLine (msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::debug (const std::string& msg)
|
||||
{
|
||||
setLevel() = Debug;
|
||||
printLogLine (msg);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::setOutputStream (const std::ostream& os)
|
||||
{ output.rdbuf(os.rdbuf()); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::setLineEnding (LineEnding eol)
|
||||
{ setEnding() = eol; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::enableTimestamp()
|
||||
{ timestamp = true; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLogger::disableTimestamp()
|
||||
{ timestamp = false; }
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // FLOGGER_H
|
|
@ -106,6 +106,7 @@ class FMenu : public FWindow, public FMenuList
|
|||
void setStatusbarMessage (const FString&) override;
|
||||
void setMenu (FMenu*);
|
||||
void setText (const FString&);
|
||||
void resetColors() override;
|
||||
|
||||
// Inquiries
|
||||
bool isSelected() const;
|
||||
|
|
|
@ -86,6 +86,7 @@ class FMenuBar : public FWindow, public FMenuList
|
|||
const FString getClassName() const override;
|
||||
|
||||
// Methods
|
||||
void resetColors() override;
|
||||
void resetMenu();
|
||||
void hide() override;
|
||||
void adjustSize() override;
|
||||
|
|
|
@ -153,7 +153,7 @@ class FMessageBox : public FDialog
|
|||
FStringList text_components{};
|
||||
FButton* button[3]{nullptr};
|
||||
std::size_t max_line_width{0};
|
||||
FColor emphasis_color{getFWidgetColors().dialog_emphasis_fg};
|
||||
FColor emphasis_color{getColorTheme()->dialog_emphasis_fg};
|
||||
int button_digit[3]{0};
|
||||
uInt num_buttons{0};
|
||||
std::size_t text_num_lines{0};
|
||||
|
@ -169,8 +169,8 @@ inline const FString FMessageBox::getClassName() const
|
|||
//----------------------------------------------------------------------
|
||||
inline const FString FMessageBox::getTitlebarText() const
|
||||
{
|
||||
const FString& tb_text = FDialog::getText(); // initialize text
|
||||
return tb_text;
|
||||
const FString& title = FDialog::getText(); // initialize text
|
||||
return title;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -228,13 +228,13 @@ int FMessageBox::error ( FWidget* parent
|
|||
, FString() << message
|
||||
, button0, button1, button2
|
||||
, parent );
|
||||
mbox.beep();
|
||||
FTerm::beep();
|
||||
mbox.setHeadline("Warning:");
|
||||
mbox.setCenterText();
|
||||
const auto& wc = mbox.getFWidgetColors();
|
||||
mbox.setForegroundColor(wc.error_box_fg);
|
||||
mbox.setBackgroundColor(wc.error_box_bg);
|
||||
mbox.emphasis_color = wc.error_box_emphasis_fg;
|
||||
const auto& wc = getColorTheme();
|
||||
mbox.setForegroundColor(wc->error_box_fg);
|
||||
mbox.setBackgroundColor(wc->error_box_bg);
|
||||
mbox.emphasis_color = wc->error_box_emphasis_fg;
|
||||
const int reply = mbox.exec();
|
||||
return reply;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue