Merge pull request #33 from gansm/master

merge
This commit is contained in:
Markus Gans 2019-02-09 13:43:15 +01:00 committed by GitHub
commit 8813290a89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
108 changed files with 3284 additions and 2307 deletions

View File

@ -1,8 +1,57 @@
2019-02-07 Markus Gans <guru.mail@muenster.de>
* Add a "dynamic layout" Chapter into the first steps document
2019-01-30 Markus Gans <guru.mail@muenster.de>
* Printing an FColorPair object can change the foreground and
background color
2019-01-27 Markus Gans <guru.mail@muenster.de>
* The print command can now have an FPoint object as a parameter
to set the cursor position
* Refactoring of the FProgressbar drawing methods
2019-01-24 Markus Gans <guru.mail@muenster.de>
* Refactoring of some methods in FVTerm and FDialog
2019-01-21 Markus Gans <guru.mail@muenster.de>
* More accurate interfaces through the strict use of FPoint()
and FSize()
2019-01-16 Markus Gans <guru.mail@muenster.de>
* New class FSize for storing dimensions
2019-01-12 Markus Gans <guru.mail@muenster.de>
* Refactoring FFileDialog::fileOpenChooser
* Refactoring FFileDialog::fileSaveChooser
* Refactoring FListBox::init()
* Refactoring FListView::init()
* Refactoring FTextView::init()
* Refactoring FTermXTerminal::resetXTermForeground()
* Refactoring FTermXTerminal::resetXTermBackground()
* Refactoring FTermXTerminal::resetXTermCursorColor()
* Refactoring FTermXTerminal::resetXTermMouseForeground()
* Refactoring FTermXTerminal::resetXTermMouseBackground()
* Refactoring FTermXTerminal::resetXTermHighlightBackground()
2019-01-11 Markus Gans <guru.mail@muenster.de>
* Generalize hide() method
2019-01-09 Markus Gans <guru.mail@muenster.de>
* Improvement in widget focusing
* Better widget visibility handling with the methods hide() and show()
2019-01-05 Markus Gans <guru.mail@muenster.de>
* Use of initializer_list for FListBox, FListView and FTextView
2019-01-04 Markus Gans <guru.mail@muenster.de>
* Use the final specifier
2019-01-03 Markus Gans <guru.mail@muenster.de> 2019-01-03 Markus Gans <guru.mail@muenster.de>
* Improved PC encoding for Cygwin and Linux * Improved PC encoding for Cygwin and Linux
* Integration of an output filter to replace missing characters * Integration of an output filter to replace missing characters
* Better Linux console support for UTF-8 encoding * Better Linux console support for UTF-8 encoding
(Default is PC charset encoding) (Default is PC charset encoding)
* Better background color for all terminals with a fixed color palette
2018-12-31 Markus Gans <guru.mail@muenster.de> 2018-12-31 Markus Gans <guru.mail@muenster.de>
* Use the override specifier * Use the override specifier

View File

@ -4,6 +4,8 @@
### Building and code analysis ### Building and code analysis
*Latest release:*<br /> *Latest release:*<br />
&#160;&#160;&#160;&#160;&#160;[![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) <br /> &#160;&#160;&#160;&#160;&#160;[![Latest Release](https://img.shields.io/github/release/gansm/finalcut.svg)](https://github.com/gansm/finalcut/releases) <br />
*License:*<br />
&#160;&#160;&#160;&#160;&#160;[![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) <br />
*Travis CI:*<br /> *Travis CI:*<br />
&#160;&#160;&#160;&#160;&#160;[![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut) <br /> &#160;&#160;&#160;&#160;&#160;[![Build Status](https://travis-ci.org/gansm/finalcut.svg?branch=master)](https://travis-ci.org/gansm/finalcut) <br />
*Coverity Scan:*<br /> *Coverity Scan:*<br />

View File

@ -59,7 +59,7 @@ case "$1" in
;; ;;
"--fulldebug"|"fulldebug") "--fulldebug"|"fulldebug")
if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy" if ! ./configure --prefix="$PREFIX" CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -Weffc++ -pedantic -pedantic-errors -Wextra -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimport -Winit-self -Winvalid-pch -Wlong-long -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpadded -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -fstack-protector -Wstrict-aliasing -Wstrict-aliasing=3 -Wswitch -Wswitch-enum -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wsign-promo -Woverloaded-virtual -Wstrict-null-sentinel -fext-numeric-literals -Wreorder -Wnoexcept -Wnarrowing -Wliteral-suffix -Wctor-dtor-privacy -ftree-loop-distribute-patterns -Wmemset-transposed-args"
then then
echo "${RED}Configure failed!${NORMAL}" 1>&2 echo "${RED}Configure failed!${NORMAL}" 1>&2
exit -1 exit -1

View File

@ -2,6 +2,22 @@
First steps with the Final Cut widget toolkit First steps with the Final Cut widget toolkit
============================================= =============================================
Table of Contents
-----------------
<!-- TOC -->
- [How to use the library](#how-to-use-the-library)
- [Memory Management](#memory-management)
- [Event Processing](#event-processing)
- [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 method](#example-of-a-callback-function)
- [Custom signals](#send-custom-signals)
- [Dynamic layout](#dynamic-layout)
<!-- /TOC -->
How to use the library How to use the library
---------------------- ----------------------
@ -20,7 +36,9 @@ int main (int argc, char* argv[])
finalcut::FApplication app(argc, argv); finalcut::FApplication app(argc, argv);
finalcut::FDialog dialog(&app); finalcut::FDialog dialog(&app);
dialog.setText ("A dialog"); dialog.setText ("A dialog");
dialog.setGeometry (25, 5, 30, 10); const finalcut::FPoint position(25, 5);
const finalcut::FSize size(30, 10);
dialog.setGeometry (position, size);
app.setMainWidget(&dialog); app.setMainWidget(&dialog);
dialog.show(); dialog.show();
return app.exec(); return app.exec();
@ -69,7 +87,9 @@ dialog.setText ("A dialog");
The title bar of the dialog box gets the text "A dialog". The title bar of the dialog box gets the text "A dialog".
```cpp ```cpp
dialog.setGeometry (25, 5, 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. The dialog window gets a width of 30 and a height of 10 characters.
The position of the window in the terminal is at x=25 and The position of the window in the terminal is at x=25 and
@ -147,11 +167,11 @@ int main (int argc, char* argv[])
// The object dialog is managed by app // The object dialog is managed by app
FDialog* dialog = new FDialog(&app); FDialog* dialog = new FDialog(&app);
dialog->setText ("Window Title"); dialog->setText ("Window Title");
dialog->setGeometry (25, 5, 40, 8); dialog->setGeometry (FPoint(25, 5), FSize(40, 8));
// The object input is managed by dialog // The object input is managed by dialog
FLineEdit* input = new FLineEdit("predefined text", dialog); FLineEdit* input = new FLineEdit("predefined text", dialog);
input->setGeometry(8, 2, 29, 1); input->setGeometry(FPoint(8, 2), FSize(29, 1));
input->setLabelText (L"&Input"); input->setLabelText (L"&Input");
// The object label is managed by dialog // The object label is managed by dialog
@ -159,7 +179,7 @@ int main (int argc, char* argv[])
"adipiscing elit, sed do eiusmod tempor " "adipiscing elit, sed do eiusmod tempor "
"incididunt ut labore et dolore magna aliqua." "incididunt ut labore et dolore magna aliqua."
, dialog ); , dialog );
label->setGeometry (2, 4, 36, 1); label->setGeometry (FPoint(2, 4), FSize(36, 1));
app.setMainWidget(dialog); app.setMainWidget(dialog);
dialog->show(); dialog->show();
return app.exec(); return app.exec();
@ -260,15 +280,15 @@ class dialogWidget : public FDialog
: FDialog(parent) : FDialog(parent)
{ {
setText ("Dialog"); setText ("Dialog");
setGeometry (25, 5, 23, 4); setGeometry (FPoint(25, 5), FSize(23, 4));
label.setGeometry (1, 1, 10, 1); label.setGeometry (FPoint(1, 1), FSize(10, 1));
label.setAlignment (fc::alignRight); label.setAlignment (fc::alignRight);
value.setGeometry (11, 1, 10, 1); value.setGeometry (FPoint(11, 1), FSize(10, 1));
id = addTimer(100); id = addTimer(100);
} }
private: private:
virtual void onTimer (FTimerEvent* ev) virtual void onTimer (FTimerEvent* ev) override
{ {
if ( id == ev->getTimerId() && n < 9999999999 ) if ( id == ev->getTimerId() && n < 9999999999 )
{ {
@ -300,7 +320,7 @@ int main (int argc, char* argv[])
After entering the source code in *timer.cpp* you can compile After entering the source code in *timer.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```cpp
g++ -O2 -std=c++11 -lfinal timer.cpp -o timer g++ -O2 -lfinal -std=c++11 timer.cpp -o timer
``` ```
@ -396,6 +416,9 @@ use `delCallbacks()` to remove all existing callbacks from an object.
<dt>FToggleButton</dt> <dt>FToggleButton</dt>
<dd>"clicked"<br />"toggled"</dd> <dd>"clicked"<br />"toggled"</dd>
<dt>FWidget</dt>
<dd>"destroy"</dd>
</dl> </dl>
&nbsp; &nbsp;
@ -423,14 +446,14 @@ int main (int argc, char* argv[])
FApplication app(argc, argv); FApplication app(argc, argv);
FDialog dialog(&app); FDialog dialog(&app);
dialog.setText ("A dialog with callback function"); dialog.setText ("A dialog with callback function");
dialog.setGeometry (25, 5, 45, 9); dialog.setGeometry (FRect(25, 5, 45, 9));
FLabel label (&dialog); FLabel label (&dialog);
label = "The button has never been pressed before"; label = "The button has never been pressed before";
label.setGeometry (2, 2, 41, 1); label.setGeometry (FPoint(2, 2), FSize(41, 1));
FButton button (&dialog); FButton button (&dialog);
// Character follows '&' will be used as the accelerator key // Character follows '&' will be used as the accelerator key
button = "&Click me"; button = "&Click me";
button.setGeometry (15, 5, 14, 1); button.setGeometry (FPoint(15, 5), FSize(14, 1));
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
button.addCallback button.addCallback
@ -472,8 +495,8 @@ class dialogWidget : public FDialog
: FDialog(parent) : FDialog(parent)
{ {
setText ("Callback method"); setText ("Callback method");
setGeometry (25, 5, 25, 7); setGeometry (FPoint(25, 5), FSize(25, 7));
button.setGeometry (7, 3, 10, 1); button.setGeometry (FPoint(7, 3), FSize(10, 1));
// Connect the button signal "clicked" with the callback method // Connect the button signal "clicked" with the callback method
button.addCallback button.addCallback
@ -504,7 +527,7 @@ int main (int argc, char* argv[])
After entering the source code in *callback-method.cpp* you can compile After entering the source code in *callback-method.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```cpp
g++ -O2 -std=c++11 -lfinal callback-method.cpp -o callback-method g++ -O2 -lfinal -std=c++11 callback-method.cpp -o callback-method
``` ```
&nbsp; &nbsp;
@ -527,13 +550,14 @@ class dialogWidget : public FDialog
explicit dialogWidget (FWidget* parent = nullptr) explicit dialogWidget (FWidget* parent = nullptr)
: FDialog(parent) : FDialog(parent)
{ {
setGeometry (25, 5, 22, 7); setGeometry (FPoint(25, 5), FSize(22, 7));
setText ("Emit signal"); setText ("Emit signal");
label.setGeometry (8, 1, 5, 1); FSize size(5, 1);
label.setGeometry (FPoint(8, 1), size);
label.setAlignment (fc::alignRight); label.setAlignment (fc::alignRight);
label.setForegroundColor (fc::Black); label.setForegroundColor (fc::Black);
plus.setGeometry (3, 3, 5, 1); plus.setGeometry (FPoint(3, 3), size);
minus.setGeometry (13, 3, 5, 1); minus.setGeometry (FPoint(13, 3), size);
plus.setNoUnderline(); plus.setNoUnderline();
minus.setNoUnderline(); minus.setNoUnderline();
@ -641,6 +665,125 @@ int main (int argc, char* argv[])
After entering the source code in *emit-signal.cpp* you can compile After entering the source code in *emit-signal.cpp* you can compile
the above program with gcc: the above program with gcc:
```cpp ```cpp
g++ -O2 -std=c++11 -lfinal emit-signal.cpp -o emit-signal g++ -O2 -lfinal -std=c++11 emit-signal.cpp -o emit-signal
``` ```
The FINAL CUT widgets emit the following default signals:
Dynamic layout
--------------
A modern terminal emulation like xterm has no fixed resolution.
They offer the possibility to change the height and width of the
terminal at any time. That triggers a resize-event that calls
the `adjustSize()` method. This method allows adapting the widget
to a changed terminal size. You can override the `adjustSize()`
method to adjust the size and position of the widget. The method
`adjustSize()` will also be called indirectly via calling methods
`setGeometry()`, `setX()`, `setY()`, `setPos()`, `setWidth()`,
`setHeight()`, `setSize()`, `setTopPadding()`, `setLeftPadding()`,
`setBottomPadding()`, `setRightPadding()`, or `setDoubleFlatLine()`.
Scalable dialogs derived from FDialog can change the dialog size by
clicking on the lower right corner of the window. You can intercept
a scaling action by overriding the `setSize()` method and adjusting
the client widgets.
**File:** *size-adjustment.cpp*
```cpp
#include <final/final.h>
using namespace finalcut;
class dialogWidget : public FDialog
{
public:
explicit dialogWidget (FWidget* parent = nullptr)
: FDialog(parent)
{
setText ("Dialog");
setResizeable();
btn.setGeometry (FPoint(1, 1), FSize(12, 1), false);
line.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));
}
private:
inline void checkMinValue (int& n)
{
if ( n < 1 ) // Checks and corrects the minimum value
n = 1;
}
void centerDialog()
{
auto x = int((getDesktopWidth() - getWidth()) / 2);
auto y = int((getDesktopHeight() - getHeight()) / 2);
checkMinValue(x);
checkMinValue(y);
setPos (FPoint(x, y), false);
}
void adjustWidgets()
{
auto bx = int(getWidth() - btn.getWidth() - 3);
auto by = int(getHeight() - 4);
btn.setPos (FPoint(bx, by), false);
line.setWidth (getWidth() - 4);
auto ly = int(getHeight() / 2) - 1;
line.setY (ly, false);
}
virtual void adjustSize() override
{
// Calling super class method adjustSize()
FDialog::adjustSize();
// Centers the dialog in the terminal
centerDialog();
}
virtual void setSize (const FSize& size, bool) override
{
// Calling super class methods setSize() + adjustSize()
FDialog::setSize (size, false);
FDialog::adjustSize();
}
virtual void draw() override
{
adjustWidgets(); // Adjust widgets before drawing
// Calling super class method draw()
FDialog::draw();
print() << FPoint (3, 3)
<< FColorPair (fc::Black, fc::White)
<< "Text on "
<< FColorPair (fc::Blue, fc::Yellow)
<< "top";
}
FLineEdit line{"Middle", this};
FButton btn{"&Bottom", this};
};
int main (int argc, char* argv[])
{
FApplication app(argc, argv);
dialogWidget dialog(&app);
app.setMainWidget(&dialog);
dialog.show();
return app.exec();
}
```
*(Note: You can close the window with the mouse,
<kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Ctrl</kbd>+<kbd>^</kbd>)*
After entering the source code in *size-adjustment.cpp* you can compile
the above program with gcc:
```cpp
g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment
```

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -30,6 +30,10 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
constexpr lDouble PI = 3.141592653589793238L; constexpr lDouble PI = 3.141592653589793238L;
@ -119,7 +123,6 @@ class Calc : public finalcut::FDialog
// Event handlers // Event handlers
virtual void onKeyPress (finalcut::FKeyEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onAccel (finalcut::FAccelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
// Callback method // Callback method
@ -250,8 +253,7 @@ Calc::Calc (FWidget* parent)
clearInfixOperator(); clearInfixOperator();
std::setlocale(LC_NUMERIC, "C"); std::setlocale(LC_NUMERIC, "C");
setText ("Calculator"); setText ("Calculator");
setGeometry (19, 6, 37, 18); setGeometry (FPoint(19, 6), FSize(37, 18));
addAccelerator('q'); // Press 'q' to quit
for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++) for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++)
{ {
@ -259,7 +261,7 @@ Calc::Calc (FWidget* parent)
button_no[key] = key; button_no[key] = key;
if ( key == Equals ) if ( key == Equals )
btn->setGeometry(30, 15, 5, 3); btn->setGeometry(FPoint(30, 15), FSize(5, 3));
else else
{ {
int x, y; int x, y;
@ -267,7 +269,7 @@ Calc::Calc (FWidget* parent)
( key <= Three ) ? n = 0 : n = 1; ( key <= Three ) ? n = 0 : n = 1;
x = int(key + n) % 5 * 7 + 2; x = int(key + n) % 5 * 7 + 2;
y = int(key + n) / 5 * 2 + 3; y = int(key + n) / 5 * 2 + 3;
btn->setGeometry(x, y, 5, 1); btn->setGeometry(FPoint(x, y), FSize(5, 1));
} }
btn->setFlat(); btn->setFlat();
@ -332,15 +334,12 @@ void Calc::drawDispay()
if ( error ) if ( error )
display = " Error "; display = " Error ";
setColor(finalcut::fc::Black, finalcut::fc::LightGray);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setPrintPos (3, 3); print() << FColorPair(finalcut::fc::Black, finalcut::fc::LightGray)
print(display); << FPoint(3, 3) << display << ' '
print(L' '); << FColorPair(wc.dialog_fg, wc.dialog_bg);
setColor(wc.dialog_fg, wc.dialog_bg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -352,13 +351,10 @@ void Calc::drawDispay()
wchar_t top_line = finalcut::fc::NF_border_line_upper; wchar_t top_line = finalcut::fc::NF_border_line_upper;
wchar_t right_line = finalcut::fc::NF_rev_border_line_right; wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
wchar_t left_line = finalcut::fc::NF_border_line_left; wchar_t left_line = finalcut::fc::NF_border_line_left;
setPrintPos (3, 2); print() << FPoint(3, 2) << finalcut::FString(33, bottom_line);
print (finalcut::FString(33, bottom_line)); print() << FPoint(2, 3) << right_line;
setPrintPos (2, 3); print() << FPoint(36, 3) << left_line;
print (right_line); print() << FPoint(3, 4);
setPrintPos (36, 3);
print (left_line);
setPrintPos (3, 4);
finalcut::FString top_bottom_line_5 (5, top_bottom_line); finalcut::FString top_bottom_line_5 (5, top_bottom_line);
finalcut::FString top_line_2 (2, top_line); finalcut::FString top_line_2 (2, top_line);
print ( top_bottom_line_5 + top_line_2 print ( top_bottom_line_5 + top_line_2
@ -375,8 +371,7 @@ void Calc::drawDispay()
finalcut::FString separator = finalcut::FString(vertical_and_right) finalcut::FString separator = finalcut::FString(vertical_and_right)
+ finalcut::FString(35, horizontal) + finalcut::FString(35, horizontal)
+ finalcut::FString(vertical_and_left); + finalcut::FString(vertical_and_left);
setPrintPos (1, 4); print() << FPoint(1, 4) << separator;
print(separator);
} }
} }
@ -1034,19 +1029,17 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
ev->accept(); ev->accept();
break; break;
case 'q':
close();
ev->accept();
break;
default: default:
finalcut::FDialog::onKeyPress(ev); finalcut::FDialog::onKeyPress(ev);
break; break;
} }
} }
//----------------------------------------------------------------------
void Calc::onAccel (finalcut::FAccelEvent* ev)
{
close();
ev->accept();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::onClose (finalcut::FCloseEvent* ev) void Calc::onClose (finalcut::FCloseEvent* ev)
{ {
@ -1088,8 +1081,8 @@ void Calc::cb_buttonClicked (finalcut::FWidget*, FDataPtr data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Calc::adjustSize() void Calc::adjustSize()
{ {
std::size_t pw = getParentWidget()->getWidth(); std::size_t pw = getDesktopWidth();
std::size_t ph = getParentWidget()->getHeight(); std::size_t ph = getDesktopHeight();
setX (1 + int(pw - getWidth()) / 2, false); setX (1 + int(pw - getWidth()) / 2, false);
setY (1 + int(ph - getHeight()) / 2, false); setY (1 + int(ph - getHeight()) / 2, false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class CheckList // class CheckList
@ -73,9 +76,10 @@ CheckList::CheckList (finalcut::FWidget* parent)
{ {
setText (L"Shopping list"); setText (L"Shopping list");
setShadow(); setShadow();
setGeometry (int(1 + (parent->getWidth() - 30) / 2), 5, 30, 13); setGeometry ( FPoint(int(1 + (parent->getWidth() - 30) / 2), 5)
, FSize(30, 13) );
listView.ignorePadding(); listView.ignorePadding();
listView.setGeometry (1, 2, getWidth(), getHeight() - 1); listView.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
// Add columns to the view // Add columns to the view
listView.addColumn ("Item"); listView.addColumn ("Item");
@ -111,7 +115,7 @@ CheckList::~CheckList() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void CheckList::populate() void CheckList::populate()
{ {
std::string list[][2] = const std::string list[][2] =
{ {
{ "Milk", "Highest" }, { "Milk", "Highest" },
{ "Cheese", "High" }, { "Cheese", "High" },

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector> #include <vector>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// Typedef // Typedef
typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr; typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr;
@ -106,11 +109,11 @@ int main (int argc, char* argv[])
std::size_t h = 13; std::size_t h = 13;
int x = int(app.getDesktopWidth() - w) / 2; int x = int(app.getDesktopWidth() - w) / 2;
int y = int(app.getDesktopHeight() - h) / 2; int y = int(app.getDesktopHeight() - h) / 2;
dgl.setGeometry (x, y, w, h); dgl.setGeometry (FPoint(x, y), FSize(w, h));
// Create a button group // Create a button group
finalcut::FButtonGroup checkButtonGroup("choice", &dgl); finalcut::FButtonGroup checkButtonGroup("choice", &dgl);
checkButtonGroup.setGeometry (2, 1, 16, 7); checkButtonGroup.setGeometry (FPoint(2, 1), FSize(16, 7));
// Create radio buttons // Create radio buttons
std::vector<FRadioButtonPtr> os(9); std::vector<FRadioButtonPtr> os(9);
@ -120,7 +123,7 @@ int main (int argc, char* argv[])
// => checkButtonGroup.setScrollSize(...) is not required // => checkButtonGroup.setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting // because a FButtonGroup is self-adjusting
for (uInt i = 0; i < os.size(); i++) for (uInt i = 0; i < os.size(); i++)
os[i]->setGeometry(1, int(1 + i), 12, 1); os[i]->setGeometry(FPoint(1, int(1 + i)), FSize(12, 1));
preset(os); preset(os);
@ -130,7 +133,7 @@ int main (int argc, char* argv[])
// Create a OK button // Create a OK button
finalcut::FButton ok("&OK", &dgl); finalcut::FButton ok("&OK", &dgl);
ok.setGeometry (10, 9, 8, 1); ok.setGeometry (FPoint(10, 9), FSize(8, 1));
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
ok.addCallback ok.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototype // function prototype
void cb_quit (finalcut::FWidget*, FDataPtr); void cb_quit (finalcut::FWidget*, FDataPtr);
@ -47,7 +50,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
finalcut::FDialog dgl(&app); finalcut::FDialog dgl(&app);
dgl.setText ("FDialog"); dgl.setText ("FDialog");
dgl.setGeometry (4, 3, 41, 11); dgl.setGeometry (FPoint(4, 3), FSize(41, 11));
// Create text labels // Create text labels
finalcut::FLabel label_1(&dgl); finalcut::FLabel label_1(&dgl);
@ -62,12 +65,12 @@ int main (int argc, char* argv[])
<< "or push the button below to exit\n" << "or push the button below to exit\n"
<< "the program."; << "the program.";
label_1.setGeometry (1, 1, 38, 2); label_1.setGeometry (FPoint(1, 1), FSize(38, 2));
label_2.setGeometry (5, 3, 34, 3); label_2.setGeometry (FPoint(5, 3), FSize(34, 3));
// Create the quit button // Create the quit button
finalcut::FButton btn("&Quit", &dgl); finalcut::FButton btn("&Quit", &dgl);
btn.setGeometry (16, 7, 9, 1); btn.setGeometry (FPoint(16, 7), FSize(9, 1));
// Connect the button signal "clicked" with the callback function // Connect the button signal "clicked" with the callback function
btn.addCallback btn.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,11 +22,14 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototypes // function prototypes
void cb_quit (finalcut::FWidget*, FDataPtr); void cb_quit (finalcut::FWidget*, FDataPtr);
void cb_publish (finalcut::FWidget*, FDataPtr); void cb_publish (finalcut::FWidget*, FDataPtr);
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// callback functions // callback functions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -48,6 +51,7 @@ void cb_publish (finalcut::FWidget* widget, FDataPtr data)
cbox2->unsetChecked(); cbox2->unsetChecked();
cbox2->setDisable(); cbox2->setDisable();
} }
cbox2->redraw(); cbox2->redraw();
} }
@ -62,7 +66,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
finalcut::FDialog dgl(&app); finalcut::FDialog dgl(&app);
dgl.setText ("Data input"); dgl.setText ("Data input");
dgl.setGeometry (4, 2, 37, 22); dgl.setGeometry (FPoint(4, 2), FSize(37, 22));
dgl.setShadow(); dgl.setShadow();
// Create input fields // Create input fields
@ -80,37 +84,37 @@ int main (int argc, char* argv[])
st_field.setLabelText (L"&State"); st_field.setLabelText (L"&State");
c_field.setLabelText (L"&Country"); c_field.setLabelText (L"&Country");
name_field.setGeometry (15, 1, 19, 1); name_field.setGeometry (FPoint(15, 1), FSize(19, 1));
email_field.setGeometry (15, 3, 19, 1); email_field.setGeometry (FPoint(15, 3), FSize(19, 1));
org_field.setGeometry (15, 5, 19, 1); org_field.setGeometry (FPoint(15, 5), FSize(19, 1));
city_field.setGeometry (15, 7, 19, 1); city_field.setGeometry (FPoint(15, 7), FSize(19, 1));
st_field.setGeometry (15, 9, 19, 1); st_field.setGeometry (FPoint(15, 9), FSize(19, 1));
c_field.setGeometry (15, 11, 4, 1); c_field.setGeometry (FPoint(15, 11), FSize(4, 1));
// Create the button group // Create the button group
finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl); finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl);
radioButtonGroup.setGeometry(2, 13, 13, 4); radioButtonGroup.setGeometry(FPoint(2, 13), FSize(13, 4));
// Create radio buttons // Create radio buttons
finalcut::FRadioButton male ("&Male", &radioButtonGroup); finalcut::FRadioButton male ("&Male", &radioButtonGroup);
finalcut::FRadioButton female ("&Female", &radioButtonGroup); finalcut::FRadioButton female ("&Female", &radioButtonGroup);
male.setGeometry (1, 1, 8, 1); male.setGeometry (FPoint(1, 1), FSize(8, 1));
female.setGeometry (1, 2, 10, 1); female.setGeometry (FPoint(1, 2), FSize(10, 1));
// Create another button group // Create another button group
finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl); finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl);
checkButtonGroup.setGeometry(16, 13, 19, 4); checkButtonGroup.setGeometry(FPoint(16, 13), FSize(19, 4));
// Create checkbox buttons // Create checkbox buttons
finalcut::FCheckBox check1 ("Save data", &checkButtonGroup); finalcut::FCheckBox check1 ("Save data", &checkButtonGroup);
finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup); finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup);
check1.setGeometry (1, 1, 13, 1); check1.setGeometry (FPoint(1, 1), FSize(13, 1));
check2.setGeometry (1, 2, 16, 1); check2.setGeometry (FPoint(1, 2), FSize(16, 1));
check2.setDisable(); check2.setDisable();
// Create a OK button // Create a OK button
finalcut::FButton btn("&OK", &dgl); finalcut::FButton btn("&OK", &dgl);
btn.setGeometry (24, 18, 10, 1); btn.setGeometry (FPoint(24, 18), FSize(10, 1));
// Connect checkbox signal "clicked" with a callback function // Connect checkbox signal "clicked" with a callback function
check1.addCallback check1.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -65,7 +65,8 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
if ( is_last_line ) if ( is_last_line )
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
, true, vdesktop );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -78,11 +79,11 @@ void Keyboard::onAccel (finalcut::FAccelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Keyboard::draw() void Keyboard::draw()
{ {
setPrintPos (1, 1); print() << finalcut::FPoint(1, 1)
print() << "---------------\n" << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";
setAreaCursor (1, 4, true, vdesktop); setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -28,6 +28,8 @@
#include <final/final.h> #include <final/final.h>
using namespace finalcut; using namespace finalcut;
using finalcut::FPoint;
using finalcut::FSize;
// Global application object // Global application object
static std::weak_ptr<FString> temp_str; static std::weak_ptr<FString> temp_str;
@ -113,7 +115,7 @@ Listbox::Listbox (FWidget* parent)
// listbox 1 // listbox 1
//---------- //----------
list1.setGeometry(2, 1, 18, 10); list1.setGeometry(FPoint(2, 1), FSize(18, 10));
list1.setText ("FListBoxItem"); list1.setText ("FListBoxItem");
for (int i = 1; i < 30; i++) for (int i = 1; i < 30; i++)
@ -124,7 +126,7 @@ Listbox::Listbox (FWidget* parent)
for (double i = 1; i<=15; i++) for (double i = 1; i<=15; i++)
double_list.push_back(2 * i + (i / 100)); double_list.push_back(2 * i + (i / 100));
list2.setGeometry(21, 1, 10, 10); list2.setGeometry(FPoint(21, 1), FSize(10, 10));
list2.setText ("double"); list2.setText ("double");
// //
@ -147,11 +149,11 @@ Listbox::Listbox (FWidget* parent)
TLD["gov"] = "Government"; TLD["gov"] = "Government";
list3.insert (TLD.begin(), TLD.end(), mapToString); list3.insert (TLD.begin(), TLD.end(), mapToString);
list3.setGeometry(32, 1, 21, 10); list3.setGeometry(FPoint(32, 1), FSize(21, 10));
list3.setText ("key: value"); list3.setText ("key: value");
// Quit button // Quit button
Quit.setGeometry(42, 12, 10, 1); Quit.setGeometry(FPoint(42, 12), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add quit button function callback // Add quit button function callback
@ -185,7 +187,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Listbox d(&app); Listbox d(&app);
d.setText (L"Listbox"); d.setText (L"Listbox");
d.setGeometry (int(1 + (app.getWidth() - 56) / 2), 5, 56, 16); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 56) / 2), 5)
, FSize(56, 16) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Listview // class Listview
@ -71,7 +74,7 @@ Listview::Listview (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
// Set FListView geometry // Set FListView geometry
listView.setGeometry(2, 1, 33, 14); listView.setGeometry(FPoint(2, 1), FSize(33, 14));
// Add columns to the view // Add columns to the view
listView.addColumn ("City"); listView.addColumn ("City");
@ -104,7 +107,7 @@ Listview::Listview (finalcut::FWidget* parent)
populate(); populate();
// Quit button // Quit button
Quit.setGeometry(24, 16, 10, 1); Quit.setGeometry(FPoint(24, 16), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add some function callbacks // Add some function callbacks
@ -128,7 +131,7 @@ Listview::~Listview() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Listview::populate() void Listview::populate()
{ {
std::string weather[][5] = const std::string weather[][5] =
{ {
{ "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" }, { "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" },
{ "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" }, { "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" },
@ -214,7 +217,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Listview d(&app); Listview d(&app);
d.setText (L"Weather data"); d.setText (L"Weather data");
d.setGeometry (int(1 + (app.getWidth() - 37) / 2), 3, 37, 20); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 37) / 2), 3)
, FSize(37, 20) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Mandelbrot // class Mandelbrot
@ -40,7 +43,7 @@ class Mandelbrot : public finalcut::FDialog
~Mandelbrot(); ~Mandelbrot();
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
private: private:
@ -89,7 +92,7 @@ void Mandelbrot::draw()
for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY) for (y0 = y_min; y0 < y_max && current_line < Lines; y0 += dY)
{ {
current_line++; current_line++;
setPrintPos (xoffset, yoffset + current_line); print() << FPoint(xoffset, yoffset + current_line);
for (x0 = x_min; x0 < x_max; x0 += dX) for (x0 = x_min; x0 < x_max; x0 += dX)
{ {
@ -116,10 +119,18 @@ void Mandelbrot::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Mandelbrot::onAccel (finalcut::FAccelEvent* ev) void Mandelbrot::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -131,9 +142,9 @@ void Mandelbrot::onClose (finalcut::FCloseEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Mandelbrot::adjustSize() void Mandelbrot::adjustSize()
{ {
std::size_t h = getParentWidget()->getHeight() - 1; std::size_t h = getDesktopHeight() - 1;
std::size_t w = getParentWidget()->getWidth() - 10; std::size_t w = getDesktopWidth() - 10;
setGeometry(6, 1, w, h, false); setGeometry(FPoint(6, 1), FSize(w, h), false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -147,8 +158,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
Mandelbrot mb(&app); Mandelbrot mb(&app);
mb.setGeometry (6, 1, 70, 23); mb.setGeometry (FPoint(6, 1), FSize(70, 23));
mb.addAccelerator('q'); // press 'q' to quit
mb.setShadow(); mb.setShadow();
// Set the mandelbrot object as main widget // Set the mandelbrot object as main widget

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Menu // class Menu
@ -140,19 +143,19 @@ Menu::Menu (finalcut::FWidget* parent)
// Headline labels // Headline labels
Headline1 << " Key "; Headline1 << " Key ";
Headline1.ignorePadding(); Headline1.ignorePadding();
Headline1.setGeometry(3, 2, 5, 1); Headline1.setGeometry(FPoint(3, 2), FSize(5, 1));
Headline1.setEmphasis(); Headline1.setEmphasis();
Headline2 << " Function "; Headline2 << " Function ";
Headline2.ignorePadding(); Headline2.ignorePadding();
Headline2.setGeometry(19, 2, 10, 1); Headline2.setGeometry(FPoint(19, 2), FSize(10, 1));
Headline2.setEmphasis(); Headline2.setEmphasis();
// Info label // Info label
Info << "<F10> Activate menu bar\n" Info << "<F10> Activate menu bar\n"
<< "<Ctrl>+<Space> Activate menu bar\n" << "<Ctrl>+<Space> Activate menu bar\n"
<< "<Meta>+<X> Exit"; << "<Meta>+<X> Exit";
Info.setGeometry(2, 1, 36, 3); Info.setGeometry(FPoint(2, 1), FSize(36, 3));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -288,8 +291,8 @@ void Menu::defaultCallback (finalcut::FMenuList* mb)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Menu::adjustSize() void Menu::adjustSize()
{ {
int pw = int(getParentWidget()->getWidth()); int pw = int(getDesktopWidth());
int ph = int(getParentWidget()->getHeight()); int ph = int(getDesktopHeight());
setX (1 + (pw - int(getWidth())) / 2, false); setX (1 + (pw - int(getWidth())) / 2, false);
setY (1 + (ph - int(getHeight())) / 4, false); setY (1 + (ph - int(getHeight())) / 4, false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
@ -325,7 +328,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Menu main_dlg (&app); Menu main_dlg (&app);
main_dlg.setText ("Menu example"); main_dlg.setText ("Menu example");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry ( FPoint(int(1 + (app.getWidth() - 40) / 2), 2)
, FSize(40, 6) );
main_dlg.setShadow(); main_dlg.setShadow();
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget

View File

@ -22,6 +22,10 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class ColorChooser // class ColorChooser
@ -67,8 +71,8 @@ class ColorChooser : public finalcut::FWidget
ColorChooser::ColorChooser (finalcut::FWidget* parent) ColorChooser::ColorChooser (finalcut::FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
setSize (8, 12); setSize (FSize(8, 12));
setFixedSize (8, 12); setFixedSize (FSize(8, 12));
unsetFocusable(); unsetFocusable();
if ( parent ) if ( parent )
@ -82,7 +86,7 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
} }
// Text label // Text label
headline.setGeometry (1, 1, 8, 1); headline.setGeometry (FPoint(1, 1), FSize(8, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline << "Color"; headline << "Color";
@ -128,7 +132,7 @@ void ColorChooser::draw()
for (FColor c = 0; c < 16; c++) for (FColor c = 0; c < 16; c++)
{ {
setPrintPos (2 + (c / 8) * 3, 3 + c % 8); print() << FPoint(2 + (c / 8) * 3, 3 + c % 8);
if ( c < 6 ) if ( c < 6 )
setColor (finalcut::fc::LightGray, c); setColor (finalcut::fc::LightGray, c);
@ -139,9 +143,7 @@ void ColorChooser::draw()
if ( c == bg_color ) if ( c == bg_color )
{ {
print (' '); print() << ' ' << finalcut::fc::Times << ' ';
print (finalcut::fc::Times);
print (' ');
} }
else else
print (" "); print (" ");
@ -209,8 +211,8 @@ class Brushes : public finalcut::FWidget
Brushes::Brushes (finalcut::FWidget* parent) Brushes::Brushes (finalcut::FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
setSize (8, 4); setSize (FSize(8, 4));
setFixedSize (8, 4); setFixedSize (FSize(8, 4));
unsetFocusable(); unsetFocusable();
if ( parent ) if ( parent )
@ -224,7 +226,7 @@ Brushes::Brushes (finalcut::FWidget* parent)
} }
// Text label // Text label
headline.setGeometry(1, 1, 8, 1); headline.setGeometry(FPoint(1, 1), FSize(8, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline << "Brush"; headline << "Brush";
@ -241,10 +243,9 @@ void Brushes::draw()
int pos; int pos;
setColor(); setColor();
finalcut::FWidget::drawBorder (1, 2, 8, 4); finalcut::FWidget::drawBorder (1, 2, 8, 4);
setColor (fg_color, bg_color); print() << FPoint(2, 3)
setPrintPos (2, 3); << FColorPair(fg_color, bg_color) << " "
print(" "); << finalcut::FString(3, finalcut::fc::MediumShade);
print(finalcut::FString(3, finalcut::fc::MediumShade));
if ( brush == L' ' ) if ( brush == L' ' )
pos = 0; pos = 0;
@ -252,10 +253,10 @@ void Brushes::draw()
pos = 3; pos = 3;
setColor(); setColor();
setPrintPos (3 + pos, 2); print() << FPoint(3 + pos, 2)
print(finalcut::fc::BlackDownPointingTriangle); << finalcut::fc::BlackDownPointingTriangle
setPrintPos (3 + pos, 4); << FPoint(3 + pos, 4)
print(finalcut::fc::BlackUpPointingTriangle); << finalcut::fc::BlackUpPointingTriangle;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -324,10 +325,10 @@ class MouseDraw : public finalcut::FDialog
MouseDraw& operator = (const MouseDraw&) = delete; MouseDraw& operator = (const MouseDraw&) = delete;
// Methods // Methods
void setGeometry (int, int, std::size_t, std::size_t, bool = true) override; void setGeometry (const FPoint&, const FSize&, bool = true) override;
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
private: private:
@ -356,16 +357,16 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setText ("Drawing with the mouse"); setText ("Drawing with the mouse");
c_chooser.setPos (1, 1); c_chooser.setPos (FPoint(1, 1));
c_chooser.addCallback c_chooser.addCallback
( (
"clicked", "clicked",
F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged) F_METHOD_CALLBACK (this, &MouseDraw::cb_colorChanged)
); );
brush.setPos (1, 12); brush.setPos (FPoint(1, 12));
finalcut::FPoint no_shadow(0, 0); FSize no_shadow(0, 0);
finalcut::FRect scroll_geometry(0, 0, 1, 1); finalcut::FRect scroll_geometry(0, 0, 1, 1);
createArea (scroll_geometry, no_shadow, canvas); createArea (scroll_geometry, no_shadow, canvas);
} }
@ -375,16 +376,15 @@ MouseDraw::~MouseDraw()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::setGeometry ( int x, int y void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
int old_w, old_h; finalcut::FDialog::setGeometry (p, s, adjust);
finalcut::FDialog::setGeometry (x, y, w, h, adjust); std::size_t w = s.getWidth();
finalcut::FPoint no_shadow(0, 0); std::size_t h = s.getHeight();
finalcut::FRect scroll_geometry (0, 0, w - 11, h - 3); finalcut::FRect scroll_geometry (FPoint(0, 0), FSize(w - 11, h - 3));
old_w = canvas->width; FSize no_shadow(0, 0);
old_h = canvas->height; int old_w = canvas->width;
int old_h = canvas->height;
resizeArea (scroll_geometry, no_shadow, canvas); resizeArea (scroll_geometry, no_shadow, canvas);
if ( old_w != canvas->width || old_h != canvas->height ) if ( old_w != canvas->width || old_h != canvas->height )
@ -395,10 +395,18 @@ void MouseDraw::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::onAccel (finalcut::FAccelEvent* ev) void MouseDraw::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -418,26 +426,25 @@ void MouseDraw::draw()
{ {
for (int y = 2; y < y_max; y++) for (int y = 2; y < y_max; y++)
{ {
setPrintPos (10, y); print() << FPoint(10, y)
print (finalcut::fc::NF_rev_border_line_right); << finalcut::fc::NF_rev_border_line_right;
} }
setPrintPos (10, y_max); print() << FPoint(10, y_max)
print (finalcut::fc::NF_rev_border_corner_lower_right); << finalcut::fc::NF_rev_border_corner_lower_right;
} }
else else
{ {
setPrintPos (10, 2); print() << FPoint(10, 2)
print (finalcut::fc::BoxDrawingsDownAndHorizontal); << finalcut::fc::BoxDrawingsDownAndHorizontal;
for (int y = 3; y < y_max; y++) for (int y = 3; y < y_max; y++)
{ {
setPrintPos (10, y); print() << FPoint(10, y) << finalcut::fc::BoxDrawingsVertical;
print (finalcut::fc::BoxDrawingsVertical);
} }
setPrintPos (10, y_max); print() << FPoint(10, y_max)
print (finalcut::fc::BoxDrawingsUpAndHorizontal); << finalcut::fc::BoxDrawingsUpAndHorizontal;
} }
drawCanvas(); drawCanvas();
@ -505,7 +512,7 @@ void MouseDraw::adjustSize()
std::size_t w = 60, h = 18; std::size_t w = 60, h = 18;
int x = 1 + int((getParentWidget()->getWidth() - w) / 2); int x = 1 + int((getParentWidget()->getWidth() - w) / 2);
int y = 1 + int((getParentWidget()->getHeight() - h) / 2); int y = 1 + int((getParentWidget()->getHeight() - h) / 2);
setGeometry (x, y, w, h, false); setGeometry (FPoint(x, y), FSize(w, h), false);
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -556,8 +563,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box // Create a simple dialog box
MouseDraw mouse_draw(&app); MouseDraw mouse_draw(&app);
mouse_draw.setGeometry (12, 4, 60, 18); mouse_draw.setGeometry (FPoint(12, 4), FSize(60, 18));
mouse_draw.addAccelerator('q'); // press 'q' to quit
// Set dialog object mouse_draw as main widget // Set dialog object mouse_draw as main widget
app.setMainWidget(&mouse_draw); app.setMainWidget(&mouse_draw);

View File

@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Scrollview // class Scrollview
@ -46,7 +49,7 @@ class Scrollview : public finalcut::FScrollView
Scrollview& operator = (const Scrollview&) = delete; Scrollview& operator = (const Scrollview&) = delete;
// Mutator // Mutator
void setScrollSize (std::size_t, std::size_t) override; void setScrollSize (const FSize&) override;
private: private:
// Method // Method
@ -75,11 +78,14 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
: finalcut::FScrollView(parent) : finalcut::FScrollView(parent)
{ {
// Sets the navigation button geometry // Sets the navigation button geometry
go_east.setGeometry (1, 1, 5, 1); go_east.setGeometry (FPoint(1, 1), FSize(5, 1));
go_south.setGeometry (int(getScrollWidth()) - 5, 1, 5, 1); go_south.setGeometry ( FPoint(int(getScrollWidth()) - 5, 1)
go_west.setGeometry ( int(getScrollWidth()) - 5 , FSize(5, 1) );
, int(getScrollHeight()) - 2, 5, 1); go_west.setGeometry ( FPoint( int(getScrollWidth()) - 5
go_north.setGeometry (1, int(getScrollHeight()) - 2, 5, 1); , int(getScrollHeight()) - 2 )
, FSize(5, 1) );
go_north.setGeometry ( FPoint(1, int(getScrollHeight()) - 2)
, FSize(5, 1) );
// Add scroll function callbacks to the buttons // Add scroll function callbacks to the buttons
go_east.addCallback go_east.addCallback
@ -112,12 +118,14 @@ Scrollview::~Scrollview()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Scrollview::setScrollSize (std::size_t width, std::size_t height) void Scrollview::setScrollSize (const FSize& size)
{ {
FScrollView::setScrollSize (width, height); FScrollView::setScrollSize (size);
go_south.setPos (int(width) - 5, 1); auto width = int(size.getWidth());
go_west.setPos (int(width) - 5, int(height) - 1); auto height = int(size.getHeight());
go_north.setPos (1, int(height) - 1); go_south.setPos (FPoint(width - 5, 1));
go_west.setPos (FPoint(width - 5, height - 1));
go_north.setPos (FPoint(1, height - 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -131,7 +139,7 @@ void Scrollview::draw()
for (int y = 0; y < int(getScrollHeight()); y++) for (int y = 0; y < int(getScrollHeight()); y++)
{ {
setPrintPos (1, 1 + y); print() << FPoint(1, 1 + y);
for (int x = 0; x < int(getScrollWidth()); x++) for (int x = 0; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f)); print (32 + ((x + y) % 0x5f));
@ -214,15 +222,15 @@ class Scrollviewdemo : public finalcut::FDialog
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent) Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setGeometry (16, 3, 50, 19); setGeometry (FPoint(16, 3), FSize(50, 19));
setText ("Scrolling viewport example"); setText ("Scrolling viewport example");
// The scrolling viewport widget // The scrolling viewport widget
sview.setGeometry(3, 2, 44, 12); sview.setGeometry(FPoint(3, 2), FSize(44, 12));
sview.setScrollSize(188, 124); sview.setScrollSize(FSize(188, 124));
// Quit button // Quit button
quit_btn.setGeometry(37, 15, 10, 1); quit_btn.setGeometry(FPoint(37, 15), FSize(10, 1));
// Add function callback // Add function callback
quit_btn.addCallback quit_btn.addCallback
@ -232,7 +240,7 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
); );
// Text label // Text label
label.setGeometry(2, 1, 46, 1); label.setGeometry(FPoint(2, 1), FSize(46, 1));
label.setEmphasis(); label.setEmphasis();
label << L"Use scrollbars to change the viewport position"; label << L"Use scrollbars to change the viewport position";
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,10 @@
#include <functional> #include <functional>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class AttribDlg // class AttribDlg
@ -47,7 +51,7 @@ class AttribDlg : public finalcut::FDialog
AttribDlg& operator = (const AttribDlg&) = delete; AttribDlg& operator = (const AttribDlg&) = delete;
// Event handlers // Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override; virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onWheel (finalcut::FWheelEvent*) override; virtual void onWheel (finalcut::FWheelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override; virtual void onClose (finalcut::FCloseEvent*) override;
@ -77,10 +81,12 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
+ finalcut::FString(getTermType()) + finalcut::FString(getTermType())
+ ")"); + ")");
next_button.setGeometry(int(getWidth()) - 13, int(getHeight()) - 4, 10, 1); next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
next_button.addAccelerator(finalcut::fc::Fkey_right); , FSize(10, 1) );
back_button.setGeometry(int(getWidth()) - 25, int(getHeight()) - 4, 10, 1); next_button.addAccelerator (finalcut::fc::Fkey_right);
back_button.addAccelerator(finalcut::fc::Fkey_left); back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, FSize(10, 1) );
back_button.addAccelerator (finalcut::fc::Fkey_left);
// Add function callbacks // Add function callbacks
next_button.addCallback next_button.addCallback
@ -101,10 +107,18 @@ AttribDlg::~AttribDlg()
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::onAccel (finalcut::FAccelEvent* ev) void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
{ {
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close(); close();
ev->accept(); ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -159,8 +173,8 @@ void AttribDlg::cb_back (finalcut::FWidget*, FDataPtr)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDlg::adjustSize() void AttribDlg::adjustSize()
{ {
int x = int((getParentWidget()->getWidth() - getWidth()) / 2); int x = int((getDesktopWidth() - getWidth()) / 2);
int y = int((getParentWidget()->getHeight() - getHeight()) / 2) + 1; int y = int((getDesktopHeight() - getHeight()) / 2) + 1;
if ( x < 1 ) if ( x < 1 )
x = 1; x = 1;
@ -168,11 +182,11 @@ void AttribDlg::adjustSize()
if ( y < 1 ) if ( y < 1 )
y = 1; y = 1;
setGeometry(x, y, 69, 21, false); setGeometry(FPoint(x, y), FSize(69, 21), false);
next_button.setGeometry ( int(getWidth()) - 13, int(getHeight()) - 4 next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
, 10, 1, false ); , FSize(10, 1), false );
back_button.setGeometry ( int(getWidth()) - 25, int(getHeight()) - 4 back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, 10, 1, false ); , FSize(10, 1), false );
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
@ -247,8 +261,7 @@ void AttribDemo::printColorLine()
for (FColor color = 0; color < colors; color++) for (FColor color = 0; color < colors; color++)
{ {
setColor (color, parent->bgcolor); print() << FColorPair(color, parent->bgcolor) << " # ";
print (" # ");
} }
} }
@ -260,8 +273,7 @@ void AttribDemo::printAltCharset()
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
setPrintPos (1, 1); print() << FPoint(1, 1) << "alternate charset: ";
print("alternate charset: ");
if ( parent->bgcolor == finalcut::fc::Default ) if ( parent->bgcolor == finalcut::fc::Default )
{ {
@ -427,7 +439,7 @@ void AttribDemo::draw()
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++) for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
{ {
setPrintPos (1, 2 + int(y)); print() << FPoint(1, 2 + int(y));
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg); setColor (wc.label_fg, wc.label_bg);
@ -439,7 +451,7 @@ void AttribDemo::draw()
if ( ! isMonochron() ) if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg); setColor(wc.label_fg, wc.label_bg);
setPrintPos (1, 15); print() << FPoint(1, 15);
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor; FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:"); print (" Background color:");
@ -448,8 +460,7 @@ void AttribDemo::draw()
else else
printf ( " %d", bg); printf ( " %d", bg);
setPrintPos (16, 17); print() << FPoint(16, 17) << "Change background color ->";
print ("Change background color ->");
} }
@ -466,13 +477,12 @@ int main (int argc, char* argv[])
// the parent object "app" (FObject destructor). // the parent object "app" (FObject destructor).
AttribDlg dialog(&app); AttribDlg dialog(&app);
dialog.setGeometry (6, 2, 69, 21); dialog.setGeometry (FPoint(6, 2), FSize(69, 21));
dialog.addAccelerator('q'); // press 'q' to quit
dialog.setShadow(); dialog.setShadow();
// Create the attribute demo widget as a child object from the dialog // Create the attribute demo widget as a child object from the dialog
AttribDemo demo(&dialog); AttribDemo demo(&dialog);
demo.setGeometry (1, 1, 67, 19); demo.setGeometry (FPoint(1, 1), FSize(67, 19));
// Set the dialog object as main widget // Set the dialog object as main widget
app.setMainWidget(&dialog); app.setMainWidget(&dialog);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -59,11 +59,11 @@ Timer::Timer (finalcut::FWidget* parent)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Timer::draw() void Timer::draw()
{ {
setPrintPos (1, 1); print() << finalcut::FPoint(1, 1)
print() << "---------------\n" << "---------------\n"
<< "Press Q to quit\n" << "Press Q to quit\n"
<< "---------------\n"; << "---------------\n";
setAreaCursor (1, 4, true, vdesktop); setAreaCursor (finalcut::FPoint(1, 4), true, vdesktop);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -75,13 +75,14 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
if ( getPrintPos().getY() == int(getDesktopHeight()) ) if ( getPrintPos().getY() == int(getDesktopHeight()) )
is_last_line = true; is_last_line = true;
setColor (FColor(1 + timer_id), finalcut::fc::Default); print() << finalcut::FColorPair (FColor(1 + timer_id))
print() << "Timer event, id " << timer_id << '\n'; << "Timer event, id " << timer_id << '\n';
if ( is_last_line ) if ( is_last_line )
scrollAreaForward (vdesktop); scrollAreaForward (vdesktop);
setAreaCursor (1, getPrintPos().getY(), true, vdesktop); setAreaCursor ( finalcut::FPoint(1, getPrintPos().getY())
, true, vdesktop );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Transparent // class Transparent
@ -108,8 +111,7 @@ void Transparent::draw()
for (int n = 1; n <= int(getClientHeight()); n++) for (int n = 1; n <= int(getClientHeight()); n++)
{ {
setPrintPos (2, 2 + n); print() << FPoint(2, 2 + n) << line;
print(line);
} }
if ( type == shadow ) if ( type == shadow )
@ -131,10 +133,8 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
if ( ev->key() == 'q' && getParentWidget() ) if ( ev->key() == 'q' && getParentWidget() )
{ {
if ( getParentWidget()->close() ) getParentWidget()->close();
ev->accept(); ev->accept();
else
ev->ignore();
} }
else else
finalcut::FDialog::onKeyPress(ev); finalcut::FDialog::onKeyPress(ev);
@ -208,23 +208,22 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
// is not required in this class and would result in a double free. // is not required in this class and would result in a double free.
transpwin = new Transparent(this); transpwin = new Transparent(this);
transpwin->setText("transparent"); transpwin->setText("transparent");
transpwin->setGeometry (6, 3, 29, 12); transpwin->setGeometry (FPoint(6, 3), FSize(29, 12));
transpwin->unsetTransparentShadow(); transpwin->unsetTransparentShadow();
shadowwin = new Transparent(this, Transparent::shadow); shadowwin = new Transparent(this, Transparent::shadow);
shadowwin->setText("shadow"); shadowwin->setText("shadow");
shadowwin->setGeometry (46, 11, 29, 12); shadowwin->setGeometry (FPoint(46, 11), FSize(29, 12));
shadowwin->unsetTransparentShadow(); shadowwin->unsetTransparentShadow();
ibg = new Transparent(this, Transparent::inherit_background); ibg = new Transparent(this, Transparent::inherit_background);
ibg->setText("inherit background"); ibg->setText("inherit background");
ibg->setGeometry (42, 3, 29, 7); ibg->setGeometry (FPoint(42, 3), FSize(29, 7));
ibg->unsetTransparentShadow(); ibg->unsetTransparentShadow();
// Statusbar at the bottom // Statusbar at the bottom
status_bar.setMessage("Press Q to quit"); status_bar.setMessage("Press Q to quit");
addAccelerator('q');
unsetTransparentShadow(); unsetTransparentShadow();
activateDialog(); activateDialog();
} }
@ -242,10 +241,8 @@ void MainWindow::draw()
setReverse(true); setReverse(true);
setColor(); setColor();
setPrintPos (2, 4); print() << FPoint(2, 4) << line1;
print(line1); print() << FPoint(2, 5) << line2;
setPrintPos (2, 5);
print(line2);
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -290,7 +287,7 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
MainWindow main_dlg (&app); MainWindow main_dlg (&app);
main_dlg.setText ("non-transparent"); main_dlg.setText ("non-transparent");
main_dlg.setGeometry (8, 16, 26, 7); main_dlg.setGeometry (FPoint(8, 16), FSize(26, 7));
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);

View File

@ -27,6 +27,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// Function prototypes // Function prototypes
sInt64 StringToNumber (const finalcut::FString&); sInt64 StringToNumber (const finalcut::FString&);
@ -303,7 +306,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
// Set FListView geometry // Set FListView geometry
listView.setGeometry(2, 1, 53, 14); listView.setGeometry(FPoint(2, 1), FSize(53, 14));
// Add columns to the view // Add columns to the view
listView.addColumn ("Name", 23); listView.addColumn ("Name", 23);
@ -358,7 +361,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
} }
// Quit button // Quit button
Quit.setGeometry(24, 16, 10, 1); Quit.setGeometry(FPoint(24, 16), FSize(10, 1));
Quit.setText (L"&Quit"); Quit.setText (L"&Quit");
// Add some function callbacks // Add some function callbacks
@ -378,9 +381,9 @@ Treeview::~Treeview() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Treeview::adjustSize() void Treeview::adjustSize()
{ {
std::size_t h = getParentWidget()->getHeight() - 4; std::size_t h = getDesktopHeight() - 4;
setHeight (h, false); setHeight (h, false);
int X = int((getParentWidget()->getWidth() - getWidth()) / 2); int X = int((getDesktopWidth() - getWidth()) / 2);
if ( X < 1 ) if ( X < 1 )
X = 1; X = 1;
@ -415,7 +418,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Treeview d(&app); Treeview d(&app);
d.setText (L"Continents"); d.setText (L"Continents");
d.setGeometry (int(1 + (app.getWidth() - 57) / 2), 3, 57, 20); d.setGeometry ( FPoint(int(1 + (app.getWidth() - 57) / 2), 3)
, FSize(57, 20) );
d.setShadow(); d.setShadow();
// Set dialog d as main widget // Set dialog d as main widget

View File

@ -26,6 +26,9 @@
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class ProgressDialog // class ProgressDialog
@ -71,25 +74,26 @@ class ProgressDialog : public finalcut::FDialog
ProgressDialog::ProgressDialog (finalcut::FWidget* parent) ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
setGeometry (int((getParentWidget()->getWidth() - 40) / 2), 7, 40, 10); setGeometry ( FPoint(int((getParentWidget()->getWidth() - 40) / 2), 7)
, FSize(40, 10) );
setText("Progress bar"); setText("Progress bar");
//setModal(); //setModal();
reset.setText("&Reset"); reset.setText("&Reset");
reset.setStatusbarMessage ("Reset the progress bar"); reset.setStatusbarMessage ("Reset the progress bar");
reset.setGeometry(2, 6, 8, 1, false); reset.setGeometry(FPoint(2, 6), FSize(8, 1), false);
reset.setDisable(); reset.setDisable();
more.setText("&More"); more.setText("&More");
more.setStatusbarMessage ("Increases the progress bar position"); more.setStatusbarMessage ("Increases the progress bar position");
more.setGeometry(15, 6, 8, 1, false); more.setGeometry(FPoint(15, 6), FSize(8, 1), false);
more.setDisable(); more.setDisable();
quit.setText("E&xit"); quit.setText("E&xit");
quit.setGeometry(28, 6, 8, 1, false); quit.setGeometry(FPoint(28, 6), FSize(8, 1), false);
quit.setDisable(); quit.setDisable();
progressBar.setGeometry(2, 3, 34, 1, false); progressBar.setGeometry(FPoint(2, 3), FSize(34, 1), false);
//progressBar.setPercentage(78); //progressBar.setPercentage(78);
reset.addCallback reset.addCallback
@ -211,8 +215,8 @@ TextWindow::TextWindow (finalcut::FWidget* parent)
: finalcut::FDialog(parent) : finalcut::FDialog(parent)
{ {
scrollText.ignorePadding(); scrollText.ignorePadding();
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1); scrollText.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
setMinimumSize (51, 6); setMinimumSize (FSize(51, 6));
scrollText.setFocus(); scrollText.setFocus();
scrollText.insert(" -----------------------------------------------\n" scrollText.insert(" -----------------------------------------------\n"
" line 1\n" " line 1\n"
@ -238,7 +242,7 @@ void TextWindow::append (const finalcut::FString& str)
void TextWindow::adjustSize() void TextWindow::adjustSize()
{ {
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
scrollText.setGeometry (1, 2, getWidth(), getHeight() - 1); scrollText.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
} }
@ -550,7 +554,7 @@ void MyDialog::initWidgets()
initToggleButtons(); initToggleButtons();
// A text input field // A text input field
myLineEdit.setGeometry(22, 1, 10, 1); myLineEdit.setGeometry(FPoint(22, 1), FSize(10, 1));
myLineEdit.setLabelText (L"&Input"); myLineEdit.setLabelText (L"&Input");
myLineEdit.setStatusbarMessage ("Press Enter to set the title"); myLineEdit.setStatusbarMessage ("Press Enter to set the title");
myLineEdit << finalcut::FString("EnTry").toLower(); myLineEdit << finalcut::FString("EnTry").toLower();
@ -559,7 +563,7 @@ void MyDialog::initWidgets()
initButtons(); initButtons();
// A multiple selection listbox // A multiple selection listbox
myList.setGeometry(38, 1, 14, 17); myList.setGeometry(FPoint(38, 1), FSize(14, 17));
myList.setText ("Items"); myList.setText ("Items");
myList.setStatusbarMessage ("99 items in a list"); myList.setStatusbarMessage ("99 items in a list");
myList.setMultiSelection(); myList.setMultiSelection();
@ -575,21 +579,21 @@ void MyDialog::initWidgets()
void MyDialog::initFlatButtons() void MyDialog::initFlatButtons()
{ {
// Flat buttons // Flat buttons
MyButton1.setGeometry(3, 3, 5, 1); MyButton1.setGeometry(FPoint(3, 3), FSize(5, 1));
MyButton1.setText (L"&SIN"); MyButton1.setText (L"&SIN");
MyButton1.setStatusbarMessage ("Sine function"); MyButton1.setStatusbarMessage ("Sine function");
MyButton1.setNoUnderline(); MyButton1.setNoUnderline();
MyButton1.setFlat(); MyButton1.setFlat();
MyButton1.setDoubleFlatLine (finalcut::fc::bottom); MyButton1.setDoubleFlatLine (finalcut::fc::bottom);
MyButton2.setGeometry(3, 5, 5, 1); MyButton2.setGeometry(FPoint(3, 5), FSize(5, 1));
MyButton2.setText (L"&COS"); MyButton2.setText (L"&COS");
MyButton2.setStatusbarMessage ("Cosine function"); MyButton2.setStatusbarMessage ("Cosine function");
MyButton2.setNoUnderline(); MyButton2.setNoUnderline();
MyButton2.setFlat(); MyButton2.setFlat();
MyButton2.setDoubleFlatLine (finalcut::fc::top); MyButton2.setDoubleFlatLine (finalcut::fc::top);
MyButton3.setGeometry(10, 3, 5, 3); MyButton3.setGeometry(FPoint(10, 3), FSize(5, 3));
MyButton3.setText (L"&="); MyButton3.setText (L"&=");
MyButton3.setStatusbarMessage ("Equal"); MyButton3.setStatusbarMessage ("Equal");
MyButton3.setNoUnderline(); MyButton3.setNoUnderline();
@ -619,25 +623,25 @@ void MyDialog::initFlatButtons()
void MyDialog::initToggleButtons() void MyDialog::initToggleButtons()
{ {
// Radio buttons in a group // Radio buttons in a group
radioButtonGroup.setGeometry(3, 8, 14, 4); radioButtonGroup.setGeometry(FPoint(3, 8), FSize(14, 4));
//radioButtonGroup->unsetBorder(); //radioButtonGroup->unsetBorder();
radio1.setGeometry(1, 1, 10, 1); radio1.setGeometry(FPoint(1, 1), FSize(10, 1));
radio1.setStatusbarMessage ("Enable button Test"); radio1.setStatusbarMessage ("Enable button Test");
radio2.setGeometry(1, 2, 11, 1); radio2.setGeometry(FPoint(1, 2), FSize(11, 1));
radio2.setText ("&Disable"); radio2.setText ("&Disable");
radio2.setStatusbarMessage ("Disable button Test"); radio2.setStatusbarMessage ("Disable button Test");
radio2.setChecked(); radio2.setChecked();
//radio2.setDisable(); //radio2.setDisable();
// Checkboxes in a group // Checkboxes in a group
checkButtonGroup.setGeometry(3, 12, 14, 4); checkButtonGroup.setGeometry(FPoint(3, 12), FSize(14, 4));
check1.setGeometry(1, 1, 11, 1); check1.setGeometry(FPoint(1, 1), FSize(11, 1));
check1.setNoUnderline(); check1.setNoUnderline();
check2.setGeometry(1, 2, 9, 1); check2.setGeometry(FPoint(1, 2), FSize(9, 1));
check2.setChecked(); check2.setChecked();
check2.setNoUnderline(); check2.setNoUnderline();
} }
@ -646,17 +650,17 @@ void MyDialog::initToggleButtons()
void MyDialog::initButtons() void MyDialog::initButtons()
{ {
// Buttons // Buttons
MyButton4.setGeometry(20, 8, 12, 1); MyButton4.setGeometry(FPoint(20, 8), FSize(12, 1));
MyButton4.setText (L"&Get input"); MyButton4.setText (L"&Get input");
MyButton4.setStatusbarMessage ("Take text from input field"); MyButton4.setStatusbarMessage ("Take text from input field");
MyButton4.setFocus(); MyButton4.setFocus();
MyButton5.setGeometry(20, 11, 12, 1); MyButton5.setGeometry(FPoint(20, 11), FSize(12, 1));
MyButton5.setText (L"&Test"); MyButton5.setText (L"&Test");
MyButton5.setStatusbarMessage ("Progressbar testing dialog"); MyButton5.setStatusbarMessage ("Progressbar testing dialog");
MyButton5.setDisable(); MyButton5.setDisable();
MyButton6.setGeometry(20, 14, 12, 1); MyButton6.setGeometry(FPoint(20, 14), FSize(12, 1));
MyButton6.setText (L"&Quit"); MyButton6.setText (L"&Quit");
MyButton6.setStatusbarMessage ("Exit the program"); MyButton6.setStatusbarMessage ("Exit the program");
MyButton6.addAccelerator('x'); MyButton6.addAccelerator('x');
@ -686,20 +690,20 @@ void MyDialog::initButtons()
void MyDialog::initLabels() void MyDialog::initLabels()
{ {
// Text labels // Text labels
headline.setGeometry(21, 3, 10, 1); headline.setGeometry(FPoint(21, 3), FSize(10, 1));
headline.setEmphasis(); headline.setEmphasis();
headline.setAlignment (finalcut::fc::alignCenter); headline.setAlignment (finalcut::fc::alignCenter);
headline = L"List items"; headline = L"List items";
tagged.setGeometry(21, 4, 7, 1); tagged.setGeometry(FPoint(21, 4), FSize(7, 1));
tagged_count.setGeometry(29, 4, 5, 1); tagged_count.setGeometry(FPoint(29, 4), FSize(5, 1));
tagged_count << 0; tagged_count << 0;
sum.setGeometry(21, 5, 7, 3); sum.setGeometry(FPoint(21, 5), FSize(7, 3));
sum.setAlignment (finalcut::fc::alignRight); sum.setAlignment (finalcut::fc::alignRight);
sum_count.setGeometry(29, 5, 5, 3); sum_count.setGeometry(FPoint(29, 5), FSize(5, 3));
sum_count << myList.getCount(); sum_count << myList.getCount();
} }
@ -741,7 +745,7 @@ void MyDialog::adjustSize()
{ {
auto h = getParentWidget()->getHeight() - 4; auto h = getParentWidget()->getHeight() - 4;
setHeight (h, false); setHeight (h, false);
auto X = int((getParentWidget()->getWidth() - getWidth()) / 2); auto X = int((getDesktopWidth() - getWidth()) / 2);
if ( X < 1 ) if ( X < 1 )
X = 1; X = 1;
@ -822,21 +826,21 @@ void MyDialog::cb_drives (finalcut::FWidget*, FDataPtr)
if ( isNewFont() ) if ( isNewFont() )
{ {
finalcut::FLabel drive (finalcut::NF_Drive, &info2); finalcut::FLabel drive (finalcut::NF_Drive, &info2);
drive.setGeometry (11, 2, 4, 1); drive.setGeometry (FPoint(11, 2), FSize(4, 1));
finalcut::FLabel net (finalcut::NF_Net_Drive, &info2); finalcut::FLabel net (finalcut::NF_Net_Drive, &info2);
net.setGeometry (11, 4, 4, 1); net.setGeometry (FPoint(11, 4), FSize(4, 1));
finalcut::FLabel cd (finalcut::NF_CD_ROM, &info2); finalcut::FLabel cd (finalcut::NF_CD_ROM, &info2);
cd.setGeometry (11, 6, 4, 1); cd.setGeometry (FPoint(11, 6), FSize(4, 1));
info2.exec(); info2.exec();
} }
else else
{ {
finalcut::FLabel drive (" - ", &info2); finalcut::FLabel drive (" - ", &info2);
drive.setGeometry (11, 2, 4, 1); drive.setGeometry (FPoint(11, 2), FSize(4, 1));
finalcut::FLabel net (" N ", &info2); finalcut::FLabel net (" N ", &info2);
net.setGeometry (11, 4, 4, 1); net.setGeometry (FPoint(11, 4), FSize(4, 1));
finalcut::FLabel cd (" CD ", &info2); finalcut::FLabel cd (" CD ", &info2);
cd.setGeometry (11, 6, 4, 1); cd.setGeometry (FPoint(11, 6), FSize(4, 1));
if ( isMonochron() ) if ( isMonochron() )
{ {
@ -962,10 +966,9 @@ void MyDialog::cb_view (finalcut::FWidget*, FDataPtr data)
const auto& view = new TextWindow(this); const auto& view = new TextWindow(this);
finalcut::FString filename(basename(const_cast<char*>(file.c_str()))); finalcut::FString filename(basename(const_cast<char*>(file.c_str())));
view->setText ("Viewer: " + filename); view->setText ("Viewer: " + filename);
view->setGeometry ( 1 + int((getRootWidget()->getWidth() - 60) / 2), view->setGeometry ( FPoint ( 1 + int((getRootWidget()->getWidth() - 60) / 2),
int(getRootWidget()->getHeight() / 6), int(getRootWidget()->getHeight() / 6) )
60, , FSize(60, getRootWidget()->getHeight() * 3 / 4) );
getRootWidget()->getHeight() * 3 / 4 );
view->setResizeable(); view->setResizeable();
std::string line = ""; std::string line = "";
std::ifstream infile; std::ifstream infile;
@ -1021,7 +1024,8 @@ int main (int argc, char* argv[])
// Create main dialog object d // Create main dialog object d
MyDialog d(&app); MyDialog d(&app);
d.setText (title); d.setText (title);
d.setGeometry (int((app.getWidth() - 56) / 2), 2, 56, app.getHeight() - 4); d.setGeometry ( FPoint(int((app.getWidth() - 56) / 2), 2)
, FSize(56, app.getHeight() - 4) );
d.setShadow(); d.setShadow();
// Set the dialog object d as the main widget of the application. // Set the dialog object d as the main widget of the application.

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <ctime> #include <ctime>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class Watch // class Watch
@ -78,20 +81,20 @@ Watch::Watch (FWidget* parent)
{ {
setText ("Watch"); setText ("Watch");
int pw = int(getParentWidget()->getWidth()); int pw = int(getParentWidget()->getWidth());
setGeometry (1 + (pw - 22) / 2, 3, 22, 13); setGeometry (FPoint(1 + (pw - 22) / 2, 3), FSize(22, 13));
// Labels // Labels
time_label.setGeometry(5, 2, 5, 1); time_label.setGeometry(FPoint(5, 2), FSize(5, 1));
time_label.setEmphasis(); time_label.setEmphasis();
time_str.setGeometry(10, 2, 8, 1); time_str.setGeometry(FPoint(10, 2), FSize(8, 1));
// Checkbox buttons // Checkbox buttons
clock_sw.setGeometry(4, 4, 9, 1); clock_sw.setGeometry(FPoint(4, 4), FSize(9, 1));
seconds_sw.setGeometry(2, 6, 11, 1); seconds_sw.setGeometry(FPoint(2, 6), FSize(11, 1));
sec = seconds_sw.setChecked(); sec = seconds_sw.setChecked();
// Quit button // Quit button
quit_btn.setGeometry(6, 9, 9, 1); quit_btn.setGeometry(FPoint(6, 9), FSize(9, 1));
// Connect switch signal "toggled" with a callback member function // Connect switch signal "toggled" with a callback member function
clock_sw.addCallback clock_sw.addCallback

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector> #include <vector>
#include <final/final.h> #include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class SmallWindow // class SmallWindow
@ -75,24 +78,24 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
left_arrow.setForegroundColor (wc.label_inactive_fg); left_arrow.setForegroundColor (wc.label_inactive_fg);
left_arrow.setEmphasis(); left_arrow.setEmphasis();
left_arrow.ignorePadding(); left_arrow.ignorePadding();
left_arrow.setGeometry (2, 2, 1, 1); left_arrow.setGeometry (FPoint(2, 2), FSize(1, 1));
right_arrow = arrow_up; right_arrow = arrow_up;
right_arrow.setForegroundColor (wc.label_inactive_fg); right_arrow.setForegroundColor (wc.label_inactive_fg);
right_arrow.setEmphasis(); right_arrow.setEmphasis();
right_arrow.ignorePadding(); right_arrow.ignorePadding();
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1); right_arrow.setGeometry (FPoint(int(getWidth()) - 1, 2), FSize(1, 1));
top_left_label = "menu"; 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.setEmphasis();
top_left_label.setGeometry (1, 1, 6, 1); top_left_label.setGeometry (FPoint(1, 1), FSize(6, 1));
top_right_label = "zoom"; top_right_label = "zoom";
top_right_label.setAlignment (finalcut::fc::alignRight); top_right_label.setAlignment (finalcut::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.setEmphasis();
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1); top_right_label.setGeometry (FPoint(int(getClientWidth()) - 5, 1), FSize(6, 1));
finalcut::FString bottom_label_text = "resize\n" finalcut::FString bottom_label_text = "resize\n"
"corner\n"; "corner\n";
@ -101,7 +104,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
bottom_label.setAlignment (finalcut::fc::alignRight); bottom_label.setAlignment (finalcut::fc::alignRight);
bottom_label.setForegroundColor (wc.label_inactive_fg); bottom_label.setForegroundColor (wc.label_inactive_fg);
bottom_label.setEmphasis(); bottom_label.setEmphasis();
bottom_label.setGeometry (13, 3, 6, 3); bottom_label.setGeometry (FPoint(13, 3), FSize(6, 3));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -126,9 +129,12 @@ void SmallWindow::adjustSize()
} }
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1); right_arrow.setGeometry ( FPoint(int(getWidth()) - 1, 2)
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1); , FSize(1, 1) );
bottom_label.setGeometry (1, int(getClientHeight()) - 2, getClientWidth(), 3); top_right_label.setGeometry ( FPoint(int(getClientWidth()) - 5, 1)
, FSize(6, 1) );
bottom_label.setGeometry ( FPoint(1, int(getClientHeight()) - 2)
, FSize(getClientWidth(), 3) );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -309,11 +315,11 @@ void Window::configureFileMenuItems()
void Window::configureDialogButtons() void Window::configureDialogButtons()
{ {
// Dialog buttons // Dialog buttons
CreateButton.setGeometry (2, 2, 9, 1); CreateButton.setGeometry (FPoint(2, 2), FSize(9, 1));
CreateButton.setText (L"&Create"); CreateButton.setText (L"&Create");
CloseButton.setGeometry (15, 2, 9, 1); CloseButton.setGeometry (FPoint(15, 2), FSize(9, 1));
CloseButton.setText (L"C&lose"); CloseButton.setText (L"C&lose");
QuitButton.setGeometry (28, 2, 9, 1); QuitButton.setGeometry (FPoint(28, 2), FSize(9, 1));
QuitButton.setText (L"&Quit"); QuitButton.setText (L"&Quit");
// Add button callback // Add button callback
@ -340,8 +346,8 @@ void Window::activateWindow (finalcut::FDialog* win)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void Window::adjustSize() void Window::adjustSize()
{ {
std::size_t w = getRootWidget()->getWidth(); std::size_t w = getDesktopWidth();
std::size_t h = getRootWidget()->getHeight(); std::size_t h = getDesktopHeight();
int X = int(1 + (w - 40) / 2) int X = int(1 + (w - 40) / 2)
, Y = int(1 + (h - 22) / 2) , Y = int(1 + (h - 22) / 2)
, dx = ( w > 80 ) ? int(w - 80) / 2 : 0 , dx = ( w > 80 ) ? int(w - 80) / 2 : 0
@ -350,7 +356,7 @@ void Window::adjustSize()
if ( Y < 2 ) if ( Y < 2 )
Y = 2; Y = 2;
setPos (X, Y); setPos (FPoint(X, Y));
auto first = windows.begin(); auto first = windows.begin();
auto iter = first; auto iter = first;
@ -361,7 +367,7 @@ void Window::adjustSize()
int n = int(std::distance(first, iter)) int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3 , x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3; , y = dy + 11 + int(n / 3) * 3;
(*iter)->dgl->setPos (x, y); (*iter)->dgl->setPos (FPoint(x, y));
} }
++iter; ++iter;
@ -426,8 +432,8 @@ void Window::cb_createWindows (finalcut::FWidget*, FDataPtr)
int n = int(std::distance(first, iter)) int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3 , x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3; , y = dy + 11 + int(n / 3) * 3;
win->setGeometry (x, y, 20, 8); win->setGeometry (FPoint(x, y), FSize(20, 8));
win->setMinimumSize (20, 8); win->setMinimumSize (FSize(20, 8));
win->setResizeable(); win->setResizeable();
win->show(); win->show();
@ -563,7 +569,8 @@ int main (int argc, char* argv[])
// Create main dialog object // Create main dialog object
Window main_dlg (&app); Window main_dlg (&app);
main_dlg.setText ("Main window"); main_dlg.setText ("Main window");
main_dlg.setGeometry (int(1 + (app.getWidth() - 40) / 2), 2, 40, 6); main_dlg.setGeometry ( FPoint(int(1 + (app.getWidth() - 40) / 2), 2)
, FSize(40, 6) );
// Set dialog main_dlg as main widget // Set dialog main_dlg as main widget
app.setMainWidget (&main_dlg); app.setMainWidget (&main_dlg);

View File

@ -11,6 +11,7 @@ lib_LTLIBRARIES = libfinal.la
libfinal_la_SOURCES = \ libfinal_la_SOURCES = \
fstring.cpp \ fstring.cpp \
fpoint.cpp \ fpoint.cpp \
fsize.cpp \
frect.cpp \ frect.cpp \
fscrollbar.cpp \ fscrollbar.cpp \
fprogressbar.cpp \ fprogressbar.cpp \
@ -72,6 +73,7 @@ finalcutinclude_HEADERS = \
include/final/fbuttongroup.h \ include/final/fbuttongroup.h \
include/final/fcharmap.h \ include/final/fcharmap.h \
include/final/fcheckbox.h \ include/final/fcheckbox.h \
include/final/fcolorpair.h \
include/final/fconfig.h \ include/final/fconfig.h \
include/final/fswitch.h \ include/final/fswitch.h \
include/final/fdialog.h \ include/final/fdialog.h \
@ -99,6 +101,7 @@ finalcutinclude_HEADERS = \
include/final/ftooltip.h \ include/final/ftooltip.h \
include/final/fobject.h \ include/final/fobject.h \
include/final/fpoint.h \ include/final/fpoint.h \
include/final/fsize.h \
include/final/foptiattr.h \ include/final/foptiattr.h \
include/final/foptimove.h \ include/final/foptimove.h \
include/final/ftermbuffer.h \ include/final/ftermbuffer.h \

View File

@ -12,6 +12,7 @@ INCLUDE_HEADERS = \
fapplication.h \ fapplication.h \
fbuttongroup.h \ fbuttongroup.h \
fbutton.h \ fbutton.h \
fcolorpair.h \
ftogglebutton.h \ ftogglebutton.h \
fcheckbox.h \ fcheckbox.h \
fswitch.h \ fswitch.h \
@ -34,6 +35,7 @@ INCLUDE_HEADERS = \
foptimove.h \ foptimove.h \
ftermbuffer.h \ ftermbuffer.h \
fpoint.h \ fpoint.h \
fsize.h \
fprogressbar.h \ fprogressbar.h \
fradiobutton.h \ fradiobutton.h \
frect.h \ frect.h \
@ -74,6 +76,7 @@ LIB = libfinal.so
OBJS = \ OBJS = \
fstring.o \ fstring.o \
fpoint.o \ fpoint.o \
fsize.o \
frect.o \ frect.o \
fscrollbar.o \ fscrollbar.o \
fprogressbar.o \ fprogressbar.o \

View File

@ -12,6 +12,7 @@ INCLUDE_HEADERS = \
fapplication.h \ fapplication.h \
fbuttongroup.h \ fbuttongroup.h \
fbutton.h \ fbutton.h \
fcolorpair.h \
ftogglebutton.h \ ftogglebutton.h \
fcheckbox.h \ fcheckbox.h \
fswitch.h \ fswitch.h \
@ -34,6 +35,7 @@ INCLUDE_HEADERS = \
foptimove.h \ foptimove.h \
ftermbuffer.h \ ftermbuffer.h \
fpoint.h \ fpoint.h \
fsize.h \
fprogressbar.h \ fprogressbar.h \
fradiobutton.h \ fradiobutton.h \
frect.h \ frect.h \
@ -74,6 +76,7 @@ LIB = libfinal.so
OBJS = \ OBJS = \
fstring.o \ fstring.o \
fpoint.o \ fpoint.o \
fsize.o \
frect.o \ frect.o \
fscrollbar.o \ fscrollbar.o \
fprogressbar.o \ fprogressbar.o \

View File

@ -1192,7 +1192,7 @@ bool FApplication::processNextEvent()
void FApplication::performTimerAction ( const FObject* receiver void FApplication::performTimerAction ( const FObject* receiver
, const FEvent* event ) , const FEvent* event )
{ {
sendEvent(receiver, event); sendEvent (receiver, event);
} }
} // namespace finalcut } // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -188,12 +188,12 @@ bool FButton::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return flags.shadow; return flags.shadow;
@ -253,8 +253,7 @@ void FButton::hide()
for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++) for (std::size_t y = 0; y < getHeight() + s + (f << 1); y++)
{ {
setPrintPos (1 - int(f), 1 + int(y - f)); print() << FPoint(1 - int(f), 1 + int(y - f)) << blank;
print (blank);
} }
destroyBlankArray (blank); destroyBlankArray (blank);
@ -417,46 +416,22 @@ void FButton::init()
detectHotkey(); detectHotkey();
} }
//----------------------------------------------------------------------
uChar FButton::getHotkey()
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::setHotkeyAccelerator() void FButton::setHotkeyAccelerator()
{ {
uChar hotkey = getHotkey(); FKey hotkey = getHotkey(text);
if ( hotkey ) if ( hotkey )
{ {
if ( std::isalpha(hotkey) || std::isdigit(hotkey) ) if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{ {
addAccelerator (FKey(std::tolower(hotkey))); addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(hotkey))); addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey // Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey))); addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
} }
else else
addAccelerator (getHotkey()); addAccelerator (hotkey);
} }
else else
delAccelerator(); delAccelerator();
@ -515,8 +490,7 @@ inline std::size_t FButton::clickAnimationIndent (FWidget* parent_widget)
for (std::size_t y = 1; y <= getHeight(); y++) for (std::size_t y = 1; y <= getHeight(); y++)
{ {
setPrintPos (1, int(y)); print() << FPoint(1, int(y)) << ' '; // clear one left █
print (' '); // clear one left █
} }
return 1; return 1;
@ -538,8 +512,7 @@ inline void FButton::clearRightMargin (FWidget* parent_widget)
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
setPrintPos (1 + int(getWidth()), y); print() << FPoint(1 + int(getWidth()), y) << ' '; // clear right
print (' '); // clear right
if ( flags.active && isMonochron() ) if ( flags.active && isMonochron() )
setReverse(false); // Dark background setReverse(false); // Dark background
@ -555,7 +528,7 @@ inline void FButton::drawMarginLeft()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (1 + int(indent), 1 + int(y)); print() << FPoint(1 + int(indent), 1 + int(y));
if ( isMonochron() && active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackRightPointingPointer); // ► print (fc::BlackRightPointingPointer); // ►
@ -571,7 +544,7 @@ inline void FButton::drawMarginRight()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (int(getWidth() + indent), 1 + int(y)); print() << FPoint(int(getWidth() + indent), 1 + int(y));
if ( isMonochron() && active_focus && y == vcenter_offset ) if ( isMonochron() && active_focus && y == vcenter_offset )
print (fc::BlackLeftPointingPointer); // ◄ print (fc::BlackLeftPointingPointer); // ◄
@ -590,7 +563,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = 0; y < vcenter_offset; y++) for (std::size_t y = 0; y < vcenter_offset; y++)
{ {
setPrintPos (2 + int(indent), 1 + int(y)); print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++) for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █ print (space_char); // █
@ -598,7 +571,7 @@ inline void FButton::drawTopBottomBackground()
for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++) for (std::size_t y = vcenter_offset + 1; y < getHeight(); y++)
{ {
setPrintPos (2 + int(indent), 1 + int(y)); print() << FPoint(2 + int(indent), 1 + int(y));
for (std::size_t x = 1; x < getWidth() - 1; x++) for (std::size_t x = 1; x < getWidth() - 1; x++)
print (space_char); // █ print (space_char); // █
@ -609,8 +582,8 @@ inline void FButton::drawTopBottomBackground()
inline void FButton::drawButtonTextLine (wchar_t button_text[]) inline void FButton::drawButtonTextLine (wchar_t button_text[])
{ {
std::size_t pos; std::size_t pos;
setPrintPos (2 + int(indent), 1 + int(vcenter_offset)); print() << FPoint(2 + int(indent), 1 + int(vcenter_offset))
setColor (button_fg, button_bg); << FColorPair (button_fg, button_bg);
if ( getWidth() < txtlength + 1 ) if ( getWidth() < txtlength + 1 )
center_offset = 0; center_offset = 0;
@ -622,11 +595,11 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
print (space_char); // █ print (space_char); // █
if ( hotkeypos == NOT_SET ) if ( hotkeypos == NOT_SET )
setCursorPos ( 2 + int(center_offset) setCursorPos (FPoint ( 2 + int(center_offset)
, 1 + int(vcenter_offset) ); // first character , 1 + int(vcenter_offset) )); // first character
else else
setCursorPos ( 2 + int(center_offset + hotkeypos) setCursorPos (FPoint ( 2 + int(center_offset + hotkeypos)
, 1 + int(vcenter_offset) ); // hotkey , 1 + int(vcenter_offset) )); // hotkey
if ( ! flags.active && isMonochron() ) if ( ! flags.active && isMonochron() )
setReverse(true); // Light background setReverse(true); // Light background
@ -667,8 +640,7 @@ inline void FButton::drawButtonTextLine (wchar_t button_text[])
if ( txtlength >= getWidth() - 1 ) if ( txtlength >= getWidth() - 1 )
{ {
// Print ellipsis // Print ellipsis
setPrintPos (int(getWidth() + indent) - 2, 1); print() << FPoint(int(getWidth() + indent) - 2, 1) << "..";
print (L"..");
} }
if ( active_focus && (isMonochron() || getMaxColor() < 16) ) if ( active_focus && (isMonochron() || getMaxColor() < 16) )

View File

@ -220,7 +220,7 @@ void FButtonGroup::hide()
for (int y = 0; y < int(getHeight()); y++) for (int y = 0; y < int(getHeight()); y++)
{ {
FWidget::setPrintPos (1, 1 + y); FWidget::setPrintPos (FPoint(1, 1 + y));
print (blank); print (blank);
} }
@ -296,8 +296,8 @@ void FButtonGroup::checkScrollSize (const FRect& r)
if ( ! scrollgeometry.contains(r) ) if ( ! scrollgeometry.contains(r) )
{ {
FRect new_size = scrollgeometry.combined(r); FRect r_combined = scrollgeometry.combined(r);
setScrollSize (new_size.getWidth(), new_size.getHeight()); setScrollSize (r_combined.getSize());
} }
} }
@ -382,45 +382,22 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
// protected methods of FButtonGroup // protected methods of FButtonGroup
//----------------------------------------------------------------------
uChar FButtonGroup::getHotkey()
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::setHotkeyAccelerator() void FButtonGroup::setHotkeyAccelerator()
{ {
uChar hotkey = getHotkey(); FKey hotkey = getHotkey(text);
if ( hotkey ) if ( hotkey )
{ {
if ( std::isalpha(hotkey) || std::isdigit(hotkey) ) if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{ {
addAccelerator (FKey(std::tolower(hotkey))); addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(hotkey))); addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey // Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey))); addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
} }
else else
addAccelerator (getHotkey()); addAccelerator (hotkey);
} }
else else
delAccelerator(); delAccelerator();
@ -472,9 +449,9 @@ void FButtonGroup::drawLabel()
length--; length--;
if ( hasBorder() ) if ( hasBorder() )
FWidget::setPrintPos (2, 1); FWidget::setPrintPos (FPoint(2, 1));
else else
FWidget::setPrintPos (0, 1); FWidget::setPrintPos (FPoint(0, 1));
drawText (LabelText, hotkeypos, length); drawText (LabelText, hotkeypos, length);
setViewportPrint(); setViewportPrint();
@ -498,7 +475,7 @@ void FButtonGroup::init()
{ {
setForegroundColor (wc.label_fg); setForegroundColor (wc.label_fg);
setBackgroundColor (wc.label_bg); setBackgroundColor (wc.label_bg);
setMinimumSize (7, 4); setMinimumSize (FSize(7, 4));
buttonlist.clear(); // no buttons yet buttonlist.clear(); // no buttons yet
} }
@ -651,7 +628,7 @@ void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr)
{ {
toggle_button->unsetChecked(); toggle_button->unsetChecked();
if ( toggle_button->isVisible() && toggle_button->isShown() ) if ( toggle_button->isShown() )
toggle_button->redraw(); toggle_button->redraw();
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2017 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -72,7 +72,7 @@ void FCheckBox::drawCheckButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1, 1); print() << FPoint(1, 1);
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -161,48 +161,30 @@ int FDialog::exec()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::setPos (int x, int y, bool) void FDialog::setPos (const FPoint& pos, bool)
{ {
int rsw, bsh, width, height; FRect old_geometry, restore;
FRect old_geometry;
setPos_error = false; setPos_error = false;
if ( getX() == x && getY() == y )
{
setPos_error = true;
return;
}
width = int(getWidth());
height = int(getHeight());
// Avoid to move widget completely outside the terminal // Avoid to move widget completely outside the terminal
if ( x + width <= 1 // or moving a zoomed dialog or a motionless dialog
|| x > int(getMaxWidth()) if ( isOutsideTerminal(pos) || isZoomed() || getPos() == pos )
|| y < 1
|| y > int(getMaxHeight()) )
{ {
setPos_error = true; setPos_error = true;
return; return;
} }
if ( isZoomed() ) int dx = getX() - pos.getX();
{ int dy = getY() - pos.getY();
setPos_error = true; int old_x = getTermX();
return; int old_y = getTermY();
}
int dx = getX() - x
, dy = getY() - y
, old_x = getTermX()
, old_y = getTermY();
const auto& shadow = getShadow(); const auto& shadow = getShadow();
rsw = shadow.getX(); // right shadow width; std::size_t width = getWidth() + shadow.getWidth(); // width + right shadow
bsh = shadow.getY(); // bottom shadow height std::size_t height = getHeight() + shadow.getHeight(); // height + bottom shadow
old_geometry = getTermGeometryWithShadow(); old_geometry = getTermGeometryWithShadow();
// move to the new position // move to the new position
FWindow::setPos(x, y, false); FWindow::setPos(pos, false);
putArea (getTermPos(), vwin); putArea (getTermPos(), vwin);
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
@ -215,28 +197,34 @@ void FDialog::setPos (int x, int y, bool)
// dy = 0 : move horizontal // dy = 0 : move horizontal
// dy < 0 : move down // dy < 0 : move down
std::size_t d_width = std::size_t(std::abs(dx));
std::size_t d_height = std::size_t(std::abs(dy));
if ( dx > 0 ) if ( dx > 0 )
{ {
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm ( old_x + width + rsw - dx, old_y restore.setRect ( old_x + int(width) - dx, old_y
, dx, height + bsh - dy ); , d_width, height - d_height );
else else
restoreVTerm ( old_x + width + rsw - dx, old_y + std::abs(dy) restore.setRect ( old_x + int(width) - dx, old_y - dy
, dx, height + bsh - std::abs(dy)); , d_width, height - d_height );
} }
else else
{ {
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm (old_x, old_y, std::abs(dx), height + bsh - dy); restore.setRect (old_x, old_y, d_width, height - d_height);
else else
restoreVTerm ( old_x, old_y + std::abs(dy) restore.setRect (old_x, old_y - dy, d_width, height - d_height);
, std::abs(dx), height + bsh - std::abs(dy) );
} }
restoreVTerm (restore);
if ( dy > 0 ) if ( dy > 0 )
restoreVTerm (old_x, old_y + height + bsh - dy, width + rsw, dy); restore.setRect ( old_x, old_y + int(height) - dy, width, d_height);
else else
restoreVTerm (old_x, old_y, width + rsw, std::abs(dy)); restore.setRect ( old_x, old_y, width, d_height);
restoreVTerm (restore);
} }
else else
{ {
@ -250,71 +238,60 @@ void FDialog::setPos (int x, int y, bool)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::move (int dx, int dy) void FDialog::move (const FPoint& d_pos)
{ {
setPos (getX() + dx, getY() + dy); setPos (getPos() + d_pos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveUp (int n) inline bool FDialog::moveUp (int n)
{ {
move (0, -n); move (FPoint(0, -n));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveDown (int n) inline bool FDialog::moveDown (int n)
{ {
move (0, n); move (FPoint(0, n));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveLeft (int n) inline bool FDialog::moveLeft (int n)
{ {
move (-n, 0); move (FPoint(-n, 0));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FDialog::moveRight (int n) inline bool FDialog::moveRight (int n)
{ {
move (n, 0); move (FPoint(n, 0));
return ! setPos_error; return ! setPos_error;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::setSize (std::size_t w, std::size_t h, bool adjust) void FDialog::setSize (const FSize& size, bool adjust)
{ {
setSize_error = false; setSize_error = false;
if ( getWidth() == w && getHeight() == h ) if ( getSize() == size || isZoomed() )
{ {
setSize_error = true; setSize_error = true;
return; return;
} }
if ( isZoomed() ) int x = getTermX();
{ int y = getTermY();
setSize_error = true; int dw = int(getWidth()) - int(size.getWidth());
return; int dh = int(getHeight()) - int(size.getHeight());
}
int x = getTermX()
, y = getTermY()
, old_width = int(getWidth())
, old_height = int(getHeight())
, dw = old_width - int(w)
, dh = old_height - int(h);
const auto& shadow = getShadow(); const auto& shadow = getShadow();
int rsw = shadow.getX(); // right shadow width; FWindow::setSize (size, adjust);
int bsh = shadow.getY(); // bottom shadow height
FWindow::setSize (w, h, adjust);
// get adjust width and height // get adjust width and height
w = getWidth(); std::size_t w = getWidth() + shadow.getWidth();
h = getHeight(); std::size_t h = getHeight()+ shadow.getHeight();
// dw > 0 : scale down width // dw > 0 : scale down width
// dw = 0 : scale only height // dw = 0 : scale only height
@ -323,39 +300,23 @@ void FDialog::setSize (std::size_t w, std::size_t h, bool adjust)
// dh = 0 : scale only width // dh = 0 : scale only width
// dh < 0 : scale up height // dh < 0 : scale up height
std::size_t d_width = std::size_t(dw);
std::size_t d_height = std::size_t(dh);
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
if ( dw > 0 ) if ( dw > 0 )
restoreVTerm (x + int(w) + rsw, y, dw, int(h) + bsh + dh); // restore right restoreVTerm (FRect(x + int(w), y, d_width, h + d_height)); // restore right
if ( dh > 0 ) if ( dh > 0 )
restoreVTerm (x, y + int(h) + bsh, int(w) + rsw + dw, dh); // restore bottom restoreVTerm (FRect(x, y + int(h), w + d_width, d_height)); // restore bottom
redraw(); redraw();
// handle overlaid windows // handle overlaid windows
if ( window_list && ! window_list->empty() ) restoreOverlaidWindows();
{
bool overlaid = false;
for (auto&& win : *window_list)
{
if ( overlaid )
putArea (win->getTermPos(), win->getVWin());
if ( vwin == win->getVWin() )
overlaid = true;
}
}
// set the cursor to the focus widget // set the cursor to the focus widget
auto focus = FWidget::getFocusWidget(); setCursorToFocusWidget();
if ( focus
&& focus->isVisible()
&& focus->hasVisibleCursor() )
{
FPoint cursor_pos = focus->getCursorPos();
focus->setCursorPos(cursor_pos);
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -364,7 +325,7 @@ bool FDialog::reduceHeight (int n)
if ( ! isResizeable() ) if ( ! isResizeable() )
return false; return false;
setSize (getWidth(), getHeight() - std::size_t(n)); setSize (FSize(getWidth(), getHeight() - std::size_t(n)));
return ! setSize_error; return ! setSize_error;
} }
@ -374,7 +335,7 @@ bool FDialog::expandHeight (int n)
if ( ! isResizeable() || getHeight() + std::size_t(getY()) > getMaxHeight() ) if ( ! isResizeable() || getHeight() + std::size_t(getY()) > getMaxHeight() )
return false; return false;
setSize (getWidth(), getHeight() + std::size_t(n)); setSize (FSize(getWidth(), getHeight() + std::size_t(n)));
return ! setSize_error; return ! setSize_error;
} }
@ -384,7 +345,7 @@ bool FDialog::reduceWidth (int n)
if ( ! isResizeable() ) if ( ! isResizeable() )
return false; return false;
setSize (getWidth() - std::size_t(n), getHeight()); setSize (FSize(getWidth() - std::size_t(n), getHeight()));
return ! setSize_error; return ! setSize_error;
} }
@ -394,7 +355,7 @@ bool FDialog::expandWidth (int n)
if ( ! isResizeable() || getWidth() + std::size_t(getX()) > getMaxWidth() ) if ( ! isResizeable() || getWidth() + std::size_t(getX()) > getMaxWidth() )
return false; return false;
setSize (getWidth() + std::size_t(n), getHeight()); setSize (FSize(getWidth() + std::size_t(n), getHeight()));
return ! setSize_error; return ! setSize_error;
} }
@ -410,7 +371,7 @@ void FDialog::activateDialog()
setFocus(); setFocus();
setFocusWidget(this); setFocusWidget(this);
if ( win_focus && numOfFocusableChildren() > 1 ) if ( win_focus )
{ {
win_focus->setFocus(); win_focus->setFocus();
win_focus->redraw(); win_focus->redraw();
@ -511,7 +472,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
{ {
// Click on titlebar menu button // Click on titlebar menu button
if ( ms.mouse_x < 4 && ms.mouse_y == 1 if ( ms.mouse_x < 4 && ms.mouse_y == 1
&& dialog_menu->isVisible() ) && dialog_menu->isShown() )
leaveMenu(); // close menu leaveMenu(); // close menu
cancelMouseResize(); // Cancel resize cancelMouseResize(); // Cancel resize
@ -548,7 +509,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
int titlebar_x = titlebar_click_pos.getX() int titlebar_x = titlebar_click_pos.getX()
, titlebar_y = titlebar_click_pos.getY(); , titlebar_y = titlebar_click_pos.getY();
if ( ! titlebar_click_pos.isNull() if ( ! titlebar_click_pos.isOrigin()
&& titlebar_x > int(getTermX()) + 3 && titlebar_x > int(getTermX()) + 3
&& titlebar_x < getTermX() + int(getWidth()) && titlebar_x < getTermX() + int(getWidth())
&& titlebar_y == int(getTermY()) ) && titlebar_y == int(getTermY()) )
@ -561,7 +522,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
// Click on titlebar menu button // Click on titlebar menu button
if ( ms.mouse_x < 4 if ( ms.mouse_x < 4
&& ms.mouse_y == 1 && ms.mouse_y == 1
&& dialog_menu->isVisible() && dialog_menu->isShown()
&& ! dialog_menu->hasSelectedItem() ) && ! dialog_menu->hasSelectedItem() )
{ {
// Sets focus to the first item // Sets focus to the first item
@ -595,7 +556,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
if ( ev->getButton() != fc::LeftButton ) if ( ev->getButton() != fc::LeftButton )
return; return;
if ( ! titlebar_click_pos.isNull() ) if ( ! titlebar_click_pos.isOrigin() )
{ {
FPoint deltaPos = ms.termPos - titlebar_click_pos; FPoint deltaPos = ms.termPos - titlebar_click_pos;
move (deltaPos); move (deltaPos);
@ -679,7 +640,7 @@ void FDialog::onAccel (FAccelEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowActive (FEvent*) void FDialog::onWindowActive (FEvent*)
{ {
if ( isVisible() && isShown() ) if ( isShown() )
drawTitleBar(); drawTitleBar();
if ( ! FWidget::getFocusWidget() ) if ( ! FWidget::getFocusWidget() )
@ -687,7 +648,6 @@ void FDialog::onWindowActive (FEvent*)
auto win_focus = getWindowFocusWidget(); auto win_focus = getWindowFocusWidget();
if ( win_focus if ( win_focus
&& win_focus->isVisible()
&& win_focus->isShown() ) && win_focus->isShown() )
{ {
win_focus->setFocus(); win_focus->setFocus();
@ -706,10 +666,10 @@ void FDialog::onWindowActive (FEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowInactive (FEvent*) void FDialog::onWindowInactive (FEvent*)
{ {
if ( dialog_menu && ! dialog_menu->isVisible() ) if ( dialog_menu && ! dialog_menu->isShown() )
FWindow::setPreviousWindow(this); FWindow::setPreviousWindow(this);
if ( isVisible() && isEnabled() ) if ( isShown() && isEnabled() )
drawTitleBar(); drawTitleBar();
if ( hasFocus() ) if ( hasFocus() )
@ -719,7 +679,7 @@ void FDialog::onWindowInactive (FEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FDialog::onWindowRaised (FEvent*) void FDialog::onWindowRaised (FEvent*)
{ {
if ( ! (isVisible() && isShown()) ) if ( ! (isShown() && isShown()) )
return; return;
putArea (getTermPos(), vwin); putArea (getTermPos(), vwin);
@ -772,7 +732,7 @@ void FDialog::draw()
clearArea(); clearArea();
drawBorder(); drawBorder();
drawTitleBar(); drawTitleBar();
setCursorPos(2, int(getHeight()) - 1); setCursorPos(FPoint(2, int(getHeight()) - 1));
if ( flags.shadow ) if ( flags.shadow )
drawDialogShadow(); drawDialogShadow();
@ -817,8 +777,8 @@ void FDialog::init()
ignorePadding(); ignorePadding();
setDialogWidget(); setDialogWidget();
// Initialize geometry values // Initialize geometry values
setGeometry (1, 1, 10, 10, false); setGeometry (FPoint(1, 1), FSize(10, 10), false);
setMinimumSize (15, 4); setMinimumSize (FSize(15, 4));
addDialog(this); addDialog(this);
setActiveWindow(this); setActiveWindow(this);
setTransparentShadow(); setTransparentShadow();
@ -861,7 +821,9 @@ void FDialog::initDialogMenu()
return; return;
} }
dialog_menu->setPos (getX(), getY() + 1); FPoint p = getPos();
p.y_ref()++;
dialog_menu->setPos (p);
dgl_menuitem = dialog_menu->getItem(); dgl_menuitem = dialog_menu->getItem();
dgl_menuitem->ignorePadding(); dgl_menuitem->ignorePadding();
dgl_menuitem->unsetFocusable(); dgl_menuitem->unsetFocusable();
@ -952,7 +914,7 @@ void FDialog::drawBorder()
, y1 = 2 , y1 = 2
, y2 = 1 + int(getHeight()) - 1; , y2 = 1 + int(getHeight()) - 1;
if ( (getMoveSizeWidget() == this || ! resize_click_pos.isNull() ) if ( (getMoveSizeWidget() == this || ! resize_click_pos.isOrigin() )
&& ! isZoomed() ) && ! isZoomed() )
setColor (wc.dialog_resize_fg, getBackgroundColor()); setColor (wc.dialog_resize_fg, getBackgroundColor());
else else
@ -962,24 +924,20 @@ void FDialog::drawBorder()
{ {
for (int y = y1; y < y2; y++) for (int y = y1; y < y2; y++)
{ {
setPrintPos (x1, y); print() << FPoint(x1, y) // Border left ⎸
// Border left ⎸ << fc::NF_border_line_left;
print (fc::NF_border_line_left); print() << FPoint(x2, y) // Border right⎹
setPrintPos (x2, y); << fc::NF_rev_border_line_right;
// Border right⎹
print (fc::NF_rev_border_line_right);
} }
setPrintPos (x1, y2); print() << FPoint(x1, y2) // Lower left corner border ⎣
// Lower left corner border ⎣ << fc::NF_border_corner_lower_left;
print (fc::NF_border_corner_lower_left);
for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _ for (std::size_t x = 1; x < getWidth() - 1; x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); print() << FPoint(x2, y2) // Lower right corner border ⎦
// Lower right corner border ⎦ << fc::NF_rev_border_corner_lower_right;
print (fc::NF_rev_border_corner_lower_right);
} }
else else
{ {
@ -1004,7 +962,7 @@ void FDialog::drawTitleBar()
if ( PRINT_WIN_NUMBER ) if ( PRINT_WIN_NUMBER )
{ {
// Print the number of window in stack // Print the number of window in stack
setPrintPos (getWidth() - 2, 1); print() << FPoint(int(getWidth()) - 2, 1);
printf ("(%d)", getWindowLayer(this)); printf ("(%d)", getWindowLayer(this));
} }
#endif // DEBUG #endif // DEBUG
@ -1014,9 +972,9 @@ void FDialog::drawTitleBar()
void FDialog::drawBarButton() void FDialog::drawBarButton()
{ {
// Print the title button // Print the title button
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( dialog_menu && dialog_menu->isVisible() ) 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 else
setColor (wc.titlebar_button_fg, wc.titlebar_button_bg); setColor (wc.titlebar_button_fg, wc.titlebar_button_bg);
@ -1138,7 +1096,7 @@ void FDialog::drawTextBar()
if ( getMaxColor() < 16 ) if ( getMaxColor() < 16 )
setBold(); setBold();
if ( isWindowActive() || (dialog_menu && dialog_menu->isVisible()) ) 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 else
setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg); setColor (wc.titlebar_inactive_fg, wc.titlebar_inactive_bg);
@ -1202,7 +1160,7 @@ void FDialog::setCursorToFocusWidget()
auto focus = FWidget::getFocusWidget(); auto focus = FWidget::getFocusWidget();
if ( focus if ( focus
&& focus->isVisible() && focus->isShown()
&& focus->hasVisibleCursor() ) && focus->hasVisibleCursor() )
{ {
FPoint cursor_pos = focus->getCursorPos(); FPoint cursor_pos = focus->getCursorPos();
@ -1238,7 +1196,7 @@ void FDialog::openMenu()
if ( ! dialog_menu ) if ( ! dialog_menu )
return; return;
if ( dialog_menu->isVisible() ) if ( dialog_menu->isShown() )
{ {
leaveMenu(); leaveMenu();
drawTitleBar(); drawTitleBar();
@ -1246,12 +1204,14 @@ void FDialog::openMenu()
else else
{ {
setOpenMenu(dialog_menu); setOpenMenu(dialog_menu);
dialog_menu->setPos (getX(), getY() + 1); FPoint pos = getPos();
pos.y_ref()++;
dialog_menu->setPos (pos);
dialog_menu->setVisible(); dialog_menu->setVisible();
drawTitleBar();
dialog_menu->show(); dialog_menu->show();
dialog_menu->raiseWindow(); dialog_menu->raiseWindow();
dialog_menu->redraw(); dialog_menu->redraw();
drawTitleBar();
} }
} }
@ -1372,7 +1332,6 @@ inline void FDialog::passEventToSubMenu ( const mouseStates& ms
{ {
// Mouse event handover to the dialog menu // Mouse event handover to the dialog menu
if ( ! ms.mouse_over_menu if ( ! ms.mouse_over_menu
|| ! dialog_menu->isVisible()
|| ! dialog_menu->isShown() ) || ! dialog_menu->isShown() )
return; return;
@ -1482,6 +1441,18 @@ inline void FDialog::lowerActivateDialog()
updateTerminal(); updateTerminal();
} }
//----------------------------------------------------------------------
bool FDialog::isOutsideTerminal (const FPoint& pos)
{
if ( pos.getX() + int(getWidth()) <= 1
|| pos.getX() > int(getMaxWidth())
|| pos.getY() < 1
|| pos.getY() > int(getMaxHeight()) )
return true;
return false;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) bool FDialog::isLowerRightResizeCorner (const mouseStates& ms)
{ {
@ -1516,7 +1487,8 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
FPoint deltaPos = ms.termPos - lower_right_pos; FPoint deltaPos = ms.termPos - lower_right_pos;
int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1; int w = lower_right_pos.getX() + deltaPos.getX() - getTermX() + 1;
int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1; int h = lower_right_pos.getY() + deltaPos.getY() - getTermY() + 1;
setSize (std::size_t(w), std::size_t(h)); const FSize& size = FSize(std::size_t(w), std::size_t(h));
setSize (size, true);
} }
else else
drawBorder(); drawBorder();
@ -1529,7 +1501,7 @@ void FDialog::resizeMouseDown (const mouseStates& ms)
void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up) void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
{ {
// Resize the dialog // Resize the dialog
if ( isResizeable() && ! resize_click_pos.isNull() ) if ( isResizeable() && ! resize_click_pos.isOrigin() )
{ {
auto r = getRootWidget(); auto r = getRootWidget();
resize_click_pos = ms.termPos; resize_click_pos = ms.termPos;
@ -1559,8 +1531,9 @@ void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up)
else else
h = int(getMaxHeight()) - getTermY() + y2_offset + 1; h = int(getMaxHeight()) - getTermY() + y2_offset + 1;
setSize ( ( w >= 0) ? std::size_t(w) : 0 const FSize size ( ( w >= 0) ? std::size_t(w) : 0
, ( h >= 0) ? std::size_t(h) : 0 ); , ( h >= 0) ? std::size_t(h) : 0 );
setSize (size);
} }
if ( mouse_up ) if ( mouse_up )
@ -1580,7 +1553,7 @@ void FDialog::cancelMouseResize()
{ {
// Cancel resize by mouse // Cancel resize by mouse
if ( resize_click_pos.isNull() ) if ( resize_click_pos.isOrigin() )
return; return;
resize_click_pos.setPoint (0, 0); resize_click_pos.setPoint (0, 0);
@ -1612,7 +1585,7 @@ inline void FDialog::cancelMoveSize()
setPos (save_geometry.getPos()); setPos (save_geometry.getPos());
if ( isResizeable() ) if ( isResizeable() )
setSize (save_geometry.getWidth(), save_geometry.getHeight()); setSize (save_geometry.getSize());
redraw(); redraw();
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -52,6 +52,40 @@ bool sortDirFirst ( const FFileDialog::dir_entry& lhs
return false; return false;
} }
//----------------------------------------------------------------------
const FString fileChooser ( FWidget* parent
, const FString& dirname
, const FString& filter
, FFileDialog::DialogType type )
{
FString ret;
FString path = dirname;
FString file_filter = filter;
if ( path.isNull() || path.isEmpty() )
{
path = FFileDialog::getHomeDir();
if ( path.isNull() || path.isEmpty() )
path = FString("/");
}
if ( file_filter.isNull() || file_filter.isEmpty() )
file_filter = FString("*");
FFileDialog fileopen ( path
, file_filter
, type
, parent );
if ( fileopen.exec() == FDialog::Accept )
ret = fileopen.getPath() + fileopen.getSelectedFile();
else
ret = FString();
return ret;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FFileDialog // class FFileDialog
@ -225,32 +259,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent
, const FString& dirname , const FString& dirname
, const FString& filter ) , const FString& filter )
{ {
FString ret; return fileChooser (parent, dirname, filter, FFileDialog::Open);
FString path = dirname;
FString file_filter = filter;
if ( path.isNull() || path.isEmpty() )
{
path = getHomeDir();
if ( path.isNull() || path.isEmpty() )
path = FString("/");
}
if ( file_filter.isNull() || file_filter.isEmpty() )
file_filter = FString("*");
FFileDialog fileopen ( path
, file_filter
, FFileDialog::Open
, parent );
if ( fileopen.exec() == FDialog::Accept )
ret = fileopen.getPath() + fileopen.getSelectedFile();
else
ret = FString();
return ret;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -258,32 +267,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
, const FString& dirname , const FString& dirname
, const FString& filter ) , const FString& filter )
{ {
FString ret; return fileChooser (parent, dirname, filter, FFileDialog::Save);
FString path = dirname;
FString file_filter = filter;
if ( path.isNull() || path.isEmpty() )
{
path = getHomeDir();
if ( path.isNull() || path.isEmpty() )
path = FString("/");
}
if ( file_filter.isNull() || file_filter.isEmpty() )
file_filter = FString("*");
FFileDialog fileopen ( path
, file_filter
, FFileDialog::Save
, parent );
if ( fileopen.exec() == FDialog::Accept )
ret = fileopen.getPath() + fileopen.getSelectedFile();
else
ret = FString();
return ret;
} }
@ -320,7 +304,7 @@ void FFileDialog::adjustSize()
setHeight (h, false); setHeight (h, false);
X = 1 + int((max_width - getWidth()) / 2); X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3); Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(FPoint(X, Y), false);
filebrowser.setHeight (h - 8, false); filebrowser.setHeight (h - 8, false);
hidden.setY (int(h) - 4, false); hidden.setY (int(h) - 4, false);
cancel.setY (int(h) - 4, false); cancel.setY (int(h) - 4, false);
@ -338,7 +322,7 @@ void FFileDialog::init()
static constexpr std::size_t h = 15; static constexpr std::size_t h = 15;
int x, y; int x, y;
setGeometry(1, 1, w, h, false); setGeometry(FPoint(1, 1), FSize(w, h), false);
auto parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
if ( parent_widget ) if ( parent_widget )
@ -354,36 +338,36 @@ void FFileDialog::init()
else else
FDialog::setText("Open file"); FDialog::setText("Open file");
widgetSettings (x, y); // Create widgets widgetSettings (FPoint(x, y)); // Create widgets
initCallbacks(); initCallbacks();
setModal(); setModal();
readDir(); readDir();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FFileDialog::widgetSettings (int x, int y) inline void FFileDialog::widgetSettings (const FPoint& pos)
{ {
filename.setLabelText ("File&name"); filename.setLabelText ("File&name");
filename.setText (filter_pattern); filename.setText (filter_pattern);
filename.setGeometry (11, 1, 28, 1); filename.setGeometry (FPoint(11, 1), FSize(28, 1));
filename.setFocus(); filename.setFocus();
filebrowser.setGeometry (2, 3, 38, 6); filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6));
printPath (directory); printPath (directory);
hidden.setText ("&hidden files"); hidden.setText ("&hidden files");
hidden.setGeometry (2, 10, 16, 1); hidden.setGeometry (FPoint(2, 10), FSize(16, 1));
cancel.setText ("&Cancel"); cancel.setText ("&Cancel");
cancel.setGeometry(19, 10, 9, 1); cancel.setGeometry(FPoint(19, 10), FSize(9, 1));
if ( dlg_type == FFileDialog::Save ) if ( dlg_type == FFileDialog::Save )
open.setText ("&Save"); open.setText ("&Save");
else else
open.setText ("&Open"); open.setText ("&Open");
open.setGeometry(30, 10, 9, 1); open.setGeometry(FPoint(30, 10), FSize(9, 1));
setGeometry (x, y, getWidth(), getHeight()); setGeometry (pos, getSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -233,33 +233,8 @@ void FLabel::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::hide() void FLabel::hide()
{ {
FColor fg, bg;
std::size_t size;
auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
hideSize (getSize());
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
size = getWidth();
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -370,30 +345,6 @@ void FLabel::init()
} }
} }
//----------------------------------------------------------------------
uChar FLabel::getHotkey()
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FLabel::getHotkeyPos ( wchar_t src[] std::size_t FLabel::getHotkeyPos ( wchar_t src[]
, wchar_t dest[] , wchar_t dest[]
@ -422,19 +373,19 @@ std::size_t FLabel::getHotkeyPos ( wchar_t src[]
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLabel::setHotkeyAccelerator() void FLabel::setHotkeyAccelerator()
{ {
uChar hotkey = getHotkey(); FKey hotkey = getHotkey(text);
if ( hotkey ) if ( hotkey )
{ {
if ( std::isalpha(hotkey) || std::isdigit(hotkey) ) if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{ {
addAccelerator (FKey(std::tolower(hotkey))); addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(hotkey))); addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey // Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey))); addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
} }
else else
addAccelerator (getHotkey()); addAccelerator (hotkey);
} }
else else
delAccelerator(); delAccelerator();
@ -529,7 +480,7 @@ void FLabel::drawMultiLine()
else else
std::wcsncpy(dest, src, length); std::wcsncpy(dest, src, length);
setPrintPos (1, 1 + int(y)); print() << FPoint(1, 1 + int(y));
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
{ {
@ -571,7 +522,7 @@ void FLabel::drawSingleLine()
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;
setPrintPos (1, 1); print() << FPoint(1, 1);
align_offset = getAlignOffset(length); align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset); printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text; delete[] label_text;
@ -632,8 +583,7 @@ void FLabel::printLine ( wchar_t line[]
if ( length > width ) if ( length > width )
{ {
// Print ellipsis // Print ellipsis
setColor (ellipsis_color, getBackgroundColor()); print() << FColorPair(ellipsis_color, getBackgroundColor()) << "..";
print ("..");
setColor(); setColor();
} }
else if ( align_offset + to_char < width ) else if ( align_offset + to_char < width )

View File

@ -230,12 +230,12 @@ bool FLineEdit::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return flags.shadow; return flags.shadow;
@ -271,42 +271,12 @@ void FLineEdit::setLabelOrientation(const label_o o)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::hide() void FLineEdit::hide()
{ {
std::size_t s, size;
FColor fg, bg;
auto parent_widget = getParentWidget();
FWidget::hide();
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
s = hasShadow() ? 1 : 0;
size = getWidth() + s;
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s; y++)
{
setPrintPos (1, 1 + int(y));
print (blank);
}
destroyBlankArray(blank);
if ( label ) if ( label )
label->hide(); label->hide();
FWidget::hide();
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
hideSize (getSize() + shadow);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -628,12 +598,13 @@ void FLineEdit::adjustLabel()
switch ( label_orientation ) switch ( label_orientation )
{ {
case label_above: case label_above:
label->setGeometry(getX(), getY() - 1, label_length, 1); label->setGeometry ( FPoint(getX(), getY() - 1)
, FSize(label_length, 1) );
break; break;
case label_left: case label_left:
label->setGeometry(getX() - int(label_length) - 1, getY() label->setGeometry ( FPoint(getX() - int(label_length) - 1, getY())
, label_length, 1); , FSize(label_length, 1) );
break; break;
} }
} }
@ -707,7 +678,7 @@ void FLineEdit::drawInputField()
std::size_t x; std::size_t x;
FString show_text; FString show_text;
bool isActiveFocus = flags.active && flags.focus; bool isActiveFocus = flags.active && flags.focus;
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( isMonochron() ) if ( isMonochron() )
{ {
@ -754,7 +725,7 @@ void FLineEdit::drawInputField()
drawShadow (); drawShadow ();
// set the cursor to the first pos. // set the cursor to the first pos.
setCursorPos (int(2 + cursor_pos - text_offset), 1); setCursorPos (FPoint(int(2 + cursor_pos - text_offset), 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -118,8 +118,6 @@ void FListBox::setCurrentItem (std::size_t index)
yoffset = 0; yoffset = 0;
adjustSize(); adjustSize();
vbar->setValue(yoffset); vbar->setValue(yoffset);
if ( isVisible() )
redraw(); redraw();
} }
@ -155,30 +153,29 @@ void FListBox::showInsideBrackets ( std::size_t index
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4)); hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->setValue (xoffset); hbar->setValue (xoffset);
if ( ! hbar->isVisible() ) if ( ! hbar->isShown() )
hbar->setVisible(); hbar->show();
} }
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::setGeometry ( int x, int y void FListBox::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the widget geometry // Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (1, int(getHeight()), getWidth() - 2 - nf_offset, 1); hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2 - nf_offset, 1));
} }
else else
{ {
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(2, int(getHeight())), FSize(getWidth() - 2, 1));
} }
} }
@ -216,38 +213,8 @@ void FListBox::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::hide() void FListBox::hide()
{ {
std::size_t n, size;
FColor fg, bg;
auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
hideSize (getSize());
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
n = isNewFont() ? 1 : 0;
size = getWidth() + n;
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
for (int y = 0; y < int(getHeight()); y++)
{
setPrintPos (1, 1 + y);
print (blank);
}
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -289,7 +256,7 @@ void FListBox::remove (std::size_t item)
hbar->setMaximum (hmax); hbar->setMaximum (hmax);
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4)); hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
if ( hbar->isVisible() && max_line_width < getWidth() - nf_offset - 3 ) if ( hbar->isShown() && isHorizontallyScrollable() )
hbar->hide(); hbar->hide();
int vmax = ( element_count > getHeight() - 2 ) int vmax = ( element_count > getHeight() - 2 )
@ -298,7 +265,7 @@ void FListBox::remove (std::size_t item)
vbar->setMaximum (vmax); vbar->setMaximum (vmax);
vbar->setPageSize (int(element_count), int(getHeight()) - 2); vbar->setPageSize (int(element_count), int(getHeight()) - 2);
if ( vbar->isVisible() && element_count < getHeight() - 1 ) if ( vbar->isShown() && isVerticallyScrollable() )
vbar->hide(); vbar->hide();
if ( current >= item && current > 1 ) if ( current >= item && current > 1 )
@ -348,8 +315,7 @@ void FListBox::clear()
for (int y = 0; y < int(getHeight()) - 2; y++) for (int y = 0; y < int(getHeight()) - 2; y++)
{ {
setPrintPos (2, 2 + y); print() << FPoint(2, 2 + y) << blank;
print (blank);
} }
destroyBlankArray (blank); destroyBlankArray (blank);
@ -490,12 +456,12 @@ void FListBox::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::RightButton ) if ( ev->getButton() == fc::RightButton )
multiSelection(current); multiSelection(current);
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset ) if ( yoffset_before != yoffset )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -558,12 +524,12 @@ void FListBox::onMouseMove (FMouseEvent* ev)
multiSelectionUpTo(current); multiSelectionUpTo(current);
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset ) if ( yoffset_before != yoffset )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -637,12 +603,12 @@ void FListBox::onTimer (FTimerEvent*)
multiSelectionUpTo(current); multiSelectionUpTo(current);
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset ) if ( yoffset_before != yoffset )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -685,12 +651,12 @@ void FListBox::onWheel (FWheelEvent* ev)
processSelect(); processSelect();
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset ) if ( yoffset_before != yoffset )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -770,15 +736,15 @@ void FListBox::adjustSize()
hbar->setWidth (width + nf_offset, false); hbar->setWidth (width + nf_offset, false);
hbar->resize(); hbar->resize();
if ( element_count <= height ) if ( isHorizontallyScrollable() )
vbar->hide(); hbar->show();
else else
vbar->setVisible();
if ( max_line_width < width - 1 )
hbar->hide(); hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else else
hbar->setVisible(); vbar->hide();
} }
@ -792,20 +758,26 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::init() void FListBox::init()
{ {
initScrollbar (vbar, fc::vertical, &FListBox::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListBox::cb_HBarChange);
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + int(nf_offset));
}
//----------------------------------------------------------------------
void FListBox::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FListBoxCallback callback )
{
try try
{ {
vbar = std::make_shared<FScrollbar>(fc::vertical, this); bar = std::make_shared<FScrollbar>(o, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -813,25 +785,15 @@ void FListBox::init()
return; return;
} }
setGeometry (1, 1, 5, 4, false); // initialize geometry values bar->setMinimum(0);
bar->setValue(0);
bar->hide();
vbar->addCallback bar->addCallback
( (
"change-value", "change-value",
F_METHOD_CALLBACK (this, &FListBox::cb_VBarChange) F_METHOD_CALLBACK (this, callback)
); );
hbar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, &FListBox::cb_HBarChange)
);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + int(nf_offset));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -850,14 +812,14 @@ void FListBox::draw()
else else
drawBorder(); drawBorder();
if ( isNewFont() && ! vbar->isVisible() ) if ( isNewFont() && ! vbar->isShown() )
{ {
setColor(); setColor();
for (int y = 2; y < int(getHeight()); y++) for (int y = 2; y < int(getHeight()); y++)
{ {
setPrintPos (int(getWidth()), y); print() << FPoint(int(getWidth()), y)
print (' '); // clear right side of the scrollbar << ' '; // clear right side of the scrollbar
} }
} }
@ -866,12 +828,8 @@ void FListBox::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
if ( vbar->isVisible() )
vbar->redraw(); vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw(); hbar->redraw();
drawList(); drawList();
if ( flags.focus && getStatusBar() ) if ( flags.focus && getStatusBar() )
@ -895,7 +853,7 @@ void FListBox::drawHeadline()
FString txt = " " + text + " "; FString txt = " " + text + " ";
std::size_t length = txt.getLength(); std::size_t length = txt.getLength();
setPrintPos (2, 1); print() << FPoint(2, 1);
if ( isEnabled() ) if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg); setColor(wc.label_emphasis_fg, wc.label_bg);
@ -907,9 +865,8 @@ void FListBox::drawHeadline()
else else
{ {
// Print ellipsis // Print ellipsis
print (text.left(uInt(getClientWidth() - 2))); print() << text.left(uInt(getClientWidth() - 2))
setColor (wc.label_ellipsis_fg, wc.label_bg); << FColorPair (wc.label_ellipsis_fg, wc.label_bg) << "..";
print("..");
} }
} }
@ -1101,7 +1058,7 @@ inline void FListBox::setLineAttributes ( int y
{ {
bool isCurrentLine = bool(y + yoffset + 1 == int(current)); bool isCurrentLine = bool(y + yoffset + 1 == int(current));
std::size_t inc_len = inc_search.getLength(); std::size_t inc_len = inc_search.getLength();
setPrintPos (2, 2 + int(y)); print() << FPoint(2, 2 + int(y));
if ( isLineSelected ) if ( isLineSelected )
{ {
@ -1134,7 +1091,7 @@ inline void FListBox::setLineAttributes ( int y
setColor ( wc.selected_current_element_fg setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg ); , wc.selected_current_element_bg );
setCursorPos (3, 2 + int(y)); // first character setCursorPos (FPoint(3, 2 + int(y))); // first character
} }
else else
{ {
@ -1151,10 +1108,10 @@ inline void FListBox::setLineAttributes ( int y
{ {
serach_mark = true; serach_mark = true;
// Place the cursor on the last found character // Place the cursor on the last found character
setCursorPos (2 + b + int(inc_len), 2 + int(y)); setCursorPos (FPoint(2 + b + int(inc_len), 2 + int(y)));
} }
else // only highlighted else // only highlighted
setCursorPos (3 + b, 2 + int(y)); // first character setCursorPos (FPoint(3 + b, 2 + int(y))); // first character
} }
else else
setColor ( wc.current_element_fg setColor ( wc.current_element_fg
@ -1185,17 +1142,17 @@ inline void FListBox::unsetAttributes()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar) inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar)
{ {
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && draw_vbar ) if ( draw_vbar )
vbar->drawBar(); vbar->drawBar();
hbar->setValue (xoffset); hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar ) if ( draw_hbar )
hbar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
@ -1222,8 +1179,10 @@ void FListBox::recalculateHorizontalBar (std::size_t len, bool has_brackets)
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4)); hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset - 4));
hbar->calculateSliderValues(); hbar->calculateSliderValues();
if ( ! hbar->isVisible() ) if ( isHorizontallyScrollable() )
hbar->setVisible(); hbar->show();
else
hbar->hide();
} }
} }
@ -1237,8 +1196,10 @@ void FListBox::recalculateVerticalBar (std::size_t element_count)
vbar->setPageSize (int(element_count), int(getHeight()) - 2); vbar->setPageSize (int(element_count), int(getHeight()) - 2);
vbar->calculateSliderValues(); vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 ) if ( isVerticallyScrollable() )
vbar->setVisible(); vbar->show();
else
vbar->hide();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1823,7 +1784,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
std::size_t len = iter->text.getLength(); std::size_t len = iter->text.getLength();
recalculateHorizontalBar (len, hasBrackets(iter)); recalculateHorizontalBar (len, hasBrackets(iter));
if ( hbar->isVisible() ) if ( hbar->isShown() )
hbar->redraw(); hbar->redraw();
} }
@ -1878,7 +1839,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
processSelect(); processSelect();
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
@ -1886,7 +1847,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
{ {
vbar->setValue (yoffset); vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset ) if ( yoffset_before != yoffset )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -1939,7 +1900,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
if ( xoffset_before != xoffset ) if ( xoffset_before != xoffset )
inc_search.clear(); inc_search.clear();
if ( isVisible() ) if ( isShown() )
{ {
drawList(); drawList();
updateTerminal(); updateTerminal();
@ -1951,7 +1912,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset ) if ( xoffset_before != xoffset )
hbar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -650,23 +650,22 @@ fc::sorting_type FListView::getColumnSortType (int column) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::setGeometry ( int x, int y void FListView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the widget geometry // Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (1, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2); vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1); hbar->setGeometry (FPoint(2, int(getHeight())), FSize(getWidth() - 2, 1));
} }
} }
@ -752,6 +751,13 @@ int FListView::addColumn (const FString& label, int width)
return int(std::distance(header.begin(), header.end())); return int(std::distance(header.begin(), header.end()));
} }
//----------------------------------------------------------------------
void FListView::hide()
{
FWidget::hide();
hideSize (getSize());
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( FListViewItem* item FObject::FObjectIterator FListView::insert ( FListViewItem* item
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
@ -818,24 +824,6 @@ FObject::FObjectIterator FListView::insert ( const FStringList& cols
return insert(item, parent_iter); return insert(item, parent_iter);
} }
//----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( const std::vector<uInt64>& cols
, FDataPtr d
, FObjectIterator parent_iter )
{
FStringList str_cols;
if ( ! cols.empty() )
{
for (uInt i = 0; i < cols.size(); i++)
str_cols.push_back (FString().setNumber(cols[i]));
}
auto item_iter = insert (str_cols, d, parent_iter);
return item_iter;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::sort() void FListView::sort()
{ {
@ -1036,13 +1024,12 @@ void FListView::onMouseDown (FMouseEvent* ev)
} }
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() if ( first_line_position_before != first_visible_line.getPosition() )
&& first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -1087,7 +1074,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
adjustSize(); adjustSize();
if ( isVisible() ) if ( isShown() )
draw(); draw();
} }
} }
@ -1103,7 +1090,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
{ {
item->setChecked(! item->isChecked()); item->setChecked(! item->isChecked());
if ( isVisible() ) if ( isShown() )
draw(); draw();
} }
} }
@ -1139,13 +1126,12 @@ void FListView::onMouseMove (FMouseEvent* ev)
if ( new_pos < int(getCount()) ) if ( new_pos < int(getCount()) )
setRelativePosition (mouse_y - 2); setRelativePosition (mouse_y - 2);
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() if ( first_line_position_before != first_visible_line.getPosition() )
&& first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -1189,7 +1175,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
adjustSize(); adjustSize();
if ( isVisible() ) if ( isShown() )
draw(); draw();
} }
@ -1226,13 +1212,12 @@ void FListView::onTimer (FTimerEvent*)
break; break;
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() if ( first_line_position_before != first_visible_line.getPosition() )
&& first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -1266,13 +1251,12 @@ void FListView::onWheel (FWheelEvent* ev)
if ( position_before != current_iter.getPosition() ) if ( position_before != current_iter.getPosition() )
processChanged(); processChanged();
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() if ( first_line_position_before != first_visible_line.getPosition() )
&& first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -1368,15 +1352,15 @@ void FListView::adjustSize()
hbar->setWidth (width, false); hbar->setWidth (width, false);
hbar->resize(); hbar->resize();
if ( element_count <= height ) if ( isHorizontallyScrollable() )
vbar->hide(); hbar->show();
else else
vbar->setVisible();
if ( max_line_width <= width )
hbar->hide(); hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else else
hbar->setVisible(); vbar->hide();
} }
@ -1384,24 +1368,29 @@ void FListView::adjustSize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::init() void FListView::init()
{ {
initScrollbar (vbar, fc::vertical, &FListView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListView::cb_HBarChange);
selflist.push_back(this); selflist.push_back(this);
root = selflist.begin(); root = selflist.begin();
null_iter = selflist.end(); null_iter = selflist.end();
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + int(nf_offset));
}
//----------------------------------------------------------------------
void FListView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FListViewCallback callback )
{
try try
{ {
vbar = std::make_shared<FScrollbar>(fc::vertical, this); bar = std::make_shared<FScrollbar>(o, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -1409,25 +1398,15 @@ void FListView::init()
return; return;
} }
setGeometry (1, 1, 5, 4, false); // initialize geometry values bar->setMinimum(0);
bar->setValue(0);
bar->hide();
vbar->addCallback bar->addCallback
( (
"change-value", "change-value",
F_METHOD_CALLBACK (this, &FListView::cb_VBarChange) F_METHOD_CALLBACK (this, callback)
); );
hbar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, &FListView::cb_HBarChange)
);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + int(nf_offset));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1484,14 +1463,14 @@ void FListView::draw()
else else
drawBorder(); drawBorder();
if ( isNewFont() && ! vbar->isVisible() ) if ( isNewFont() && ! vbar->isShown() )
{ {
setColor(); setColor();
for (int y = 2; y < int(getHeight()); y++) for (int y = 2; y < int(getHeight()); y++)
{ {
setPrintPos (int(getWidth()), y); print() << FPoint(int(getWidth()), y)
print (' '); // clear right side of the scrollbar << ' '; // clear right side of the scrollbar
} }
} }
@ -1500,12 +1479,8 @@ void FListView::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
if ( vbar->isVisible() )
vbar->redraw(); vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw(); hbar->redraw();
drawList(); drawList();
if ( flags.focus && getStatusBar() ) if ( flags.focus && getStatusBar() )
@ -1568,8 +1543,7 @@ void FListView::drawHeadlines()
last = h.begin() + len; last = h.begin() + len;
} }
setPrintPos (2, 1); print() << FPoint(2, 1) << std::vector<charData>(first, last);
print() << std::vector<charData>(first, last);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1588,7 +1562,7 @@ void FListView::drawList()
const auto item = static_cast<FListViewItem*>(*iter); const auto item = static_cast<FListViewItem*>(*iter);
int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0; int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
int checkbox_offset = ( item->isCheckable() ) ? 1 : 0; int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
setPrintPos (2, 2 + int(y)); print() << FPoint(2, 2 + int(y));
// Draw one FListViewItem // Draw one FListViewItem
drawListLine (item, flags.focus, is_current_line); drawListLine (item, flags.focus, is_current_line);
@ -1596,8 +1570,8 @@ void FListView::drawList()
if ( flags.focus && is_current_line ) if ( flags.focus && is_current_line )
{ {
setVisibleCursor (item->isCheckable()); setVisibleCursor (item->isCheckable());
setCursorPos ( 3 + tree_offset + checkbox_offset - xoffset setCursorPos (FPoint ( 3 + tree_offset + checkbox_offset - xoffset
, 2 + int(y)); // first character , 2 + int(y) )); // first character
} }
last_visible_line = iter; last_visible_line = iter;
@ -1614,8 +1588,8 @@ void FListView::drawList()
// Clean empty space after last element // Clean empty space after last element
while ( y < uInt(getClientHeight()) ) while ( y < uInt(getClientHeight()) )
{ {
setPrintPos (2, 2 + int(y)); print() << FPoint(2, 2 + int(y))
print (FString(std::size_t(getClientWidth()), ' ')); << FString(std::size_t(getClientWidth()), ' ');
y++; y++;
} }
} }
@ -1692,7 +1666,7 @@ void FListView::drawListLine ( const FListViewItem* item
std::size_t i; std::size_t i;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
*this << element_str[i]; print() << element_str[i];
for (; i < getWidth() - nf_offset - 2; i++) for (; i < getWidth() - nf_offset - 2; i++)
print (' '); print (' ');
@ -1875,10 +1849,10 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
static constexpr int ellipsis_length = 2; static constexpr int ellipsis_length = 2;
int width = iter->width; int width = iter->width;
headerline << ' '; headerline << ' '
headerline << text.left(uInt(width - ellipsis_length)); << text.left(uInt(width - ellipsis_length))
setColor (wc.label_ellipsis_fg, wc.label_bg); << FColorPair (wc.label_ellipsis_fg, wc.label_bg)
headerline << ".."; << "..";
if ( iter == header.end() - 1 ) // Last element if ( iter == header.end() - 1 ) // Last element
headerline << ' '; headerline << ' ';
@ -1887,17 +1861,17 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::updateDrawing (bool draw_vbar, bool draw_hbar) void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
{ {
if ( isVisible() ) if ( isShown() )
draw(); draw();
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() && draw_vbar ) if ( draw_vbar )
vbar->drawBar(); vbar->drawBar();
hbar->setValue (xoffset); hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar ) if ( draw_hbar )
hbar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();
@ -1982,8 +1956,10 @@ void FListView::recalculateHorizontalBar (std::size_t len)
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset) - 4); hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset) - 4);
hbar->calculateSliderValues(); hbar->calculateSliderValues();
if ( ! hbar->isVisible() ) if ( isHorizontallyScrollable() )
hbar->setVisible(); hbar->show();
else
hbar->hide();
} }
} }
@ -1997,8 +1973,10 @@ void FListView::recalculateVerticalBar (std::size_t element_count)
vbar->setPageSize (int(element_count), int(getHeight()) - 2); vbar->setPageSize (int(element_count), int(getHeight()) - 2);
vbar->calculateSliderValues(); vbar->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 ) if ( isVerticallyScrollable() )
vbar->setVisible(); vbar->show();
else
vbar->hide();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2032,7 +2010,7 @@ void FListView::mouseHeaderClicked()
sort(); sort();
if ( isVisible() ) if ( isShown() )
updateDrawing (true, false); updateDrawing (true, false);
break; break;
@ -2551,7 +2529,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
break; break;
} }
if ( isVisible() ) if ( isShown() )
drawList(); drawList();
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::scrollStepBackward
@ -2559,8 +2537,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
{ {
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() if ( first_line_position_before != first_visible_line.getPosition() )
&& first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar(); vbar->drawBar();
updateTerminal(); updateTerminal();
@ -2611,7 +2588,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
break; break;
} }
if ( isVisible() ) if ( isShown() )
{ {
drawHeadlines(); drawHeadlines();
drawList(); drawList();
@ -2624,7 +2601,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset ) if ( xoffset_before != xoffset )
hbar->drawBar(); hbar->drawBar();
updateTerminal(); updateTerminal();

View File

@ -433,7 +433,7 @@ void FMenu::init(FWidget* parent)
setLeftPadding(1); setLeftPadding(1);
setBottomPadding(1); setBottomPadding(1);
setRightPadding(1); setRightPadding(1);
setGeometry (1, 1, 10, 2, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(10, 2), false); // initialize geometry values
setTransparentShadow(); setTransparentShadow();
setMenuWidget(); setMenuWidget();
hide(); hide();
@ -498,7 +498,8 @@ void FMenu::calculateDimensions()
adjust_X = adjustX(getX()); adjust_X = adjustX(getX());
// set widget geometry // set widget geometry
setGeometry (adjust_X, getY(), max_item_width + 2, getCount() + 2); setGeometry ( FPoint(adjust_X, getY())
, FSize(max_item_width + 2, getCount() + 2) );
// set geometry of all items // set geometry of all items
iter = item_list.begin(); iter = item_list.begin();
@ -507,14 +508,14 @@ void FMenu::calculateDimensions()
while ( iter != last ) while ( iter != last )
{ {
(*iter)->setGeometry (item_X, item_Y, max_item_width, 1); (*iter)->setGeometry (FPoint(item_X, item_Y), FSize(max_item_width, 1));
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
int menu_X = getTermX() + int(max_item_width) + 1; int menu_X = getTermX() + int(max_item_width) + 1;
int menu_Y = (*iter)->getTermY() - 2; int menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position // set sub-menu position
(*iter)->getMenu()->setPos (menu_X, menu_Y, false); (*iter)->getMenu()->setPos (FPoint(menu_X, menu_Y), false);
} }
item_Y++; item_Y++;
@ -540,7 +541,7 @@ void FMenu::adjustItems()
menu_Y = (*iter)->getTermY() - 2; menu_Y = (*iter)->getTermY() - 2;
// set sub-menu position // set sub-menu position
menu->setPos (menu_X, menu_Y); menu->setPos (FPoint(menu_X, menu_Y));
// call sub-menu adjustItems() // call sub-menu adjustItems()
if ( menu->getCount() > 0 ) if ( menu->getCount() > 0 )
@ -574,7 +575,7 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select)
if ( ! sub_menu ) if ( ! sub_menu )
return; return;
if ( sub_menu->isVisible() ) if ( sub_menu->isShown() )
return; return;
if ( select ) if ( select )
@ -585,7 +586,6 @@ void FMenu::openSubMenu (FMenu* sub_menu, bool select)
sub_menu->getSelectedItem()->setFocus(); sub_menu->getSelectedItem()->setFocus();
} }
sub_menu->setVisible();
sub_menu->show(); sub_menu->show();
opened_sub_menu = sub_menu; opened_sub_menu = sub_menu;
raiseWindow (sub_menu); raiseWindow (sub_menu);
@ -737,7 +737,7 @@ void FMenu::mouseDownSelection (FMenuItem* m_item, bool& focus_changed)
if ( m_item->hasMenu() ) if ( m_item->hasMenu() )
{ {
auto sub_menu = m_item->getMenu(); auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isShown() )
shown_sub_menu = sub_menu; shown_sub_menu = sub_menu;
} }
} }
@ -766,7 +766,7 @@ bool FMenu::mouseUpOverList (FPoint mouse_pos)
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
{ {
auto sub_menu = (*iter)->getMenu(); auto sub_menu = (*iter)->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM); openSubMenu (sub_menu, SELECT_ITEM);
else if ( opened_sub_menu ) else if ( opened_sub_menu )
{ {
@ -851,7 +851,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms)
{ {
auto sub_menu = m_item->getMenu(); auto sub_menu = m_item->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isShown() )
shown_sub_menu = sub_menu; shown_sub_menu = sub_menu;
} }
else if ( opened_sub_menu ) else if ( opened_sub_menu )
@ -1045,7 +1045,7 @@ bool FMenu::selectNextItem()
} }
while ( ! next->isEnabled() while ( ! next->isEnabled()
|| ! next->acceptFocus() || ! next->acceptFocus()
|| ! next->isVisible() || ! next->isShown()
|| next->isSeparator() ); || next->isSeparator() );
if ( next == *iter ) if ( next == *iter )
@ -1095,7 +1095,7 @@ bool FMenu::selectPrevItem()
} }
while ( ! prev->isEnabled() while ( ! prev->isEnabled()
|| ! prev->acceptFocus() || ! prev->acceptFocus()
|| ! prev->isVisible() || ! prev->isShown()
|| prev->isSeparator() ); || prev->isSeparator() );
if ( prev == *iter ) if ( prev == *iter )
@ -1251,8 +1251,8 @@ void FMenu::drawItems()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenu::drawSeparator (int y) inline void FMenu::drawSeparator (int y)
{ {
setPrintPos (1, 2 + y); print() << FPoint(1, 2 + y)
setColor (wc.menu_active_fg, wc.menu_active_bg); << FColorPair(wc.menu_active_fg, wc.menu_active_bg);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -1498,7 +1498,7 @@ inline void FMenu::setLineAttributes (FMenuItem* menuitem, int y)
setReverse(true); setReverse(true);
} }
setPrintPos (2, 2 + y); print() << FPoint(2, 2 + y);
setColor(); setColor();
} }
@ -1514,9 +1514,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
if ( is_selected ) if ( is_selected )
{ {
if ( is_checkable ) if ( is_checkable )
menuitem->setCursorPos (3, 1); menuitem->setCursorPos (FPoint(3, 1));
else else
menuitem->setCursorPos (2, 1); menuitem->setCursorPos (FPoint(2, 1));
} }
} }
else else
@ -1525,9 +1525,9 @@ inline void FMenu::setCursorToHotkeyPosition (FMenuItem* menuitem)
{ {
// set cursor to the hotkey position // set cursor to the hotkey position
if ( is_checkable ) if ( is_checkable )
menuitem->setCursorPos (3 + int(hotkeypos), 1); menuitem->setCursorPos (FPoint(3 + int(hotkeypos), 1));
else else
menuitem->setCursorPos (2 + int(hotkeypos), 1); menuitem->setCursorPos (FPoint(2 + int(hotkeypos), 1));
} }
} }
} }
@ -1575,7 +1575,7 @@ inline void FMenu::keyRight (FKeyEvent* ev)
{ {
auto sub_menu = getSelectedItem()->getMenu(); auto sub_menu = getSelectedItem()->getMenu();
if ( ! sub_menu->isVisible() ) if ( ! sub_menu->isShown() )
openSubMenu (sub_menu, SELECT_ITEM); openSubMenu (sub_menu, SELECT_ITEM);
else else
keypressMenuBar(ev); // select next menu keypressMenuBar(ev); // select next menu

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -66,15 +66,14 @@ void FMenuBar::hide()
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
auto blank = createBlankArray (screenWidth + 1); auto blank = createBlankArray (screenWidth + 1);
setPrintPos (1, 1); print() << FPoint(1, 1) << blank;
print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::adjustSize() void FMenuBar::adjustSize()
{ {
setGeometry (1, 1, getDesktopWidth(), 1, false); setGeometry (FPoint(1, 1), FSize(getDesktopWidth(), 1), false);
adjustItems(); adjustItems();
} }
@ -236,7 +235,7 @@ void FMenuBar::init()
auto r = getRootWidget(); auto r = getRootWidget();
auto w = r->getWidth(); auto w = r->getWidth();
// initialize geometry values // initialize geometry values
setGeometry (1, 1, w, 1, false); setGeometry (FPoint(1, 1), FSize(w, 1), false);
setAlwaysOnTop(); setAlwaysOnTop();
setMenuBar(this); setMenuBar(this);
ignorePadding(); ignorePadding();
@ -254,8 +253,7 @@ void FMenuBar::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::calculateDimensions() void FMenuBar::calculateDimensions()
{ {
int item_X = 1; FPoint item_pos (1, 1);
int item_Y = 1;
auto iter = item_list.begin(); auto iter = item_list.begin();
auto last = item_list.end(); auto last = item_list.end();
@ -266,13 +264,13 @@ void FMenuBar::calculateDimensions()
int item_width = int(len) + 2; int item_width = int(len) + 2;
// set item geometry // set item geometry
(*iter)->setGeometry (item_X, item_Y, std::size_t(item_width), 1, false); (*iter)->setGeometry (item_pos, FSize(std::size_t(item_width), 1), false);
// set menu position // set menu position
if ( (*iter)->hasMenu() ) if ( (*iter)->hasMenu() )
(*iter)->getMenu()->setPos (item_X, item_Y, false); (*iter)->getMenu()->setPos (item_pos, false);
item_X += item_width; item_pos.x_ref() += item_width;
++iter; ++iter;
} }
@ -301,7 +299,7 @@ bool FMenuBar::selectNextItem()
next = static_cast<FMenuItem*>(*next_element); next = static_cast<FMenuItem*>(*next_element);
} while ( ! next->isEnabled() } while ( ! next->isEnabled()
|| ! next->acceptFocus() || ! next->acceptFocus()
|| ! next->isVisible() || ! next->isShown()
|| next->isSeparator() ); || next->isSeparator() );
if ( next == *iter ) if ( next == *iter )
@ -365,7 +363,7 @@ bool FMenuBar::selectPrevItem()
} }
while ( ! prev->isEnabled() while ( ! prev->isEnabled()
|| ! prev->acceptFocus() || ! prev->acceptFocus()
|| ! prev->isVisible() || ! prev->isShown()
|| prev->isSeparator() ); || prev->isSeparator() );
if ( prev == *iter ) if ( prev == *iter )
@ -502,7 +500,7 @@ void FMenuBar::drawItems()
if ( item_list.empty() ) if ( item_list.empty() )
return; return;
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -665,14 +663,12 @@ inline void FMenuBar::drawEllipsis (const menuText& txtdata, std::size_t x)
if ( txtdata.startpos < screenWidth ) if ( txtdata.startpos < screenWidth )
{ {
// Print ellipsis // Print ellipsis
setPrintPos (int(screenWidth) - 1, 1); print() << FPoint(int(screenWidth) - 1, 1) << "..";
print ("..");
} }
else if ( txtdata.startpos - 1 <= screenWidth ) else if ( txtdata.startpos - 1 <= screenWidth )
{ {
// Hide first character from text // Hide first character from text
setPrintPos (int(screenWidth), 1); print() << FPoint(int(screenWidth), 1) << ' ';
print (' ');
} }
} }
} }
@ -719,7 +715,7 @@ void FMenuBar::adjustItems()
auto menu = (*iter)->getMenu(); auto menu = (*iter)->getMenu();
// set menu position // set menu position
menu->setPos (menu->adjustX(item_X), item_Y); menu->setPos (FPoint(menu->adjustX(item_X), item_Y));
// call menu adjustItems() // call menu adjustItems()
menu->adjustItems(); menu->adjustItems();
@ -737,6 +733,7 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
return; return;
auto focused_widget = getFocusWidget(); auto focused_widget = getFocusWidget();
unselectItem();
item->setSelected(); item->setSelected();
item->setFocus(); item->setFocus();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -194,7 +194,7 @@ void FMenuItem::setText (const FString& txt)
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setWidth(text_length); updateSuperMenuDimensions();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -209,13 +209,7 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
root->accelerator_list->push_back(accel); root->accelerator_list->push_back(accel);
} }
if ( isMenu(super_menu) ) updateSuperMenuDimensions();
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -241,13 +235,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
} }
} }
if ( isMenu(super_menu) ) updateSuperMenuDimensions();
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -258,7 +246,7 @@ void FMenuItem::openMenu()
auto dd_menu = getMenu(); // Drop-down menu auto dd_menu = getMenu(); // Drop-down menu
if ( dd_menu->isVisible() ) if ( dd_menu->isShown() )
return; return;
auto openmenu = static_cast<FMenu*>(getOpenMenu()); auto openmenu = static_cast<FMenu*>(getOpenMenu());
@ -273,7 +261,6 @@ void FMenuItem::openMenu()
createDialogList (dd_menu); createDialogList (dd_menu);
setOpenMenu(dd_menu); setOpenMenu(dd_menu);
dd_menu->setVisible();
dd_menu->show(); dd_menu->show();
dd_menu->raiseWindow(); dd_menu->raiseWindow();
dd_menu->redraw(); dd_menu->redraw();
@ -541,7 +528,7 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setGeometry (1, 1, text_length + 2, 1, false); setGeometry (FPoint(1, 1), FSize(text_length + 2, 1), false);
if ( ! parent ) if ( ! parent )
return; return;
@ -604,6 +591,18 @@ uChar FMenuItem::hotKey()
return 0; return 0;
} }
//----------------------------------------------------------------------
void FMenuItem::updateSuperMenuDimensions()
{
if ( ! super_menu || ! isMenu(super_menu) )
return;
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processActivate() void FMenuItem::processActivate()
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -165,7 +165,6 @@ void FMessageBox::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::adjustSize() void FMessageBox::adjustSize()
{ {
int X, Y;
std::size_t max_width; std::size_t max_width;
std::size_t max_height; std::size_t max_height;
auto root_widget = getRootWidget(); auto root_widget = getRootWidget();
@ -182,9 +181,9 @@ void FMessageBox::adjustSize()
max_height = 24; max_height = 24;
} }
X = 1 + int((max_width - getWidth()) / 2); int x = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3); int y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false); setPos(FPoint(x, y), false);
FDialog::adjustSize(); FDialog::adjustSize();
} }
@ -235,7 +234,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[0] = new FButton (this); button[0] = new FButton (this);
button[0]->setText(button_text[button0]); button[0]->setText(button_text[button0]);
button[0]->setPos(3, int(getHeight()) - 4, false); button[0]->setPos(FPoint(3, int(getHeight()) - 4), false);
button[0]->setWidth(1, false); button[0]->setWidth(1, false);
button[0]->setHeight(1, false); button[0]->setHeight(1, false);
button[0]->setFocus(); button[0]->setFocus();
@ -244,7 +243,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[1] = new FButton(this); button[1] = new FButton(this);
button[1]->setText(button_text[button1]); button[1]->setText(button_text[button1]);
button[1]->setPos(17, int(getHeight()) - 4, false); button[1]->setPos(FPoint(17, int(getHeight()) - 4), false);
button[1]->setWidth(0, false); button[1]->setWidth(0, false);
button[1]->setHeight(1, false); button[1]->setHeight(1, false);
} }
@ -253,7 +252,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{ {
button[2] = new FButton(this); button[2] = new FButton(this);
button[2]->setText(button_text[button2]); button[2]->setText(button_text[button2]);
button[2]->setPos(32, int(getHeight()) - 4, false); button[2]->setPos(FPoint(32, int(getHeight()) - 4), false);
button[2]->setWidth(0, false); button[2]->setWidth(0, false);
button[2]->setHeight(1, false); button[2]->setHeight(1, false);
} }
@ -309,8 +308,8 @@ inline void FMessageBox::initCallbacks()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMessageBox::calculateDimensions() void FMessageBox::calculateDimensions()
{ {
std::size_t w, h; FSize size;
std::size_t headline_height = 0; std::size_t headline_height{0};
text_split = text.split("\n"); text_split = text.split("\n");
max_line_width = 0; max_line_width = 0;
text_num_lines = uInt(text_split.size()); text_num_lines = uInt(text_split.size());
@ -330,13 +329,13 @@ void FMessageBox::calculateDimensions()
max_line_width = len; max_line_width = len;
} }
h = text_num_lines + 8 + headline_height; size.setHeight (text_num_lines + 8 + headline_height);
w = max_line_width + 4; size.setWidth (max_line_width + 4);
if ( w < 20 ) if ( size.getWidth() < 20 )
w = 20; size.setWidth(20);
setSize (w, h); setSize(size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -360,8 +359,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2); center_x = int((max_line_width - headline_length) / 2);
setPrintPos (1 + msg_x + center_x, 4); print() << FPoint(1 + msg_x + center_x, 4) << headline_text;
print (headline_text);
head_offset = 2; head_offset = 2;
} }
@ -374,8 +372,8 @@ void FMessageBox::draw()
if ( center_text ) // center one line if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2); center_x = int((max_line_width - line_length) / 2);
setPrintPos (1 + msg_x + center_x, 4 + head_offset + i); print() << FPoint(1 + msg_x + center_x, 4 + head_offset + i)
print(text_components[i]); << text_components[i];
} }
if ( isMonochron() ) if ( isMonochron() )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -576,7 +576,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
{ {
if ( (btn & button_mask) >= button1_pressed_move if ( (btn & button_mask) >= button1_pressed_move
&& (btn & button_mask) <= button3_pressed_move && (btn & button_mask) <= button3_pressed_move
&& mouse_position != zero_point ) && ! mouse_position.isOrigin() )
{ {
b_state.mouse_moved = true; b_state.mouse_moved = true;
} }
@ -811,7 +811,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
{ {
if ( (btn & button_mask) >= button1_move if ( (btn & button_mask) >= button1_move
&& (btn & button_mask) <= button3_move && (btn & button_mask) <= button3_move
&& mouse_position != zero_point ) && ! mouse_position.isOrigin() )
{ {
b_state.mouse_moved = true; b_state.mouse_moved = true;
} }
@ -1078,7 +1078,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
{ {
if ( (btn & button_mask) >= button1_pressed_move if ( (btn & button_mask) >= button1_pressed_move
&& (btn & button_mask) <= button3_pressed_move && (btn & button_mask) <= button3_pressed_move
&& mouse_position != zero_point ) && ! mouse_position.isOrigin() )
{ {
b_state.mouse_moved = true; b_state.mouse_moved = true;
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -77,7 +77,7 @@ void FPoint::setPoint (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FPoint::isNull() const bool FPoint::isOrigin() const
{ {
return xpos == 0 && ypos == 0; return xpos == 0 && ypos == 0;
} }
@ -85,7 +85,7 @@ bool FPoint::isNull() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FPoint& p) std::ostream& operator << (std::ostream& outstr, const FPoint& p)
{ {
outstr << p.getX() << " " << p.getY(); outstr << p.xpos << " " << p.ypos;
return outstr; return outstr;
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -56,24 +56,23 @@ void FProgressbar::setPercentage (std::size_t percentage_value)
else else
percentage = percentage_value; percentage = percentage_value;
if ( isVisible() ) if ( isShown() )
{ {
drawPercentage(); drawProgressLabel();
drawBar(); drawProgressBar();
} }
updateTerminal(); updateTerminal();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::setGeometry ( int x, int y void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the progress bar geometry // Set the progress bar geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
bar_length = w; bar_length = size.getWidth();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -84,12 +83,12 @@ bool FProgressbar::setShadow (bool enable)
&& getEncoding() != fc::ASCII ) && getEncoding() != fc::ASCII )
{ {
flags.shadow = true; flags.shadow = true;
setShadowSize(1, 1); setShadowSize(FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
setShadowSize(0, 0); setShadowSize(FSize(0, 0));
} }
return enable; return enable;
@ -98,40 +97,11 @@ bool FProgressbar::setShadow (bool enable)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::hide() void FProgressbar::hide()
{ {
FColor fg, bg;
auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
if ( parent_widget ) hideSize (getSize() + shadow);
{ print() << FPoint(int(getWidth()) - 4, 0)
fg = parent_widget->getForegroundColor(); << (" "); // hide percentage
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
std::size_t s = hasShadow() ? 1 : 0;
auto size = getWidth() + s;
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight() + s; y++)
{
setPrintPos (1, 1 + int(y));
print (blank);
}
destroyBlankArray (blank);
setPrintPos (int(getWidth()) - 4, 0);
print (" "); // hide percentage
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -139,10 +109,10 @@ void FProgressbar::reset()
{ {
percentage = NOT_SET; percentage = NOT_SET;
if ( isVisible() ) if ( isShown() )
{ {
drawPercentage(); drawProgressLabel();
drawBar(); drawProgressBar();
} }
updateTerminal(); updateTerminal();
@ -153,8 +123,8 @@ void FProgressbar::reset()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::draw() void FProgressbar::draw()
{ {
drawPercentage(); drawProgressLabel();
drawBar(); drawProgressBar();
if ( flags.shadow ) if ( flags.shadow )
drawShadow (); drawShadow ();
@ -163,7 +133,7 @@ void FProgressbar::draw()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawPercentage() void FProgressbar::drawProgressLabel()
{ {
auto parent_widget = getParentWidget(); auto parent_widget = getParentWidget();
@ -176,7 +146,7 @@ void FProgressbar::drawPercentage()
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
setPrintPos (int(getWidth()) - 3, 0); print() << FPoint(int(getWidth()) - 3, 0);
if ( percentage > 100 ) if ( percentage > 100 )
print ("--- %"); print ("--- %");
@ -188,62 +158,16 @@ void FProgressbar::drawPercentage()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FProgressbar::drawBar() void FProgressbar::drawProgressBar()
{ {
std::size_t i = 0; std::size_t len = 0;
double length; print() << FPoint(1, 1)
setPrintPos (1, 1); << FColorPair(wc.progressbar_bg, wc.progressbar_fg);
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
if ( percentage == NOT_SET ) if ( percentage > 0 && percentage <= 100 )
length = double(-0/100); len = drawProgressIndicator();
else
length = double(bar_length * percentage) / 100;
if ( isMonochron() ) drawProgressBackground(len);
setReverse(false);
for (; i < trunc(length); i++)
print (' ');
if ( isMonochron() )
setReverse(true);
if ( percentage > 0 && percentage <= 100 && trunc(length) < bar_length )
{
if ( round(length) > trunc(length) || getMaxColor() < 16 )
{
if ( isMonochron() )
{
setReverse(false);
print (' ');
setReverse(true);
}
else
print (' ');
}
else
{
setColor (wc.progressbar_fg, wc.progressbar_bg);
print (fc::LeftHalfBlock); // ▌
}
i++;
}
setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 )
{
for (; i < bar_length; i++)
print (fc::MediumShade); // ▒
}
else
{
for (; i < bar_length; i++)
print (' ');
}
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
@ -252,4 +176,56 @@ void FProgressbar::drawBar()
flush_out(); flush_out();
} }
//----------------------------------------------------------------------
std::size_t FProgressbar::drawProgressIndicator()
{
// Draw the progress indicator
if ( isMonochron() )
setReverse(false);
double length = double(bar_length * percentage) / 100;
auto len = std::size_t(trunc(length));
print() << FString (len, L' ');
if ( isMonochron() )
setReverse(true);
if ( len >= bar_length )
return len;
if ( round(length) > len || getMaxColor() < 16 )
{
if ( isMonochron() )
setReverse(false);
print(' ');
if ( isMonochron() )
setReverse(true);
}
else
{
print() << FColorPair(wc.progressbar_fg, wc.progressbar_bg)
<< fc::LeftHalfBlock; // ▌
}
len++;
return len;
}
//----------------------------------------------------------------------
void FProgressbar::drawProgressBackground (std::size_t len)
{
// Draw the progress background
std::size_t bg_len = bar_length - len;
setColor (wc.progressbar_fg, wc.progressbar_bg);
if ( getMaxColor() < 16 )
print() << FString (bg_len, fc::MediumShade); // ▒
else
print() << FString (bg_len, L' ');
}
} // namespace finalcut } // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2017 Markus Gans * e Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -73,7 +73,7 @@ void FRadioButton::drawRadioButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1, 1); print() << FPoint(1, 1);
setColor(); setColor();
if ( isMonochron() ) if ( isMonochron() )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -32,6 +32,14 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// constructor and destructor // 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)
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FRect::FRect (const FPoint& p1, const FPoint& p2) FRect::FRect (const FPoint& p1, const FPoint& p2)
: X1(p1.getX()) : X1(p1.getX())
@ -47,7 +55,7 @@ FRect::~FRect() // destructor
// public methods of FRect // public methods of FRect
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FRect::isNull() const bool FRect::isEmpty() const
{ {
return X2 == X1 - 1 && Y2 == Y1 - 1; return X2 == X1 - 1 && Y2 == Y1 - 1;
} }
@ -133,13 +141,29 @@ void FRect::setSize (std::size_t w, std::size_t h)
Y2 = Y1 + int(h) - 1; Y2 = Y1 + int(h) - 1;
} }
//----------------------------------------------------------------------
void FRect::setSize (const FSize& s)
{
X2 = X1 + int(s.getWidth()) - 1;
Y2 = Y1 + int(s.getHeight()) - 1;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FRect::setRect (const FRect& r) void FRect::setRect (const FRect& r)
{ {
setRect ( r.X1 X1 = r.X1;
, r.Y1 Y1 = r.Y1;
, std::size_t(r.X2 - r.X1 + 1) X2 = r.X2;
, std::size_t(r.Y2 - r.Y1 + 1) ); Y2 = r.Y2;
}
//----------------------------------------------------------------------
void FRect::setRect (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;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -247,21 +271,21 @@ FRect& FRect::operator = (const FRect& r)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FRect operator + (const FRect& r, const FPoint& p) FRect operator + (const FRect& r, const FSize& s)
{ {
return FRect ( r.X1 return FRect ( r.X1
, r.Y1 , r.Y1
, std::size_t(r.X2 - r.X1 + 1 + p.getX()) , std::size_t(r.X2 - r.X1) + 1 + s.getWidth()
, std::size_t(r.Y2 - r.Y1 + 1 + p.getY()) ); , std::size_t(r.Y2 - r.Y1) + 1 + s.getHeight() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FRect operator - (const FRect& r, const FPoint& p) FRect operator - (const FRect& r, const FSize& s)
{ {
return FRect ( r.X1 return FRect ( r.X1
, r.Y1 , r.Y1
, std::size_t(r.X2 - r.X1 + 1 - p.getX()) , std::size_t(r.X2 - r.X1 + 1) - s.getWidth()
, std::size_t(r.Y2 - r.Y1 + 1 - p.getY()) ); , std::size_t(r.Y2 - r.Y1 + 1) - s.getHeight() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -285,10 +309,10 @@ bool operator != (const FRect& r1, const FRect& r2)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FRect& r) std::ostream& operator << (std::ostream& outstr, const FRect& r)
{ {
outstr << r.getX1() << " " outstr << r.X1 << " "
<< r.getY1() << " " << r.Y1 << " "
<< r.getX2() << " " << r.X2 << " "
<< r.getY2(); << r.Y2;
return outstr; return outstr;
} }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -37,12 +37,12 @@ FScrollbar::FScrollbar(FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
// The default scrollbar orientation is vertical // The default scrollbar orientation is vertical
setGeometry(1, 1, 1, length, false); setGeometry(FPoint(1, 1), FSize(1, length), false);
init(); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::FScrollbar(int o, FWidget* parent) FScrollbar::FScrollbar(fc::orientation o, FWidget* parent)
: FWidget(parent) : FWidget(parent)
{ {
setOrientation (o); setOrientation (o);
@ -124,7 +124,7 @@ void FScrollbar::setPageSize (int document_size, int page_size)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::setOrientation (int o) void FScrollbar::setOrientation (fc::orientation o)
{ {
std::size_t nf = 0; std::size_t nf = 0;
length = ( getHeight() > getWidth() ) ? getHeight() : getWidth(); length = ( getHeight() > getWidth() ) ? getHeight() : getWidth();
@ -148,15 +148,16 @@ void FScrollbar::setOrientation (int o)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::setGeometry ( int x, int y void FScrollbar::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the scrollbar geometry // Set the scrollbar geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
std::size_t nf = 0; std::size_t nf = 0;
std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
length = ( h > w ) ? h : w; length = ( h > w ) ? h : w;
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
@ -188,6 +189,7 @@ void FScrollbar::resize()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::redraw() void FScrollbar::redraw()
{ {
if ( isShown() )
draw(); draw();
} }
@ -238,7 +240,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= slider_pos; z++) for (z = 1; z <= slider_pos; z++)
{ {
setPrintPos (1, 1 + z); print() << FPoint(1, 1 + z);
if ( isNewFont() ) if ( isNewFont() )
{ {
@ -261,7 +263,7 @@ void FScrollbar::drawVerticalBar()
for (z = 1; z <= int(slider_length); z++) for (z = 1; z <= int(slider_length); z++)
{ {
setPrintPos (1, 1 + slider_pos + z); print() << FPoint(1, 1 + slider_pos + z);
if ( isNewFont() ) if ( isNewFont() )
print (' '); print (' ');
@ -276,7 +278,7 @@ void FScrollbar::drawVerticalBar()
for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++) for (z = slider_pos + int(slider_length) + 1; z <= int(bar_length); z++)
{ {
setPrintPos (1, 1 + z); print() << FPoint(1, 1 + z);
if ( isNewFont() ) if ( isNewFont() )
{ {
@ -303,9 +305,9 @@ void FScrollbar::drawHorizontalBar()
setColor (wc.scrollbar_fg, wc.scrollbar_bg); setColor (wc.scrollbar_fg, wc.scrollbar_bg);
if ( isNewFont() ) if ( isNewFont() )
setPrintPos (3, 1); print() << FPoint(3, 1);
else else
setPrintPos (2, 1); print() << FPoint(2, 1);
for (z = 0; z < slider_pos; z++) for (z = 0; z < slider_pos; z++)
{ {
@ -348,6 +350,9 @@ void FScrollbar::drawHorizontalBar()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::drawBar() void FScrollbar::drawBar()
{ {
if ( ! isShown() )
return;
if ( slider_pos == current_slider_pos || length < 3 ) if ( slider_pos == current_slider_pos || length < 3 )
return; return;
@ -564,7 +569,7 @@ void FScrollbar::init()
{ {
unsetFocusable(); unsetFocusable();
ignorePadding(); ignorePadding();
setGeometry(1, 1, getWidth(), getHeight()); setGeometry(FPoint(1, 1), FSize(getWidth(), getHeight()));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -585,43 +590,43 @@ void FScrollbar::drawButtons()
if ( isNewFont() ) if ( isNewFont() )
{ {
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::NF_rev_up_arrow1); print() << fc::NF_rev_up_arrow1
print (fc::NF_rev_up_arrow2); << fc::NF_rev_up_arrow2
setPrintPos (1, int(length)); << FPoint(1, int(length))
print (fc::NF_rev_down_arrow1); << fc::NF_rev_down_arrow1
print (fc::NF_rev_down_arrow2); << fc::NF_rev_down_arrow2;
} }
else // horizontal else // horizontal
{ {
print (fc::NF_rev_left_arrow1); print() << fc::NF_rev_left_arrow1
print (fc::NF_rev_left_arrow2); << fc::NF_rev_left_arrow2
setPrintPos (int(length) - 1, 1); << FPoint(int(length) - 1, 1)
print (fc::NF_rev_right_arrow1); << fc::NF_rev_right_arrow1
print (fc::NF_rev_right_arrow2); << fc::NF_rev_right_arrow2;
} }
} }
else else
{ {
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
print (fc::BlackUpPointingTriangle); // ▲ print() << fc::BlackUpPointingTriangle // ▲
setPrintPos (1, int(length)); << FPoint(1, int(length))
print (fc::BlackDownPointingTriangle); // ▼ << fc::BlackDownPointingTriangle; // ▼
} }
else // horizontal else // horizontal
{ {
print (fc::BlackLeftPointingPointer); // ◄ print() << fc::BlackLeftPointingPointer // ◄
setPrintPos (int(length), 1); << FPoint(int(length), 1)
print (fc::BlackRightPointingPointer); // ► << fc::BlackRightPointingPointer; // ►
} }
if ( isMonochron() ) if ( isMonochron() )

View File

@ -4,7 +4,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -61,7 +61,7 @@ void FScrollView::setScrollWidth (std::size_t width)
if ( viewport ) if ( viewport )
{ {
FPoint no_shadow(0, 0); FSize no_shadow(0, 0);
scroll_geometry.setWidth (width); scroll_geometry.setWidth (width);
resizeArea (scroll_geometry, no_shadow, viewport); resizeArea (scroll_geometry, no_shadow, viewport);
@ -89,7 +89,7 @@ void FScrollView::setScrollHeight (std::size_t height)
if ( viewport ) if ( viewport )
{ {
FPoint no_shadow(0, 0); FSize no_shadow(0, 0);
scroll_geometry.setHeight (height); scroll_geometry.setHeight (height);
resizeArea (scroll_geometry, no_shadow, viewport); resizeArea (scroll_geometry, no_shadow, viewport);
addPreprocessingHandler addPreprocessingHandler
@ -106,10 +106,11 @@ void FScrollView::setScrollHeight (std::size_t height)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setScrollSize (std::size_t width, std::size_t height) void FScrollView::setScrollSize (const FSize& size)
{ {
int xoffset_end int xoffset_end, yoffset_end;
, yoffset_end; std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
if ( width < getViewportWidth() ) if ( width < getViewportWidth() )
width = getViewportWidth(); width = getViewportWidth();
@ -122,7 +123,7 @@ void FScrollView::setScrollSize (std::size_t width, std::size_t height)
if ( viewport ) if ( viewport )
{ {
FPoint no_shadow(0, 0); FSize no_shadow(0, 0);
scroll_geometry.setSize (width, height); scroll_geometry.setSize (width, height);
resizeArea (scroll_geometry, no_shadow, viewport); resizeArea (scroll_geometry, no_shadow, viewport);
addPreprocessingHandler addPreprocessingHandler
@ -185,9 +186,9 @@ void FScrollView::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setPos (int x, int y, bool adjust) void FScrollView::setPos (const FPoint& p, bool adjust)
{ {
FWidget::setPos (x, y, adjust); FWidget::setPos (p, adjust);
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1 scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
, getTermY() + getTopPadding() - 1 ); , getTermY() + getTopPadding() - 1 );
@ -224,26 +225,29 @@ void FScrollView::setHeight (std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setSize (std::size_t w, std::size_t h, bool adjust) void FScrollView::setSize (const FSize& size, bool adjust)
{ {
FWidget::setSize (w, h, adjust); std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
FWidget::setSize (size, adjust);
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
, h - horizontal_border_spacing ); , h - horizontal_border_spacing );
calculateScrollbarPos(); calculateScrollbarPos();
if ( getScrollWidth() < getViewportWidth() if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() ) || getScrollHeight() < getViewportHeight() )
setScrollSize (getViewportWidth(), getViewportHeight()); setScrollSize (getViewportSize());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setGeometry ( int x, int y void FScrollView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the scroll view geometry // Set the scroll view geometry
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
std::size_t w = size.getWidth();
std::size_t h = size.getHeight();
scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1 scroll_geometry.setPos ( getTermX() + getLeftPadding() - 1
, getTermY() + getTopPadding() - 1 ); , getTermY() + getTopPadding() - 1 );
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
@ -253,7 +257,7 @@ void FScrollView::setGeometry ( int x, int y
if ( getScrollWidth() < getViewportWidth() if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() ) || getScrollHeight() < getViewportHeight() )
{ {
setScrollSize (getViewportWidth(), getViewportHeight()); setScrollSize (getViewportSize());
} }
else if ( ! adjust && viewport ) else if ( ! adjust && viewport )
{ {
@ -263,15 +267,17 @@ void FScrollView::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setCursorPos (int x, int y) void FScrollView::setCursorPos (const FPoint& p)
{ {
FWidget::setCursorPos (x + getLeftPadding(), y + getTopPadding()); FWidget::setCursorPos (FPoint ( p.getX() + getLeftPadding()
, p.getY() + getTopPadding() ));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::setPrintPos (int x, int y) void FScrollView::setPrintPos (const FPoint& p)
{ {
FWidget::setPrintPos (x + getLeftPadding(), y + getTopPadding()); FWidget::setPrintPos (FPoint( p.getX() + getLeftPadding()
, p.getY() + getTopPadding() ));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -356,7 +362,7 @@ void FScrollView::scrollTo (int x, int y)
changeX = bool(xoffset_before != xoffset); changeX = bool(xoffset_before != xoffset);
changeY = bool(yoffset_before != yoffset); changeY = bool(yoffset_before != yoffset);
if ( ! isVisible() || ! viewport || ! (changeX || changeY) ) if ( ! isShown() || ! viewport || ! (changeX || changeY) )
return; return;
if ( changeX ) if ( changeX )
@ -368,7 +374,7 @@ void FScrollView::scrollTo (int x, int y)
if ( update_scrollbar ) if ( update_scrollbar )
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);
drawHBar(); hbar->drawBar();
} }
} }
@ -381,7 +387,7 @@ void FScrollView::scrollTo (int x, int y)
if ( update_scrollbar ) if ( update_scrollbar )
{ {
vbar->setValue (yoffset); vbar->setValue (yoffset);
drawVBar(); vbar->drawBar();
} }
} }
@ -422,8 +428,8 @@ void FScrollView::draw()
setViewportPrint(); setViewportPrint();
copy2area(); copy2area();
redrawVBar(); vbar->redraw();
redrawHBar(); hbar->redraw();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -719,26 +725,23 @@ inline FPoint FScrollView::getViewportCursorPos()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::init (FWidget* parent) void FScrollView::init (FWidget* parent)
{ {
int xoffset_end;
int yoffset_end;
assert ( parent != 0 ); assert ( parent != 0 );
assert ( ! parent->isInstanceOf("FScrollView") ); assert ( ! parent->isInstanceOf("FScrollView") );
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
init_scrollbar(); setGeometry (FPoint(1, 1), FSize(4, 4));
setGeometry (1, 1, 4, 4); setMinimumSize (FSize(4, 4));
setMinimumSize (4, 4); int xoffset_end = int(getScrollWidth() - getViewportWidth());
xoffset_end = int(getScrollWidth() - getViewportWidth()); int yoffset_end = int(getScrollHeight() - getViewportHeight());
yoffset_end = int(getScrollHeight() - getViewportHeight());
nf_offset = isNewFont() ? 1 : 0; nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY()); setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX()); setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (yoffset_end - getScrollY())); setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset); setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FSize no_shadow(0, 0);
FPoint no_shadow(0, 0);
std::size_t w = getViewportWidth(); std::size_t w = getViewportWidth();
std::size_t h = getViewportHeight(); std::size_t h = getViewportHeight();
@ -760,19 +763,13 @@ void FScrollView::init (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::init_scrollbar() void FScrollView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FScrollViewCallback callback )
{ {
try try
{ {
vbar = std::make_shared<FScrollbar>(fc::vertical, this); bar = std::make_shared<FScrollbar>(o, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -780,16 +777,16 @@ void FScrollView::init_scrollbar()
return; return;
} }
vbar->addCallback term_area* area = getPrintArea();
( bar->setPrintArea(area);
"change-value", bar->setMinimum(0);
F_METHOD_CALLBACK (this, &FScrollView::cb_VBarChange) bar->setValue(0);
); bar->hide();
hbar->addCallback bar->addCallback
( (
"change-value", "change-value",
F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange) F_METHOD_CALLBACK (this, callback)
); );
} }
@ -801,13 +798,13 @@ void FScrollView::calculateScrollbarPos()
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(width), 2, 2, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(2, height - 2));
hbar->setGeometry (1, int(height), width - 2, 1); hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(width), 2, 1, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (2, int(height), width - 2, 1); hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
} }
vbar->resize(); vbar->resize();
@ -821,7 +818,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
{ {
case fc::Auto: case fc::Auto:
if ( getScrollWidth() > getViewportWidth() ) if ( getScrollWidth() > getViewportWidth() )
hbar->setVisible(); hbar->show();
else else
hbar->hide(); hbar->hide();
break; break;
@ -831,7 +828,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
break; break;
case fc::Scroll: case fc::Scroll:
hbar->setVisible(); hbar->show();
break; break;
} }
} }
@ -843,7 +840,7 @@ void FScrollView::setVerticalScrollBarVisibility()
{ {
case fc::Auto: case fc::Auto:
if ( getScrollHeight() > getViewportHeight() ) if ( getScrollHeight() > getViewportHeight() )
vbar->setVisible(); vbar->show();
else else
vbar->hide(); vbar->hide();
break; break;
@ -853,7 +850,7 @@ void FScrollView::setVerticalScrollBarVisibility()
break; break;
case fc::Scroll: case fc::Scroll:
vbar->setVisible(); vbar->show();
break; break;
} }
} }
@ -981,48 +978,4 @@ void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
update_scrollbar = true; update_scrollbar = true;
} }
//----------------------------------------------------------------------
inline void FScrollView::redrawHBar()
{
child_print_area = nullptr;
if ( hbar->isVisible() )
hbar->redraw();
child_print_area = viewport;
}
//----------------------------------------------------------------------
inline void FScrollView::redrawVBar()
{
child_print_area = nullptr;
if ( vbar->isVisible() )
vbar->redraw();
child_print_area = viewport;
}
//----------------------------------------------------------------------
inline void FScrollView::drawHBar()
{
child_print_area = nullptr;
if ( hbar->isVisible() )
hbar->drawBar();
child_print_area = viewport;
}
//----------------------------------------------------------------------
inline void FScrollView::drawVBar()
{
child_print_area = nullptr;
if ( vbar->isVisible() )
vbar->drawBar();
child_print_area = viewport;
}
} // namespace finalcut } // namespace finalcut

110
src/fsize.cpp Normal file
View File

@ -0,0 +1,110 @@
/***********************************************************************
* fsize.cpp - Height and width of a two-dimensional surface *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2014-2019 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/fsize.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FSize
//----------------------------------------------------------------------
FSize::~FSize() // destructor
{ }
// public methods of FSize
//----------------------------------------------------------------------
FSize& FSize::operator = (const FSize& s)
{
width = s.width;
height = s.height;
return *this;
}
//----------------------------------------------------------------------
FSize& FSize::operator += (const FSize& s)
{
std::size_t max = std::numeric_limits<std::size_t>::max();
width = ( width < max - s.width) ? width + s.width : max;
height = ( height < max - s.height) ? height + s.height : max;
return *this;
}
//----------------------------------------------------------------------
FSize& FSize::operator -= (const FSize& s)
{
width = ( width >= s.width ) ? width - s.width : 0;
height = ( height >= s.height ) ? height - s.height : 0;
return *this;
}
//----------------------------------------------------------------------
void FSize::setWidth (std::size_t w)
{
width = w;
}
//----------------------------------------------------------------------
void FSize::setHeight (std::size_t h)
{
height = h;
}
//----------------------------------------------------------------------
void FSize::setSize (FSize s)
{
width = s.width;
height = s.height;
}
//----------------------------------------------------------------------
void FSize::setSize (std::size_t w, std::size_t h)
{
width = w;
height = h;
}
//----------------------------------------------------------------------
bool FSize::isEmpty() const
{
return width == 0 && height == 0;
}
//----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FSize& s)
{
outstr << s.width << " " << s.height;
return outstr;
}
//----------------------------------------------------------------------
std::istream& operator >> (std::istream& instr, FSize& s)
{
std::size_t w, h;
instr >> w;
instr >> h;
s.setSize (w, h);
return instr;
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -99,7 +99,7 @@ bool FStatusKey::setMouseFocus(bool enable)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent) void FStatusKey::init (FWidget* parent)
{ {
setGeometry (1, 1, 1, 1); setGeometry (FPoint(1, 1), FSize(1, 1));
if ( parent && parent->isInstanceOf("FStatusBar") ) if ( parent && parent->isInstanceOf("FStatusBar") )
{ {
@ -178,8 +178,7 @@ void FStatusBar::hide()
setColor (fg, bg); setColor (fg, bg);
screenWidth = getDesktopWidth(); screenWidth = getDesktopWidth();
auto blank = createBlankArray(screenWidth + 1); auto blank = createBlankArray(screenWidth + 1);
setPrintPos (1, 1); print() << FPoint(1, 1) << blank;
print (blank);
destroyBlankArray (blank); destroyBlankArray (blank);
} }
@ -214,7 +213,7 @@ void FStatusBar::drawMessage()
space_offset = 0; space_offset = 0;
setColor (wc.statusbar_fg, wc.statusbar_bg); setColor (wc.statusbar_fg, wc.statusbar_bg);
setPrintPos (x, 1); setPrintPos (FPoint(x, 1));
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);
@ -312,7 +311,8 @@ void FStatusBar::clear()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FStatusBar::adjustSize() void FStatusBar::adjustSize()
{ {
setGeometry (1, int(getDesktopHeight()), getDesktopWidth(), 1, false); setGeometry ( FPoint(1, int(getDesktopHeight()))
, FSize(getDesktopWidth(), 1), false );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -495,7 +495,6 @@ void FStatusBar::cb_statuskey_activated (FWidget* widget, FDataPtr)
} }
} }
if ( isVisible() && isShown() )
redraw(); redraw();
} }
@ -508,7 +507,7 @@ void FStatusBar::init()
std::size_t w = r->getWidth(); std::size_t w = r->getWidth();
int h = int(r->getHeight()); int h = int(r->getHeight());
// initialize geometry values // initialize geometry values
setGeometry (1, h, w, 1, false); setGeometry (FPoint(1, h), FSize(w, 1), false);
setAlwaysOnTop(); setAlwaysOnTop();
setStatusBar(this); setStatusBar(this);
ignorePadding(); ignorePadding();
@ -541,7 +540,7 @@ void FStatusBar::drawKeys()
return; return;
} }
setPrintPos (1, 1); print() << FPoint(1, 1);
if ( isMonochron() ) if ( isMonochron() )
setReverse(true); setReverse(true);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -127,7 +127,7 @@ void FSwitch::drawCheckButton()
if ( ! isVisible() ) if ( ! isVisible() )
return; return;
setPrintPos (1 + int(switch_offset_pos), 1); print() << FPoint(1 + int(switch_offset_pos), 1);
if ( checked ) if ( checked )
drawChecked(); drawChecked();
@ -175,13 +175,13 @@ void FSwitch::drawChecked()
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
setBold(false); setBold(false);
setColor (wc.button_inactive_fg, wc.button_inactive_bg); print() << FColorPair(wc.button_inactive_fg, wc.button_inactive_bg)
print (off); << off;
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
setCursorPos (3 + int(switch_offset_pos), 1); setCursorPos (FPoint(3 + int(switch_offset_pos), 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -228,7 +228,7 @@ void FSwitch::drawUnchecked()
if ( isMonochron() || getMaxColor() < 16 ) if ( isMonochron() || getMaxColor() < 16 )
setBold(false); setBold(false);
setCursorPos (7 + int(switch_offset_pos), 1); setCursorPos (FPoint(7 + int(switch_offset_pos), 1));
} }
} // namespace finalcut } // namespace finalcut

View File

@ -133,6 +133,22 @@ bool FTerm::isCursorHideable()
return false; return false;
} }
//----------------------------------------------------------------------
bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setTermType (const char term_name[]) void FTerm::setTermType (const char term_name[])
{ {
@ -511,11 +527,11 @@ void FTerm::detectTermSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setTermSize (std::size_t width, std::size_t height) void FTerm::setTermSize (const FSize& size)
{ {
// Set xterm size to {width} x {height} // Set xterm size
xterm->setTermSize (width, height); xterm->setTermSize (size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1095,6 +1111,7 @@ void FTerm::init_cygwin_charmap()
if ( ! isCygwinTerminal() ) if ( ! isCygwinTerminal() )
return; return;
// PC encoding changes
for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{ {
if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲ if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲
@ -1114,6 +1131,17 @@ void FTerm::init_cygwin_charmap()
|| fc::character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √ || fc::character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √
fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
} }
// General encoding changes
characterSub& sub_map = data->getCharSubstitutionMap();
sub_map[L''] = L'*';
sub_map[L''] = L'*';
sub_map[L''] = L'*';
sub_map[L''] = L'*';
sub_map[L''] = L'*';
sub_map[L''] = L'';
sub_map[L''] = L'x';
sub_map[L'ˣ'] = L'`';
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1487,22 +1515,6 @@ inline bool FTerm::hasNoFontSettingOption()
return false; return false;
} }
//----------------------------------------------------------------------
inline bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::redefineColorPalette() void FTerm::redefineColorPalette()
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -81,7 +81,7 @@ int FTermBuffer::write (const FString& s)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTermBuffer::write (int c) int FTermBuffer::write (wchar_t c)
{ {
charData nc; // next character charData nc; // next character
nc = FVTerm::getAttribute(); nc = FVTerm::getAttribute();
@ -93,6 +93,15 @@ int FTermBuffer::write (int c)
return 1; return 1;
} }
//----------------------------------------------------------------------
void FTermBuffer::write (const FColorPair& pair)
{
charData nc; // next character
nc = FVTerm::getAttribute();
nc.fg_color = pair.fg_color;
nc.bg_color = pair.bg_color;
}
// FTermBuffer non-member operators // FTermBuffer non-member operators
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -67,7 +67,7 @@ void FTermcapQuirks::setFTermDetection (FTermDetection* td)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup() void FTermcapQuirks::terminalFixup()
{ {
auto td = term_detection; auto& td = term_detection;
if ( td->isCygwinTerminal() ) if ( td->isCygwinTerminal() )
{ {
@ -114,6 +114,8 @@ void FTermcapQuirks::terminalFixup()
// Fixes general quirks // Fixes general quirks
general(); general();
// ECMA-48 (ANSI X3.64) compatible terminal
ecma48();
} }
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__DragonFly__)
@ -548,11 +550,16 @@ void FTermcapQuirks::general()
if ( ! TCAP(fc::t_cursor_address) ) if ( ! TCAP(fc::t_cursor_address) )
TCAP(fc::t_cursor_address) = \ TCAP(fc::t_cursor_address) = \
C_STR(CSI "%i%p1%d;%p2%dH"); C_STR(CSI "%i%p1%d;%p2%dH");
}
//----------------------------------------------------------------------
void FTermcapQuirks::ecma48()
{
// Test for standard ECMA-48 (ANSI X3.64) terminal // Test for standard ECMA-48 (ANSI X3.64) terminal
if ( TCAP(fc::t_exit_underline_mode) if ( ! TCAP(fc::t_exit_underline_mode)
&& std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) == 0 ) || std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 )
{ return;
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal // Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = \ TCAP(fc::t_enter_dbl_underline_mode) = \
C_STR(CSI "21m"); // Exit single underline, too C_STR(CSI "21m"); // Exit single underline, too
@ -583,7 +590,6 @@ void FTermcapQuirks::general()
TCAP(fc::t_exit_crossed_out_mode) = \ TCAP(fc::t_exit_crossed_out_mode) = \
C_STR(CSI "29m"); C_STR(CSI "29m");
}
} }
} // namespace finalcut } // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -457,7 +457,10 @@ char* FTermDetection::termtype_256color_quirks()
if ( (color_env.string5 && std::strlen(color_env.string5) > 0) if ( (color_env.string5 && std::strlen(color_env.string5) > 0)
|| (color_env.string6 && std::strlen(color_env.string6) > 0) ) || (color_env.string6 && std::strlen(color_env.string6) > 0) )
{
terminal_type.kde_konsole = true; terminal_type.kde_konsole = true;
new_termtype = C_STR("konsole-256color");
}
if ( color_env.string3 && std::strlen(color_env.string3) > 0 ) if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
decscusr_support = true; decscusr_support = true;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2019 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -126,12 +126,12 @@ void FTermXTerminal::setTitle (const FString& title)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setTermSize (std::size_t width, std::size_t height) void FTermXTerminal::setTermSize (const FSize& size)
{ {
// Set xterm size to {term_width} x {term_height} // Set xterm size to {term_width} x {term_height}
term_width = width; term_width = size.getWidth();
term_height = height; term_height = size.getHeight();
setXTermSize(); setXTermSize();
} }
@ -605,23 +605,18 @@ void FTermXTerminal::resetXTermColorMap()
{ {
// Reset the entire color table // Reset the entire color table
if ( term_detection->isGnomeTerminal() if ( term_detection->isMinttyTerm() )
&& term_detection->getGnomeTerminalID() < 3502 ) {
return; FTerm::putstringf (ESC "c"); // Full Reset (RIS)
}
if ( term_detection->isPuttyTerminal() else if ( canResetColor() )
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "104" BEL); FTerm::putstringf (OSC "104" BEL);
oscPostfix(); oscPostfix();
std::fflush(stdout); std::fflush(stdout);
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -629,17 +624,7 @@ void FTermXTerminal::resetXTermForeground()
{ {
// Reset the XTerm text foreground color // Reset the XTerm text foreground color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstring (OSC "110" BEL); FTerm::putstring (OSC "110" BEL);
@ -653,17 +638,7 @@ void FTermXTerminal::resetXTermBackground()
{ {
// Reset the XTerm text background color // Reset the XTerm text background color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstring (OSC "111" BEL); FTerm::putstring (OSC "111" BEL);
@ -677,16 +652,7 @@ void FTermXTerminal::resetXTermCursorColor()
{ {
// Reset the text cursor color // Reset the text cursor color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstring (OSC "112" BEL); FTerm::putstring (OSC "112" BEL);
@ -700,16 +666,7 @@ void FTermXTerminal::resetXTermMouseForeground()
{ {
// Reset the mouse foreground color // Reset the mouse foreground color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstring (OSC "113" BEL); FTerm::putstring (OSC "113" BEL);
@ -723,16 +680,7 @@ void FTermXTerminal::resetXTermMouseBackground()
{ {
// Reset the mouse background color // Reset the mouse background color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstring (OSC "114" BEL); FTerm::putstring (OSC "114" BEL);
@ -746,17 +694,7 @@ void FTermXTerminal::resetXTermHighlightBackground()
{ {
// Reset the highlight background color // Reset the highlight background color
if ( term_detection->isGnomeTerminal() if ( canResetColor() )
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
{ {
oscPrefix(); oscPrefix();
FTerm::putstringf (OSC "117" BEL); FTerm::putstringf (OSC "117" BEL);
@ -765,6 +703,25 @@ void FTermXTerminal::resetXTermHighlightBackground()
} }
} }
//----------------------------------------------------------------------
bool FTermXTerminal::canResetColor()
{
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return false;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return false;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
return true;
return false;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPrefix() void FTermXTerminal::oscPrefix()
{ {

View File

@ -84,25 +84,24 @@ const FString FTextView::getText() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::setGeometry ( int x, int y void FTextView::setGeometry ( const FPoint& pos, const FSize& size
, std::size_t w, std::size_t h , bool adjust)
, bool adjust )
{ {
// Set the text view geometry // Set the text view geometry
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
std::size_t width = getWidth(); std::size_t width = getWidth();
std::size_t height = getHeight(); std::size_t height = getHeight();
if ( isNewFont() ) if ( isNewFont() )
{ {
vbar->setGeometry (int(width), 1, 2, height - 1); vbar->setGeometry (FPoint(int(width), 1), FSize(2, height - 1));
hbar->setGeometry (1, int(height), width - 2, 1); hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
} }
else else
{ {
vbar->setGeometry (int(width), 2, 1, height - 2); vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (2, int(height), width - 2, 1); hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
} }
vbar->resize(); vbar->resize();
@ -140,7 +139,7 @@ void FTextView::scrollTo (int x, int y)
bool changeX = bool(x != xoffset); bool changeX = bool(x != xoffset);
bool changeY = bool(y != yoffset); bool changeY = bool(y != yoffset);
if ( ! isVisible() || ! (changeX || changeY) ) if ( ! isShown() || ! (changeX || changeY) )
return; return;
if ( changeX && isHorizontallyScrollable() ) if ( changeX && isHorizontallyScrollable() )
@ -157,7 +156,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar ) if ( update_scrollbar )
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);
drawHBar(); hbar->drawBar();
} }
} }
@ -175,7 +174,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar ) if ( update_scrollbar )
{ {
vbar->setValue (yoffset); vbar->setValue (yoffset);
drawVBar(); vbar->drawBar();
} }
} }
@ -186,38 +185,8 @@ void FTextView::scrollTo (int x, int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::hide() void FTextView::hide()
{ {
FColor fg, bg;
auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
hideSize (getSize());
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
std::size_t n = isNewFont() ? 1 : 0;
auto size = getWidth() + n;
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
for (std::size_t y = 0; y < getHeight(); y++)
{
setPrintPos (1, 1 + int(y));
print (blank);
}
destroyBlankArray (blank);
flush_out();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -264,8 +233,8 @@ void FTextView::insert (const FString& str, int pos)
hbar->setPageSize (int(maxLineWidth), int(getTextWidth())); hbar->setPageSize (int(maxLineWidth), int(getTextWidth()));
hbar->calculateSliderValues(); hbar->calculateSliderValues();
if ( ! hbar->isVisible() ) if ( ! hbar->isShown() )
hbar->setVisible(); hbar->show();
} }
} }
} }
@ -278,10 +247,10 @@ void FTextView::insert (const FString& str, int pos)
vbar->setPageSize (int(getRows()), int(getTextHeight())); vbar->setPageSize (int(getRows()), int(getTextHeight()));
vbar->calculateSliderValues(); vbar->calculateSliderValues();
if ( ! vbar->isVisible() && getRows() > getTextHeight() ) if ( ! vbar->isShown() && getRows() > getTextHeight() )
vbar->setVisible(); vbar->show();
if ( vbar->isVisible() && getRows() <= getTextHeight() ) if ( vbar->isShown() && getRows() <= getTextHeight() )
vbar->hide(); vbar->hide();
processChanged(); processChanged();
@ -328,8 +297,7 @@ void FTextView::clear()
for (int y = 0; y < int(getTextHeight()); y++) for (int y = 0; y < int(getTextHeight()); y++)
{ {
setPrintPos (2, 2 - nf_offset + y); print() << FPoint(2, 2 - nf_offset + y) << blank;
print (blank);
} }
destroyBlankArray (blank); destroyBlankArray (blank);
@ -462,10 +430,7 @@ void FTextView::onMouseUp (FMouseEvent* ev)
} }
} }
if ( vbar->isVisible() )
vbar->redraw(); vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw(); hbar->redraw();
} }
@ -518,7 +483,7 @@ void FTextView::onWheel (FWheelEvent* ev)
break; break;
} }
if ( isVisible() ) if ( isShown() )
drawText(); drawText();
updateTerminal(); updateTerminal();
@ -593,12 +558,12 @@ void FTextView::adjustSize()
if ( last_line < int(height) + nf_offset - 1 ) if ( last_line < int(height) + nf_offset - 1 )
vbar->hide(); vbar->hide();
else else
vbar->setVisible(); vbar->show();
if ( max_width < int(width) - nf_offset - 1 ) if ( max_width < int(width) - nf_offset - 1 )
hbar->hide(); hbar->hide();
else else
hbar->setVisible(); hbar->show();
} }
@ -618,20 +583,25 @@ std::size_t FTextView::getTextWidth()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::init() void FTextView::init()
{ {
initScrollbar (vbar, fc::vertical, &FTextView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FTextView::cb_HBarChange);
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg); setBackgroundColor (wc.dialog_bg);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + nf_offset);
}
//----------------------------------------------------------------------
void FTextView::initScrollbar ( FScrollbarPtr& bar
, fc::orientation o
, FTextViewCallback callback )
{
try try
{ {
vbar = std::make_shared<FScrollbar>(fc::vertical, this); bar = std::make_shared<FScrollbar>(o, this);
vbar->setMinimum(0);
vbar->setValue(0);
vbar->hide();
hbar = std::make_shared<FScrollbar>(fc::horizontal, this);
hbar->setMinimum(0);
hbar->setValue(0);
hbar->hide();
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
@ -639,23 +609,15 @@ void FTextView::init()
return; return;
} }
vbar->addCallback bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
( (
"change-value", "change-value",
F_METHOD_CALLBACK (this, &FTextView::cb_VBarChange) F_METHOD_CALLBACK (this, callback)
); );
hbar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, &FTextView::cb_HBarChange)
);
nf_offset = isNewFont() ? 1 : 0;
setTopPadding(1);
setLeftPadding(1);
setBottomPadding(1);
setRightPadding(1 + nf_offset);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -687,10 +649,10 @@ void FTextView::draw()
if ( isMonochron() ) if ( isMonochron() )
setReverse(false); setReverse(false);
if ( vbar->isVisible() ) if ( vbar->isShown() )
vbar->redraw(); vbar->redraw();
if ( hbar->isVisible() ) if ( hbar->isShown() )
hbar->redraw(); hbar->redraw();
drawText(); drawText();
@ -707,7 +669,7 @@ void FTextView::draw()
} }
} }
setCursorPos (int(getWidth()), int(getHeight())); setCursorPos (FPoint(int(getWidth()), int(getHeight())));
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }
@ -732,7 +694,7 @@ void FTextView::drawText()
{ {
std::size_t i; std::size_t i;
FString line; FString line;
setPrintPos (2, 2 - nf_offset + int(y)); print() << FPoint(2, 2 - nf_offset + int(y));
line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset) line = data[y + std::size_t(yoffset)].mid ( std::size_t(1 + xoffset)
, getTextWidth() ); , getTextWidth() );
const auto line_str = line.wc_str(); const auto line_str = line.wc_str();
@ -768,20 +730,6 @@ void FTextView::processChanged()
emitCallback("changed"); emitCallback("changed");
} }
//----------------------------------------------------------------------
inline void FTextView::drawHBar()
{
if ( hbar->isVisible() )
hbar->drawBar();
}
//----------------------------------------------------------------------
inline void FTextView::drawVBar()
{
if ( vbar->isVisible() )
vbar->drawBar();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_VBarChange (FWidget*, FDataPtr) void FTextView::cb_VBarChange (FWidget*, FDataPtr)
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -76,24 +76,24 @@ FToggleButton::~FToggleButton() // destructor
// public methods of FToggleButton // public methods of FToggleButton
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::setGeometry ( int x, int y void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
, std::size_t w, std::size_t h
, bool adjust ) , bool adjust )
{ {
// Set the toggle button geometry // Set the toggle button geometry
std::size_t hotkey_mark = ( getHotkey() ) ? 1 : 0; FSize size = s;
std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
std::size_t min_width = button_width + text.getLength() - hotkey_mark; std::size_t min_width = button_width + text.getLength() - hotkey_mark;
if ( w < min_width ) if ( size.getWidth() < min_width )
w = min_width; size.setWidth(min_width);
const FRect geometry(x, y, w, h); const FRect geometry(pos, size);
if ( hasGroup() ) if ( hasGroup() )
getGroup()->checkScrollSize(geometry); getGroup()->checkScrollSize(geometry);
FWidget::setGeometry(x, y, w, h, adjust); FWidget::setGeometry(pos, size, adjust);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -188,7 +188,7 @@ bool FToggleButton::setChecked (bool enable)
void FToggleButton::setText (const FString& txt) void FToggleButton::setText (const FString& txt)
{ {
text = txt; text = txt;
std::size_t hotkey_mark = ( getHotkey() ) ? 1 : 0; std::size_t hotkey_mark = ( getHotkey(text) ) ? 1 : 0;
setWidth(button_width + text.getLength() - hotkey_mark); setWidth(button_width + text.getLength() - hotkey_mark);
@ -202,32 +202,8 @@ void FToggleButton::setText (const FString& txt)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::hide() void FToggleButton::hide()
{ {
std::size_t size;
FColor fg, bg;
auto parent_widget = getParentWidget();
FWidget::hide(); FWidget::hide();
hideSize (getSize());
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
size = getWidth();
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
destroyBlankArray (blank);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -385,46 +361,22 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
// protected methods of FToggleButton // protected methods of FToggleButton
//----------------------------------------------------------------------
uChar FToggleButton::getHotkey()
{
if ( text.isEmpty() )
return 0;
std::size_t length = text.getLength();
for (std::size_t i = 0; i < length; i++)
{
try
{
if ( i + 1 < length && text[i] == '&' )
return uChar(text[++i]);
}
catch (const std::out_of_range&)
{
return 0;
}
}
return 0;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::setHotkeyAccelerator() void FToggleButton::setHotkeyAccelerator()
{ {
uChar hotkey = getHotkey(); FKey hotkey = getHotkey(text);
if ( hotkey ) if ( hotkey )
{ {
if ( std::isalpha(hotkey) || std::isdigit(hotkey) ) if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
{ {
addAccelerator (FKey(std::tolower(hotkey))); addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(hotkey))); addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey // Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey))); addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
} }
else else
addAccelerator (getHotkey()); addAccelerator (hotkey);
} }
else else
delAccelerator(); delAccelerator();
@ -459,7 +411,7 @@ void FToggleButton::draw()
// set the cursor to the button // set the cursor to the button
if ( isRadioButton() || isCheckboxButton() ) if ( isRadioButton() || isCheckboxButton() )
setCursorPos (2, 1); setCursorPos (FPoint(2, 1));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -493,7 +445,7 @@ void FToggleButton::drawLabel()
if ( hotkeypos != NOT_SET ) if ( hotkeypos != NOT_SET )
length--; length--;
setPrintPos (1 + int(label_offset_pos), 1); print() << FPoint(1 + int(label_offset_pos), 1);
drawText (LabelText, hotkeypos, length); drawText (LabelText, hotkeypos, length);
delete[] LabelText; delete[] LabelText;
} }
@ -576,7 +528,7 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::init() void FToggleButton::init()
{ {
setGeometry (1, 1, 4, 1, false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(4, 1), false); // initialize geometry values
if ( isEnabled() ) if ( isEnabled() )
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2016-2018 Markus Gans * * Copyright 2016-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -87,8 +87,7 @@ void FToolTip::draw()
for (std::size_t i = 0; i < text_num_lines; i++) for (std::size_t i = 0; i < text_num_lines; i++)
{ {
setPrintPos (3, 2 + int(i)); print() << FPoint(3, 2 + int(i)) << text_components[i];
print(text_components[i]);
} }
unsetBold(); unsetBold();
@ -124,8 +123,8 @@ void FToolTip::init()
setAlwaysOnTop(); setAlwaysOnTop();
ignorePadding(); ignorePadding();
// initialize geometry values // initialize geometry values
setGeometry (1, 1, 3, 3, false); setGeometry (FPoint(1, 1), FSize(3, 3), false);
setMinimumSize (3, 3); setMinimumSize (FSize(3, 3));
setForegroundColor (wc.tooltip_fg); setForegroundColor (wc.tooltip_fg);
setBackgroundColor (wc.tooltip_bg); setBackgroundColor (wc.tooltip_bg);
calculateDimensions(); calculateDimensions();
@ -164,7 +163,7 @@ void FToolTip::calculateDimensions()
else else
x = y = 1; x = y = 1;
setGeometry (x, y, w, h); setGeometry (FPoint(x, y), FSize(w, h));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -148,14 +148,12 @@ void FVTerm::hideCursor (bool enable)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::setPrintCursor (int x, int y) void FVTerm::setPrintCursor (const FPoint& pos)
{ {
auto win = getPrintArea(); if ( auto win = getPrintArea() )
if ( win )
{ {
win->cursor_x = x - win->offset_left; win->cursor_x = pos.getX() - win->offset_left;
win->cursor_y = y - win->offset_top; win->cursor_y = pos.getY() - win->offset_top;
} }
} }
@ -177,31 +175,23 @@ void FVTerm::clearArea (int fillchar)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createVTerm (const FRect& r) void FVTerm::createVTerm (const FSize& size)
{ {
// initialize virtual terminal // initialize virtual terminal
const FPoint shadow(0, 0);
createArea (r, shadow, vterm); const FRect box(0, 0, size.getWidth(), size.getHeight());
const FSize shadow(0, 0);
createArea (box, shadow, vterm);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createVTerm (int width, int height) void FVTerm::resizeVTerm (const FSize& size)
{ {
// initialize virtual terminal // resize virtual terminal
createArea (0, 0, width, height, 0, 0, vterm);
}
//---------------------------------------------------------------------- const FRect box(0, 0, size.getWidth(), size.getHeight());
void FVTerm::resizeVTerm (const FRect& r) const FSize shadow(0, 0);
{ resizeArea (box, shadow, vterm);
const FPoint shadow(0, 0);
resizeArea (r, shadow, vterm);
}
//----------------------------------------------------------------------
void FVTerm::resizeVTerm (int width, int height)
{
resizeArea (0, 0, width, height, 0, 0, vterm);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -321,7 +311,9 @@ int FVTerm::printf (const FString format, ...)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (const FString& s) int FVTerm::print (const FString& s)
{ {
assert ( ! s.isNull() ); if ( s.isNull() )
return -1;
auto area = getPrintArea(); auto area = getPrintArea();
if ( ! area ) if ( ! area )
@ -338,9 +330,7 @@ int FVTerm::print (const FString& s)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FVTerm::print (term_area* area, const FString& s) int FVTerm::print (term_area* area, const FString& s)
{ {
assert ( ! s.isNull() ); if ( s.isNull() || ! area )
if ( ! area )
return -1; return -1;
std::vector<charData> term_string; std::vector<charData> term_string;
@ -567,6 +557,19 @@ int FVTerm::print (term_area* area, charData& term_char)
return 1; return 1;
} }
//----------------------------------------------------------------------
void FVTerm::print (const FPoint& p)
{
setPrintCursor (p);
}
//----------------------------------------------------------------------
void FVTerm::print (const FColorPair& pair)
{
setColor (pair.fg_color, pair.bg_color);
}
// protected methods of FVTerm // protected methods of FVTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::term_area* FVTerm::getPrintArea() FVTerm::term_area* FVTerm::getPrintArea()
@ -593,23 +596,8 @@ FVTerm::term_area* FVTerm::getPrintArea()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createArea ( const FRect& r void FVTerm::createArea ( const FRect& box
, const FPoint& p , const FSize& shadow
, term_area*& area )
{
createArea ( r.getX()
, r.getY()
, int(r.getWidth())
, int(r.getHeight())
, p.getX()
, p.getY()
, area );
}
//----------------------------------------------------------------------
void FVTerm::createArea ( int offset_left, int offset_top
, int width, int height
, int rsw, int bsh
, term_area*& area ) , term_area*& area )
{ {
// initialize virtual window // initialize virtual window
@ -625,34 +613,26 @@ void FVTerm::createArea ( int offset_left, int offset_top
} }
area->widget = static_cast<FWidget*>(this); area->widget = static_cast<FWidget*>(this);
resizeArea (offset_left, offset_top, width, height, rsw, bsh, area); resizeArea (box, shadow, area);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::resizeArea ( const FRect& r void FVTerm::resizeArea ( const FRect& box
, const FPoint& p , const FSize& shadow
, term_area* area )
{
resizeArea ( r.getX()
, r.getY()
, int(r.getWidth())
, int(r.getHeight())
, p.getX()
, p.getY()
, area );
}
//----------------------------------------------------------------------
void FVTerm::resizeArea ( int offset_left, int offset_top
, int width, int height
, int rsw, int bsh
, term_area* area ) , term_area* area )
{ {
// Resize the virtual window to a new size. // Resize the virtual window to a new size.
int offset_left = box.getX();
int offset_top = box.getY();
int width = int(box.getWidth());
int height = int(box.getHeight());
int rsw = int(shadow.getWidth());
int bsh = int(shadow.getHeight());
assert ( offset_top >= 0 ); assert ( offset_top >= 0 );
assert ( width > 0 ); assert ( width > 0 && width + rsw > 0 );
assert ( height > 0 ); assert ( height > 0 && height + bsh > 0 );
assert ( rsw >= 0 ); assert ( rsw >= 0 );
assert ( bsh >= 0 ); assert ( bsh >= 0 );
std::size_t area_size; std::size_t area_size;
@ -701,17 +681,16 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
area->bottom_shadow = bsh; area->bottom_shadow = bsh;
area->has_changes = false; area->has_changes = false;
setTextToDefault (area, width + rsw, height + bsh); FSize size(std::size_t(width + rsw), std::size_t(height + bsh));
setTextToDefault (area, size);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setTextToDefault ( term_area* area inline void FVTerm::setTextToDefault ( term_area* area
, int width , const FSize& size )
, int height )
{ {
charData default_char; charData default_char;
line_changes unchanged; line_changes unchanged;
int size = width * height;
default_char.code = ' '; default_char.code = ' ';
default_char.fg_color = fc::Default; default_char.fg_color = fc::Default;
@ -720,13 +699,13 @@ inline void FVTerm::setTextToDefault ( term_area* area
default_char.attr.byte[1] = 0; default_char.attr.byte[1] = 0;
default_char.attr.byte[2] = 0; default_char.attr.byte[2] = 0;
std::fill_n (area->text, size, default_char); std::fill_n (area->text, size.getArea(), default_char);
unchanged.xmin = uInt(width); unchanged.xmin = uInt(size.getWidth());
unchanged.xmax = 0; unchanged.xmax = 0;
unchanged.trans_count = 0; unchanged.trans_count = 0;
std::fill_n (area->changes, height, unchanged); std::fill_n (area->changes, size.getHeight(), unchanged);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -734,6 +713,9 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
, std::size_t height , std::size_t height
, std::size_t size ) , std::size_t size )
{ {
// Reallocate "height" lines for changes
// and "size" bytes for the text area
if ( area->changes != 0 ) if ( area->changes != 0 )
delete[] area->changes; delete[] area->changes;
@ -757,6 +739,8 @@ inline bool FVTerm::reallocateTextArea ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size) inline bool FVTerm::reallocateTextArea (term_area* area, std::size_t size)
{ {
// Reallocate "size" bytes for the text area
if ( area->text != 0 ) if ( area->text != 0 )
delete[] area->text; delete[] area->text;
@ -800,17 +784,10 @@ void FVTerm::removeArea (term_area*& area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::restoreVTerm (const FRect& box) void FVTerm::restoreVTerm (const FRect& box)
{ {
restoreVTerm ( box.getX() int x = box.getX() - 1;
, box.getY() int y = box.getY() - 1;
, int(box.getWidth()) int w = int(box.getWidth());
, int(box.getHeight()) ); int h = int(box.getHeight());
}
//----------------------------------------------------------------------
void FVTerm::restoreVTerm (int x, int y, int w, int h)
{
x--;
y--;
if ( x < 0 ) if ( x < 0 )
x = 0; x = 0;
@ -841,7 +818,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
{ {
int xpos = x + tx; int xpos = x + tx;
auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character auto tc = &vterm->text[ypos * vterm->width + xpos]; // terminal character
auto sc = generateCharacter(xpos, ypos); // shown character auto sc = generateCharacter(FPoint(xpos, ypos)); // shown character
std::memcpy (tc, &sc, sizeof(*tc)); std::memcpy (tc, &sc, sizeof(*tc));
} }
@ -859,15 +836,6 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
{ {
// Determines the covered state for the given position // Determines the covered state for the given position
return isCovered (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
FVTerm::covered_state FVTerm::isCovered ( int x, int y
, term_area* area )
{
// Determines the covered state for the given position
if ( ! area ) if ( ! area )
return non_covered; return non_covered;
@ -893,10 +861,12 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
, std::size_t(win->width + win->right_shadow) , std::size_t(win->width + win->right_shadow)
, std::size_t(win->height + win->bottom_shadow) ); , std::size_t(win->height + win->bottom_shadow) );
if ( found && geometry.contains(x, y) ) if ( found && geometry.contains(pos) )
{ {
int line_len = win->width + win->right_shadow; int width = win->width + win->right_shadow;
auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)]; int x = pos.getX();
int y = pos.getY();
auto tmp = &win->text[(y - win_y) * width + (x - win_x)];
if ( tmp->attr.bit.trans_shadow ) if ( tmp->attr.bit.trans_shadow )
{ {
@ -919,22 +889,25 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedColor ( term_area* area void FVTerm::updateOverlappedColor ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Add the overlapping color to this character // Add the overlapping color to this character
int& aw = area->width; int x = area_pos.getX();
int& rsh = area->right_shadow; int y = area_pos.getY();
int line_len = aw + rsh; int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * width + x];
// Terminal character // Terminal character
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Overlapped character // Overlapped character
auto oc = getOverlappedCharacter (tx + 1, ty + 1, area->widget); auto oc = getOverlappedCharacter (terminal_pos + FPoint(1, 1), area->widget);
nc.fg_color = oc.fg_color; nc.fg_color = oc.fg_color;
nc.bg_color = oc.bg_color; nc.bg_color = oc.bg_color;
nc.attr.bit.reverse = false; nc.attr.bit.reverse = false;
@ -953,33 +926,39 @@ void FVTerm::updateOverlappedColor ( term_area* area
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateOverlappedCharacter (term_area* area, int tx, int ty) void FVTerm::updateOverlappedCharacter ( term_area* area
, const FPoint& terminal_pos )
{ {
// Restore one character on vterm // Restore one character on vterm
// Terminal character // Terminal character
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc); oc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == oc);
std::memcpy (tc, &oc, sizeof(*tc)); std::memcpy (tc, &oc, sizeof(*tc));
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateShadedCharacter ( term_area* area void FVTerm::updateShadedCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Get covered character + add the current color // Get covered character + add the current color
int& aw = area->width; int x = area_pos.getX();
int& rsh = area->right_shadow; int y = area_pos.getY();
int line_len = aw + rsh; int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * width + x];
// Terminal character // Terminal character
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// Overlapped character // Overlapped character
auto oc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto oc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
oc.fg_color = ac->fg_color; oc.fg_color = ac->fg_color;
oc.bg_color = ac->bg_color; oc.bg_color = ac->bg_color;
oc.attr.bit.reverse = false; oc.attr.bit.reverse = false;
@ -999,22 +978,25 @@ void FVTerm::updateShadedCharacter ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateInheritBackground ( term_area* area void FVTerm::updateInheritBackground ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Add the covered background to this character // Add the covered background to this character
int& aw = area->width; int x = area_pos.getX();
int& rsh = area->right_shadow; int y = area_pos.getY();
int line_len = aw + rsh; int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * width + x];
// Terminal character // Terminal character
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
// New character // New character
charData nc; charData nc;
std::memcpy (&nc, ac, sizeof(nc)); std::memcpy (&nc, ac, sizeof(nc));
// Covered character // Covered character
auto cc = getCoveredCharacter (tx + 1, ty + 1, area->widget); auto cc = getCoveredCharacter (terminal_pos + FPoint(1, 1), area->widget);
nc.bg_color = cc.bg_color; nc.bg_color = cc.bg_color;
nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc); nc.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(*tc)); std::memcpy (tc, &nc, sizeof(*tc));
@ -1022,15 +1004,18 @@ void FVTerm::updateInheritBackground ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateCharacter ( term_area* area void FVTerm::updateCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
// Copy a area character to the virtual terminal // Copy a area character to the virtual terminal
int& aw = area->width; int x = area_pos.getX();
int& rsh = area->right_shadow; int y = area_pos.getY();
int line_len = aw + rsh; int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * width + x];
// Terminal character // Terminal character
auto tc = &vterm->text[ty * vterm->width + tx]; auto tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(*tc)); std::memcpy (tc, ac, sizeof(*tc));
@ -1043,41 +1028,42 @@ void FVTerm::updateCharacter ( term_area* area
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::updateVTermCharacter ( term_area* area bool FVTerm::updateVTermCharacter ( term_area* area
, int x, int y, int tx, int ty ) , const FPoint& area_pos
, const FPoint& terminal_pos )
{ {
int& aw = area->width; int x = area_pos.getX();
int& rsh = area->right_shadow; int y = area_pos.getY();
int line_len = aw + rsh; int width = area->width + area->right_shadow;
// Area character // Area character
auto ac = &area->text[y * line_len + x]; auto ac = &area->text[y * width + x];
// Get covered state // Get covered state
auto is_covered = isCovered(tx, ty, area); auto is_covered = isCovered(terminal_pos, area);
if ( is_covered == fully_covered ) if ( is_covered == fully_covered )
return false; return false;
if ( is_covered == half_covered ) if ( is_covered == half_covered )
{ {
updateOverlappedColor(area, x, y, tx, ty); updateOverlappedColor(area, area_pos, terminal_pos);
} }
else if ( ac->attr.bit.transparent ) // Transparent else if ( ac->attr.bit.transparent ) // Transparent
{ {
updateOverlappedCharacter(area, tx, ty); updateOverlappedCharacter(area, terminal_pos);
} }
else // Not transparent else // Not transparent
{ {
if ( ac->attr.bit.trans_shadow ) // Transparent shadow if ( ac->attr.bit.trans_shadow ) // Transparent shadow
{ {
updateShadedCharacter (area, x, y, tx, ty); updateShadedCharacter (area, area_pos, terminal_pos);
} }
else if ( ac->attr.bit.inherit_bg ) else if ( ac->attr.bit.inherit_bg )
{ {
updateInheritBackground (area, x, y, tx, ty); updateInheritBackground (area, area_pos, terminal_pos);
} }
else // Default else // Default
{ {
updateCharacter (area, x, y, tx, ty); updateCharacter (area, area_pos, terminal_pos);
} }
} }
@ -1167,14 +1153,12 @@ void FVTerm::updateVTerm (term_area* area)
if ( ! area || ! area->visible ) if ( ! area || ! area->visible )
return; return;
int ax = area->offset_left int ax = area->offset_left;
, ay = area->offset_top int ay = area->offset_top;
, aw = area->width int width = area->width + area->right_shadow;
, ah = area->height int height = area->height + area->bottom_shadow;
, rsh = area->right_shadow int ol = 0; // Outside left
, bsh = area->bottom_shadow int y_end;
, ol = 0 // Outside left
, y_end;
// Call the processing handler methods // Call the processing handler methods
callPreprocessingHandler(area); callPreprocessingHandler(area);
@ -1185,10 +1169,10 @@ void FVTerm::updateVTerm (term_area* area)
ax = 0; ax = 0;
} }
if ( ah + bsh + ay > vterm->height ) if ( height + ay > vterm->height )
y_end = vterm->height - ay; y_end = vterm->height - ay;
else else
y_end = ah + bsh; y_end = height;
for (int y = 0; y < y_end; y++) // Line loop for (int y = 0; y < y_end; y++) // Line loop
{ {
@ -1203,7 +1187,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( ax == 0 ) if ( ax == 0 )
line_xmin = ol; line_xmin = ol;
if ( aw + rsh + ax - ol >= vterm->width ) if ( width + ax - ol >= vterm->width )
line_xmax = vterm->width + ol - ax - 1; line_xmax = vterm->width + ol - ax - 1;
if ( ax + line_xmin >= vterm->width ) if ( ax + line_xmin >= vterm->width )
@ -1212,15 +1196,15 @@ void FVTerm::updateVTerm (term_area* area)
for (int x = line_xmin; x <= line_xmax; x++) // Column loop for (int x = line_xmin; x <= line_xmax; x++) // Column loop
{ {
// Global terminal positions // Global terminal positions
int tx = ax + x int tx = ax + x;
, ty = ay + y; int ty = ay + y;
if ( tx < 0 || ty < 0 ) if ( tx < 0 || ty < 0 )
continue; continue;
tx -= ol; tx -= ol;
if ( updateVTermCharacter (area, x, y, tx, ty) ) if ( updateVTermCharacter(area, FPoint(x, y), FPoint(tx, ty)) )
modified = true; modified = true;
if ( ! modified ) if ( ! modified )
@ -1239,7 +1223,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( _xmax > int(vterm->changes[ay + y].xmax) ) if ( _xmax > int(vterm->changes[ay + y].xmax) )
vterm->changes[ay + y].xmax = uInt(_xmax); vterm->changes[ay + y].xmax = uInt(_xmax);
area->changes[y].xmin = uInt(aw + rsh); area->changes[y].xmin = uInt(width);
area->changes[y].xmax = 0; area->changes[y].xmax = 0;
} }
@ -1271,9 +1255,9 @@ bool FVTerm::updateVTermCursor (term_area* area)
x = ax + cx; x = ax + cx;
y = ay + cy; y = ay + cy;
if ( isInsideArea(cx, cy, area) if ( isInsideArea (FPoint(cx, cy), area)
&& isInsideTerminal(x, y) && isInsideTerminal (FPoint(x, y))
&& isCovered(x, y, area) == non_covered ) && isCovered (FPoint(x, y), area) == non_covered )
{ {
vterm->input_cursor_x = x; vterm->input_cursor_x = x;
vterm->input_cursor_y = y; vterm->input_cursor_y = y;
@ -1287,16 +1271,15 @@ bool FVTerm::updateVTermCursor (term_area* area)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::isInsideArea (int x, int y, term_area* area) bool FVTerm::isInsideArea (const FPoint& pos, term_area* area)
{ {
// Check whether the coordinates are within the area // Check whether the coordinates are within the area
int ax = 0, ay = 0; auto aw = std::size_t(area->width);
std::size_t aw = std::size_t(area->width); auto ah = std::size_t(area->height);
std::size_t ah = std::size_t(area->height); FRect area_geometry(0, 0, aw, ah);
FRect area_geometry(ax, ay, aw, ah);
if ( area_geometry.contains(x, y) ) if ( area_geometry.contains(pos) )
return true; return true;
else else
return false; return false;
@ -1306,41 +1289,27 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
void FVTerm::setAreaCursor ( const FPoint& pos void FVTerm::setAreaCursor ( const FPoint& pos
, bool visible , bool visible
, term_area* area ) , term_area* area )
{
setAreaCursor (pos.getX(), pos.getY(), visible, area);
}
//----------------------------------------------------------------------
void FVTerm::setAreaCursor ( int x, int y
, bool visible
, term_area* area )
{ {
if ( ! area ) if ( ! area )
return; return;
area->input_cursor_x = x - 1; area->input_cursor_x = pos.getX() - 1;
area->input_cursor_y = y - 1; area->input_cursor_y = pos.getY() - 1;
area->input_cursor_visible = visible; area->input_cursor_visible = visible;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getArea (const FPoint& pos, term_area* area) void FVTerm::getArea (const FPoint& pos, term_area* area)
{
return getArea (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
void FVTerm::getArea (int ax, int ay, term_area* area)
{ {
// Copies a block from the virtual terminal position to the given area // Copies a block from the virtual terminal position to the given area
int y_end;
int length;
if ( ! area ) if ( ! area )
return; return;
ax--; int y_end;
ay--; int length;
int ax = pos.getX() - 1;
int ay = pos.getY() - 1;
if ( area->height + ay > vterm->height ) if ( area->height + ay > vterm->height )
y_end = area->height - ay; y_end = area->height - ay;
@ -1368,26 +1337,20 @@ void FVTerm::getArea (int ax, int ay, term_area* area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getArea (const FRect& box, term_area* area) void FVTerm::getArea (const FRect& box, term_area* area)
{
getArea ( box.getX()
, box.getY()
, int(box.getWidth())
, int(box.getHeight())
, area );
}
//----------------------------------------------------------------------
void FVTerm::getArea (int x, int y, int w, int h, term_area* area)
{ {
// Copies a block from the virtual terminal rectangle to the given area // Copies a block from the virtual terminal rectangle to the given area
if ( ! area ) if ( ! area )
return; return;
int dx = x - area->offset_left + 1 int x = box.getX();
, dy = y - area->offset_top + 1 int y = box.getY();
, y_end int w = int(box.getWidth());
, length; int h = int(box.getHeight());
int dx = x - area->offset_left + 1;
int dy = y - area->offset_top + 1;
int y_end;
int length;
if ( x < 0 || y < 0 ) if ( x < 0 || y < 0 )
return; return;
@ -1425,39 +1388,18 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
{ {
// Copies the given area block to the virtual terminal position // Copies the given area block to the virtual terminal position
if ( ! area )
return;
if ( ! area->visible )
return;
putArea (pos.getX(), pos.getY(), area);
}
//----------------------------------------------------------------------
void FVTerm::putArea (int ax, int ay, term_area* area)
{
// Copies the given area block to the virtual terminal position
charData* tc; // terminal character charData* tc; // terminal character
charData* ac; // area character charData* ac; // area character
if ( ! area ) if ( ! area || ! area->visible )
return; return;
if ( ! area->visible ) int ax = pos.getX() - 1;
return; int ay = pos.getY() - 1;
int width = area->width + area->right_shadow;
ax--; int height = area->height + area->bottom_shadow;
ay--; int ol = 0; // outside left
int y_end, length;
int aw = area->width
, ah = area->height
, rsh = area->right_shadow
, bsh = area->bottom_shadow
, ol = 0 // outside left
, y_end
, length;
if ( ax < 0 ) if ( ax < 0 )
{ {
@ -1465,27 +1407,25 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
ax = 0; ax = 0;
} }
if ( ay + ah + bsh > vterm->height ) if ( ay + height > vterm->height )
y_end = vterm->height - ay; y_end = vterm->height - ay;
else else
y_end = ah + bsh; y_end = height;
if ( aw + rsh - ol + ax > vterm->width ) if ( width - ol + ax > vterm->width )
length = vterm->width - ax; length = vterm->width - ax;
else else
length = aw + rsh - ol; length = width - ol;
if ( length < 1 ) if ( length < 1 )
return; return;
for (int y = 0; y < y_end; y++) // line loop for (int y = 0; y < y_end; y++) // line loop
{ {
int line_len = aw + rsh;
if ( area->changes[y].trans_count == 0 ) if ( area->changes[y].trans_count == 0 )
{ {
// Line has only covered characters // Line has only covered characters
ac = &area->text[y * line_len + ol]; ac = &area->text[y * width + ol];
tc = &vterm->text[(ay + y) * vterm->width + ax]; tc = &vterm->text[(ay + y) * vterm->width + ax];
putAreaLine (ac, tc, length); putAreaLine (ac, tc, length);
} }
@ -1496,9 +1436,9 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
{ {
int cx = ax + x; int cx = ax + x;
int cy = ay + y; int cy = ay + y;
ac = &area->text[y * line_len + ol + x]; ac = &area->text[y * width + ol + x];
tc = &vterm->text[cy * vterm->width + cx]; tc = &vterm->text[cy * vterm->width + cx];
putAreaCharacter (cx + 1, cy + 1, area->widget, ac, tc); putAreaCharacter (FPoint(cx + 1, cy + 1), area->widget, ac, tc);
} }
} }
@ -1558,7 +1498,7 @@ void FVTerm::scrollAreaForward (term_area* area)
{ {
setTermXY (0, vdesktop->height); setTermXY (0, vdesktop->height);
FTerm::scrollTermForward(); FTerm::scrollTermForward();
putArea (1, 1, vdesktop); putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 0 to (y_max - 1) // avoid update lines from 0 to (y_max - 1)
for (int y = 0; y < y_max; y++) for (int y = 0; y < y_max; y++)
@ -1618,7 +1558,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
{ {
setTermXY (0, 0); setTermXY (0, 0);
FTerm::scrollTermReverse(); FTerm::scrollTermReverse();
putArea (1, 1, vdesktop); putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 1 to y_max // avoid update lines from 1 to y_max
for (int y = 1; y <= y_max; y++) for (int y = 1; y <= y_max; y++)
@ -1685,16 +1625,11 @@ void FVTerm::clearArea (term_area* area, int fillchar)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::generateCharacter (const FPoint& pos) FVTerm::charData FVTerm::generateCharacter (const FPoint& pos)
{
// Generates characters for a given position considering all areas
return generateCharacter (pos.getX(), pos.getY());
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::generateCharacter (int x, int y)
{ {
// Generates characters for a given position considering all areas // Generates characters for a given position considering all areas
int x = pos.getX();
int y =pos.getY();
auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character
if ( ! FWidget::window_list || FWidget::window_list->empty() ) if ( ! FWidget::window_list || FWidget::window_list->empty() )
@ -1758,24 +1693,14 @@ FVTerm::charData FVTerm::generateCharacter (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::charData FVTerm::getCharacter ( character_type type FVTerm::charData FVTerm::getCharacter ( character_type char_type
, const FPoint& pos , const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped or the covered character for a given position // Gets the overlapped or the covered character for a given position
return getCharacter (type, pos.getX(), pos.getY(), obj);
}
//---------------------------------------------------------------------- int x = pos.getX() - 1;
FVTerm::charData FVTerm::getCharacter ( character_type char_type int y = pos.getY() - 1;
, int x
, int y
, FVTerm* obj )
{
// Gets the overlapped or the covered character for the position (x,y)
x--;
y--;
int xx = x; int xx = x;
int yy = y; int yy = y;
@ -1825,7 +1750,7 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
// Window visible and contains current character // Window visible and contains current character
if ( geometry.contains(x, y) ) if ( geometry.contains(x, y) )
getAreaCharacter (x, y, win, cc); getAreaCharacter (FPoint(x, y), win, cc);
} }
else if ( char_type == covered_character ) else if ( char_type == covered_character )
break; break;
@ -1839,16 +1764,7 @@ FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the covered character for a given position // Gets the covered character for a given position
return getCharacter (covered_character, pos.getX(), pos.getY(), obj); return getCharacter (covered_character, pos, obj);
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::getCoveredCharacter ( int x
, int y
, FVTerm* obj)
{
// Gets the covered character for the position (x,y)
return getCharacter (covered_character, x, y, obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1856,16 +1772,7 @@ FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped character for a given position // Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj); return getCharacter (overlapped_character, pos, obj);
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::getOverlappedCharacter ( int x
, int y
, FVTerm* obj)
{
// Gets the overlapped character for the position (x,y)
return getCharacter (overlapped_character, x, y, obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1963,10 +1870,10 @@ void FVTerm::init (bool disable_alt_screen)
// Create virtual terminal // Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry); createVTerm (term_geometry.getSize());
// Create virtual desktop area // Create virtual desktop area
FPoint shadow_size(0, 0); FSize shadow_size(0, 0);
createArea (term_geometry, shadow_size, vdesktop); createArea (term_geometry, shadow_size, vdesktop);
vdesktop->visible = true; vdesktop->visible = true;
active_area = vdesktop; active_area = vdesktop;
@ -2039,7 +1946,7 @@ void FVTerm::putAreaLine (charData* ac, charData* tc, int length)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj void FVTerm::putAreaCharacter ( const FPoint& pos, FVTerm* obj
, charData* ac , charData* ac
, charData* tc ) , charData* tc )
{ {
@ -2047,7 +1954,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{ {
// Restore one character on vterm // Restore one character on vterm
charData ch; charData ch;
ch = getCoveredCharacter (x, y, obj); ch = getCoveredCharacter (pos, obj);
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (tc, &ch, sizeof(*tc));
} }
else // Mot transparent else // Mot transparent
@ -2056,7 +1963,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{ {
// Get covered character + add the current color // Get covered character + add the current color
charData ch; charData ch;
ch = getCoveredCharacter (x, y, obj); ch = getCoveredCharacter (pos, obj);
ch.fg_color = ac->fg_color; ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color; ch.bg_color = ac->bg_color;
ch.attr.bit.reverse = false; ch.attr.bit.reverse = false;
@ -2077,7 +1984,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
// Add the covered background to this character // Add the covered background to this character
charData ch, cc; charData ch, cc;
std::memcpy (&ch, ac, sizeof(ch)); std::memcpy (&ch, ac, sizeof(ch));
cc = getCoveredCharacter (x, y, obj); cc = getCoveredCharacter (pos, obj);
ch.bg_color = cc.bg_color; ch.bg_color = cc.bg_color;
std::memcpy (tc, &ch, sizeof(*tc)); std::memcpy (tc, &ch, sizeof(*tc));
} }
@ -2087,12 +1994,14 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::getAreaCharacter ( int x, int y, term_area* area void FVTerm::getAreaCharacter ( const FPoint& pos, term_area* area
, charData*& cc ) , charData*& cc )
{ {
int area_x = area->offset_left; int area_x = area->offset_left;
int area_y = area->offset_top; int area_y = area->offset_top;
int line_len = area->width + area->right_shadow; int line_len = area->width + area->right_shadow;
int x = pos.getX();
int y = pos.getY();
auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)]; auto tmp = &area->text[(y - area_y) * line_len + (x - area_x)];
// Current character not transparent // Current character not transparent
@ -2652,7 +2561,7 @@ bool FVTerm::updateTerminalCursor()
int x = vterm->input_cursor_x; int x = vterm->input_cursor_x;
int y = vterm->input_cursor_y; int y = vterm->input_cursor_y;
if ( isInsideTerminal(x, y) ) if ( isInsideTerminal(FPoint(x, y)) )
{ {
setTermXY (x, y); setTermXY (x, y);
showCursor(); showCursor();
@ -2666,12 +2575,13 @@ bool FVTerm::updateTerminalCursor()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::isInsideTerminal (int x, int y) bool FVTerm::isInsideTerminal (const FPoint& pos)
{ {
// Check whether the coordinates are within the virtual terminal // Check whether the coordinates are within the virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber()); FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x, y) ) if ( term_geometry.contains(pos) )
return true; return true;
else else
return false; return false;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -247,6 +247,12 @@ void FWidget::setMainWidget (FWidget* obj)
app_object->focusFirstChild(); app_object->focusFirstChild();
} }
//----------------------------------------------------------------------
bool FWidget::setVisible (bool enable)
{
return (flags.visible = enable);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setEnable (bool enable) bool FWidget::setEnable (bool enable)
{ {
@ -267,17 +273,11 @@ bool FWidget::setFocus (bool enable)
// set widget focus // set widget focus
if ( enable && ! flags.focus ) if ( enable && ! flags.focus )
{ {
int focusable_children = numOfFocusableChildren();
if ( last_focus ) if ( last_focus )
last_focus->unsetFocus(); last_focus->unsetFocus();
if ( (!isDialogWidget() && focusable_children == 0)
|| (isDialogWidget() && focusable_children == 1) )
{
FWidget::setFocusWidget(this); FWidget::setFocusWidget(this);
} }
}
auto window = FWindow::getWindowWidget(this); auto window = FWindow::getWindowWidget(this);
@ -292,6 +292,7 @@ bool FWidget::setFocus (bool enable)
if ( has_raised && window->isVisible() && window->isShown() ) if ( has_raised && window->isVisible() && window->isShown() )
window->redraw(); window->redraw();
} }
window->setWindowFocusWidget(this); window->setWindowFocusWidget(this);
} }
@ -299,7 +300,7 @@ bool FWidget::setFocus (bool enable)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setColor () void FWidget::setColor()
{ {
// Changes colors to the widget default colors // Changes colors to the widget default colors
setColor (foreground_color, background_color); setColor (foreground_color, background_color);
@ -338,25 +339,27 @@ void FWidget::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPos (int x, int y, bool adjust) void FWidget::setPos (const FPoint& p, bool adjust)
{ {
if ( getX() == x && wsize.getX() == x FPoint pos = p;
&& getY() == y && wsize.getY() == y )
if ( getX() == pos.getX() && wsize.getX() == pos.getX()
&& getY() == pos.getY() && wsize.getY() == pos.getY() )
{ {
return; return;
} }
if ( ! isWindowWidget() ) if ( ! isWindowWidget() )
{ {
if ( x < 1 ) if ( pos.getX() < 1 )
x = 1; pos.setX(1);
if ( y < 1 ) if ( pos.getY() < 1 )
y = 1; pos.setY(1);
} }
wsize.setPos(x, y); wsize.setPos(pos);
adjust_wsize.setPos(x, y); adjust_wsize.setPos(pos);
if ( adjust ) if ( adjust )
adjustSize(); adjustSize();
@ -407,8 +410,10 @@ void FWidget::setHeight (std::size_t height, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setSize (std::size_t width, std::size_t height, bool adjust) void FWidget::setSize (const FSize& size, bool adjust)
{ {
std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
width = std::min (width, size_hints.max_width); width = std::min (width, size_hints.max_width);
width = std::max (width, size_hints.min_width); width = std::max (width, size_hints.min_width);
height = std::min (height, size_hints.max_height); height = std::min (height, size_hints.max_height);
@ -551,34 +556,34 @@ void FWidget::setTermOffsetWithPadding()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setTermSize (std::size_t w, std::size_t h) void FWidget::setTermSize (const FSize& size)
{ {
// Set xterm size to w x h // Set xterm size to width x height
if ( isXTerminal() ) if ( isXTerminal() )
{ {
rootObject->wsize.setRect(1, 1, w, h); rootObject->wsize.setRect(FPoint(1, 1), size);
rootObject->adjust_wsize = rootObject->wsize; rootObject->adjust_wsize = rootObject->wsize;
FTerm::setTermSize (w, h); // w = columns / h = lines FTerm::setTermSize(size); // width = columns / height = lines
detectTermSize(); detectTermSize();
} }
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setGeometry ( int x, int y void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
// Sets the geometry of the widget relative to its parent // Sets the geometry of the widget relative to its parent
int term_x, term_y; int x = p.getX();
int y = p.getY();
std::size_t w = s.getWidth();
std::size_t h = s.getHeight();
w = std::min (w, size_hints.max_width); w = std::min (w, size_hints.max_width);
w = std::max (w, size_hints.min_width); w = std::max (w, size_hints.min_width);
h = std::min (h, size_hints.max_height); h = std::min (h, size_hints.max_height);
h = std::max (h, size_hints.min_height); h = std::max (h, size_hints.min_height);
if ( getX() == x && getY() == y && getWidth() == w && getHeight() == h ) if ( getPos() == p && getWidth() == w && getHeight() == h )
return; return;
if ( ! isWindowWidget() ) if ( ! isWindowWidget() )
@ -596,8 +601,8 @@ void FWidget::setGeometry ( int x, int y
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h); ( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
adjust_wsize = wsize; adjust_wsize = wsize;
term_x = getTermX(); int term_x = getTermX();
term_y = getTermY(); int term_y = getTermY();
client_offset.setCoordinates ( term_x - 1 + padding.left client_offset.setCoordinates ( term_x - 1 + padding.left
, term_y - 1 + padding.top , term_y - 1 + padding.top
@ -614,11 +619,11 @@ void FWidget::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setCursorPos (int x, int y) bool FWidget::setCursorPos (const FPoint& pos)
{ {
// sets the input cursor position // sets the input cursor position
widget_cursor_position.setPoint(x, y); widget_cursor_position.setPoint(pos);
if ( ! flags.focus || isWindowWidget() ) if ( ! flags.focus || isWindowWidget() )
return false; return false;
@ -639,8 +644,8 @@ bool FWidget::setCursorPos (int x, int y)
widget_offsetY += (1 - area->widget->getTopPadding()); widget_offsetY += (1 - area->widget->getTopPadding());
} }
setAreaCursor ( widget_offsetX + x setAreaCursor ( FPoint ( widget_offsetX + pos.getX()
, widget_offsetY + y , widget_offsetY + pos.getY() )
, flags.visible_cursor , flags.visible_cursor
, area ); , area );
return true; return true;
@ -650,10 +655,11 @@ bool FWidget::setCursorPos (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPrintPos (int x, int y) void FWidget::setPrintPos (const FPoint& pos)
{ {
setPrintCursor ( offset.getX1() + getX() + x - 1, FPoint p{ offset.getX1() + getX() + pos.getX() - 1,
offset.getY1() + getY() + y - 1 ); offset.getY1() + getY() + pos.getY() - 1 };
setPrintCursor(p);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -741,7 +747,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y) FWidget* FWidget::childWidgetAt (FWidget* p, const FPoint& pos)
{ {
if ( p && p->hasChildren() ) if ( p && p->hasChildren() )
{ {
@ -759,11 +765,11 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
auto widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled() if ( widget->isEnabled()
&& widget->isVisible() && widget->isShown()
&& ! widget->isWindowWidget() && ! widget->isWindowWidget()
&& widget->getTermGeometry().contains(x, y) ) && widget->getTermGeometry().contains(pos) )
{ {
auto child = childWidgetAt(widget, x, y); auto child = childWidgetAt(widget, pos);
return ( child != 0 ) ? child : widget; return ( child != 0 ) ? child : widget;
} }
@ -790,7 +796,9 @@ int FWidget::numOfFocusableChildren()
{ {
auto widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->acceptFocus() ) if ( widget->isShown()
&& widget->acceptFocus()
&& ! widget->isWindowWidget() )
num++; num++;
} }
@ -984,7 +992,7 @@ void FWidget::redraw()
setColor (wc.term_fg, wc.term_bg); setColor (wc.term_fg, wc.term_bg);
clearArea (vdesktop); clearArea (vdesktop);
} }
else if ( ! isVisible() ) else if ( ! isShown() )
return; return;
draw(); draw();
@ -1014,7 +1022,7 @@ void FWidget::resize()
FRect term_geometry = getTermGeometry(); FRect term_geometry = getTermGeometry();
term_geometry.move (-1, -1); term_geometry.move (-1, -1);
resizeVTerm (term_geometry); resizeVTerm (term_geometry.getSize());
resizeArea (term_geometry, getShadow(), vdesktop); resizeArea (term_geometry, getShadow(), vdesktop);
adjustSizeGlobal(); adjustSizeGlobal();
} }
@ -1053,6 +1061,7 @@ void FWidget::show()
} }
draw(); draw();
flags.hidden = false;
flags.shown = true; flags.shown = true;
if ( hasChildren() ) if ( hasChildren() )
@ -1065,6 +1074,8 @@ void FWidget::show()
if ( (*iter)->isWidget() ) if ( (*iter)->isWidget() )
{ {
auto widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( ! widget->flags.hidden )
widget->show(); widget->show();
} }
@ -1087,9 +1098,10 @@ void FWidget::show()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::hide() void FWidget::hide()
{ {
flags.hidden = true;
if ( isVisible() ) if ( isVisible() )
{ {
flags.visible = false;
flags.shown = false; flags.shown = false;
if ( ! isDialogWidget() if ( ! isDialogWidget()
@ -1204,10 +1216,10 @@ void FWidget::detectTermSize()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::move (int dx, int dy) void FWidget::move (const FPoint& pos)
{ {
wsize.move(dx, dy); wsize.move(pos);
adjust_wsize.move(dx, dy); adjust_wsize.move(pos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1261,14 +1273,13 @@ void FWidget::clearShadow()
{ {
for (std::size_t y = 1; y <= getHeight(); y++) for (std::size_t y = 1; y <= getHeight(); y++)
{ {
setPrintPos (w + 1, int(y)); print() << FPoint(w + 1, int(y)) << ' '; // clear █
print (' '); // clear █
} }
} }
if ( h <= offset.getY2() ) if ( h <= offset.getY2() )
{ {
setPrintPos (2, h + 1); print() << FPoint(2, h + 1);
for (std::size_t i = 1; i <= getWidth(); i++) for (std::size_t i = 1; i <= getWidth(); i++)
print (' '); // clear ▀ print (' '); // clear ▀
@ -1296,7 +1307,7 @@ void FWidget::drawFlatBorder()
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + int(y) + 1); print() << FPoint(x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[uLong(y)] ) if ( double_flatline_mask.left[uLong(y)] )
// left+right line (on left side) // left+right line (on left side)
@ -1306,7 +1317,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
} }
setPrintPos (x2, y1 + 1); print() << FPoint(x2, y1 + 1);
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
@ -1317,10 +1328,10 @@ void FWidget::drawFlatBorder()
// left line (on right side) // left line (on right side)
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
setPrintPos (x2, y1 + int(y) + 2); print() << FPoint(x2, y1 + int(y) + 2);
} }
setPrintPos (x1, y1); print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1332,7 +1343,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
} }
setPrintPos (x1, y2); print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1364,7 +1375,7 @@ void FWidget::clearFlatBorder()
// clear on left side // clear on left side
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x1 - 1, y1 + int(y) + 1); print() << FPoint(x1 - 1, y1 + int(y) + 1);
if ( double_flatline_mask.left[y] ) if ( double_flatline_mask.left[y] )
print (fc::NF_border_line_left); print (fc::NF_border_line_left);
@ -1375,7 +1386,7 @@ void FWidget::clearFlatBorder()
// clear on right side // clear on right side
for (std::size_t y = 0; y < getHeight(); y++) for (std::size_t y = 0; y < getHeight(); y++)
{ {
setPrintPos (x2, y1 + int(y) + 1); print() << FPoint(x2, y1 + int(y) + 1);
if ( double_flatline_mask.right[y] ) if ( double_flatline_mask.right[y] )
print (fc::NF_rev_border_line_right); print (fc::NF_rev_border_line_right);
@ -1384,7 +1395,7 @@ void FWidget::clearFlatBorder()
} }
// clear at top // clear at top
setPrintPos (x1, y1); print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1395,7 +1406,7 @@ void FWidget::clearFlatBorder()
} }
// clear at bottom // clear at bottom
setPrintPos (x1, y2); print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++) for (std::size_t x = 0; x < getWidth(); x++)
{ {
@ -1606,6 +1617,41 @@ void FWidget::adjustSizeGlobal()
} }
} }
//----------------------------------------------------------------------
void FWidget::hideSize (const FSize& size)
{
if ( size.isEmpty() )
return;
FColor fg, bg;
auto parent_widget = getParentWidget();
if ( parent_widget )
{
fg = parent_widget->getForegroundColor();
bg = parent_widget->getBackgroundColor();
}
else
{
fg = wc.dialog_fg;
bg = wc.dialog_bg;
}
setColor (fg, bg);
auto blank = createBlankArray(size.getWidth());
if ( blank == 0 )
return;
for (int y = 0; y < int(size.getWidth()); y++)
{
print() << FPoint(1, 1 + y) << blank;
}
destroyBlankArray (blank);
flush_out();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::focusNextChild() bool FWidget::focusNextChild()
{ {
@ -1655,7 +1701,7 @@ bool FWidget::focusNextChild()
} while ( ! next } while ( ! next
|| ! next->isEnabled() || ! next->isEnabled()
|| ! next->acceptFocus() || ! next->acceptFocus()
|| ! next->isVisible() || ! next->isShown()
|| next->isWindowWidget() ); || next->isWindowWidget() );
bool accpt = changeFocus (next, parent, fc::FocusNextWidget); bool accpt = changeFocus (next, parent, fc::FocusNextWidget);
@ -1716,7 +1762,7 @@ bool FWidget::focusPrevChild()
} while ( ! prev } while ( ! prev
|| ! prev->isEnabled() || ! prev->isEnabled()
|| ! prev->acceptFocus() || ! prev->acceptFocus()
|| ! prev->isVisible() || ! prev->isShown()
|| prev->isWindowWidget() ); || prev->isWindowWidget() );
bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget); bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget);
@ -2140,7 +2186,7 @@ void FWidget::drawWindows()
while ( iter != last ) while ( iter != last )
{ {
if ( (*iter)->isVisible() ) if ( (*iter)->isShown() )
{ {
auto win = (*iter)->getVWin(); auto win = (*iter)->getVWin();
int w = win->width + win->right_shadow; int w = win->width + win->right_shadow;
@ -2170,7 +2216,7 @@ void FWidget::drawChildren()
{ {
auto widget = static_cast<FWidget*>(*iter); auto widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible() && ! widget->isWindowWidget() ) if ( widget->isShown() && ! widget->isWindowWidget() )
widget->redraw(); widget->redraw();
} }
@ -2182,9 +2228,9 @@ void FWidget::drawChildren()
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2) void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
{ {
// transparent shadow // transparent shadow
setPrintPos (x2 + 1, y1);
setTransparent(); setTransparent();
print (" "); print() << FPoint(x2 + 1, y1) << " ";
unsetTransparent(); unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
@ -2192,14 +2238,12 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + int(y)); print() << FPoint(x2 + 1, y1 + int(y)) << " ";
print (" ");
} }
unsetTransShadow(); unsetTransShadow();
setPrintPos (x1, y2 + 1);
setTransparent(); setTransparent();
print (" "); print() << FPoint(x1, y2 + 1) << " ";
unsetTransparent(); unsetTransparent();
setColor (wc.shadow_bg, wc.shadow_fg); setColor (wc.shadow_bg, wc.shadow_fg);
@ -2218,12 +2262,12 @@ void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2) void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
{ {
// non-transparent shadow // non-transparent shadow
int block; wchar_t block;
if ( ! hasShadowCharacter() ) if ( ! hasShadowCharacter() )
return; return;
setPrintPos (x2 + 1, y1); print() << FPoint(x2 + 1, y1);
if ( isWindowWidget() ) if ( isWindowWidget() )
{ {
@ -2241,11 +2285,10 @@ void FWidget::drawBlockShadow (int x1, int y1, int x2, int y2)
for (std::size_t y = 1; y < getHeight(); y++) for (std::size_t y = 1; y < getHeight(); y++)
{ {
setPrintPos (x2 + 1, y1 + int(y)); print() << FPoint(x2 + 1, y1 + int(y)) << block; // █
print (block); // █
} }
setPrintPos (x1 + 1, y2 + 1); print() << FPoint(x1 + 1, y2 + 1);
if ( isWindowWidget() ) if ( isWindowWidget() )
setInheritBackground(); setInheritBackground();
@ -2262,8 +2305,7 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
{ {
// Use box-drawing characters to draw a border // Use box-drawing characters to draw a border
setPrintPos (x1, y1); print() << FPoint(x1, y1) << fc::BoxDrawingsDownAndRight; // ┌
print (fc::BoxDrawingsDownAndRight); // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
@ -2272,14 +2314,13 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); print() << FPoint(x1, y)
print (fc::BoxDrawingsVertical); // │ << fc::BoxDrawingsVertical // │
setPrintPos (x2, y); << FPoint(x2, y)
print (fc::BoxDrawingsVertical); // │ << fc::BoxDrawingsVertical; // │
} }
setPrintPos (x1, y2); print() << FPoint(x1, y2) << fc::BoxDrawingsUpAndRight; // └
print (fc::BoxDrawingsUpAndRight); // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
@ -2288,10 +2329,10 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
{ {
setPrintPos (x, y1); print() << FPoint(x, y1)
print (fc::BoxDrawingsHorizontal); // ─ << fc::BoxDrawingsHorizontal // ─
setPrintPos (x, y2); << FPoint(x, y2)
print (fc::BoxDrawingsHorizontal); // ─ << fc::BoxDrawingsHorizontal; // ─
} }
} }
@ -2300,8 +2341,8 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
{ {
// Use new graphical font characters to draw a border // Use new graphical font characters to draw a border
setPrintPos (x1, y1); print() << FPoint(x1, y1)
print (fc::NF_border_corner_middle_upper_left); // ┌ << fc::NF_border_corner_middle_upper_left; // ┌
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
@ -2310,14 +2351,14 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
for (int y = y1 + 1; y <= y2; y++) for (int y = y1 + 1; y <= y2; y++)
{ {
setPrintPos (x1, y); print() << FPoint(x1, y)
print (fc::NF_border_line_left); // border left ⎸ << fc::NF_border_line_left // border left ⎸
setPrintPos (x2, y); << FPoint(x2, y)
print (fc::NF_rev_border_line_right); // border right⎹ << fc::NF_rev_border_line_right; // border right⎹
} }
setPrintPos (x1, y2); print() << FPoint(x1, y2)
print (fc::NF_border_corner_middle_lower_left); // └ << fc::NF_border_corner_middle_lower_left; // └
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─ print (fc::BoxDrawingsHorizontal); // ─
@ -2331,16 +2372,9 @@ void FWidget::setColorTheme()
// Sets the default color theme // Sets the default color theme
if ( getMaxColor() < 16 ) // for 8 color mode if ( getMaxColor() < 16 ) // for 8 color mode
{
wc.set8ColorTheme(); wc.set8ColorTheme();
}
else else
{
wc.set16ColorTheme(); wc.set16ColorTheme();
if ( isKdeTerminal() )
wc.term_bg = fc::SkyBlue2;
}
} }
} // namespace finalcut } // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -20,6 +20,7 @@
* <http://www.gnu.org/licenses/>. * * <http://www.gnu.org/licenses/>. *
***********************************************************************/ ***********************************************************************/
#include "final/fterm.h"
#include "final/fwidgetcolors.h" #include "final/fwidgetcolors.h"
namespace finalcut namespace finalcut
@ -206,6 +207,9 @@ void FWidgetColors::set16ColorTheme()
scrollbar_button_bg = fc::LightGray; scrollbar_button_bg = fc::LightGray;
progressbar_fg = fc::DarkGray; progressbar_fg = fc::DarkGray;
progressbar_bg = fc::LightBlue; progressbar_bg = fc::LightBlue;
if ( ! FTerm::canChangeColorPalette() && FTerm::getMaxColor() > 16 )
term_bg = fc::SkyBlue2;
} }
} // namespace finalcut } // namespace finalcut

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -179,9 +179,9 @@ bool FWindow::setTransparentShadow (bool enable)
flags.shadow = flags.trans_shadow = enable; flags.shadow = flags.trans_shadow = enable;
if ( enable ) if ( enable )
setShadowSize (2, 1); setShadowSize (FSize(2, 1));
else else
setShadowSize (0, 0); setShadowSize (FSize(0, 0));
return enable; return enable;
} }
@ -196,13 +196,13 @@ bool FWindow::setShadow (bool enable)
{ {
flags.shadow = true; flags.shadow = true;
flags.trans_shadow = false; flags.trans_shadow = false;
setShadowSize (1, 1); setShadowSize (FSize(1, 1));
} }
else else
{ {
flags.shadow = false; flags.shadow = false;
flags.trans_shadow = false; flags.trans_shadow = false;
setShadowSize (0, 0); setShadowSize (FSize(0, 0));
} }
return enable; return enable;
@ -251,8 +251,7 @@ void FWindow::drawBorder()
, y1 = 1 , y1 = 1
, y2 = 1 + int(getHeight()) - 1; , y2 = 1 + int(getHeight()) - 1;
setPrintPos (x1, y1); print() << FPoint(x1, y1) << fc::NF_border_corner_upper_left; // ⎡
print (fc::NF_border_corner_upper_left); // ⎡
for (int x = x1 + 1; x < x2; x++) for (int x = x1 + 1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯ print (fc::NF_border_line_upper); // ¯
@ -261,24 +260,20 @@ void FWindow::drawBorder()
for (int y = y1 + 1; y < y2; y++) for (int y = y1 + 1; y < y2; y++)
{ {
setPrintPos (x1, y); print() << FPoint(x1, y) // border left ⎸
// border left ⎸ << fc::NF_border_line_left
print (fc::NF_border_line_left); << FPoint(x2, y) // border right⎹
setPrintPos (x2, y); << fc::NF_rev_border_line_right;
// border right⎹
print (fc::NF_rev_border_line_right);
} }
setPrintPos (x1, y2); print() << FPoint(x1, y2) // lower left corner border ⎣
// lower left corner border ⎣ << fc::NF_border_corner_lower_left;
print (fc::NF_border_corner_lower_left);
for (std::size_t x = 2; x < getWidth(); x++) // low line _ for (std::size_t x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom); print (fc::NF_border_line_bottom);
setPrintPos (x2, y2); print() << FPoint(x2, y2) // lower right corner border ⎦
// lower right corner border ⎦ << fc::NF_rev_border_corner_lower_right;
print (fc::NF_rev_border_corner_lower_right);
} }
else else
{ {
@ -326,12 +321,14 @@ void FWindow::setY (int y, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setPos (int x, int y, bool adjust) void FWindow::setPos (const FPoint& p, bool adjust)
{ {
if ( y < 1 ) FPoint pos = p;
y = 1;
FWidget::setPos (x, y, adjust); if ( pos.getY() < 1 )
pos.setY(1);
FWidget::setPos (pos, adjust);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -369,11 +366,11 @@ void FWindow::setHeight (std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setSize (std::size_t w, std::size_t h, bool adjust) void FWindow::setSize (const FSize& size, bool adjust)
{ {
std::size_t old_width = getWidth(); std::size_t old_width = getWidth();
std::size_t old_height = getHeight(); std::size_t old_height = getHeight();
FWidget::setSize (w, h, adjust); FWidget::setSize (size, adjust);
if ( isVirtualWindow() if ( isVirtualWindow()
&& (getWidth() != old_width || getHeight() != old_height) ) && (getWidth() != old_width || getHeight() != old_height) )
@ -385,26 +382,24 @@ void FWindow::setSize (std::size_t w, std::size_t h, bool adjust)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setGeometry ( int x, int y void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust)
, std::size_t w, std::size_t h
, bool adjust )
{ {
// Sets the geometry of the widget // Sets the geometry of the widget
int old_x = getX(); int old_x = getX();
int old_y = getY(); int old_y = getY();
std::size_t old_width = getWidth(); FPoint pos = p;
std::size_t old_height = getHeight(); FSize old_size = getSize();
if ( y < 1 ) if ( pos.getY() < 1 )
y = 1; pos.setY(1);
FWidget::setGeometry (x, y, w, h, adjust); FWidget::setGeometry (pos, size, adjust);
if ( ! isVirtualWindow() ) if ( ! isVirtualWindow() )
return; return;
if ( getWidth() != old_width || getHeight() != old_height ) if ( getSize() != old_size )
{ {
FRect geometry = getTermGeometry(); FRect geometry = getTermGeometry();
geometry.move(-1, -1); geometry.move(-1, -1);
@ -421,9 +416,9 @@ void FWindow::setGeometry ( int x, int y
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::move (int dx, int dy) void FWindow::move (const FPoint& pos)
{ {
FWidget::move (dx, dy); FWidget::move(pos);
if ( isVirtualWindow() ) if ( isVirtualWindow() )
{ {
@ -676,7 +671,7 @@ bool FWindow::zoomWindow()
// save the current geometry // save the current geometry
normalGeometry = getGeometry(); normalGeometry = getGeometry();
FRect oldGeometry = getTermGeometryWithShadow(); FRect oldGeometry = getTermGeometryWithShadow();
setGeometry (1, 1, getMaxWidth(), getMaxHeight()); setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()));
restoreVTerm (oldGeometry); restoreVTerm (oldGeometry);
redraw(); redraw();
} }
@ -767,18 +762,13 @@ bool FWindow::activatePrevWindow()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWindow::setShadowSize (int right, int bottom) void FWindow::setShadowSize (const FSize& size)
{ {
int old_right = getShadow().getX() const FSize& old_shadow = getShadow();
, old_bottom = getShadow().getY(); FWidget::setShadowSize (size);
const FSize& new_shadow = getShadow();
FWidget::setShadowSize (right, bottom); if ( isVirtualWindow() && (new_shadow != old_shadow) )
int new_right = getShadow().getX()
, new_bottom = getShadow().getY();
if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) )
{ {
auto geometry = getTermGeometry(); auto geometry = getTermGeometry();
geometry.move(-1, -1); geometry.move(-1, -1);
@ -796,7 +786,7 @@ void FWindow::adjustSize()
FWidget::adjustSize(); FWidget::adjustSize();
if ( zoomed ) if ( zoomed )
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false); setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()), false);
else if ( isVirtualWindow() ) else if ( isVirtualWindow() )
{ {
if ( getX() != old_x ) if ( getX() != old_x )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -42,7 +42,7 @@ namespace fc
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class emptyFString class emptyFString final
{ {
public: public:
// Constructors // Constructors

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -144,7 +144,6 @@ class FButton : public FWidget
// Methods // Methods
void init(); void init();
uChar getHotkey();
void setHotkeyAccelerator(); void setHotkeyAccelerator();
void detectHotkey(); void detectHotkey();
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);

View File

@ -117,9 +117,6 @@ class FButtonGroup : public FScrollView
virtual void onFocusIn (FFocusEvent*) override; virtual void onFocusIn (FFocusEvent*) override;
protected: protected:
// Accessor
uChar getHotkey();
// Mutator // Mutator
void setHotkeyAccelerator(); void setHotkeyAccelerator();

View File

@ -0,0 +1,96 @@
/***********************************************************************
* fcolorpair.h - Foreground and background color of a character *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2019 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/>. *
***********************************************************************/
/* Standalone class
*
*
*
* FClassName
*
*/
#ifndef FCOLORPAIR_H
#define FCOLORPAIR_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
//#include ...
namespace finalcut
{
//----------------------------------------------------------------------
// class FColorPair
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FColorPair
{
public:
// Constructors
FColorPair (FColor fg = fc::Default, FColor bg = fc::Default)
: fg_color(fg)
, bg_color(bg)
{ }
// Copy constructor
FColorPair (const FColorPair& pair)
: fg_color(pair.fg_color)
, bg_color(pair.bg_color)
{ }
// Destructor
~FColorPair() = default;
// Assignment operator (=)
FColorPair& operator = (const FColorPair& pair)
{
fg_color = pair.fg_color;
bg_color = pair.bg_color;
return *this;
}
// Accessor
const char* getClassName() const
{ return "FColorPair"; }
// Methods
void swap()
{
std::swap (fg_color, bg_color);
}
// Data Members
FColor fg_color; // Foreground color
FColor bg_color; // Background color
};
#pragma pack(pop)
} // namespace finalcut
#endif // FCOLORPAIR_H

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -47,7 +47,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FColorPalette class FColorPalette final
{ {
public: public:
// Constructor // Constructor

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -76,8 +76,6 @@ class FDialog : public FWindow
public: public:
// Using-declaration // Using-declaration
using FWindow::setResizeable; using FWindow::setResizeable;
using FWindow::move;
using FWindow::setPos;
// Enumeration // Enumeration
enum DialogCode enum DialogCode
@ -124,13 +122,13 @@ class FDialog : public FWindow
virtual void show() override; virtual void show() override;
virtual void hide() override; virtual void hide() override;
int exec(); int exec();
virtual void setPos (int, int, bool = true) override; virtual void setPos (const FPoint&, bool = true) override;
virtual void move (int, int) override; virtual void move (const FPoint&) override;
bool moveUp (int); bool moveUp (int);
bool moveDown (int); bool moveDown (int);
bool moveLeft (int); bool moveLeft (int);
bool moveRight (int); bool moveRight (int);
virtual void setSize (std::size_t, std::size_t, bool = true) override; virtual void setSize (const FSize&, bool = true) override;
bool reduceHeight (int); bool reduceHeight (int);
bool expandHeight (int); bool expandHeight (int);
bool reduceWidth (int); bool reduceWidth (int);
@ -207,6 +205,7 @@ class FDialog : public FWindow
void moveSizeKey (FKeyEvent*); void moveSizeKey (FKeyEvent*);
void raiseActivateDialog(); void raiseActivateDialog();
void lowerActivateDialog(); void lowerActivateDialog();
bool isOutsideTerminal (const FPoint&);
bool isLowerRightResizeCorner (const mouseStates&); bool isLowerRightResizeCorner (const mouseStates&);
void resizeMouseDown (const mouseStates&); void resizeMouseDown (const mouseStates&);
void resizeMouseUpMove (const mouseStates&, bool = false); void resizeMouseUpMove (const mouseStates&, bool = false);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -336,7 +336,7 @@ class FTimerEvent : public FEvent // timer event
int getTimerId() const; int getTimerId() const;
protected: protected:
int id; int id{0};
}; };
#pragma pack(pop) #pragma pack(pop)
@ -353,15 +353,22 @@ class FUserEvent : public FEvent // timer event
{ {
public: public:
FUserEvent() = default; FUserEvent() = default;
// Disable copy constructor
FUserEvent (const FUserEvent&) = delete;
FUserEvent (fc::events, int); FUserEvent (fc::events, int);
~FUserEvent(); ~FUserEvent();
// Disable assignment operator (=)
FUserEvent& operator = (const FUserEvent&) = delete;
int getUserId() const; int getUserId() const;
FDataPtr getData() const; FDataPtr getData() const;
void setData (FDataPtr); void setData (FDataPtr);
protected: protected:
int uid; int uid{0};
FDataPtr data_pointer{nullptr}; FDataPtr data_pointer{nullptr};
}; };

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -139,6 +139,11 @@ class FFileDialog : public FDialog
static const FString fileSaveChooser ( FWidget* static const FString fileSaveChooser ( FWidget*
, const FString& = FString() , const FString& = FString()
, const FString& = FString() ); , const FString& = FString() );
// Friend function
friend const FString fileChooser ( FWidget*
, const FString&
, const FString&
, FFileDialog::DialogType);
protected: protected:
// Method // Method
@ -164,7 +169,7 @@ class FFileDialog : public FDialog
// Method // Method
void init(); void init();
void widgetSettings (int, int); void widgetSettings (const FPoint&);
void initCallbacks(); void initCallbacks();
bool pattern_match (const char* const, char[]); bool pattern_match (const char* const, char[]);
void clear(); void clear();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -56,7 +56,7 @@ class FApplication;
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FKeyboardCommand class FKeyboardCommand final
{ {
public: public:
// Constructor // Constructor
@ -81,7 +81,7 @@ class FKeyboardCommand
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FKeyboard class FKeyboard final
{ {
public: public:
// Constants // Constants

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -143,7 +143,6 @@ class FLabel : public FWidget
// Methods // Methods
void init(); void init();
uChar getHotkey();
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t); std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
void setHotkeyAccelerator(); void setHotkeyAccelerator();
std::size_t getAlignOffset (std::size_t); std::size_t getAlignOffset (std::size_t);

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * e Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -185,8 +185,7 @@ class FListBox : public FWidget
void showInsideBrackets (std::size_t, fc::brackets_type); void showInsideBrackets (std::size_t, fc::brackets_type);
void showNoBrackets (std::size_t); void showNoBrackets (std::size_t);
void showNoBrackets (listBoxItems::iterator); void showNoBrackets (listBoxItems::iterator);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setMultiSelection (bool); void setMultiSelection (bool);
void setMultiSelection (); void setMultiSelection ();
@ -211,6 +210,11 @@ class FListBox : public FWidget
template <typename Container, typename LazyConverter> template <typename Container, typename LazyConverter>
void insert (Container, LazyConverter); void insert (Container, LazyConverter);
void insert (FListBoxItem); void insert (FListBoxItem);
template <typename T>
void insert ( const std::initializer_list<T>& list
, fc::brackets_type = fc::NoBrackets
, bool = false
, FDataPtr = nullptr );
template <typename ItemT> template <typename ItemT>
void insert ( const ItemT& void insert ( const ItemT&
, fc::brackets_type = fc::NoBrackets , fc::brackets_type = fc::NoBrackets
@ -238,6 +242,7 @@ class FListBox : public FWidget
private: private:
// Typedef // Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr; typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FListBox::*FListBoxCallback)(FWidget*, FDataPtr);
// Enumeration // Enumeration
enum convert_type enum convert_type
@ -250,8 +255,15 @@ class FListBox : public FWidget
// Accessors // Accessors
static FString& getString (listBoxItems::iterator); static FString& getString (listBoxItems::iterator);
// Inquiry
bool isHorizontallyScrollable();
bool isVerticallyScrollable();
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FListBoxCallback );
virtual void draw() override; virtual void draw() override;
void drawHeadline(); void drawHeadline();
void drawList(); void drawList();
@ -489,6 +501,22 @@ void FListBox::insert (Container container, LazyConverter convert)
recalculateVerticalBar(size); recalculateVerticalBar(size);
} }
//----------------------------------------------------------------------
template <typename T>
void FListBox::insert ( const std::initializer_list<T>& list
, fc::brackets_type b
, bool s
, FDataPtr d )
{
for (auto& item : list)
{
FListBoxItem listItem (FString() << item, d);
listItem.brackets = b;
listItem.selected = s;
insert (listItem);
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename ItemT> template <typename ItemT>
void FListBox::insert ( const ItemT& item void FListBox::insert ( const ItemT& item
@ -502,6 +530,14 @@ void FListBox::insert ( const ItemT& item
insert (listItem); insert (listItem);
} }
//----------------------------------------------------------------------
inline bool FListBox::isHorizontallyScrollable()
{ return bool( max_line_width >= getClientWidth() - 1 ); }
//----------------------------------------------------------------------
inline bool FListBox::isVerticallyScrollable()
{ return bool( getCount() > getClientHeight() ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FListBox::listBoxItems::iterator \ inline FListBox::listBoxItems::iterator \
FListBox::index2iterator (std::size_t index) FListBox::index2iterator (std::size_t index)

View File

@ -295,8 +295,7 @@ class FListView : public FWidget
FListViewItem* getCurrentItem(); FListViewItem* getCurrentItem();
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setColumnAlignment (int, fc::text_alignment); void setColumnAlignment (int, fc::text_alignment);
void setColumnText (int, const FString&); void setColumnText (int, const FString&);
@ -315,6 +314,7 @@ class FListView : public FWidget
// Methods // Methods
virtual int addColumn (const FString&, int = USE_MAX_SIZE); virtual int addColumn (const FString&, int = USE_MAX_SIZE);
virtual void hide() override;
FObjectIterator insert (FListViewItem*); FObjectIterator insert (FListViewItem*);
FObjectIterator insert (FListViewItem*, FObjectIterator); FObjectIterator insert (FListViewItem*, FObjectIterator);
FObjectIterator insert ( const FStringList& FObjectIterator insert ( const FStringList&
@ -324,13 +324,27 @@ class FListView : public FWidget
FObjectIterator insert ( const FStringList& FObjectIterator insert ( const FStringList&
, FDataPtr , FDataPtr
, FObjectIterator ); , FObjectIterator );
FObjectIterator insert ( const std::vector<uInt64>& template <typename T>
FObjectIterator insert ( const std::initializer_list<T>&
, FDataPtr = nullptr ); , FDataPtr = nullptr );
FObjectIterator insert ( const std::vector<uInt64>& template <typename T>
FObjectIterator insert ( const std::initializer_list<T>&
, FObjectIterator ); , FObjectIterator );
FObjectIterator insert ( const std::vector<uInt64>& template <typename T>
FObjectIterator insert ( const std::initializer_list<T>&
, FDataPtr , FDataPtr
, FObjectIterator ); , FObjectIterator );
template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>&
, FDataPtr = nullptr );
template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>&
, FObjectIterator );
template <typename ColT>
FObjectIterator insert ( const std::vector<ColT>&
, FDataPtr
, FObjectIterator );
FObjectIterator beginOfList(); FObjectIterator beginOfList();
FObjectIterator endOfList(); FObjectIterator endOfList();
virtual void sort(); virtual void sort();
@ -360,12 +374,20 @@ class FListView : public FWidget
typedef std::vector<Header> headerItems; typedef std::vector<Header> headerItems;
typedef std::vector<fc::sorting_type> sortTypes; typedef std::vector<fc::sorting_type> sortTypes;
typedef std::shared_ptr<FScrollbar> FScrollbarPtr; typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FListView::*FListViewCallback)(FWidget*, FDataPtr);
// Constants // Constants
static constexpr int USE_MAX_SIZE = -1; static constexpr int USE_MAX_SIZE = -1;
// Inquiry
bool isHorizontallyScrollable();
bool isVerticallyScrollable();
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FListViewCallback );
template <typename Compare> template <typename Compare>
void sort (Compare); void sort (Compare);
std::size_t getAlignOffset ( fc::text_alignment std::size_t getAlignOffset ( fc::text_alignment
@ -537,16 +559,63 @@ inline FObject::FObjectIterator
{ return insert (cols, 0, parent_iter); } { return insert (cols, 0, parent_iter); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template<typename T>
inline FObject::FObjectIterator inline FObject::FObjectIterator
FListView::insert (const std::vector<uInt64>& cols, FDataPtr d) FListView::insert (const std::initializer_list<T>& list, FDataPtr d)
{ return insert (list, d, root); }
//----------------------------------------------------------------------
template<typename T>
inline FObject::FObjectIterator
FListView::insert ( const std::initializer_list<T>& list
, FObjectIterator parent_iter )
{ return insert (list, 0, parent_iter); }
//----------------------------------------------------------------------
template<typename T>
FObject::FObjectIterator
FListView::insert ( const std::initializer_list<T>& list
, FDataPtr d
, FObjectIterator parent_iter )
{
FStringList str_cols;
for (auto& col : list)
str_cols.push_back (FString() << col);
auto item_iter = insert (str_cols, d, parent_iter);
return item_iter;
}
//----------------------------------------------------------------------
template <typename ColT>
inline FObject::FObjectIterator
FListView::insert (const std::vector<ColT>& cols, FDataPtr d)
{ return insert (cols, d, root); } { return insert (cols, d, root); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
template <typename ColT>
inline FObject::FObjectIterator inline FObject::FObjectIterator
FListView::insert ( const std::vector<uInt64>& cols FListView::insert ( const std::vector<ColT>& cols
, FObjectIterator parent_iter ) , FObjectIterator parent_iter )
{ return insert (cols, 0, parent_iter); } { return insert (cols, 0, parent_iter); }
//----------------------------------------------------------------------
template <typename ColT>
FObject::FObjectIterator
FListView::insert ( const std::vector<ColT>& cols
, FDataPtr d
, FObjectIterator parent_iter )
{
FStringList str_cols;
for (auto& col : cols)
str_cols.push_back (FString() << col);
auto item_iter = insert (str_cols, d, parent_iter);
return item_iter;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FObjectIterator FListView::beginOfList() inline FObject::FObjectIterator FListView::beginOfList()
{ return itemlist.begin(); } { return itemlist.begin(); }
@ -555,6 +624,14 @@ inline FObject::FObjectIterator FListView::beginOfList()
inline FObject::FObjectIterator FListView::endOfList() inline FObject::FObjectIterator FListView::endOfList()
{ return itemlist.end(); } { return itemlist.end(); }
//----------------------------------------------------------------------
inline bool FListView::isHorizontallyScrollable()
{ return bool( max_line_width > getClientWidth() ); }
//----------------------------------------------------------------------
inline bool FListView::isVerticallyScrollable()
{ return bool( getCount() > getClientHeight() ); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FListView::scrollTo (const FPoint& pos) inline void FListView::scrollTo (const FPoint& pos)
{ scrollTo(pos.getX(), pos.getY()); } { scrollTo(pos.getX(), pos.getY()); }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -172,6 +172,7 @@ class FMenuItem : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
uChar hotKey(); uChar hotKey();
void updateSuperMenuDimensions();
void processActivate(); void processActivate();
void processDeactivate(); void processDeactivate();
void createDialogList (FMenu*); void createDialogList (FMenu*);

View File

@ -177,7 +177,6 @@ class FMouse
uInt16 max_width{80}; uInt16 max_width{80};
uInt16 max_height{25}; uInt16 max_height{25};
struct timeval time_mousepressed{}; struct timeval time_mousepressed{};
FPoint zero_point{0, 0}; // zero point (x=0, y=0)
FPoint mouse{0, 0}; // mouse click position FPoint mouse{0, 0}; // mouse click position
FPoint new_mouse_position{}; FPoint new_mouse_position{};
}; };
@ -192,7 +191,7 @@ class FMouse
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FMouseGPM : public FMouse class FMouseGPM final : public FMouse
{ {
public: public:
// Constructor // Constructor
@ -264,7 +263,7 @@ inline bool FMouseGPM::isGpmMouseEnabled()
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FMouseX11 : public FMouse class FMouseX11 final : public FMouse
{ {
public: public:
// Constructor // Constructor
@ -327,7 +326,7 @@ class FMouseX11 : public FMouse
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FMouseSGR : public FMouse class FMouseSGR final : public FMouse
{ {
public: public:
// Constructor // Constructor
@ -390,7 +389,7 @@ class FMouseSGR : public FMouse
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FMouseUrxvt : public FMouse class FMouseUrxvt final : public FMouse
{ {
public: public:
// Constructor // Constructor

View File

@ -71,7 +71,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FOptiAttr class FOptiAttr final
{ {
public: public:
// Typedefs // Typedefs

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2015-2018 Markus Gans * * Copyright 2015-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -75,7 +75,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FOptiMove class FOptiMove final
{ {
public: public:
// Typedef // Typedef

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -78,10 +78,11 @@ class FPoint
int getY() const; int getY() const;
void setX (int); void setX (int);
void setY (int); void setY (int);
void setPoint (const FPoint&);
void setPoint (int, int); void setPoint (int, int);
// Inquiry // Inquiry
bool isNull() const; bool isOrigin() const;
// Point references // Point references
int& x_ref(); int& x_ref();
@ -140,6 +141,10 @@ inline int FPoint::getX() const
inline int FPoint::getY() const inline int FPoint::getY() const
{ return ypos; } { return ypos; }
//----------------------------------------------------------------------
inline void FPoint::setPoint (const FPoint& p)
{ setPoint(p.xpos, p.ypos); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int& FPoint::x_ref() inline int& FPoint::x_ref()
{ return xpos; } { return xpos; }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -82,9 +82,8 @@ class FProgressbar : public FWidget
// Mutators // Mutators
void setPercentage (std::size_t); void setPercentage (std::size_t);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
bool setShadow (bool); bool setShadow (bool);
bool setShadow(); bool setShadow();
bool unsetShadow(); bool unsetShadow();
@ -102,8 +101,10 @@ class FProgressbar : public FWidget
// Methods // Methods
virtual void draw() override; virtual void draw() override;
void drawPercentage(); void drawProgressLabel();
void drawBar(); void drawProgressBar();
std::size_t drawProgressIndicator();
void drawProgressBackground (std::size_t);
// Data Members // Data Members
std::size_t percentage{NOT_SET}; std::size_t percentage{NOT_SET};

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -24,8 +24,12 @@
* *
* *
* 1 * * 1 *
* FRect - - - - FPoint * FRect -- - - FPoint
* * :
* :
* : 1
* - - - FSize
*
*/ */
#ifndef FRECT_H #ifndef FRECT_H
@ -37,6 +41,7 @@
#include <algorithm> #include <algorithm>
#include "final/fpoint.h" #include "final/fpoint.h"
#include "final/fsize.h"
namespace finalcut namespace finalcut
{ {
@ -55,6 +60,7 @@ class FRect
FRect () = default; FRect () = default;
FRect (const FRect&); // copy constructor FRect (const FRect&); // copy constructor
FRect (int, int, std::size_t, std::size_t); FRect (int, int, std::size_t, std::size_t);
FRect (const FPoint&, const FSize&);
FRect (const FPoint&, const FPoint&); FRect (const FPoint&, const FPoint&);
// Destructor // Destructor
@ -63,8 +69,8 @@ class FRect
// Overloaded operators // Overloaded operators
FRect& operator = (const FRect&); FRect& operator = (const FRect&);
friend FRect operator + (const FRect&, const FPoint&); friend FRect operator + (const FRect&, const FSize&);
friend FRect operator - (const FRect&, const FPoint&); friend FRect operator - (const FRect&, const FSize&);
friend bool operator == (const FRect&, const FRect&); friend bool operator == (const FRect&, const FRect&);
friend bool operator != (const FRect&, const FRect&); friend bool operator != (const FRect&, const FRect&);
friend std::ostream& operator << (std::ostream&, const FRect&); friend std::ostream& operator << (std::ostream&, const FRect&);
@ -85,6 +91,7 @@ class FRect
FPoint getLowerRightPos() const; FPoint getLowerRightPos() const;
std::size_t getWidth() const; std::size_t getWidth() const;
std::size_t getHeight() const; std::size_t getHeight() const;
FSize getSize() const;
// Mutators // Mutators
void setX1 (int); void setX1 (int);
@ -98,13 +105,15 @@ class FRect
void setWidth (std::size_t); void setWidth (std::size_t);
void setHeight (std::size_t); void setHeight (std::size_t);
void setSize (std::size_t, std::size_t); void setSize (std::size_t, std::size_t);
void setSize (const FSize&);
void setRect (const FRect&); void setRect (const FRect&);
void setRect (const FPoint&, const FSize&);
void setRect (int, int, std::size_t, std::size_t); void setRect (int, int, std::size_t, std::size_t);
void setCoordinates (const FPoint&, const FPoint&); void setCoordinates (const FPoint&, const FPoint&);
void setCoordinates (int, int, int, int); void setCoordinates (int, int, int, int);
// Inquiry // Inquiry
bool isNull() const; bool isEmpty() const;
// Coordinate references // Coordinate references
int& x1_ref(); int& x1_ref();
@ -211,6 +220,10 @@ inline std::size_t FRect::getHeight() const
return ( h < 0 ) ? 0 : std::size_t(h); return ( h < 0 ) ? 0 : std::size_t(h);
} }
//----------------------------------------------------------------------
inline FSize FRect::getSize() const
{ return FSize(getWidth(), getHeight()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline int& FRect::x1_ref() inline int& FRect::x1_ref()
{ return X1; } { return X1; }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2012-2018 Markus Gans * * Copyright 2012-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -85,7 +85,7 @@ class FScrollbar : public FWidget
// Constructors // Constructors
explicit FScrollbar (FWidget* = nullptr); explicit FScrollbar (FWidget* = nullptr);
explicit FScrollbar (int = fc::vertical, FWidget* = nullptr); explicit FScrollbar (fc::orientation = fc::vertical, FWidget* = nullptr);
// Disable copy constructor // Disable copy constructor
FScrollbar (const FScrollbar&) = delete; FScrollbar (const FScrollbar&) = delete;
@ -108,10 +108,9 @@ class FScrollbar : public FWidget
void setValue (int); void setValue (int);
void setSteps (double); void setSteps (double);
void setPageSize (int, int); void setPageSize (int, int);
void setOrientation (int); void setOrientation (fc::orientation);
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
// Methods // Methods
virtual void resize() override; virtual void resize() override;
@ -159,7 +158,7 @@ class FScrollbar : public FWidget
double steps{1}; double steps{1};
int pagesize{0}; int pagesize{0};
std::size_t length{20}; std::size_t length{20};
int bar_orientation{fc::vertical}; fc::orientation bar_orientation{fc::vertical};
int max_color{getMaxColor()}; int max_color{getMaxColor()};
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -73,8 +73,6 @@ class FScrollView : public FWidget
public: public:
// Using-declaration // Using-declaration
using FWidget::setGeometry; using FWidget::setGeometry;
using FWidget::setPrintPos;
using FWidget::setPos;
// Constructor // Constructor
explicit FScrollView (FWidget* = nullptr); explicit FScrollView (FWidget* = nullptr);
@ -92,8 +90,10 @@ class FScrollView : public FWidget
virtual const char* getClassName() const override; virtual const char* getClassName() const override;
std::size_t getViewportWidth() const; std::size_t getViewportWidth() const;
std::size_t getViewportHeight() const; std::size_t getViewportHeight() const;
const FSize getViewportSize();
std::size_t getScrollWidth() const; std::size_t getScrollWidth() const;
std::size_t getScrollHeight() const; std::size_t getScrollHeight() const;
const FSize getScrollSize() const;
const FPoint getScrollPos() const; const FPoint getScrollPos() const;
int getScrollX() const; int getScrollX() const;
int getScrollY() const; int getScrollY() const;
@ -101,18 +101,17 @@ class FScrollView : public FWidget
// Mutator // Mutator
virtual void setScrollWidth (std::size_t); virtual void setScrollWidth (std::size_t);
virtual void setScrollHeight (std::size_t); virtual void setScrollHeight (std::size_t);
virtual void setScrollSize (std::size_t, std::size_t); virtual void setScrollSize (const FSize&);
virtual void setX (int, bool = true) override; virtual void setX (int, bool = true) override;
virtual void setY (int, bool = true) override; virtual void setY (int, bool = true) override;
virtual void setPos (int, int, bool = true) override; virtual void setPos (const FPoint&, bool = true) override;
virtual void setWidth (std::size_t, bool = true) override; virtual void setWidth (std::size_t, bool = true) override;
virtual void setHeight (std::size_t, bool = true) override; virtual void setHeight (std::size_t, bool = true) override;
virtual void setSize (std::size_t, std::size_t, bool = true) override; virtual void setSize (const FSize&, bool = true) override;
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setCursorPos (int, int); void setCursorPos (const FPoint&);
void setPrintPos (int, int); void setPrintPos (const FPoint&);
bool setViewportPrint (bool); bool setViewportPrint (bool);
bool setViewportPrint(); bool setViewportPrint();
bool unsetViewportPrint(); bool unsetViewportPrint();
@ -156,6 +155,7 @@ class FScrollView : public FWidget
private: private:
// Typedef // Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr; typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FScrollView::*FScrollViewCallback)(FWidget*, FDataPtr);
// Constants // Constants
static constexpr int vertical_border_spacing = 2; static constexpr int vertical_border_spacing = 2;
@ -166,15 +166,13 @@ class FScrollView : public FWidget
// Methods // Methods
void init (FWidget*); void init (FWidget*);
void init_scrollbar(); void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FScrollViewCallback );
void calculateScrollbarPos(); void calculateScrollbarPos();
void setHorizontalScrollBarVisibility(); void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility(); void setVerticalScrollBarVisibility();
void setViewportCursor(); void setViewportCursor();
void redrawHBar();
void redrawVBar();
void drawHBar();
void drawVBar();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_VBarChange (FWidget*, FDataPtr);
@ -209,6 +207,10 @@ inline std::size_t FScrollView::getViewportWidth() const
inline std::size_t FScrollView::getViewportHeight() const inline std::size_t FScrollView::getViewportHeight() const
{ return getHeight() - horizontal_border_spacing; } { return getHeight() - horizontal_border_spacing; }
//----------------------------------------------------------------------
inline const FSize FScrollView::getViewportSize()
{ return FSize(getViewportWidth(), getViewportHeight()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FScrollView::getScrollWidth() const inline std::size_t FScrollView::getScrollWidth() const
{ return scroll_geometry.getWidth(); } { return scroll_geometry.getWidth(); }
@ -217,6 +219,10 @@ inline std::size_t FScrollView::getScrollWidth() const
inline std::size_t FScrollView::getScrollHeight() const inline std::size_t FScrollView::getScrollHeight() const
{ return scroll_geometry.getHeight(); } { return scroll_geometry.getHeight(); }
//----------------------------------------------------------------------
inline const FSize FScrollView::getScrollSize() const
{ return scroll_geometry.getSize(); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint FScrollView::getScrollPos() const inline const FPoint FScrollView::getScrollPos() const
{ return viewport_geometry.getPos(); } { return viewport_geometry.getPos(); }

184
src/include/final/fsize.h Normal file
View File

@ -0,0 +1,184 @@
/***********************************************************************
* fsize.h - Height and width of a two-dimensional surface *
* *
* This file is part of the Final Cut widget toolkit *
* *
* Copyright 2014-2018 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/>. *
***********************************************************************/
/* Standalone class
*
*
*
* FSize
*
*/
#ifndef FSIZE_H
#define FSIZE_H
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
#error "Only <final/final.h> can be included directly."
#endif
#include <iostream>
#include "final/ftypes.h"
namespace finalcut
{
//----------------------------------------------------------------------
// class FSize
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FSize
{
public:
// Constructors
FSize () = default;
FSize (const FSize&); // copy constructor
FSize (std::size_t, std::size_t);
// Destructor
virtual ~FSize();
// Overloaded operators
FSize& operator = (const FSize&);
FSize& operator += (const FSize&);
FSize& operator -= (const FSize&);
friend bool operator < (const FSize&, const FSize&);
friend bool operator <= (const FSize&, const FSize&);
friend bool operator == (const FSize&, const FSize&);
friend bool operator != (const FSize&, const FSize&);
friend bool operator >= (const FSize&, const FSize&);
friend bool operator > (const FSize&, const FSize&);
friend FSize operator + (const FSize&, const FSize&);
friend FSize operator - (const FSize&, const FSize&);
friend std::ostream& operator << (std::ostream&, const FSize&);
friend std::istream& operator >> (std::istream&, FSize&);
// Accessors
virtual const char* getClassName();
std::size_t getWidth() const;
std::size_t getHeight() const;
std::size_t getArea() const;
void setWidth (std::size_t);
void setHeight (std::size_t);
void setSize (FSize);
void setSize (std::size_t, std::size_t);
// Inquiry
bool isEmpty() const;
// Side references
std::size_t& width_ref();
std::size_t& height_ref();
private:
// Data Members
std::size_t width{0};
std::size_t height{0};
};
#pragma pack(pop)
// FSize inline functions
//----------------------------------------------------------------------
inline FSize::FSize (const FSize& s) // copy constructor
: width(s.width)
, height(s.height)
{ }
//----------------------------------------------------------------------
inline FSize::FSize (std::size_t w, std::size_t h)
: width(w)
, height(h)
{ }
//----------------------------------------------------------------------
inline bool operator < (const FSize& s1, const FSize& s2)
{ return s1.width < s2.width && s1.height < s2.height; }
//----------------------------------------------------------------------
inline bool operator <= (const FSize& s1, const FSize& s2)
{ return s1.width <= s2.width && s1.height <= s2.height; }
//----------------------------------------------------------------------
inline bool operator == (const FSize& s1, const FSize& s2)
{ return s1.width == s2.width && s1.height == s2.height; }
//----------------------------------------------------------------------
inline bool operator != (const FSize& s1, const FSize& s2)
{ return s1.width != s2.width || s1.height != s2.height; }
//----------------------------------------------------------------------
inline bool operator >= (const FSize& s1, const FSize& s2)
{ return s1.width >= s2.width && s1.height >= s2.height; }
//----------------------------------------------------------------------
inline bool operator > (const FSize& s1, const FSize& s2)
{ return s1.width > s2.width && s1.height > s2.height; }
//----------------------------------------------------------------------
inline FSize operator + (const FSize& s1, const FSize& s2)
{
std::size_t max = std::numeric_limits<std::size_t>::max();
std::size_t w = ( s1.width < max - s2.width) ? s1.width + s2.width : max;
std::size_t h = ( s1.height < max - s2.height) ? s1.height + s2.height : max;
return FSize(w, h);
}
//----------------------------------------------------------------------
inline FSize operator - (const FSize& s1, const FSize& s2)
{
std::size_t w = ( s1.width >= s2.width ) ? s1.width - s2.width : 0;
std::size_t h = ( s1.height >= s2.height ) ? s1.height - s2.height : 0;
return FSize(w, h);
}
//----------------------------------------------------------------------
inline const char* FSize::getClassName()
{ return "FSize"; }
//----------------------------------------------------------------------
inline std::size_t FSize::getWidth() const
{ return width; }
//----------------------------------------------------------------------
inline std::size_t FSize::getHeight() const
{ return height; }
//----------------------------------------------------------------------
inline std::size_t FSize::getArea() const
{ return width * height; }
//----------------------------------------------------------------------
inline std::size_t& FSize::width_ref()
{ return width; }
//----------------------------------------------------------------------
inline std::size_t& FSize::height_ref()
{ return height; }
} // namespace finalcut
#endif // FSIZE_H

View File

@ -151,7 +151,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTerm class FTerm final
{ {
public: public:
// Typedefs // Typedefs
@ -224,6 +224,7 @@ class FTerm
static bool hasShadowCharacter(); static bool hasShadowCharacter();
static bool hasHalfBlockCharacter(); static bool hasHalfBlockCharacter();
static bool hasAlternateScreen(); static bool hasAlternateScreen();
static bool canChangeColorPalette();
// Mutators // Mutators
static void setTermType (const char[]); static void setTermType (const char[]);
@ -246,7 +247,7 @@ class FTerm
static char* enableCursor(); static char* enableCursor();
static char* disableCursor(); static char* disableCursor();
static void detectTermSize(); static void detectTermSize();
static void setTermSize (std::size_t, std::size_t); static void setTermSize (const FSize&);
static void setTermTitle (const FString&); static void setTermTitle (const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape); static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap(); static void saveColorMap();
@ -364,7 +365,6 @@ class FTerm
static void init_tab_quirks(); static void init_tab_quirks();
static void init_captureFontAndTitle(); static void init_captureFontAndTitle();
static bool hasNoFontSettingOption(); static bool hasNoFontSettingOption();
static bool canChangeColorPalette();
static void redefineColorPalette(); static void redefineColorPalette();
static void restoreColorPalette(); static void restoreColorPalette();
static void setInsertCursorStyle(); static void setInsertCursorStyle();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2017-2018 Markus Gans * * Copyright 2017-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -67,6 +67,8 @@ class FTermBuffer
// Overloaded operators // Overloaded operators
template <typename type> template <typename type>
FTermBuffer& operator << (const type&); FTermBuffer& operator << (const type&);
FTermBuffer& operator << (const FColorPair&);
// Non-member operators // Non-member operators
friend std::vector<charData>& operator << ( std::vector<charData>& friend std::vector<charData>& operator << ( std::vector<charData>&
, const FTermBuffer& ); , const FTermBuffer& );
@ -82,7 +84,8 @@ class FTermBuffer
void clear(); void clear();
int writef (const FString, ...); int writef (const FString, ...);
int write (const FString&); int write (const FString&);
int write (int); int write (wchar_t);
void write (const FColorPair&);
FTermBuffer& write (); FTermBuffer& write ();
std::vector<charData> getBuffer(); std::vector<charData> getBuffer();
@ -104,6 +107,13 @@ inline FTermBuffer& FTermBuffer::operator << (const type& s)
return *this; return *this;
} }
//----------------------------------------------------------------------
inline FTermBuffer& FTermBuffer::operator << (const FColorPair& pair)
{
write (pair);
return *this;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FTermBuffer::getClassName() const inline const char* FTermBuffer::getClassName() const
{ return "FTermBuffer"; } { return "FTermBuffer"; }

View File

@ -75,7 +75,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermcap class FTermcap final
{ {
public: public:
// Typedef // Typedef

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -51,7 +51,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermcapQuirks class FTermcapQuirks final
{ {
public: public:
// Constructors // Constructors
@ -85,6 +85,7 @@ class FTermcapQuirks
static void sunConsole(); static void sunConsole();
static void screen(); static void screen();
static void general(); static void general();
static void ecma48();
// Data Members // Data Members
static FTermcap::tcap_map* tcap; static FTermcap::tcap_map* tcap;

View File

@ -53,7 +53,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermData class FTermData final
{ {
public: public:
// Typedefs // Typedefs

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -43,7 +43,7 @@ namespace finalcut
// class FTermDebugData // class FTermDebugData
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class FTermDebugData class FTermDebugData final
{ {
public: public:
// Constructors // Constructors

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -57,7 +57,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermDetection class FTermDetection final
{ {
public: public:
// Typedefs // Typedefs

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -56,7 +56,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermFreeBSD class FTermFreeBSD final
{ {
public: public:
// Typedef // Typedef

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -50,7 +50,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermios class FTermios final
{ {
public: public:
// Constructors // Constructors

View File

@ -66,7 +66,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermLinux class FTermLinux final
{ {
public: public:
// Constructors // Constructors

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -52,7 +52,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermOpenBSD class FTermOpenBSD final
{ {
public: public:
// Constructors // Constructors

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2018 Markus Gans * * Copyright 2018-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -50,7 +50,7 @@ namespace finalcut
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
class FTermXTerminal class FTermXTerminal final
{ {
public: public:
// Constructors // Constructors
@ -65,7 +65,7 @@ class FTermXTerminal
static void setCursorStyle (fc::xtermCursorStyle); static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (const FString&); static void setFont (const FString&);
static void setTitle (const FString&); static void setTitle (const FString&);
static void setTermSize (std::size_t, std::size_t); static void setTermSize (const FSize&);
static void setForeground (const FString&); static void setForeground (const FString&);
static void setBackground (const FString&); static void setBackground (const FString&);
static void setCursorColor (const FString&); static void setCursorColor (const FString&);
@ -126,6 +126,7 @@ class FTermXTerminal
static void resetXTermMouseForeground(); static void resetXTermMouseForeground();
static void resetXTermMouseBackground(); static void resetXTermMouseBackground();
static void resetXTermHighlightBackground(); static void resetXTermHighlightBackground();
static bool canResetColor();
static void oscPrefix(); static void oscPrefix();
static void oscPostfix(); static void oscPostfix();
static const FString* captureXTermFont(); static const FString* captureXTermFont();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -97,8 +97,7 @@ class FTextView : public FWidget
const FStringList& getLines() const; const FStringList& getLines() const;
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t
, bool = true ) override; , bool = true ) override;
void setText (const FString&); void setText (const FString&);
void scrollToX (int); void scrollToX (int);
@ -109,7 +108,11 @@ class FTextView : public FWidget
// Methods // Methods
virtual void hide() override; virtual void hide() override;
template<typename T>
void append (const std::initializer_list<T>&);
void append (const FString&); void append (const FString&);
template<typename T>
void insert (const std::initializer_list<T>&, int);
void insert (const FString&, int); void insert (const FString&, int);
void replaceRange (const FString&, int, int); void replaceRange (const FString&, int, int);
void deleteRange (int, int); void deleteRange (int, int);
@ -132,6 +135,7 @@ class FTextView : public FWidget
private: private:
// Typedef // Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr; typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FTextView::*FTextViewCallback)(FWidget*, FDataPtr);
// Accessors // Accessors
std::size_t getTextHeight(); std::size_t getTextHeight();
@ -143,11 +147,12 @@ class FTextView : public FWidget
// Methods // Methods
void init(); void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FTextViewCallback );
virtual void draw() override; virtual void draw() override;
void drawText(); void drawText();
void processChanged(); void processChanged();
void drawHBar();
void drawVBar();
// Callback methods // Callback methods
void cb_VBarChange (FWidget*, FDataPtr); void cb_VBarChange (FWidget*, FDataPtr);
@ -187,6 +192,25 @@ inline const FStringList& FTextView::getLines() const
inline void FTextView::scrollTo (const FPoint& pos) inline void FTextView::scrollTo (const FPoint& pos)
{ scrollTo(pos.getX(), pos.getY()); } { scrollTo(pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
template<typename T>
void FTextView::append (const std::initializer_list<T>& list)
{
for (auto& str : list)
insert(str, -1);
}
//----------------------------------------------------------------------
template<typename T>
void FTextView::insert (const std::initializer_list<T>& list, int pos)
{
for (auto& str : list)
{
insert(str, pos);
pos++;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTextView::deleteRange (int from, int to) inline void FTextView::deleteRange (int from, int to)
{ replaceRange (FString(), from, to); } { replaceRange (FString(), from, to); }

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * This file is part of the Final Cut widget toolkit *
* * * *
* Copyright 2014-2018 Markus Gans * * Copyright 2014-2019 Markus Gans *
* * * *
* The Final Cut is free software; you can redistribute it and/or * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU Lesser General Public License *
@ -91,9 +91,8 @@ class FToggleButton : public FWidget
FString& getText(); FString& getText();
// Mutators // Mutators
virtual void setGeometry ( int, int virtual void setGeometry ( const FPoint&, const FSize&
, std::size_t, std::size_t , bool = true ) override;
, bool = true) override;
bool setNoUnderline (bool); bool setNoUnderline (bool);
bool setNoUnderline(); bool setNoUnderline();
bool unsetNoUnderline(); bool unsetNoUnderline();
@ -125,7 +124,6 @@ class FToggleButton : public FWidget
protected: protected:
// Accessor // Accessor
uChar getHotkey();
FButtonGroup* getGroup() const; FButtonGroup* getGroup() const;
// Mutator // Mutator

View File

@ -58,6 +58,7 @@
#include <vector> #include <vector>
#include "final/fterm.h" #include "final/fterm.h"
#include "final/fcolorpair.h"
// Preprocessing handler macro // Preprocessing handler macro
@ -132,6 +133,8 @@ class FVTerm
template <typename type> template <typename type>
FVTerm& operator << (const type&); FVTerm& operator << (const type&);
FVTerm& operator << (const std::vector<charData>&); FVTerm& operator << (const std::vector<charData>&);
FVTerm& operator << (const FPoint&);
FVTerm& operator << (const FColorPair&);
// Accessors // Accessors
virtual const char* getClassName() const; virtual const char* getClassName() const;
@ -158,7 +161,6 @@ class FVTerm
void hideCursor(); void hideCursor();
void showCursor(); void showCursor();
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
void setPrintCursor (int, int);
FColor rgb2ColorIndex (uInt8, uInt8, uInt8); FColor rgb2ColorIndex (uInt8, uInt8, uInt8);
void setColor (FColor, FColor); void setColor (FColor, FColor);
static void setNormal(); static void setNormal();
@ -277,10 +279,8 @@ class FVTerm
// Methods // Methods
virtual void clearArea (int = ' '); virtual void clearArea (int = ' ');
void createVTerm (const FRect&); void createVTerm (const FSize&);
void createVTerm (int, int); void resizeVTerm (const FSize&);
void resizeVTerm (const FRect&);
void resizeVTerm (int, int);
void putVTerm(); void putVTerm();
void updateTerminal (terminal_update); void updateTerminal (terminal_update);
void updateTerminal(); void updateTerminal();
@ -297,7 +297,9 @@ class FVTerm
int print (term_area*, wchar_t); int print (term_area*, wchar_t);
int print (charData&); int print (charData&);
int print (term_area*, charData&); int print (term_area*, charData&);
FVTerm& print(); virtual void print (const FPoint&);
virtual void print (const FColorPair&);
virtual FVTerm& print();
static void beep(); static void beep();
static void redefineDefaultColors (bool); static void redefineDefaultColors (bool);
static char* moveCursor (int, int, int, int); static char* moveCursor (int, int, int, int);
@ -321,6 +323,7 @@ class FVTerm
FTerm::initializationValues& getInitValues(); FTerm::initializationValues& getInitValues();
// Mutators // Mutators
void setPrintArea (term_area*);
static void setInsertCursor (bool); static void setInsertCursor (bool);
static void setInsertCursor(); static void setInsertCursor();
static void unsetInsertCursor(); static void unsetInsertCursor();
@ -337,85 +340,58 @@ class FVTerm
// Methods // Methods
void createArea ( const FRect& void createArea ( const FRect&
, const FPoint& , const FSize&
, term_area*& ); , term_area*& );
void createArea ( int, int, int, int
, int, int
, term_area*& );
void resizeArea ( const FRect& void resizeArea ( const FRect&
, const FPoint& , const FSize&
, term_area* ); , term_area* );
void resizeArea ( int, int, int, int
, int, int
, term_area* );
static void removeArea (term_area*&); static void removeArea (term_area*&);
static void restoreVTerm (const FRect&); static void restoreVTerm (const FRect&);
static void restoreVTerm (int, int, int, int); void setTextToDefault (term_area*, const FSize&);
void setTextToDefault (term_area*, int, int);
static bool reallocateTextArea ( term_area* static bool reallocateTextArea ( term_area*
, std::size_t , std::size_t
, std::size_t ); , std::size_t );
static bool reallocateTextArea ( term_area* static bool reallocateTextArea ( term_area*
, std::size_t ); , std::size_t );
static covered_state isCovered ( const FPoint& static covered_state isCovered (const FPoint&, term_area*);
, term_area* );
static covered_state isCovered ( int, int
, term_area* );
static void updateOverlappedColor ( term_area* static void updateOverlappedColor ( term_area*
, int, int, int, int ); , const FPoint&
static void updateOverlappedCharacter (term_area*, int, int); , const FPoint& );
static void updateOverlappedCharacter ( term_area*
, const FPoint& );
static void updateShadedCharacter ( term_area* static void updateShadedCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void updateInheritBackground ( term_area* static void updateInheritBackground ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void updateCharacter ( term_area* static void updateCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static bool updateVTermCharacter ( term_area* static bool updateVTermCharacter ( term_area*
, int, int, int, int ); , const FPoint&
, const FPoint& );
static void callPreprocessingHandler (term_area*); static void callPreprocessingHandler (term_area*);
void updateVTerm(); void updateVTerm();
void updateVTerm (term_area*); void updateVTerm (term_area*);
bool updateVTermCursor (term_area*); bool updateVTermCursor (term_area*);
static bool isInsideArea (int, int, term_area*); static bool isInsideArea (const FPoint&, term_area*);
static void setAreaCursor ( const FPoint& static void setAreaCursor ( const FPoint&
, bool, term_area* ); , bool, term_area* );
static void setAreaCursor ( int, int
, bool, term_area*);
static void getArea (const FPoint&, term_area*); static void getArea (const FPoint&, term_area*);
static void getArea (int, int, term_area*);
static void getArea (const FRect&, term_area*); static void getArea (const FRect&, term_area*);
static void getArea (int, int, int, int, term_area*);
static void putArea (const FPoint&, term_area*); static void putArea (const FPoint&, term_area*);
static void putArea (int, int, term_area*);
void scrollAreaForward (term_area*); void scrollAreaForward (term_area*);
void scrollAreaReverse (term_area*); void scrollAreaReverse (term_area*);
void clearArea (term_area*, int = ' '); void clearArea (term_area*, int = ' ');
static charData generateCharacter (const FPoint&); static charData generateCharacter (const FPoint&);
static charData generateCharacter (int, int);
static charData getCharacter ( character_type static charData getCharacter ( character_type
, const FPoint& , const FPoint&
, FVTerm* ); , FVTerm* );
static charData getCharacter ( character_type
, int
, int, FVTerm* );
static charData getCoveredCharacter (const FPoint&, FVTerm*); static charData getCoveredCharacter (const FPoint&, FVTerm*);
static charData getCoveredCharacter (int, int, FVTerm*);
static charData getOverlappedCharacter (const FPoint&, FVTerm*); static charData getOverlappedCharacter (const FPoint&, FVTerm*);
static charData getOverlappedCharacter (int, int, FVTerm*);
void processTerminalUpdate(); void processTerminalUpdate();
static void startTerminalUpdate(); static void startTerminalUpdate();
static void finishTerminalUpdate(); static void finishTerminalUpdate();
@ -451,17 +427,14 @@ class FVTerm
static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768; static constexpr uInt TERMINAL_OUTPUT_BUFFER_SIZE = 32768;
// Buffer size for character output on the terminal // Buffer size for character output on the terminal
// Mutators
void setPrintArea (term_area*);
// Methods // Methods
void init (bool); void init (bool);
static void init_characterLengths (FOptiMove*); static void init_characterLengths (FOptiMove*);
void finish(); void finish();
static void putAreaLine (charData*, charData*, int); static void putAreaLine (charData*, charData*, int);
static void putAreaCharacter ( int, int, FVTerm* static void putAreaCharacter ( const FPoint&, FVTerm*
, charData*, charData* ); , charData*, charData* );
static void getAreaCharacter ( int, int, term_area* static void getAreaCharacter ( const FPoint&, term_area*
, charData*& ); , charData*& );
bool clearTerm (int = ' '); bool clearTerm (int = ' ');
bool clearFullArea (term_area*, charData&); bool clearFullArea (term_area*, charData&);
@ -477,7 +450,7 @@ class FVTerm
bool printWrap (term_area*); bool printWrap (term_area*);
void updateTerminalLine (uInt); void updateTerminalLine (uInt);
bool updateTerminalCursor(); bool updateTerminalCursor();
bool isInsideTerminal (int, int); bool isInsideTerminal (const FPoint&);
static void markAsPrinted (uInt, uInt); static void markAsPrinted (uInt, uInt);
static void markAsPrinted (uInt, uInt, uInt); static void markAsPrinted (uInt, uInt, uInt);
static void newFontChanges (charData*&); static void newFontChanges (charData*&);
@ -582,6 +555,20 @@ inline FVTerm& FVTerm::operator << \
return *this; return *this;
} }
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << (const FPoint& pos)
{
print (pos);
return *this;
}
//----------------------------------------------------------------------
inline FVTerm& FVTerm::operator << (const FColorPair& pair)
{
print (pair);
return *this;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const char* FVTerm::getClassName() const inline const char* FVTerm::getClassName() const
{ return "FVTerm"; } { return "FVTerm"; }
@ -648,10 +635,6 @@ inline void FVTerm::hideCursor()
inline void FVTerm::showCursor() inline void FVTerm::showCursor()
{ return hideCursor(false); } { return hideCursor(false); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintCursor (const FPoint& pos)
{ setPrintCursor (pos.getX(), pos.getY()); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setColor (FColor fg, FColor bg) inline void FVTerm::setColor (FColor fg, FColor bg)
{ {
@ -1063,6 +1046,10 @@ inline char* FVTerm::moveCursor (int xold, int yold, int xnew, int ynew)
inline void FVTerm::printMoveDurations() inline void FVTerm::printMoveDurations()
{ return FTerm::printMoveDurations(); } { return FTerm::printMoveDurations(); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline std::size_t FVTerm::getLineNumber() inline std::size_t FVTerm::getLineNumber()
{ return FTerm::getLineNumber(); } { return FTerm::getLineNumber(); }
@ -1143,10 +1130,6 @@ inline void FVTerm::changeTermSizeFinished()
inline void FVTerm::exitWithMessage (const FString& message) inline void FVTerm::exitWithMessage (const FString& message)
{ FTerm::exitWithMessage(message); } { FTerm::exitWithMessage(message); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; }
} // namespace finalcut } // namespace finalcut
#endif // FVTERM_H #endif // FVTERM_H

Some files were not shown because too many files have changed in this diff Show More