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>
* Improved PC encoding for Cygwin and Linux
* Integration of an output filter to replace missing characters
* Better Linux console support for UTF-8 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>
* Use the override specifier

View File

@ -4,6 +4,8 @@
### Building and code analysis
*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 />
*License:*<br />
&#160;&#160;&#160;&#160;&#160;[![license](https://img.shields.io/github/license/gansm/finalcut.svg?colorA=#333)](COPYING) <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 />
*Coverity Scan:*<br />

View File

@ -59,7 +59,7 @@ case "$1" in
;;
"--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
echo "${RED}Configure failed!${NORMAL}" 1>&2
exit -1

View File

@ -2,6 +2,22 @@
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
----------------------
@ -20,7 +36,9 @@ int main (int argc, char* argv[])
finalcut::FApplication app(argc, argv);
finalcut::FDialog dialog(&app);
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);
dialog.show();
return app.exec();
@ -69,7 +87,9 @@ dialog.setText ("A dialog");
The title bar of the dialog box gets the text "A dialog".
```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 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
FDialog* dialog = new FDialog(&app);
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
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");
// The object label is managed by dialog
@ -159,7 +179,7 @@ int main (int argc, char* argv[])
"adipiscing elit, sed do eiusmod tempor "
"incididunt ut labore et dolore magna aliqua."
, dialog );
label->setGeometry (2, 4, 36, 1);
label->setGeometry (FPoint(2, 4), FSize(36, 1));
app.setMainWidget(dialog);
dialog->show();
return app.exec();
@ -260,15 +280,15 @@ class dialogWidget : public FDialog
: FDialog(parent)
{
setText ("Dialog");
setGeometry (25, 5, 23, 4);
label.setGeometry (1, 1, 10, 1);
setGeometry (FPoint(25, 5), FSize(23, 4));
label.setGeometry (FPoint(1, 1), FSize(10, 1));
label.setAlignment (fc::alignRight);
value.setGeometry (11, 1, 10, 1);
value.setGeometry (FPoint(11, 1), FSize(10, 1));
id = addTimer(100);
}
private:
virtual void onTimer (FTimerEvent* ev)
virtual void onTimer (FTimerEvent* ev) override
{
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
the above program with gcc:
```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>
<dd>"clicked"<br />"toggled"</dd>
<dt>FWidget</dt>
<dd>"destroy"</dd>
</dl>
&nbsp;
@ -423,14 +446,14 @@ int main (int argc, char* argv[])
FApplication app(argc, argv);
FDialog dialog(&app);
dialog.setText ("A dialog with callback function");
dialog.setGeometry (25, 5, 45, 9);
dialog.setGeometry (FRect(25, 5, 45, 9));
FLabel label (&dialog);
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);
// Character follows '&' will be used as the accelerator key
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
button.addCallback
@ -472,8 +495,8 @@ class dialogWidget : public FDialog
: FDialog(parent)
{
setText ("Callback method");
setGeometry (25, 5, 25, 7);
button.setGeometry (7, 3, 10, 1);
setGeometry (FPoint(25, 5), FSize(25, 7));
button.setGeometry (FPoint(7, 3), FSize(10, 1));
// Connect the button signal "clicked" with the callback method
button.addCallback
@ -504,7 +527,7 @@ int main (int argc, char* argv[])
After entering the source code in *callback-method.cpp* you can compile
the above program with gcc:
```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;
@ -527,13 +550,14 @@ class dialogWidget : public FDialog
explicit dialogWidget (FWidget* parent = nullptr)
: FDialog(parent)
{
setGeometry (25, 5, 22, 7);
setGeometry (FPoint(25, 5), FSize(22, 7));
setText ("Emit signal");
label.setGeometry (8, 1, 5, 1);
FSize size(5, 1);
label.setGeometry (FPoint(8, 1), size);
label.setAlignment (fc::alignRight);
label.setForegroundColor (fc::Black);
plus.setGeometry (3, 3, 5, 1);
minus.setGeometry (13, 3, 5, 1);
plus.setGeometry (FPoint(3, 3), size);
minus.setGeometry (FPoint(13, 3), size);
plus.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
the above program with gcc:
```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 *
* *
* Copyright 2016-2018 Markus Gans *
* Copyright 2016-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 *
@ -30,6 +30,10 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
constexpr lDouble PI = 3.141592653589793238L;
@ -119,7 +123,6 @@ class Calc : public finalcut::FDialog
// Event handlers
virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onAccel (finalcut::FAccelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override;
// Callback method
@ -250,8 +253,7 @@ Calc::Calc (FWidget* parent)
clearInfixOperator();
std::setlocale(LC_NUMERIC, "C");
setText ("Calculator");
setGeometry (19, 6, 37, 18);
addAccelerator('q'); // Press 'q' to quit
setGeometry (FPoint(19, 6), FSize(37, 18));
for (std::size_t key = 0; key < Calc::NUM_OF_BUTTONS; key++)
{
@ -259,7 +261,7 @@ Calc::Calc (FWidget* parent)
button_no[key] = key;
if ( key == Equals )
btn->setGeometry(30, 15, 5, 3);
btn->setGeometry(FPoint(30, 15), FSize(5, 3));
else
{
int x, y;
@ -267,7 +269,7 @@ Calc::Calc (FWidget* parent)
( key <= Three ) ? n = 0 : n = 1;
x = int(key + n) % 5 * 7 + 2;
y = int(key + n) / 5 * 2 + 3;
btn->setGeometry(x, y, 5, 1);
btn->setGeometry(FPoint(x, y), FSize(5, 1));
}
btn->setFlat();
@ -332,15 +334,12 @@ void Calc::drawDispay()
if ( error )
display = " Error ";
setColor(finalcut::fc::Black, finalcut::fc::LightGray);
if ( isMonochron() )
setReverse(false);
setPrintPos (3, 3);
print(display);
print(L' ');
setColor(wc.dialog_fg, wc.dialog_bg);
print() << FColorPair(finalcut::fc::Black, finalcut::fc::LightGray)
<< FPoint(3, 3) << display << ' '
<< FColorPair(wc.dialog_fg, wc.dialog_bg);
if ( isMonochron() )
setReverse(true);
@ -352,13 +351,10 @@ void Calc::drawDispay()
wchar_t top_line = finalcut::fc::NF_border_line_upper;
wchar_t right_line = finalcut::fc::NF_rev_border_line_right;
wchar_t left_line = finalcut::fc::NF_border_line_left;
setPrintPos (3, 2);
print (finalcut::FString(33, bottom_line));
setPrintPos (2, 3);
print (right_line);
setPrintPos (36, 3);
print (left_line);
setPrintPos (3, 4);
print() << FPoint(3, 2) << finalcut::FString(33, bottom_line);
print() << FPoint(2, 3) << right_line;
print() << FPoint(36, 3) << left_line;
print() << FPoint(3, 4);
finalcut::FString top_bottom_line_5 (5, top_bottom_line);
finalcut::FString top_line_2 (2, top_line);
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(35, horizontal)
+ finalcut::FString(vertical_and_left);
setPrintPos (1, 4);
print(separator);
print() << FPoint(1, 4) << separator;
}
}
@ -1034,19 +1029,17 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
ev->accept();
break;
case 'q':
close();
ev->accept();
break;
default:
finalcut::FDialog::onKeyPress(ev);
break;
}
}
//----------------------------------------------------------------------
void Calc::onAccel (finalcut::FAccelEvent* ev)
{
close();
ev->accept();
}
//----------------------------------------------------------------------
void Calc::onClose (finalcut::FCloseEvent* ev)
{
@ -1088,8 +1081,8 @@ void Calc::cb_buttonClicked (finalcut::FWidget*, FDataPtr data)
//----------------------------------------------------------------------
void Calc::adjustSize()
{
std::size_t pw = getParentWidget()->getWidth();
std::size_t ph = getParentWidget()->getHeight();
std::size_t pw = getDesktopWidth();
std::size_t ph = getDesktopHeight();
setX (1 + int(pw - getWidth()) / 2, false);
setY (1 + int(ph - getHeight()) / 2, false);
finalcut::FDialog::adjustSize();

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -27,6 +27,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class CheckList
@ -73,9 +76,10 @@ CheckList::CheckList (finalcut::FWidget* parent)
{
setText (L"Shopping list");
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.setGeometry (1, 2, getWidth(), getHeight() - 1);
listView.setGeometry (FPoint(1, 2), FSize(getWidth(), getHeight() - 1));
// Add columns to the view
listView.addColumn ("Item");
@ -111,7 +115,7 @@ CheckList::~CheckList() // destructor
//----------------------------------------------------------------------
void CheckList::populate()
{
std::string list[][2] =
const std::string list[][2] =
{
{ "Milk", "Highest" },
{ "Cheese", "High" },

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector>
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// Typedef
typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr;
@ -106,11 +109,11 @@ int main (int argc, char* argv[])
std::size_t h = 13;
int x = int(app.getDesktopWidth() - w) / 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
finalcut::FButtonGroup checkButtonGroup("choice", &dgl);
checkButtonGroup.setGeometry (2, 1, 16, 7);
checkButtonGroup.setGeometry (FPoint(2, 1), FSize(16, 7));
// Create radio buttons
std::vector<FRadioButtonPtr> os(9);
@ -120,7 +123,7 @@ int main (int argc, char* argv[])
// => checkButtonGroup.setScrollSize(...) is not required
// because a FButtonGroup is self-adjusting
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);
@ -130,7 +133,7 @@ int main (int argc, char* argv[])
// Create a OK button
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
ok.addCallback

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototype
void cb_quit (finalcut::FWidget*, FDataPtr);
@ -47,7 +50,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box
finalcut::FDialog dgl(&app);
dgl.setText ("FDialog");
dgl.setGeometry (4, 3, 41, 11);
dgl.setGeometry (FPoint(4, 3), FSize(41, 11));
// Create text labels
finalcut::FLabel label_1(&dgl);
@ -62,12 +65,12 @@ int main (int argc, char* argv[])
<< "or push the button below to exit\n"
<< "the program.";
label_1.setGeometry (1, 1, 38, 2);
label_2.setGeometry (5, 3, 34, 3);
label_1.setGeometry (FPoint(1, 1), FSize(38, 2));
label_2.setGeometry (FPoint(5, 3), FSize(34, 3));
// Create the quit button
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
btn.addCallback

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -22,11 +22,14 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
// function prototypes
void cb_quit (finalcut::FWidget*, FDataPtr);
void cb_publish (finalcut::FWidget*, FDataPtr);
//----------------------------------------------------------------------
// callback functions
//----------------------------------------------------------------------
@ -48,6 +51,7 @@ void cb_publish (finalcut::FWidget* widget, FDataPtr data)
cbox2->unsetChecked();
cbox2->setDisable();
}
cbox2->redraw();
}
@ -62,7 +66,7 @@ int main (int argc, char* argv[])
// Create a simple dialog box
finalcut::FDialog dgl(&app);
dgl.setText ("Data input");
dgl.setGeometry (4, 2, 37, 22);
dgl.setGeometry (FPoint(4, 2), FSize(37, 22));
dgl.setShadow();
// Create input fields
@ -80,37 +84,37 @@ int main (int argc, char* argv[])
st_field.setLabelText (L"&State");
c_field.setLabelText (L"&Country");
name_field.setGeometry (15, 1, 19, 1);
email_field.setGeometry (15, 3, 19, 1);
org_field.setGeometry (15, 5, 19, 1);
city_field.setGeometry (15, 7, 19, 1);
st_field.setGeometry (15, 9, 19, 1);
c_field.setGeometry (15, 11, 4, 1);
name_field.setGeometry (FPoint(15, 1), FSize(19, 1));
email_field.setGeometry (FPoint(15, 3), FSize(19, 1));
org_field.setGeometry (FPoint(15, 5), FSize(19, 1));
city_field.setGeometry (FPoint(15, 7), FSize(19, 1));
st_field.setGeometry (FPoint(15, 9), FSize(19, 1));
c_field.setGeometry (FPoint(15, 11), FSize(4, 1));
// Create the button group
finalcut::FButtonGroup radioButtonGroup ("Sex", &dgl);
radioButtonGroup.setGeometry(2, 13, 13, 4);
radioButtonGroup.setGeometry(FPoint(2, 13), FSize(13, 4));
// Create radio buttons
finalcut::FRadioButton male ("&Male", &radioButtonGroup);
finalcut::FRadioButton female ("&Female", &radioButtonGroup);
male.setGeometry (1, 1, 8, 1);
female.setGeometry (1, 2, 10, 1);
male.setGeometry (FPoint(1, 1), FSize(8, 1));
female.setGeometry (FPoint(1, 2), FSize(10, 1));
// Create another button group
finalcut::FButtonGroup checkButtonGroup ("&Data options", &dgl);
checkButtonGroup.setGeometry(16, 13, 19, 4);
checkButtonGroup.setGeometry(FPoint(16, 13), FSize(19, 4));
// Create checkbox buttons
finalcut::FCheckBox check1 ("Save data", &checkButtonGroup);
finalcut::FCheckBox check2 ("Encrypt data", &checkButtonGroup);
check1.setGeometry (1, 1, 13, 1);
check2.setGeometry (1, 2, 16, 1);
check1.setGeometry (FPoint(1, 1), FSize(13, 1));
check2.setGeometry (FPoint(1, 2), FSize(16, 1));
check2.setDisable();
// Create a OK button
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
check1.addCallback

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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 )
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()
{
setPrintPos (1, 1);
print() << "---------------\n"
print() << finalcut::FPoint(1, 1)
<< "---------------\n"
<< "Press Q to quit\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 *
* *
* Copyright 2017-2018 Markus Gans *
* Copyright 2017-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 *
@ -28,6 +28,8 @@
#include <final/final.h>
using namespace finalcut;
using finalcut::FPoint;
using finalcut::FSize;
// Global application object
static std::weak_ptr<FString> temp_str;
@ -113,7 +115,7 @@ Listbox::Listbox (FWidget* parent)
// listbox 1
//----------
list1.setGeometry(2, 1, 18, 10);
list1.setGeometry(FPoint(2, 1), FSize(18, 10));
list1.setText ("FListBoxItem");
for (int i = 1; i < 30; i++)
@ -124,7 +126,7 @@ Listbox::Listbox (FWidget* parent)
for (double i = 1; i<=15; i++)
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");
//
@ -147,11 +149,11 @@ Listbox::Listbox (FWidget* parent)
TLD["gov"] = "Government";
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");
// Quit button
Quit.setGeometry(42, 12, 10, 1);
Quit.setGeometry(FPoint(42, 12), FSize(10, 1));
Quit.setText (L"&Quit");
// Add quit button function callback
@ -185,7 +187,8 @@ int main (int argc, char* argv[])
// Create main dialog object
Listbox d(&app);
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();
// Set dialog d as main widget

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -27,6 +27,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Listview
@ -71,7 +74,7 @@ Listview::Listview (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
{
// Set FListView geometry
listView.setGeometry(2, 1, 33, 14);
listView.setGeometry(FPoint(2, 1), FSize(33, 14));
// Add columns to the view
listView.addColumn ("City");
@ -104,7 +107,7 @@ Listview::Listview (finalcut::FWidget* parent)
populate();
// Quit button
Quit.setGeometry(24, 16, 10, 1);
Quit.setGeometry(FPoint(24, 16), FSize(10, 1));
Quit.setText (L"&Quit");
// Add some function callbacks
@ -128,7 +131,7 @@ Listview::~Listview() // destructor
//----------------------------------------------------------------------
void Listview::populate()
{
std::string weather[][5] =
const std::string weather[][5] =
{
{ "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" },
{ "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" },
@ -214,7 +217,8 @@ int main (int argc, char* argv[])
// Create main dialog object
Listview d(&app);
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();
// Set dialog d as main widget

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -22,6 +22,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Menu
@ -140,19 +143,19 @@ Menu::Menu (finalcut::FWidget* parent)
// Headline labels
Headline1 << " Key ";
Headline1.ignorePadding();
Headline1.setGeometry(3, 2, 5, 1);
Headline1.setGeometry(FPoint(3, 2), FSize(5, 1));
Headline1.setEmphasis();
Headline2 << " Function ";
Headline2.ignorePadding();
Headline2.setGeometry(19, 2, 10, 1);
Headline2.setGeometry(FPoint(19, 2), FSize(10, 1));
Headline2.setEmphasis();
// Info label
Info << "<F10> Activate menu bar\n"
<< "<Ctrl>+<Space> Activate menu bar\n"
<< "<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()
{
int pw = int(getParentWidget()->getWidth());
int ph = int(getParentWidget()->getHeight());
int pw = int(getDesktopWidth());
int ph = int(getDesktopHeight());
setX (1 + (pw - int(getWidth())) / 2, false);
setY (1 + (ph - int(getHeight())) / 4, false);
finalcut::FDialog::adjustSize();
@ -325,7 +328,8 @@ int main (int argc, char* argv[])
// Create main dialog object
Menu main_dlg (&app);
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();
// Set dialog main_dlg as main widget

View File

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

View File

@ -22,6 +22,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Scrollview
@ -46,7 +49,7 @@ class Scrollview : public finalcut::FScrollView
Scrollview& operator = (const Scrollview&) = delete;
// Mutator
void setScrollSize (std::size_t, std::size_t) override;
void setScrollSize (const FSize&) override;
private:
// Method
@ -75,11 +78,14 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
: finalcut::FScrollView(parent)
{
// Sets the navigation button geometry
go_east.setGeometry (1, 1, 5, 1);
go_south.setGeometry (int(getScrollWidth()) - 5, 1, 5, 1);
go_west.setGeometry ( int(getScrollWidth()) - 5
, int(getScrollHeight()) - 2, 5, 1);
go_north.setGeometry (1, int(getScrollHeight()) - 2, 5, 1);
go_east.setGeometry (FPoint(1, 1), FSize(5, 1));
go_south.setGeometry ( FPoint(int(getScrollWidth()) - 5, 1)
, FSize(5, 1) );
go_west.setGeometry ( FPoint( int(getScrollWidth()) - 5
, int(getScrollHeight()) - 2 )
, FSize(5, 1) );
go_north.setGeometry ( FPoint(1, int(getScrollHeight()) - 2)
, FSize(5, 1) );
// Add scroll function callbacks to the buttons
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);
go_south.setPos (int(width) - 5, 1);
go_west.setPos (int(width) - 5, int(height) - 1);
go_north.setPos (1, int(height) - 1);
FScrollView::setScrollSize (size);
auto width = int(size.getWidth());
auto height = int(size.getHeight());
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++)
{
setPrintPos (1, 1 + y);
print() << FPoint(1, 1 + y);
for (int x = 0; x < int(getScrollWidth()); x++)
print (32 + ((x + y) % 0x5f));
@ -214,15 +222,15 @@ class Scrollviewdemo : public finalcut::FDialog
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
: finalcut::FDialog(parent)
{
setGeometry (16, 3, 50, 19);
setGeometry (FPoint(16, 3), FSize(50, 19));
setText ("Scrolling viewport example");
// The scrolling viewport widget
sview.setGeometry(3, 2, 44, 12);
sview.setScrollSize(188, 124);
sview.setGeometry(FPoint(3, 2), FSize(44, 12));
sview.setScrollSize(FSize(188, 124));
// Quit button
quit_btn.setGeometry(37, 15, 10, 1);
quit_btn.setGeometry(FPoint(37, 15), FSize(10, 1));
// Add function callback
quit_btn.addCallback
@ -232,7 +240,7 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
);
// Text label
label.setGeometry(2, 1, 46, 1);
label.setGeometry(FPoint(2, 1), FSize(46, 1));
label.setEmphasis();
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 *
* *
* Copyright 2015-2018 Markus Gans *
* Copyright 2015-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 *
@ -23,6 +23,10 @@
#include <functional>
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
using finalcut::FColorPair;
//----------------------------------------------------------------------
// class AttribDlg
@ -47,7 +51,7 @@ class AttribDlg : public finalcut::FDialog
AttribDlg& operator = (const AttribDlg&) = delete;
// Event handlers
virtual void onAccel (finalcut::FAccelEvent*) override;
virtual void onKeyPress (finalcut::FKeyEvent*) override;
virtual void onWheel (finalcut::FWheelEvent*) override;
virtual void onClose (finalcut::FCloseEvent*) override;
@ -77,10 +81,12 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
+ finalcut::FString(getTermType())
+ ")");
next_button.setGeometry(int(getWidth()) - 13, int(getHeight()) - 4, 10, 1);
next_button.addAccelerator(finalcut::fc::Fkey_right);
back_button.setGeometry(int(getWidth()) - 25, int(getHeight()) - 4, 10, 1);
back_button.addAccelerator(finalcut::fc::Fkey_left);
next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
, FSize(10, 1) );
next_button.addAccelerator (finalcut::fc::Fkey_right);
back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, FSize(10, 1) );
back_button.addAccelerator (finalcut::fc::Fkey_left);
// Add function callbacks
next_button.addCallback
@ -101,10 +107,18 @@ AttribDlg::~AttribDlg()
{ }
//----------------------------------------------------------------------
void AttribDlg::onAccel (finalcut::FAccelEvent* ev)
void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
{
close();
ev->accept();
if ( ! ev )
return;
if ( ev->key() == 'q' )
{
close();
ev->accept();
}
else
finalcut::FDialog::onKeyPress(ev);
}
//----------------------------------------------------------------------
@ -159,8 +173,8 @@ void AttribDlg::cb_back (finalcut::FWidget*, FDataPtr)
//----------------------------------------------------------------------
void AttribDlg::adjustSize()
{
int x = int((getParentWidget()->getWidth() - getWidth()) / 2);
int y = int((getParentWidget()->getHeight() - getHeight()) / 2) + 1;
int x = int((getDesktopWidth() - getWidth()) / 2);
int y = int((getDesktopHeight() - getHeight()) / 2) + 1;
if ( x < 1 )
x = 1;
@ -168,11 +182,11 @@ void AttribDlg::adjustSize()
if ( y < 1 )
y = 1;
setGeometry(x, y, 69, 21, false);
next_button.setGeometry ( int(getWidth()) - 13, int(getHeight()) - 4
, 10, 1, false );
back_button.setGeometry ( int(getWidth()) - 25, int(getHeight()) - 4
, 10, 1, false );
setGeometry(FPoint(x, y), FSize(69, 21), false);
next_button.setGeometry ( FPoint(int(getWidth()) - 13, int(getHeight()) - 4)
, FSize(10, 1), false );
back_button.setGeometry ( FPoint(int(getWidth()) - 25, int(getHeight()) - 4)
, FSize(10, 1), false );
finalcut::FDialog::adjustSize();
}
@ -247,8 +261,7 @@ void AttribDemo::printColorLine()
for (FColor color = 0; color < colors; color++)
{
setColor (color, parent->bgcolor);
print (" # ");
print() << FColorPair(color, parent->bgcolor) << " # ";
}
}
@ -260,8 +273,7 @@ void AttribDemo::printAltCharset()
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
setPrintPos (1, 1);
print("alternate charset: ");
print() << FPoint(1, 1) << "alternate charset: ";
if ( parent->bgcolor == finalcut::fc::Default )
{
@ -427,7 +439,7 @@ void AttribDemo::draw()
for (std::size_t y = 0; y < getParentWidget()->getHeight() - 7; y++)
{
setPrintPos (1, 2 + int(y));
print() << FPoint(1, 2 + int(y));
if ( ! isMonochron() )
setColor (wc.label_fg, wc.label_bg);
@ -439,7 +451,7 @@ void AttribDemo::draw()
if ( ! isMonochron() )
setColor(wc.label_fg, wc.label_bg);
setPrintPos (1, 15);
print() << FPoint(1, 15);
FColor bg = static_cast<AttribDlg*>(getParent())->bgcolor;
print (" Background color:");
@ -448,8 +460,7 @@ void AttribDemo::draw()
else
printf ( " %d", bg);
setPrintPos (16, 17);
print ("Change background color ->");
print() << FPoint(16, 17) << "Change background color ->";
}
@ -466,13 +477,12 @@ int main (int argc, char* argv[])
// the parent object "app" (FObject destructor).
AttribDlg dialog(&app);
dialog.setGeometry (6, 2, 69, 21);
dialog.addAccelerator('q'); // press 'q' to quit
dialog.setGeometry (FPoint(6, 2), FSize(69, 21));
dialog.setShadow();
// Create the attribute demo widget as a child object from the 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
app.setMainWidget(&dialog);

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -59,11 +59,11 @@ Timer::Timer (finalcut::FWidget* parent)
//----------------------------------------------------------------------
void Timer::draw()
{
setPrintPos (1, 1);
print() << "---------------\n"
print() << finalcut::FPoint(1, 1)
<< "---------------\n"
<< "Press Q to quit\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()) )
is_last_line = true;
setColor (FColor(1 + timer_id), finalcut::fc::Default);
print() << "Timer event, id " << timer_id << '\n';
print() << finalcut::FColorPair (FColor(1 + timer_id))
<< "Timer event, id " << timer_id << '\n';
if ( is_last_line )
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 *
* *
* Copyright 2016-2018 Markus Gans *
* Copyright 2016-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 *
@ -22,6 +22,9 @@
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class Transparent
@ -108,8 +111,7 @@ void Transparent::draw()
for (int n = 1; n <= int(getClientHeight()); n++)
{
setPrintPos (2, 2 + n);
print(line);
print() << FPoint(2, 2 + n) << line;
}
if ( type == shadow )
@ -131,10 +133,8 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
if ( ev->key() == 'q' && getParentWidget() )
{
if ( getParentWidget()->close() )
ev->accept();
else
ev->ignore();
getParentWidget()->close();
ev->accept();
}
else
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.
transpwin = new Transparent(this);
transpwin->setText("transparent");
transpwin->setGeometry (6, 3, 29, 12);
transpwin->setGeometry (FPoint(6, 3), FSize(29, 12));
transpwin->unsetTransparentShadow();
shadowwin = new Transparent(this, Transparent::shadow);
shadowwin->setText("shadow");
shadowwin->setGeometry (46, 11, 29, 12);
shadowwin->setGeometry (FPoint(46, 11), FSize(29, 12));
shadowwin->unsetTransparentShadow();
ibg = new Transparent(this, Transparent::inherit_background);
ibg->setText("inherit background");
ibg->setGeometry (42, 3, 29, 7);
ibg->setGeometry (FPoint(42, 3), FSize(29, 7));
ibg->unsetTransparentShadow();
// Statusbar at the bottom
status_bar.setMessage("Press Q to quit");
addAccelerator('q');
unsetTransparentShadow();
activateDialog();
}
@ -242,10 +241,8 @@ void MainWindow::draw()
setReverse(true);
setColor();
setPrintPos (2, 4);
print(line1);
setPrintPos (2, 5);
print(line2);
print() << FPoint(2, 4) << line1;
print() << FPoint(2, 5) << line2;
if ( isMonochron() )
setReverse(false);
@ -290,7 +287,7 @@ int main (int argc, char* argv[])
// Create main dialog object
MainWindow main_dlg (&app);
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
app.setMainWidget (&main_dlg);

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -23,6 +23,9 @@
#include <vector>
#include <final/final.h>
using finalcut::FPoint;
using finalcut::FSize;
//----------------------------------------------------------------------
// class SmallWindow
@ -75,24 +78,24 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
left_arrow.setForegroundColor (wc.label_inactive_fg);
left_arrow.setEmphasis();
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.setForegroundColor (wc.label_inactive_fg);
right_arrow.setEmphasis();
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.setForegroundColor (wc.label_inactive_fg);
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.setAlignment (finalcut::fc::alignRight);
top_right_label.setForegroundColor (wc.label_inactive_fg);
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"
"corner\n";
@ -101,7 +104,7 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
bottom_label.setAlignment (finalcut::fc::alignRight);
bottom_label.setForegroundColor (wc.label_inactive_fg);
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();
right_arrow.setGeometry (int(getWidth()) - 1, 2, 1, 1);
top_right_label.setGeometry (int(getClientWidth()) - 5, 1, 6, 1);
bottom_label.setGeometry (1, int(getClientHeight()) - 2, getClientWidth(), 3);
right_arrow.setGeometry ( FPoint(int(getWidth()) - 1, 2)
, FSize(1, 1) );
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()
{
// Dialog buttons
CreateButton.setGeometry (2, 2, 9, 1);
CreateButton.setGeometry (FPoint(2, 2), FSize(9, 1));
CreateButton.setText (L"&Create");
CloseButton.setGeometry (15, 2, 9, 1);
CloseButton.setGeometry (FPoint(15, 2), FSize(9, 1));
CloseButton.setText (L"C&lose");
QuitButton.setGeometry (28, 2, 9, 1);
QuitButton.setGeometry (FPoint(28, 2), FSize(9, 1));
QuitButton.setText (L"&Quit");
// Add button callback
@ -340,8 +346,8 @@ void Window::activateWindow (finalcut::FDialog* win)
//----------------------------------------------------------------------
void Window::adjustSize()
{
std::size_t w = getRootWidget()->getWidth();
std::size_t h = getRootWidget()->getHeight();
std::size_t w = getDesktopWidth();
std::size_t h = getDesktopHeight();
int X = int(1 + (w - 40) / 2)
, Y = int(1 + (h - 22) / 2)
, dx = ( w > 80 ) ? int(w - 80) / 2 : 0
@ -350,7 +356,7 @@ void Window::adjustSize()
if ( Y < 2 )
Y = 2;
setPos (X, Y);
setPos (FPoint(X, Y));
auto first = windows.begin();
auto iter = first;
@ -361,7 +367,7 @@ void Window::adjustSize()
int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3;
(*iter)->dgl->setPos (x, y);
(*iter)->dgl->setPos (FPoint(x, y));
}
++iter;
@ -426,8 +432,8 @@ void Window::cb_createWindows (finalcut::FWidget*, FDataPtr)
int n = int(std::distance(first, iter))
, x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3
, y = dy + 11 + int(n / 3) * 3;
win->setGeometry (x, y, 20, 8);
win->setMinimumSize (20, 8);
win->setGeometry (FPoint(x, y), FSize(20, 8));
win->setMinimumSize (FSize(20, 8));
win->setResizeable();
win->show();
@ -563,7 +569,8 @@ int main (int argc, char* argv[])
// Create main dialog object
Window main_dlg (&app);
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
app.setMainWidget (&main_dlg);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -72,7 +72,7 @@ void FCheckBox::drawCheckButton()
if ( ! isVisible() )
return;
setPrintPos (1, 1);
print() << FPoint(1, 1);
setColor();
if ( isMonochron() )

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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;
}
//----------------------------------------------------------------------
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
@ -225,32 +259,7 @@ const FString FFileDialog::fileOpenChooser ( FWidget* parent
, const FString& dirname
, const FString& filter )
{
FString ret;
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;
return fileChooser (parent, dirname, filter, FFileDialog::Open);
}
//----------------------------------------------------------------------
@ -258,32 +267,7 @@ const FString FFileDialog::fileSaveChooser ( FWidget* parent
, const FString& dirname
, const FString& filter )
{
FString ret;
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;
return fileChooser (parent, dirname, filter, FFileDialog::Save);
}
@ -320,7 +304,7 @@ void FFileDialog::adjustSize()
setHeight (h, false);
X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false);
setPos(FPoint(X, Y), false);
filebrowser.setHeight (h - 8, false);
hidden.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;
int x, y;
setGeometry(1, 1, w, h, false);
setGeometry(FPoint(1, 1), FSize(w, h), false);
auto parent_widget = getParentWidget();
if ( parent_widget )
@ -354,36 +338,36 @@ void FFileDialog::init()
else
FDialog::setText("Open file");
widgetSettings (x, y); // Create widgets
widgetSettings (FPoint(x, y)); // Create widgets
initCallbacks();
setModal();
readDir();
}
//----------------------------------------------------------------------
inline void FFileDialog::widgetSettings (int x, int y)
inline void FFileDialog::widgetSettings (const FPoint& pos)
{
filename.setLabelText ("File&name");
filename.setText (filter_pattern);
filename.setGeometry (11, 1, 28, 1);
filename.setGeometry (FPoint(11, 1), FSize(28, 1));
filename.setFocus();
filebrowser.setGeometry (2, 3, 38, 6);
filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6));
printPath (directory);
hidden.setText ("&hidden files");
hidden.setGeometry (2, 10, 16, 1);
hidden.setGeometry (FPoint(2, 10), FSize(16, 1));
cancel.setText ("&Cancel");
cancel.setGeometry(19, 10, 9, 1);
cancel.setGeometry(FPoint(19, 10), FSize(9, 1));
if ( dlg_type == FFileDialog::Save )
open.setText ("&Save");
else
open.setText ("&Open");
open.setGeometry(30, 10, 9, 1);
setGeometry (x, y, getWidth(), getHeight());
open.setGeometry(FPoint(30, 10), FSize(9, 1));
setGeometry (pos, getSize());
}
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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()
{
FColor fg, bg;
std::size_t size;
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);
size = getWidth();
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
destroyBlankArray (blank);
hideSize (getSize());
}
//----------------------------------------------------------------------
@ -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[]
, wchar_t dest[]
@ -422,19 +373,19 @@ std::size_t FLabel::getHotkeyPos ( wchar_t src[]
//----------------------------------------------------------------------
void FLabel::setHotkeyAccelerator()
{
uChar hotkey = getHotkey();
FKey hotkey = getHotkey(text);
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::toupper(hotkey)));
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey)));
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (getHotkey());
addAccelerator (hotkey);
}
else
delAccelerator();
@ -529,7 +480,7 @@ void FLabel::drawMultiLine()
else
std::wcsncpy(dest, src, length);
setPrintPos (1, 1 + int(y));
print() << FPoint(1, 1 + int(y));
if ( hotkeypos != NOT_SET )
{
@ -571,7 +522,7 @@ void FLabel::drawSingleLine()
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (1, 1);
print() << FPoint(1, 1);
align_offset = getAlignOffset(length);
printLine (label_text, length, hotkeypos, align_offset);
delete[] label_text;
@ -632,8 +583,7 @@ void FLabel::printLine ( wchar_t line[]
if ( length > width )
{
// Print ellipsis
setColor (ellipsis_color, getBackgroundColor());
print ("..");
print() << FColorPair(ellipsis_color, getBackgroundColor()) << "..";
setColor();
}
else if ( align_offset + to_char < width )

View File

@ -230,12 +230,12 @@ bool FLineEdit::setShadow (bool enable)
&& getEncoding() != fc::ASCII )
{
flags.shadow = true;
setShadowSize(1, 1);
setShadowSize(FSize(1, 1));
}
else
{
flags.shadow = false;
setShadowSize(0, 0);
setShadowSize(FSize(0, 0));
}
return flags.shadow;
@ -271,42 +271,12 @@ void FLineEdit::setLabelOrientation(const label_o o)
//----------------------------------------------------------------------
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 )
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 )
{
case label_above:
label->setGeometry(getX(), getY() - 1, label_length, 1);
label->setGeometry ( FPoint(getX(), getY() - 1)
, FSize(label_length, 1) );
break;
case label_left:
label->setGeometry(getX() - int(label_length) - 1, getY()
, label_length, 1);
label->setGeometry ( FPoint(getX() - int(label_length) - 1, getY())
, FSize(label_length, 1) );
break;
}
}
@ -707,7 +678,7 @@ void FLineEdit::drawInputField()
std::size_t x;
FString show_text;
bool isActiveFocus = flags.active && flags.focus;
setPrintPos (1, 1);
print() << FPoint(1, 1);
if ( isMonochron() )
{
@ -754,7 +725,7 @@ void FLineEdit::drawInputField()
drawShadow ();
// 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 *
* *
* Copyright 2014-2018 Markus Gans *
* 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 *
@ -118,9 +118,7 @@ void FListBox::setCurrentItem (std::size_t index)
yoffset = 0;
adjustSize();
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->setValue (xoffset);
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( ! hbar->isShown() )
hbar->show();
}
}
}
//----------------------------------------------------------------------
void FListBox::setGeometry ( int x, int y
, std::size_t w, std::size_t h
, bool adjust )
void FListBox::setGeometry ( const FPoint& pos, const FSize& size
, bool adjust)
{
// Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust);
FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() )
{
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2);
hbar->setGeometry (1, int(getHeight()), getWidth() - 2 - nf_offset, 1);
vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2 - nf_offset, 1));
}
else
{
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2);
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1);
vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
hbar->setGeometry (FPoint(2, int(getHeight())), FSize(getWidth() - 2, 1));
}
}
@ -216,38 +213,8 @@ void FListBox::setText (const FString& txt)
//----------------------------------------------------------------------
void FListBox::hide()
{
std::size_t n, 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);
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);
hideSize (getSize());
}
//----------------------------------------------------------------------
@ -289,7 +256,7 @@ void FListBox::remove (std::size_t item)
hbar->setMaximum (hmax);
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();
int vmax = ( element_count > getHeight() - 2 )
@ -298,7 +265,7 @@ void FListBox::remove (std::size_t item)
vbar->setMaximum (vmax);
vbar->setPageSize (int(element_count), int(getHeight()) - 2);
if ( vbar->isVisible() && element_count < getHeight() - 1 )
if ( vbar->isShown() && isVerticallyScrollable() )
vbar->hide();
if ( current >= item && current > 1 )
@ -348,8 +315,7 @@ void FListBox::clear()
for (int y = 0; y < int(getHeight()) - 2; y++)
{
setPrintPos (2, 2 + y);
print (blank);
print() << FPoint(2, 2 + y) << blank;
}
destroyBlankArray (blank);
@ -490,12 +456,12 @@ void FListBox::onMouseDown (FMouseEvent* ev)
if ( ev->getButton() == fc::RightButton )
multiSelection(current);
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -558,12 +524,12 @@ void FListBox::onMouseMove (FMouseEvent* ev)
multiSelectionUpTo(current);
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -637,12 +603,12 @@ void FListBox::onTimer (FTimerEvent*)
multiSelectionUpTo(current);
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -685,12 +651,12 @@ void FListBox::onWheel (FWheelEvent* ev)
processSelect();
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -770,15 +736,15 @@ void FListBox::adjustSize()
hbar->setWidth (width + nf_offset, false);
hbar->resize();
if ( element_count <= height )
vbar->hide();
if ( isHorizontallyScrollable() )
hbar->show();
else
vbar->setVisible();
if ( max_line_width < width - 1 )
hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else
hbar->setVisible();
vbar->hide();
}
@ -792,20 +758,26 @@ inline FString& FListBox::getString (listBoxItems::iterator iter)
//----------------------------------------------------------------------
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);
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
{
vbar = std::make_shared<FScrollbar>(fc::vertical, 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();
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
@ -813,25 +785,15 @@ void FListBox::init()
return;
}
setGeometry (1, 1, 5, 4, false); // initialize geometry values
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
vbar->addCallback
bar->addCallback
(
"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
drawBorder();
if ( isNewFont() && ! vbar->isVisible() )
if ( isNewFont() && ! vbar->isShown() )
{
setColor();
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (int(getWidth()), y);
print (' '); // clear right side of the scrollbar
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
}
}
@ -866,12 +828,8 @@ void FListBox::draw()
if ( isMonochron() )
setReverse(false);
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
drawList();
if ( flags.focus && getStatusBar() )
@ -895,7 +853,7 @@ void FListBox::drawHeadline()
FString txt = " " + text + " ";
std::size_t length = txt.getLength();
setPrintPos (2, 1);
print() << FPoint(2, 1);
if ( isEnabled() )
setColor(wc.label_emphasis_fg, wc.label_bg);
@ -907,9 +865,8 @@ void FListBox::drawHeadline()
else
{
// Print ellipsis
print (text.left(uInt(getClientWidth() - 2)));
setColor (wc.label_ellipsis_fg, wc.label_bg);
print("..");
print() << text.left(uInt(getClientWidth() - 2))
<< FColorPair (wc.label_ellipsis_fg, wc.label_bg) << "..";
}
}
@ -1101,7 +1058,7 @@ inline void FListBox::setLineAttributes ( int y
{
bool isCurrentLine = bool(y + yoffset + 1 == int(current));
std::size_t inc_len = inc_search.getLength();
setPrintPos (2, 2 + int(y));
print() << FPoint(2, 2 + int(y));
if ( isLineSelected )
{
@ -1134,7 +1091,7 @@ inline void FListBox::setLineAttributes ( int y
setColor ( wc.selected_current_element_fg
, wc.selected_current_element_bg );
setCursorPos (3, 2 + int(y)); // first character
setCursorPos (FPoint(3, 2 + int(y))); // first character
}
else
{
@ -1151,10 +1108,10 @@ inline void FListBox::setLineAttributes ( int y
{
serach_mark = true;
// 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
setCursorPos (3 + b, 2 + int(y)); // first character
setCursorPos (FPoint(3 + b, 2 + int(y))); // first character
}
else
setColor ( wc.current_element_fg
@ -1185,17 +1142,17 @@ inline void FListBox::unsetAttributes()
//----------------------------------------------------------------------
inline void FListBox::updateDrawing (bool draw_vbar, bool draw_hbar)
{
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (yoffset);
if ( vbar->isVisible() && draw_vbar )
if ( draw_vbar )
vbar->drawBar();
hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar )
if ( draw_hbar )
hbar->drawBar();
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->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( isHorizontallyScrollable() )
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->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
vbar->setVisible();
if ( isVerticallyScrollable() )
vbar->show();
else
vbar->hide();
}
//----------------------------------------------------------------------
@ -1823,7 +1784,7 @@ void FListBox::lazyConvert(listBoxItems::iterator iter, int y)
std::size_t len = iter->text.getLength();
recalculateHorizontalBar (len, hasBrackets(iter));
if ( hbar->isVisible() )
if ( hbar->isShown() )
hbar->redraw();
}
@ -1878,7 +1839,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
processSelect();
}
if ( isVisible() )
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
@ -1886,7 +1847,7 @@ void FListBox::cb_VBarChange (FWidget*, FDataPtr)
{
vbar->setValue (yoffset);
if ( vbar->isVisible() && yoffset_before != yoffset )
if ( yoffset_before != yoffset )
vbar->drawBar();
updateTerminal();
@ -1939,7 +1900,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
if ( xoffset_before != xoffset )
inc_search.clear();
if ( isVisible() )
if ( isShown() )
{
drawList();
updateTerminal();
@ -1951,7 +1912,7 @@ void FListBox::cb_HBarChange (FWidget*, FDataPtr)
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
if ( xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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
, std::size_t w, std::size_t h
, bool adjust )
void FListView::setGeometry ( const FPoint& pos, const FSize& size
, bool adjust)
{
// Set the widget geometry
FWidget::setGeometry(x, y, w, h, adjust);
FWidget::setGeometry(pos, size, adjust);
if ( isNewFont() )
{
vbar->setGeometry (int(getWidth()), 2, 2, getHeight() - 2);
hbar->setGeometry (1, int(getHeight()), getWidth() - 2, 1);
vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(2, getHeight() - 2));
hbar->setGeometry (FPoint(1, int(getHeight())), FSize(getWidth() - 2, 1));
}
else
{
vbar->setGeometry (int(getWidth()), 2, 1, getHeight() - 2);
hbar->setGeometry (2, int(getHeight()), getWidth() - 2, 1);
vbar->setGeometry (FPoint(int(getWidth()), 2), FSize(1, getHeight() - 2));
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()));
}
//----------------------------------------------------------------------
void FListView::hide()
{
FWidget::hide();
hideSize (getSize());
}
//----------------------------------------------------------------------
FObject::FObjectIterator FListView::insert ( FListViewItem* item
, FObjectIterator parent_iter )
@ -818,24 +824,6 @@ FObject::FObjectIterator FListView::insert ( const FStringList& cols
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()
{
@ -1036,13 +1024,12 @@ void FListView::onMouseDown (FMouseEvent* ev)
}
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1087,7 +1074,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
adjustSize();
if ( isVisible() )
if ( isShown() )
draw();
}
}
@ -1103,7 +1090,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
{
item->setChecked(! item->isChecked());
if ( isVisible() )
if ( isShown() )
draw();
}
}
@ -1139,13 +1126,12 @@ void FListView::onMouseMove (FMouseEvent* ev)
if ( new_pos < int(getCount()) )
setRelativePosition (mouse_y - 2);
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1189,7 +1175,7 @@ void FListView::onMouseDoubleClick (FMouseEvent* ev)
adjustSize();
if ( isVisible() )
if ( isShown() )
draw();
}
@ -1226,13 +1212,12 @@ void FListView::onTimer (FTimerEvent*)
break;
}
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1266,13 +1251,12 @@ void FListView::onWheel (FWheelEvent* ev)
if ( position_before != current_iter.getPosition() )
processChanged();
if ( isVisible() )
if ( isShown() )
drawList();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -1368,15 +1352,15 @@ void FListView::adjustSize()
hbar->setWidth (width, false);
hbar->resize();
if ( element_count <= height )
vbar->hide();
if ( isHorizontallyScrollable() )
hbar->show();
else
vbar->setVisible();
if ( max_line_width <= width )
hbar->hide();
if ( isVerticallyScrollable() )
vbar->show();
else
hbar->setVisible();
vbar->hide();
}
@ -1384,24 +1368,29 @@ void FListView::adjustSize()
//----------------------------------------------------------------------
void FListView::init()
{
initScrollbar (vbar, fc::vertical, &FListView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FListView::cb_HBarChange);
selflist.push_back(this);
root = selflist.begin();
null_iter = selflist.end();
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
setForegroundColor (wc.dialog_fg);
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
{
vbar = std::make_shared<FScrollbar>(fc::vertical, 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();
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
@ -1409,25 +1398,15 @@ void FListView::init()
return;
}
setGeometry (1, 1, 5, 4, false); // initialize geometry values
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
vbar->addCallback
bar->addCallback
(
"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
drawBorder();
if ( isNewFont() && ! vbar->isVisible() )
if ( isNewFont() && ! vbar->isShown() )
{
setColor();
for (int y = 2; y < int(getHeight()); y++)
{
setPrintPos (int(getWidth()), y);
print (' '); // clear right side of the scrollbar
print() << FPoint(int(getWidth()), y)
<< ' '; // clear right side of the scrollbar
}
}
@ -1500,12 +1479,8 @@ void FListView::draw()
if ( isMonochron() )
setReverse(false);
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
drawList();
if ( flags.focus && getStatusBar() )
@ -1568,8 +1543,7 @@ void FListView::drawHeadlines()
last = h.begin() + len;
}
setPrintPos (2, 1);
print() << std::vector<charData>(first, last);
print() << FPoint(2, 1) << std::vector<charData>(first, last);
}
//----------------------------------------------------------------------
@ -1588,7 +1562,7 @@ void FListView::drawList()
const auto item = static_cast<FListViewItem*>(*iter);
int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
setPrintPos (2, 2 + int(y));
print() << FPoint(2, 2 + int(y));
// Draw one FListViewItem
drawListLine (item, flags.focus, is_current_line);
@ -1596,8 +1570,8 @@ void FListView::drawList()
if ( flags.focus && is_current_line )
{
setVisibleCursor (item->isCheckable());
setCursorPos ( 3 + tree_offset + checkbox_offset - xoffset
, 2 + int(y)); // first character
setCursorPos (FPoint ( 3 + tree_offset + checkbox_offset - xoffset
, 2 + int(y) )); // first character
}
last_visible_line = iter;
@ -1614,8 +1588,8 @@ void FListView::drawList()
// Clean empty space after last element
while ( y < uInt(getClientHeight()) )
{
setPrintPos (2, 2 + int(y));
print (FString(std::size_t(getClientWidth()), ' '));
print() << FPoint(2, 2 + int(y))
<< FString(std::size_t(getClientWidth()), ' ');
y++;
}
}
@ -1692,7 +1666,7 @@ void FListView::drawListLine ( const FListViewItem* item
std::size_t i;
for (i = 0; i < len; i++)
*this << element_str[i];
print() << element_str[i];
for (; i < getWidth() - nf_offset - 2; i++)
print (' ');
@ -1875,10 +1849,10 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
static constexpr int ellipsis_length = 2;
int width = iter->width;
headerline << ' ';
headerline << text.left(uInt(width - ellipsis_length));
setColor (wc.label_ellipsis_fg, wc.label_bg);
headerline << "..";
headerline << ' '
<< text.left(uInt(width - ellipsis_length))
<< FColorPair (wc.label_ellipsis_fg, wc.label_bg)
<< "..";
if ( iter == header.end() - 1 ) // Last element
headerline << ' ';
@ -1887,17 +1861,17 @@ void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter
//----------------------------------------------------------------------
void FListView::updateDrawing (bool draw_vbar, bool draw_hbar)
{
if ( isVisible() )
if ( isShown() )
draw();
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible() && draw_vbar )
if ( draw_vbar )
vbar->drawBar();
hbar->setValue (xoffset);
if ( hbar->isVisible() && draw_hbar )
if ( draw_hbar )
hbar->drawBar();
updateTerminal();
@ -1982,8 +1956,10 @@ void FListView::recalculateHorizontalBar (std::size_t len)
hbar->setPageSize (int(max_line_width), int(getWidth() - nf_offset) - 4);
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( isHorizontallyScrollable() )
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->calculateSliderValues();
if ( ! vbar->isVisible() && element_count >= getHeight() - 1 )
vbar->setVisible();
if ( isVerticallyScrollable() )
vbar->show();
else
vbar->hide();
}
//----------------------------------------------------------------------
@ -2032,7 +2010,7 @@ void FListView::mouseHeaderClicked()
sort();
if ( isVisible() )
if ( isShown() )
updateDrawing (true, false);
break;
@ -2551,7 +2529,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
break;
}
if ( isVisible() )
if ( isShown() )
drawList();
if ( scrollType >= FScrollbar::scrollStepBackward
@ -2559,8 +2537,7 @@ void FListView::cb_VBarChange (FWidget*, FDataPtr)
{
vbar->setValue (first_visible_line.getPosition());
if ( vbar->isVisible()
&& first_line_position_before != first_visible_line.getPosition() )
if ( first_line_position_before != first_visible_line.getPosition() )
vbar->drawBar();
updateTerminal();
@ -2611,7 +2588,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
break;
}
if ( isVisible() )
if ( isShown() )
{
drawHeadlines();
drawList();
@ -2624,7 +2601,7 @@ void FListView::cb_HBarChange (FWidget*, FDataPtr)
{
hbar->setValue (xoffset);
if ( hbar->isVisible() && xoffset_before != xoffset )
if ( xoffset_before != xoffset )
hbar->drawBar();
updateTerminal();

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -194,7 +194,7 @@ void FMenuItem::setText (const FString& txt)
if ( hotkey )
text_length--;
setWidth(text_length);
updateSuperMenuDimensions();
}
//----------------------------------------------------------------------
@ -209,13 +209,7 @@ void FMenuItem::addAccelerator (FKey key, FWidget* obj)
root->accelerator_list->push_back(accel);
}
if ( isMenu(super_menu) )
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
updateSuperMenuDimensions();
}
//----------------------------------------------------------------------
@ -241,13 +235,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
}
}
if ( isMenu(super_menu) )
{
auto menu_ptr = static_cast<FMenu*>(super_menu);
if ( menu_ptr )
menu_ptr->calculateDimensions();
}
updateSuperMenuDimensions();
}
//----------------------------------------------------------------------
@ -258,7 +246,7 @@ void FMenuItem::openMenu()
auto dd_menu = getMenu(); // Drop-down menu
if ( dd_menu->isVisible() )
if ( dd_menu->isShown() )
return;
auto openmenu = static_cast<FMenu*>(getOpenMenu());
@ -273,7 +261,6 @@ void FMenuItem::openMenu()
createDialogList (dd_menu);
setOpenMenu(dd_menu);
dd_menu->setVisible();
dd_menu->show();
dd_menu->raiseWindow();
dd_menu->redraw();
@ -541,7 +528,7 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey )
text_length--;
setGeometry (1, 1, text_length + 2, 1, false);
setGeometry (FPoint(1, 1), FSize(text_length + 2, 1), false);
if ( ! parent )
return;
@ -604,6 +591,18 @@ uChar FMenuItem::hotKey()
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()
{

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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()
{
int X, Y;
std::size_t max_width;
std::size_t max_height;
auto root_widget = getRootWidget();
@ -182,9 +181,9 @@ void FMessageBox::adjustSize()
max_height = 24;
}
X = 1 + int((max_width - getWidth()) / 2);
Y = 1 + int((max_height - getHeight()) / 3);
setPos(X, Y, false);
int x = 1 + int((max_width - getWidth()) / 2);
int y = 1 + int((max_height - getHeight()) / 3);
setPos(FPoint(x, y), false);
FDialog::adjustSize();
}
@ -235,7 +234,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[0] = new FButton (this);
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]->setHeight(1, false);
button[0]->setFocus();
@ -244,7 +243,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[1] = new FButton(this);
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]->setHeight(1, false);
}
@ -253,7 +252,7 @@ inline void FMessageBox::allocation (int button0, int button1, int button2)
{
button[2] = new FButton(this);
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]->setHeight(1, false);
}
@ -309,8 +308,8 @@ inline void FMessageBox::initCallbacks()
//----------------------------------------------------------------------
void FMessageBox::calculateDimensions()
{
std::size_t w, h;
std::size_t headline_height = 0;
FSize size;
std::size_t headline_height{0};
text_split = text.split("\n");
max_line_width = 0;
text_num_lines = uInt(text_split.size());
@ -330,13 +329,13 @@ void FMessageBox::calculateDimensions()
max_line_width = len;
}
h = text_num_lines + 8 + headline_height;
w = max_line_width + 4;
size.setHeight (text_num_lines + 8 + headline_height);
size.setWidth (max_line_width + 4);
if ( w < 20 )
w = 20;
if ( size.getWidth() < 20 )
size.setWidth(20);
setSize (w, h);
setSize(size);
}
//----------------------------------------------------------------------
@ -360,8 +359,7 @@ void FMessageBox::draw()
if ( center_text ) // center one line
center_x = int((max_line_width - headline_length) / 2);
setPrintPos (1 + msg_x + center_x, 4);
print (headline_text);
print() << FPoint(1 + msg_x + center_x, 4) << headline_text;
head_offset = 2;
}
@ -374,8 +372,8 @@ void FMessageBox::draw()
if ( center_text ) // center one line
center_x = int((max_line_width - line_length) / 2);
setPrintPos (1 + msg_x + center_x, 4 + head_offset + i);
print(text_components[i]);
print() << FPoint(1 + msg_x + center_x, 4 + head_offset + i)
<< text_components[i];
}
if ( isMonochron() )

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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
&& (btn & button_mask) <= button3_pressed_move
&& mouse_position != zero_point )
&& ! mouse_position.isOrigin() )
{
b_state.mouse_moved = true;
}
@ -811,7 +811,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
{
if ( (btn & button_mask) >= button1_move
&& (btn & button_mask) <= button3_move
&& mouse_position != zero_point )
&& ! mouse_position.isOrigin() )
{
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
&& (btn & button_mask) <= button3_pressed_move
&& mouse_position != zero_point )
&& ! mouse_position.isOrigin() )
{
b_state.mouse_moved = true;
}

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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;
}
@ -85,7 +85,7 @@ bool FPoint::isNull() const
//----------------------------------------------------------------------
std::ostream& operator << (std::ostream& outstr, const FPoint& p)
{
outstr << p.getX() << " " << p.getY();
outstr << p.xpos << " " << p.ypos;
return outstr;
}

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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
percentage = percentage_value;
if ( isVisible() )
if ( isShown() )
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
}
updateTerminal();
}
//----------------------------------------------------------------------
void FProgressbar::setGeometry ( int x, int y
, std::size_t w, std::size_t h
void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
, bool adjust )
{
// Set the progress bar geometry
FWidget::setGeometry (x, y, w, h, adjust);
bar_length = w;
FWidget::setGeometry (pos, size, adjust);
bar_length = size.getWidth();
}
//----------------------------------------------------------------------
@ -84,12 +83,12 @@ bool FProgressbar::setShadow (bool enable)
&& getEncoding() != fc::ASCII )
{
flags.shadow = true;
setShadowSize(1, 1);
setShadowSize(FSize(1, 1));
}
else
{
flags.shadow = false;
setShadowSize(0, 0);
setShadowSize(FSize(0, 0));
}
return enable;
@ -98,40 +97,11 @@ bool FProgressbar::setShadow (bool enable)
//----------------------------------------------------------------------
void FProgressbar::hide()
{
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);
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
FSize shadow = hasShadow() ? FSize(1, 1) : FSize(0, 0);
hideSize (getSize() + shadow);
print() << FPoint(int(getWidth()) - 4, 0)
<< (" "); // hide percentage
}
//----------------------------------------------------------------------
@ -139,10 +109,10 @@ void FProgressbar::reset()
{
percentage = NOT_SET;
if ( isVisible() )
if ( isShown() )
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
}
updateTerminal();
@ -153,8 +123,8 @@ void FProgressbar::reset()
//----------------------------------------------------------------------
void FProgressbar::draw()
{
drawPercentage();
drawBar();
drawProgressLabel();
drawProgressBar();
if ( flags.shadow )
drawShadow ();
@ -163,7 +133,7 @@ void FProgressbar::draw()
}
//----------------------------------------------------------------------
void FProgressbar::drawPercentage()
void FProgressbar::drawProgressLabel()
{
auto parent_widget = getParentWidget();
@ -176,7 +146,7 @@ void FProgressbar::drawPercentage()
if ( isMonochron() )
setReverse(true);
setPrintPos (int(getWidth()) - 3, 0);
print() << FPoint(int(getWidth()) - 3, 0);
if ( percentage > 100 )
print ("--- %");
@ -188,62 +158,16 @@ void FProgressbar::drawPercentage()
}
//----------------------------------------------------------------------
void FProgressbar::drawBar()
void FProgressbar::drawProgressBar()
{
std::size_t i = 0;
double length;
setPrintPos (1, 1);
setColor ( wc.progressbar_bg
, wc.progressbar_fg );
std::size_t len = 0;
print() << FPoint(1, 1)
<< FColorPair(wc.progressbar_bg, wc.progressbar_fg);
if ( percentage == NOT_SET )
length = double(-0/100);
else
length = double(bar_length * percentage) / 100;
if ( percentage > 0 && percentage <= 100 )
len = drawProgressIndicator();
if ( isMonochron() )
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 (' ');
}
drawProgressBackground(len);
if ( isMonochron() )
setReverse(false);
@ -252,4 +176,56 @@ void FProgressbar::drawBar()
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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -73,7 +73,7 @@ void FRadioButton::drawRadioButton()
if ( ! isVisible() )
return;
setPrintPos (1, 1);
print() << FPoint(1, 1);
setColor();
if ( isMonochron() )

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -32,6 +32,14 @@ namespace finalcut
//----------------------------------------------------------------------
// constructor and destructor
//----------------------------------------------------------------------
FRect::FRect (const FPoint& p, const FSize& s)
: X1(p.getX())
, Y1(p.getY())
, X2(p.getX() + int(s.getWidth()) - 1)
, Y2(p.getY() + int(s.getHeight()) - 1)
{ }
//----------------------------------------------------------------------
FRect::FRect (const FPoint& p1, const FPoint& p2)
: X1(p1.getX())
@ -47,7 +55,7 @@ FRect::~FRect() // destructor
// public methods of FRect
//----------------------------------------------------------------------
bool FRect::isNull() const
bool FRect::isEmpty() const
{
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;
}
//----------------------------------------------------------------------
void FRect::setSize (const FSize& s)
{
X2 = X1 + int(s.getWidth()) - 1;
Y2 = Y1 + int(s.getHeight()) - 1;
}
//----------------------------------------------------------------------
void FRect::setRect (const FRect& r)
{
setRect ( r.X1
, r.Y1
, std::size_t(r.X2 - r.X1 + 1)
, std::size_t(r.Y2 - r.Y1 + 1) );
X1 = r.X1;
Y1 = r.Y1;
X2 = r.X2;
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
, r.Y1
, std::size_t(r.X2 - r.X1 + 1 + p.getX())
, std::size_t(r.Y2 - r.Y1 + 1 + p.getY()) );
, std::size_t(r.X2 - r.X1) + 1 + s.getWidth()
, 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
, r.Y1
, std::size_t(r.X2 - r.X1 + 1 - p.getX())
, std::size_t(r.Y2 - r.Y1 + 1 - p.getY()) );
, std::size_t(r.X2 - r.X1 + 1) - s.getWidth()
, 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)
{
outstr << r.getX1() << " "
<< r.getY1() << " "
<< r.getX2() << " "
<< r.getY2();
outstr << r.X1 << " "
<< r.Y1 << " "
<< r.X2 << " "
<< r.Y2;
return outstr;
}

View File

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

View File

@ -4,7 +4,7 @@
* *
* 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 *
* 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 )
{
FPoint no_shadow(0, 0);
FSize no_shadow(0, 0);
scroll_geometry.setWidth (width);
resizeArea (scroll_geometry, no_shadow, viewport);
@ -89,7 +89,7 @@ void FScrollView::setScrollHeight (std::size_t height)
if ( viewport )
{
FPoint no_shadow(0, 0);
FSize no_shadow(0, 0);
scroll_geometry.setHeight (height);
resizeArea (scroll_geometry, no_shadow, viewport);
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
, yoffset_end;
int xoffset_end, yoffset_end;
std::size_t width = size.getWidth();
std::size_t height = size.getHeight();
if ( width < getViewportWidth() )
width = getViewportWidth();
@ -122,7 +123,7 @@ void FScrollView::setScrollSize (std::size_t width, std::size_t height)
if ( viewport )
{
FPoint no_shadow(0, 0);
FSize no_shadow(0, 0);
scroll_geometry.setSize (width, height);
resizeArea (scroll_geometry, no_shadow, viewport);
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
, 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
, h - horizontal_border_spacing );
calculateScrollbarPos();
if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() )
setScrollSize (getViewportWidth(), getViewportHeight());
setScrollSize (getViewportSize());
}
//----------------------------------------------------------------------
void FScrollView::setGeometry ( int x, int y
, std::size_t w, std::size_t h
void FScrollView::setGeometry ( const FPoint& pos, const FSize& size
, bool adjust )
{
// 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
, getTermY() + getTopPadding() - 1 );
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
@ -253,7 +257,7 @@ void FScrollView::setGeometry ( int x, int y
if ( getScrollWidth() < getViewportWidth()
|| getScrollHeight() < getViewportHeight() )
{
setScrollSize (getViewportWidth(), getViewportHeight());
setScrollSize (getViewportSize());
}
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);
changeY = bool(yoffset_before != yoffset);
if ( ! isVisible() || ! viewport || ! (changeX || changeY) )
if ( ! isShown() || ! viewport || ! (changeX || changeY) )
return;
if ( changeX )
@ -368,7 +374,7 @@ void FScrollView::scrollTo (int x, int y)
if ( update_scrollbar )
{
hbar->setValue (xoffset);
drawHBar();
hbar->drawBar();
}
}
@ -381,7 +387,7 @@ void FScrollView::scrollTo (int x, int y)
if ( update_scrollbar )
{
vbar->setValue (yoffset);
drawVBar();
vbar->drawBar();
}
}
@ -422,8 +428,8 @@ void FScrollView::draw()
setViewportPrint();
copy2area();
redrawVBar();
redrawHBar();
vbar->redraw();
hbar->redraw();
}
//----------------------------------------------------------------------
@ -719,26 +725,23 @@ inline FPoint FScrollView::getViewportCursorPos()
//----------------------------------------------------------------------
void FScrollView::init (FWidget* parent)
{
int xoffset_end;
int yoffset_end;
assert ( parent != 0 );
assert ( ! parent->isInstanceOf("FScrollView") );
initScrollbar (vbar, fc::vertical, &FScrollView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_HBarChange);
setForegroundColor (wc.dialog_fg);
setBackgroundColor (wc.dialog_bg);
init_scrollbar();
setGeometry (1, 1, 4, 4);
setMinimumSize (4, 4);
xoffset_end = int(getScrollWidth() - getViewportWidth());
yoffset_end = int(getScrollHeight() - getViewportHeight());
setGeometry (FPoint(1, 1), FSize(4, 4));
setMinimumSize (FSize(4, 4));
int xoffset_end = int(getScrollWidth() - getViewportWidth());
int yoffset_end = int(getScrollHeight() - getViewportHeight());
nf_offset = isNewFont() ? 1 : 0;
setTopPadding (1 - getScrollY());
setLeftPadding (1 - getScrollX());
setBottomPadding (1 - (yoffset_end - getScrollY()));
setRightPadding (1 - (xoffset_end - getScrollX()) + nf_offset);
FPoint no_shadow(0, 0);
FSize no_shadow(0, 0);
std::size_t w = getViewportWidth();
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
{
vbar = std::make_shared<FScrollbar>(fc::vertical, 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();
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
@ -780,16 +777,16 @@ void FScrollView::init_scrollbar()
return;
}
vbar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, &FScrollView::cb_VBarChange)
);
term_area* area = getPrintArea();
bar->setPrintArea(area);
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
hbar->addCallback
bar->addCallback
(
"change-value",
F_METHOD_CALLBACK (this, &FScrollView::cb_HBarChange)
F_METHOD_CALLBACK (this, callback)
);
}
@ -801,13 +798,13 @@ void FScrollView::calculateScrollbarPos()
if ( isNewFont() )
{
vbar->setGeometry (int(width), 2, 2, height - 2);
hbar->setGeometry (1, int(height), width - 2, 1);
vbar->setGeometry (FPoint(int(width), 2), FSize(2, height - 2));
hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
}
else
{
vbar->setGeometry (int(width), 2, 1, height - 2);
hbar->setGeometry (2, int(height), width - 2, 1);
vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
}
vbar->resize();
@ -821,7 +818,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
{
case fc::Auto:
if ( getScrollWidth() > getViewportWidth() )
hbar->setVisible();
hbar->show();
else
hbar->hide();
break;
@ -831,7 +828,7 @@ void FScrollView::setHorizontalScrollBarVisibility()
break;
case fc::Scroll:
hbar->setVisible();
hbar->show();
break;
}
}
@ -843,7 +840,7 @@ void FScrollView::setVerticalScrollBarVisibility()
{
case fc::Auto:
if ( getScrollHeight() > getViewportHeight() )
vbar->setVisible();
vbar->show();
else
vbar->hide();
break;
@ -853,7 +850,7 @@ void FScrollView::setVerticalScrollBarVisibility()
break;
case fc::Scroll:
vbar->setVisible();
vbar->show();
break;
}
}
@ -981,48 +978,4 @@ void FScrollView::cb_HBarChange (FWidget*, FDataPtr)
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

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 *
* *
* Copyright 2014-2018 Markus Gans *
* 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 *
@ -99,7 +99,7 @@ bool FStatusKey::setMouseFocus(bool enable)
//----------------------------------------------------------------------
void FStatusKey::init (FWidget* parent)
{
setGeometry (1, 1, 1, 1);
setGeometry (FPoint(1, 1), FSize(1, 1));
if ( parent && parent->isInstanceOf("FStatusBar") )
{
@ -178,8 +178,7 @@ void FStatusBar::hide()
setColor (fg, bg);
screenWidth = getDesktopWidth();
auto blank = createBlankArray(screenWidth + 1);
setPrintPos (1, 1);
print (blank);
print() << FPoint(1, 1) << blank;
destroyBlankArray (blank);
}
@ -214,7 +213,7 @@ void FStatusBar::drawMessage()
space_offset = 0;
setColor (wc.statusbar_fg, wc.statusbar_bg);
setPrintPos (x, 1);
setPrintPos (FPoint(x, 1));
if ( isMonochron() )
setReverse(true);
@ -312,7 +311,8 @@ void FStatusBar::clear()
//----------------------------------------------------------------------
void FStatusBar::adjustSize()
{
setGeometry (1, int(getDesktopHeight()), getDesktopWidth(), 1, false);
setGeometry ( FPoint(1, int(getDesktopHeight()))
, FSize(getDesktopWidth(), 1), false );
}
//----------------------------------------------------------------------
@ -495,8 +495,7 @@ 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();
int h = int(r->getHeight());
// initialize geometry values
setGeometry (1, h, w, 1, false);
setGeometry (FPoint(1, h), FSize(w, 1), false);
setAlwaysOnTop();
setStatusBar(this);
ignorePadding();
@ -541,7 +540,7 @@ void FStatusBar::drawKeys()
return;
}
setPrintPos (1, 1);
print() << FPoint(1, 1);
if ( isMonochron() )
setReverse(true);

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -127,7 +127,7 @@ void FSwitch::drawCheckButton()
if ( ! isVisible() )
return;
setPrintPos (1 + int(switch_offset_pos), 1);
print() << FPoint(1 + int(switch_offset_pos), 1);
if ( checked )
drawChecked();
@ -175,13 +175,13 @@ void FSwitch::drawChecked()
if ( isMonochron() || getMaxColor() < 16 )
setBold(false);
setColor (wc.button_inactive_fg, wc.button_inactive_bg);
print (off);
print() << FColorPair(wc.button_inactive_fg, wc.button_inactive_bg)
<< off;
if ( isMonochron() )
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 )
setBold(false);
setCursorPos (7 + int(switch_offset_pos), 1);
setCursorPos (FPoint(7 + int(switch_offset_pos), 1));
}
} // namespace finalcut

View File

@ -133,6 +133,22 @@ bool FTerm::isCursorHideable()
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[])
{
@ -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() )
return;
// PC encoding changes
for (std::size_t i = 0; i <= fc::lastCharItem; i++ )
{
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::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;
}
//----------------------------------------------------------------------
inline bool FTerm::canChangeColorPalette()
{
if ( isCygwinTerminal()
|| isKdeTerminal()
|| isTeraTerm()
|| isMltermTerminal()
|| isNetBSDTerm()
|| isOpenBSDTerm()
|| isSunTerminal()
|| isAnsiTerminal() )
return false;
return FTermcap::can_change_color_palette;
}
//----------------------------------------------------------------------
void FTerm::redefineColorPalette()
{

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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
nc = FVTerm::getAttribute();
@ -93,6 +93,15 @@ int FTermBuffer::write (int c)
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
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -67,7 +67,7 @@ void FTermcapQuirks::setFTermDetection (FTermDetection* td)
//----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup()
{
auto td = term_detection;
auto& td = term_detection;
if ( td->isCygwinTerminal() )
{
@ -114,6 +114,8 @@ void FTermcapQuirks::terminalFixup()
// Fixes general quirks
general();
// ECMA-48 (ANSI X3.64) compatible terminal
ecma48();
}
#if defined(__FreeBSD__) || defined(__DragonFly__)
@ -548,42 +550,46 @@ void FTermcapQuirks::general()
if ( ! TCAP(fc::t_cursor_address) )
TCAP(fc::t_cursor_address) = \
C_STR(CSI "%i%p1%d;%p2%dH");
}
//----------------------------------------------------------------------
void FTermcapQuirks::ecma48()
{
// Test for standard ECMA-48 (ANSI X3.64) terminal
if ( TCAP(fc::t_exit_underline_mode)
&& std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) == 0 )
{
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = \
C_STR(CSI "21m"); // Exit single underline, too
if ( ! TCAP(fc::t_exit_underline_mode)
|| std::strncmp(TCAP(fc::t_exit_underline_mode), CSI "24m", 5) != 0 )
return;
TCAP(fc::t_exit_dbl_underline_mode) = \
C_STR(CSI "24m");
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
TCAP(fc::t_enter_dbl_underline_mode) = \
C_STR(CSI "21m"); // Exit single underline, too
TCAP(fc::t_exit_bold_mode) = \
C_STR(CSI "22m"); // Exit dim, too
TCAP(fc::t_exit_dbl_underline_mode) = \
C_STR(CSI "24m");
TCAP(fc::t_exit_dim_mode) = \
C_STR(CSI "22m");
TCAP(fc::t_exit_bold_mode) = \
C_STR(CSI "22m"); // Exit dim, too
TCAP(fc::t_exit_underline_mode) = \
C_STR(CSI "24m");
TCAP(fc::t_exit_dim_mode) = \
C_STR(CSI "22m");
TCAP(fc::t_exit_blink_mode) = \
C_STR(CSI "25m");
TCAP(fc::t_exit_underline_mode) = \
C_STR(CSI "24m");
TCAP(fc::t_exit_reverse_mode) = \
C_STR(CSI "27m");
TCAP(fc::t_exit_blink_mode) = \
C_STR(CSI "25m");
TCAP(fc::t_exit_secure_mode) = \
C_STR(CSI "28m");
TCAP(fc::t_exit_reverse_mode) = \
C_STR(CSI "27m");
TCAP(fc::t_enter_crossed_out_mode) = \
C_STR(CSI "9m");
TCAP(fc::t_exit_secure_mode) = \
C_STR(CSI "28m");
TCAP(fc::t_exit_crossed_out_mode) = \
C_STR(CSI "29m");
}
TCAP(fc::t_enter_crossed_out_mode) = \
C_STR(CSI "9m");
TCAP(fc::t_exit_crossed_out_mode) = \
C_STR(CSI "29m");
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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)
|| (color_env.string6 && std::strlen(color_env.string6) > 0) )
{
terminal_type.kde_konsole = true;
new_termtype = C_STR("konsole-256color");
}
if ( color_env.string3 && std::strlen(color_env.string3) > 0 )
decscusr_support = true;

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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 *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-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 *
@ -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}
term_width = width;
term_height = height;
term_width = size.getWidth();
term_height = size.getHeight();
setXTermSize();
}
@ -605,23 +605,18 @@ void FTermXTerminal::resetXTermColorMap()
{
// Reset the entire color table
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( term_detection->isMinttyTerm() )
{
FTerm::putstringf (ESC "c"); // Full Reset (RIS)
}
else if ( canResetColor() )
{
oscPrefix();
FTerm::putstringf (OSC "104" BEL);
oscPostfix();
std::fflush(stdout);
}
}
//----------------------------------------------------------------------
@ -629,17 +624,7 @@ void FTermXTerminal::resetXTermForeground()
{
// Reset the XTerm text foreground color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
FTerm::putstring (OSC "110" BEL);
@ -653,17 +638,7 @@ void FTermXTerminal::resetXTermBackground()
{
// Reset the XTerm text background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal()
|| term_detection->isMltermTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
FTerm::putstring (OSC "111" BEL);
@ -677,16 +652,7 @@ void FTermXTerminal::resetXTermCursorColor()
{
// Reset the text cursor color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
FTerm::putstring (OSC "112" BEL);
@ -700,16 +666,7 @@ void FTermXTerminal::resetXTermMouseForeground()
{
// Reset the mouse foreground color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
FTerm::putstring (OSC "113" BEL);
@ -723,16 +680,7 @@ void FTermXTerminal::resetXTermMouseBackground()
{
// Reset the mouse background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
FTerm::putstring (OSC "114" BEL);
@ -746,17 +694,7 @@ void FTermXTerminal::resetXTermHighlightBackground()
{
// Reset the highlight background color
if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 )
return;
if ( term_detection->isPuttyTerminal() )
return;
if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm()
|| term_detection->isUrxvtTerminal()
|| FTermcap::osc_support )
if ( canResetColor() )
{
oscPrefix();
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()
{

View File

@ -84,25 +84,24 @@ const FString FTextView::getText() const
}
//----------------------------------------------------------------------
void FTextView::setGeometry ( int x, int y
, std::size_t w, std::size_t h
, bool adjust )
void FTextView::setGeometry ( const FPoint& pos, const FSize& size
, bool adjust)
{
// 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 height = getHeight();
if ( isNewFont() )
{
vbar->setGeometry (int(width), 1, 2, height - 1);
hbar->setGeometry (1, int(height), width - 2, 1);
vbar->setGeometry (FPoint(int(width), 1), FSize(2, height - 1));
hbar->setGeometry (FPoint(1, int(height)), FSize(width - 2, 1));
}
else
{
vbar->setGeometry (int(width), 2, 1, height - 2);
hbar->setGeometry (2, int(height), width - 2, 1);
vbar->setGeometry (FPoint(int(width), 2), FSize(1, height - 2));
hbar->setGeometry (FPoint(2, int(height)), FSize(width - 2, 1));
}
vbar->resize();
@ -140,7 +139,7 @@ void FTextView::scrollTo (int x, int y)
bool changeX = bool(x != xoffset);
bool changeY = bool(y != yoffset);
if ( ! isVisible() || ! (changeX || changeY) )
if ( ! isShown() || ! (changeX || changeY) )
return;
if ( changeX && isHorizontallyScrollable() )
@ -157,7 +156,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar )
{
hbar->setValue (xoffset);
drawHBar();
hbar->drawBar();
}
}
@ -175,7 +174,7 @@ void FTextView::scrollTo (int x, int y)
if ( update_scrollbar )
{
vbar->setValue (yoffset);
drawVBar();
vbar->drawBar();
}
}
@ -186,38 +185,8 @@ void FTextView::scrollTo (int x, int y)
//----------------------------------------------------------------------
void FTextView::hide()
{
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);
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();
hideSize (getSize());
}
//----------------------------------------------------------------------
@ -264,8 +233,8 @@ void FTextView::insert (const FString& str, int pos)
hbar->setPageSize (int(maxLineWidth), int(getTextWidth()));
hbar->calculateSliderValues();
if ( ! hbar->isVisible() )
hbar->setVisible();
if ( ! hbar->isShown() )
hbar->show();
}
}
}
@ -278,10 +247,10 @@ void FTextView::insert (const FString& str, int pos)
vbar->setPageSize (int(getRows()), int(getTextHeight()));
vbar->calculateSliderValues();
if ( ! vbar->isVisible() && getRows() > getTextHeight() )
vbar->setVisible();
if ( ! vbar->isShown() && getRows() > getTextHeight() )
vbar->show();
if ( vbar->isVisible() && getRows() <= getTextHeight() )
if ( vbar->isShown() && getRows() <= getTextHeight() )
vbar->hide();
processChanged();
@ -328,8 +297,7 @@ void FTextView::clear()
for (int y = 0; y < int(getTextHeight()); y++)
{
setPrintPos (2, 2 - nf_offset + y);
print (blank);
print() << FPoint(2, 2 - nf_offset + y) << blank;
}
destroyBlankArray (blank);
@ -462,11 +430,8 @@ void FTextView::onMouseUp (FMouseEvent* ev)
}
}
if ( vbar->isVisible() )
vbar->redraw();
if ( hbar->isVisible() )
hbar->redraw();
vbar->redraw();
hbar->redraw();
}
//----------------------------------------------------------------------
@ -518,7 +483,7 @@ void FTextView::onWheel (FWheelEvent* ev)
break;
}
if ( isVisible() )
if ( isShown() )
drawText();
updateTerminal();
@ -593,12 +558,12 @@ void FTextView::adjustSize()
if ( last_line < int(height) + nf_offset - 1 )
vbar->hide();
else
vbar->setVisible();
vbar->show();
if ( max_width < int(width) - nf_offset - 1 )
hbar->hide();
else
hbar->setVisible();
hbar->show();
}
@ -618,20 +583,25 @@ std::size_t FTextView::getTextWidth()
//----------------------------------------------------------------------
void FTextView::init()
{
initScrollbar (vbar, fc::vertical, &FTextView::cb_VBarChange);
initScrollbar (hbar, fc::horizontal, &FTextView::cb_HBarChange);
setForegroundColor (wc.dialog_fg);
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
{
vbar = std::make_shared<FScrollbar>(fc::vertical, 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();
bar = std::make_shared<FScrollbar>(o, this);
}
catch (const std::bad_alloc& ex)
{
@ -639,23 +609,15 @@ void FTextView::init()
return;
}
vbar->addCallback
bar->setMinimum(0);
bar->setValue(0);
bar->hide();
bar->addCallback
(
"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() )
setReverse(false);
if ( vbar->isVisible() )
if ( vbar->isShown() )
vbar->redraw();
if ( hbar->isVisible() )
if ( hbar->isShown() )
hbar->redraw();
drawText();
@ -707,7 +669,7 @@ void FTextView::draw()
}
}
setCursorPos (int(getWidth()), int(getHeight()));
setCursorPos (FPoint(int(getWidth()), int(getHeight())));
updateTerminal();
flush_out();
}
@ -732,7 +694,7 @@ void FTextView::drawText()
{
std::size_t i;
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)
, getTextWidth() );
const auto line_str = line.wc_str();
@ -768,20 +730,6 @@ void FTextView::processChanged()
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)
{

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -76,24 +76,24 @@ FToggleButton::~FToggleButton() // destructor
// public methods of FToggleButton
//----------------------------------------------------------------------
void FToggleButton::setGeometry ( int x, int y
, std::size_t w, std::size_t h
void FToggleButton::setGeometry ( const FPoint& pos, const FSize& s
, bool adjust )
{
// 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;
if ( w < min_width )
w = min_width;
if ( size.getWidth() < min_width )
size.setWidth(min_width);
const FRect geometry(x, y, w, h);
const FRect geometry(pos, size);
if ( hasGroup() )
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)
{
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);
@ -202,32 +202,8 @@ void FToggleButton::setText (const FString& txt)
//----------------------------------------------------------------------
void FToggleButton::hide()
{
std::size_t 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);
size = getWidth();
if ( size == 0 )
return;
auto blank = createBlankArray(size + 1);
setPrintPos (1, 1);
print (blank);
destroyBlankArray (blank);
hideSize (getSize());
}
//----------------------------------------------------------------------
@ -385,46 +361,22 @@ void FToggleButton::onFocusOut (FFocusEvent* out_ev)
// 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()
{
uChar hotkey = getHotkey();
FKey hotkey = getHotkey(text);
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::toupper(hotkey)));
addAccelerator (FKey(std::tolower(int(hotkey))));
addAccelerator (FKey(std::toupper(int(hotkey))));
// Meta + hotkey
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(hotkey)));
addAccelerator (fc::Fmkey_meta + FKey(std::tolower(int(hotkey))));
}
else
addAccelerator (getHotkey());
addAccelerator (hotkey);
}
else
delAccelerator();
@ -459,7 +411,7 @@ void FToggleButton::draw()
// set the cursor to the button
if ( isRadioButton() || isCheckboxButton() )
setCursorPos (2, 1);
setCursorPos (FPoint(2, 1));
}
//----------------------------------------------------------------------
@ -493,7 +445,7 @@ void FToggleButton::drawLabel()
if ( hotkeypos != NOT_SET )
length--;
setPrintPos (1 + int(label_offset_pos), 1);
print() << FPoint(1 + int(label_offset_pos), 1);
drawText (LabelText, hotkeypos, length);
delete[] LabelText;
}
@ -576,7 +528,7 @@ void FToggleButton::setGroup (FButtonGroup* btngroup)
//----------------------------------------------------------------------
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() )
{

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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++)
{
setPrintPos (3, 2 + int(i));
print(text_components[i]);
print() << FPoint(3, 2 + int(i)) << text_components[i];
}
unsetBold();
@ -124,8 +123,8 @@ void FToolTip::init()
setAlwaysOnTop();
ignorePadding();
// initialize geometry values
setGeometry (1, 1, 3, 3, false);
setMinimumSize (3, 3);
setGeometry (FPoint(1, 1), FSize(3, 3), false);
setMinimumSize (FSize(3, 3));
setForegroundColor (wc.tooltip_fg);
setBackgroundColor (wc.tooltip_bg);
calculateDimensions();
@ -164,7 +163,7 @@ void FToolTip::calculateDimensions()
else
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 ( win )
if ( auto win = getPrintArea() )
{
win->cursor_x = x - win->offset_left;
win->cursor_y = y - win->offset_top;
win->cursor_x = pos.getX() - win->offset_left;
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
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
createArea (0, 0, width, height, 0, 0, vterm);
}
// resize virtual terminal
//----------------------------------------------------------------------
void FVTerm::resizeVTerm (const FRect& r)
{
const FPoint shadow(0, 0);
resizeArea (r, shadow, vterm);
}
//----------------------------------------------------------------------
void FVTerm::resizeVTerm (int width, int height)
{
resizeArea (0, 0, width, height, 0, 0, vterm);
const FRect box(0, 0, size.getWidth(), size.getHeight());
const FSize shadow(0, 0);
resizeArea (box, shadow, vterm);
}
//----------------------------------------------------------------------
@ -321,7 +311,9 @@ int FVTerm::printf (const FString format, ...)
//----------------------------------------------------------------------
int FVTerm::print (const FString& s)
{
assert ( ! s.isNull() );
if ( s.isNull() )
return -1;
auto area = getPrintArea();
if ( ! area )
@ -338,9 +330,7 @@ int FVTerm::print (const FString& s)
//----------------------------------------------------------------------
int FVTerm::print (term_area* area, const FString& s)
{
assert ( ! s.isNull() );
if ( ! area )
if ( s.isNull() || ! area )
return -1;
std::vector<charData> term_string;
@ -567,6 +557,19 @@ int FVTerm::print (term_area* area, charData& term_char)
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
//----------------------------------------------------------------------
FVTerm::term_area* FVTerm::getPrintArea()
@ -593,23 +596,8 @@ FVTerm::term_area* FVTerm::getPrintArea()
}
//----------------------------------------------------------------------
void FVTerm::createArea ( const FRect& r
, const FPoint& p
, 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
void FVTerm::createArea ( const FRect& box
, const FSize& shadow
, term_area*& area )
{
// initialize virtual window
@ -625,34 +613,26 @@ void FVTerm::createArea ( int offset_left, int offset_top
}
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
, const FPoint& p
, 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
void FVTerm::resizeArea ( const FRect& box
, const FSize& shadow
, term_area* area )
{
// 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 ( width > 0 );
assert ( height > 0 );
assert ( width > 0 && width + rsw > 0 );
assert ( height > 0 && height + bsh > 0 );
assert ( rsw >= 0 );
assert ( bsh >= 0 );
std::size_t area_size;
@ -693,25 +673,24 @@ void FVTerm::resizeArea ( int offset_left, int offset_top
if ( ! realloc_success )
return;
area->offset_left = offset_left;
area->offset_top = offset_top;
area->width = width;
area->height = height;
area->right_shadow = rsw;
area->bottom_shadow = bsh;
area->has_changes = false;
area->offset_left = offset_left;
area->offset_top = offset_top;
area->width = width;
area->height = height;
area->right_shadow = rsw;
area->bottom_shadow = bsh;
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
, int width
, int height )
, const FSize& size )
{
charData default_char;
line_changes unchanged;
int size = width * height;
default_char.code = ' ';
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[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.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 size )
{
// Reallocate "height" lines for changes
// and "size" bytes for the text area
if ( area->changes != 0 )
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)
{
// Reallocate "size" bytes for the text area
if ( area->text != 0 )
delete[] area->text;
@ -800,17 +784,10 @@ void FVTerm::removeArea (term_area*& area)
//----------------------------------------------------------------------
void FVTerm::restoreVTerm (const FRect& box)
{
restoreVTerm ( box.getX()
, box.getY()
, int(box.getWidth())
, int(box.getHeight()) );
}
//----------------------------------------------------------------------
void FVTerm::restoreVTerm (int x, int y, int w, int h)
{
x--;
y--;
int x = box.getX() - 1;
int y = box.getY() - 1;
int w = int(box.getWidth());
int h = int(box.getHeight());
if ( x < 0 )
x = 0;
@ -841,7 +818,7 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
{
int xpos = x + tx;
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));
}
@ -859,15 +836,6 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos
{
// 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 )
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->height + win->bottom_shadow) );
if ( found && geometry.contains(x, y) )
if ( found && geometry.contains(pos) )
{
int line_len = win->width + win->right_shadow;
auto tmp = &win->text[(y - win_y) * line_len + (x - win_x)];
int width = win->width + win->right_shadow;
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 )
{
@ -919,22 +889,25 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
//----------------------------------------------------------------------
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
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character
auto ac = &area->text[y * line_len + x];
auto ac = &area->text[y * width + x];
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
std::memcpy (&nc, ac, sizeof(nc));
// 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.bg_color = oc.bg_color;
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
// Terminal character
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
auto tc = &vterm->text[ty * vterm->width + tx];
// 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);
std::memcpy (tc, &oc, sizeof(*tc));
}
//----------------------------------------------------------------------
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
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character
auto ac = &area->text[y * line_len + x];
auto ac = &area->text[y * width + x];
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
// 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.bg_color = ac->bg_color;
oc.attr.bit.reverse = false;
@ -999,22 +978,25 @@ void FVTerm::updateShadedCharacter ( 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
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character
auto ac = &area->text[y * line_len + x];
auto ac = &area->text[y * width + x];
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
// New character
charData nc;
std::memcpy (&nc, ac, sizeof(nc));
// 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.attr.bit.no_changes = bool(tc->attr.bit.printed && *tc == nc);
std::memcpy (tc, &nc, sizeof(*tc));
@ -1022,15 +1004,18 @@ void FVTerm::updateInheritBackground ( 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
int& aw = area->width;
int& rsh = area->right_shadow;
int line_len = aw + rsh;
int x = area_pos.getX();
int y = area_pos.getY();
int tx = terminal_pos.getX();
int ty = terminal_pos.getY();
int width = area->width + area->right_shadow;
// Area character
auto ac = &area->text[y * line_len + x];
auto ac = &area->text[y * width + x];
// Terminal character
auto tc = &vterm->text[ty * vterm->width + tx];
std::memcpy (tc, ac, sizeof(*tc));
@ -1043,41 +1028,42 @@ void FVTerm::updateCharacter ( 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& rsh = area->right_shadow;
int line_len = aw + rsh;
int x = area_pos.getX();
int y = area_pos.getY();
int width = area->width + area->right_shadow;
// Area character
auto ac = &area->text[y * line_len + x];
auto ac = &area->text[y * width + x];
// Get covered state
auto is_covered = isCovered(tx, ty, area);
auto is_covered = isCovered(terminal_pos, area);
if ( is_covered == fully_covered )
return false;
if ( is_covered == half_covered )
{
updateOverlappedColor(area, x, y, tx, ty);
updateOverlappedColor(area, area_pos, terminal_pos);
}
else if ( ac->attr.bit.transparent ) // Transparent
{
updateOverlappedCharacter(area, tx, ty);
updateOverlappedCharacter(area, terminal_pos);
}
else // Not transparent
{
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 )
{
updateInheritBackground (area, x, y, tx, ty);
updateInheritBackground (area, area_pos, terminal_pos);
}
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 )
return;
int ax = area->offset_left
, ay = area->offset_top
, aw = area->width
, ah = area->height
, rsh = area->right_shadow
, bsh = area->bottom_shadow
, ol = 0 // Outside left
, y_end;
int ax = area->offset_left;
int ay = area->offset_top;
int width = area->width + area->right_shadow;
int height = area->height + area->bottom_shadow;
int ol = 0; // Outside left
int y_end;
// Call the processing handler methods
callPreprocessingHandler(area);
@ -1185,10 +1169,10 @@ void FVTerm::updateVTerm (term_area* area)
ax = 0;
}
if ( ah + bsh + ay > vterm->height )
if ( height + ay > vterm->height )
y_end = vterm->height - ay;
else
y_end = ah + bsh;
y_end = height;
for (int y = 0; y < y_end; y++) // Line loop
{
@ -1203,7 +1187,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( ax == 0 )
line_xmin = ol;
if ( aw + rsh + ax - ol >= vterm->width )
if ( width + ax - ol >= vterm->width )
line_xmax = vterm->width + ol - ax - 1;
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
{
// Global terminal positions
int tx = ax + x
, ty = ay + y;
int tx = ax + x;
int ty = ay + y;
if ( tx < 0 || ty < 0 )
continue;
tx -= ol;
if ( updateVTermCharacter (area, x, y, tx, ty) )
if ( updateVTermCharacter(area, FPoint(x, y), FPoint(tx, ty)) )
modified = true;
if ( ! modified )
@ -1239,7 +1223,7 @@ void FVTerm::updateVTerm (term_area* area)
if ( _xmax > int(vterm->changes[ay + y].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;
}
@ -1271,9 +1255,9 @@ bool FVTerm::updateVTermCursor (term_area* area)
x = ax + cx;
y = ay + cy;
if ( isInsideArea(cx, cy, area)
&& isInsideTerminal(x, y)
&& isCovered(x, y, area) == non_covered )
if ( isInsideArea (FPoint(cx, cy), area)
&& isInsideTerminal (FPoint(x, y))
&& isCovered (FPoint(x, y), area) == non_covered )
{
vterm->input_cursor_x = x;
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
int ax = 0, ay = 0;
std::size_t aw = std::size_t(area->width);
std::size_t ah = std::size_t(area->height);
FRect area_geometry(ax, ay, aw, ah);
auto aw = std::size_t(area->width);
auto ah = std::size_t(area->height);
FRect area_geometry(0, 0, aw, ah);
if ( area_geometry.contains(x, y) )
if ( area_geometry.contains(pos) )
return true;
else
return false;
@ -1306,41 +1289,27 @@ bool FVTerm::isInsideArea (int x, int y, term_area* area)
void FVTerm::setAreaCursor ( const FPoint& pos
, bool visible
, term_area* area )
{
setAreaCursor (pos.getX(), pos.getY(), visible, area);
}
//----------------------------------------------------------------------
void FVTerm::setAreaCursor ( int x, int y
, bool visible
, term_area* area )
{
if ( ! area )
return;
area->input_cursor_x = x - 1;
area->input_cursor_y = y - 1;
area->input_cursor_x = pos.getX() - 1;
area->input_cursor_y = pos.getY() - 1;
area->input_cursor_visible = visible;
}
//----------------------------------------------------------------------
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
int y_end;
int length;
if ( ! area )
return;
ax--;
ay--;
int y_end;
int length;
int ax = pos.getX() - 1;
int ay = pos.getY() - 1;
if ( area->height + ay > vterm->height )
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)
{
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
if ( ! area )
return;
int dx = x - area->offset_left + 1
, dy = y - area->offset_top + 1
, y_end
, length;
int x = box.getX();
int y = box.getY();
int w = int(box.getWidth());
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 )
return;
@ -1425,39 +1388,18 @@ void FVTerm::putArea (const FPoint& pos, term_area* area)
{
// 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* ac; // area character
if ( ! area )
if ( ! area || ! area->visible )
return;
if ( ! area->visible )
return;
ax--;
ay--;
int aw = area->width
, ah = area->height
, rsh = area->right_shadow
, bsh = area->bottom_shadow
, ol = 0 // outside left
, y_end
, length;
int ax = pos.getX() - 1;
int ay = pos.getY() - 1;
int width = area->width + area->right_shadow;
int height = area->height + area->bottom_shadow;
int ol = 0; // outside left
int y_end, length;
if ( ax < 0 )
{
@ -1465,27 +1407,25 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
ax = 0;
}
if ( ay + ah + bsh > vterm->height )
if ( ay + height > vterm->height )
y_end = vterm->height - ay;
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;
else
length = aw + rsh - ol;
length = width - ol;
if ( length < 1 )
return;
for (int y = 0; y < y_end; y++) // line loop
{
int line_len = aw + rsh;
if ( area->changes[y].trans_count == 0 )
{
// 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];
putAreaLine (ac, tc, length);
}
@ -1496,9 +1436,9 @@ void FVTerm::putArea (int ax, int ay, term_area* area)
{
int cx = ax + x;
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];
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);
FTerm::scrollTermForward();
putArea (1, 1, vdesktop);
putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 0 to (y_max - 1)
for (int y = 0; y < y_max; y++)
@ -1618,7 +1558,7 @@ void FVTerm::scrollAreaReverse (term_area* area)
{
setTermXY (0, 0);
FTerm::scrollTermReverse();
putArea (1, 1, vdesktop);
putArea (FPoint(1, 1), vdesktop);
// avoid update lines from 1 to y_max
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)
{
// 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
int x = pos.getX();
int y =pos.getY();
auto sc = &vdesktop->text[y * vdesktop->width + x]; // shown character
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
, FVTerm* obj )
{
// Gets the overlapped or the covered character for a given position
return getCharacter (type, pos.getX(), pos.getY(), obj);
}
//----------------------------------------------------------------------
FVTerm::charData FVTerm::getCharacter ( character_type char_type
, int x
, int y
, FVTerm* obj )
{
// Gets the overlapped or the covered character for the position (x,y)
x--;
y--;
int x = pos.getX() - 1;
int y = pos.getY() - 1;
int xx = x;
int yy = y;
@ -1825,7 +1750,7 @@ FVTerm::charData FVTerm::getCharacter ( character_type char_type
// Window visible and contains current character
if ( geometry.contains(x, y) )
getAreaCharacter (x, y, win, cc);
getAreaCharacter (FPoint(x, y), win, cc);
}
else if ( char_type == covered_character )
break;
@ -1839,16 +1764,7 @@ FVTerm::charData FVTerm::getCoveredCharacter ( const FPoint& pos
, FVTerm* obj )
{
// Gets the covered character for a given position
return getCharacter (covered_character, pos.getX(), pos.getY(), 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);
return getCharacter (covered_character, pos, obj);
}
//----------------------------------------------------------------------
@ -1856,16 +1772,7 @@ FVTerm::charData FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj )
{
// Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos.getX(), pos.getY(), 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);
return getCharacter (overlapped_character, pos, obj);
}
//----------------------------------------------------------------------
@ -1963,10 +1870,10 @@ void FVTerm::init (bool disable_alt_screen)
// Create virtual terminal
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
createVTerm (term_geometry);
createVTerm (term_geometry.getSize());
// Create virtual desktop area
FPoint shadow_size(0, 0);
FSize shadow_size(0, 0);
createArea (term_geometry, shadow_size, vdesktop);
vdesktop->visible = true;
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* tc )
{
@ -2047,7 +1954,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{
// Restore one character on vterm
charData ch;
ch = getCoveredCharacter (x, y, obj);
ch = getCoveredCharacter (pos, obj);
std::memcpy (tc, &ch, sizeof(*tc));
}
else // Mot transparent
@ -2056,7 +1963,7 @@ void FVTerm::putAreaCharacter ( int x, int y, FVTerm* obj
{
// Get covered character + add the current color
charData ch;
ch = getCoveredCharacter (x, y, obj);
ch = getCoveredCharacter (pos, obj);
ch.fg_color = ac->fg_color;
ch.bg_color = ac->bg_color;
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
charData ch, cc;
std::memcpy (&ch, ac, sizeof(ch));
cc = getCoveredCharacter (x, y, obj);
cc = getCoveredCharacter (pos, obj);
ch.bg_color = cc.bg_color;
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 )
{
int area_x = area->offset_left;
int area_y = area->offset_top;
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)];
// Current character not transparent
@ -2652,7 +2561,7 @@ bool FVTerm::updateTerminalCursor()
int x = vterm->input_cursor_x;
int y = vterm->input_cursor_y;
if ( isInsideTerminal(x, y) )
if ( isInsideTerminal(FPoint(x, y)) )
{
setTermXY (x, y);
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
FRect term_geometry (0, 0, getColumnNumber(), getLineNumber());
if ( term_geometry.contains(x, y) )
if ( term_geometry.contains(pos) )
return true;
else
return false;

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -247,6 +247,12 @@ void FWidget::setMainWidget (FWidget* obj)
app_object->focusFirstChild();
}
//----------------------------------------------------------------------
bool FWidget::setVisible (bool enable)
{
return (flags.visible = enable);
}
//----------------------------------------------------------------------
bool FWidget::setEnable (bool enable)
{
@ -267,16 +273,10 @@ bool FWidget::setFocus (bool enable)
// set widget focus
if ( enable && ! flags.focus )
{
int focusable_children = numOfFocusableChildren();
if ( last_focus )
last_focus->unsetFocus();
if ( (!isDialogWidget() && focusable_children == 0)
|| (isDialogWidget() && focusable_children == 1) )
{
FWidget::setFocusWidget(this);
}
FWidget::setFocusWidget(this);
}
auto window = FWindow::getWindowWidget(this);
@ -292,6 +292,7 @@ bool FWidget::setFocus (bool enable)
if ( has_raised && window->isVisible() && window->isShown() )
window->redraw();
}
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
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
&& getY() == y && wsize.getY() == y )
FPoint pos = p;
if ( getX() == pos.getX() && wsize.getX() == pos.getX()
&& getY() == pos.getY() && wsize.getY() == pos.getY() )
{
return;
}
if ( ! isWindowWidget() )
{
if ( x < 1 )
x = 1;
if ( pos.getX() < 1 )
pos.setX(1);
if ( y < 1 )
y = 1;
if ( pos.getY() < 1 )
pos.setY(1);
}
wsize.setPos(x, y);
adjust_wsize.setPos(x, y);
wsize.setPos(pos);
adjust_wsize.setPos(pos);
if ( adjust )
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::max (width, size_hints.min_width);
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() )
{
rootObject->wsize.setRect(1, 1, w, h);
rootObject->wsize.setRect(FPoint(1, 1), size);
rootObject->adjust_wsize = rootObject->wsize;
FTerm::setTermSize (w, h); // w = columns / h = lines
FTerm::setTermSize(size); // width = columns / height = lines
detectTermSize();
}
}
//----------------------------------------------------------------------
void FWidget::setGeometry ( int x, int y
, std::size_t w, std::size_t h
, bool adjust )
void FWidget::setGeometry (const FPoint& p, const FSize& s, bool adjust)
{
// 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::max (w, size_hints.min_width);
h = std::min (h, size_hints.max_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;
if ( ! isWindowWidget() )
@ -596,8 +601,8 @@ void FWidget::setGeometry ( int x, int y
( h < 1 ) ? wsize.setHeight(1) : wsize.setHeight(h);
adjust_wsize = wsize;
term_x = getTermX();
term_y = getTermY();
int term_x = getTermX();
int term_y = getTermY();
client_offset.setCoordinates ( term_x - 1 + padding.left
, 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
widget_cursor_position.setPoint(x, y);
widget_cursor_position.setPoint(pos);
if ( ! flags.focus || isWindowWidget() )
return false;
@ -639,8 +644,8 @@ bool FWidget::setCursorPos (int x, int y)
widget_offsetY += (1 - area->widget->getTopPadding());
}
setAreaCursor ( widget_offsetX + x
, widget_offsetY + y
setAreaCursor ( FPoint ( widget_offsetX + pos.getX()
, widget_offsetY + pos.getY() )
, flags.visible_cursor
, area );
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,
offset.getY1() + getY() + y - 1 );
FPoint p{ offset.getX1() + getX() + pos.getX() - 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() )
{
@ -759,11 +765,11 @@ FWidget* FWidget::childWidgetAt (FWidget* p, int x, int y)
auto widget = static_cast<FWidget*>(*iter);
if ( widget->isEnabled()
&& widget->isVisible()
&& widget->isShown()
&& ! 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;
}
@ -790,7 +796,9 @@ int FWidget::numOfFocusableChildren()
{
auto widget = static_cast<FWidget*>(*iter);
if ( widget->acceptFocus() )
if ( widget->isShown()
&& widget->acceptFocus()
&& ! widget->isWindowWidget() )
num++;
}
@ -984,7 +992,7 @@ void FWidget::redraw()
setColor (wc.term_fg, wc.term_bg);
clearArea (vdesktop);
}
else if ( ! isVisible() )
else if ( ! isShown() )
return;
draw();
@ -1014,7 +1022,7 @@ void FWidget::resize()
FRect term_geometry = getTermGeometry();
term_geometry.move (-1, -1);
resizeVTerm (term_geometry);
resizeVTerm (term_geometry.getSize());
resizeArea (term_geometry, getShadow(), vdesktop);
adjustSizeGlobal();
}
@ -1053,6 +1061,7 @@ void FWidget::show()
}
draw();
flags.hidden = false;
flags.shown = true;
if ( hasChildren() )
@ -1065,7 +1074,9 @@ void FWidget::show()
if ( (*iter)->isWidget() )
{
auto widget = static_cast<FWidget*>(*iter);
widget->show();
if ( ! widget->flags.hidden )
widget->show();
}
++iter;
@ -1087,9 +1098,10 @@ void FWidget::show()
//----------------------------------------------------------------------
void FWidget::hide()
{
flags.hidden = true;
if ( isVisible() )
{
flags.visible = false;
flags.shown = false;
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);
adjust_wsize.move(dx, dy);
wsize.move(pos);
adjust_wsize.move(pos);
}
//----------------------------------------------------------------------
@ -1261,14 +1273,13 @@ void FWidget::clearShadow()
{
for (std::size_t y = 1; y <= getHeight(); y++)
{
setPrintPos (w + 1, int(y));
print (' '); // clear █
print() << FPoint(w + 1, int(y)) << ' '; // clear █
}
}
if ( h <= offset.getY2() )
{
setPrintPos (2, h + 1);
print() << FPoint(2, h + 1);
for (std::size_t i = 1; i <= getWidth(); i++)
print (' '); // clear ▀
@ -1296,7 +1307,7 @@ void FWidget::drawFlatBorder()
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)] )
// left+right line (on left side)
@ -1306,7 +1317,7 @@ void FWidget::drawFlatBorder()
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++)
{
@ -1317,10 +1328,10 @@ void FWidget::drawFlatBorder()
// left line (on right side)
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++)
{
@ -1332,7 +1343,7 @@ void FWidget::drawFlatBorder()
print (fc::NF_border_line_bottom);
}
setPrintPos (x1, y2);
print() << FPoint(x1, y2);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1364,7 +1375,7 @@ void FWidget::clearFlatBorder()
// clear on left side
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] )
print (fc::NF_border_line_left);
@ -1375,7 +1386,7 @@ void FWidget::clearFlatBorder()
// clear on right side
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] )
print (fc::NF_rev_border_line_right);
@ -1384,7 +1395,7 @@ void FWidget::clearFlatBorder()
}
// clear at top
setPrintPos (x1, y1);
print() << FPoint(x1, y1);
for (std::size_t x = 0; x < getWidth(); x++)
{
@ -1395,7 +1406,7 @@ void FWidget::clearFlatBorder()
}
// clear at bottom
setPrintPos (x1, y2);
print() << FPoint(x1, y2);
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()
{
@ -1655,7 +1701,7 @@ bool FWidget::focusNextChild()
} while ( ! next
|| ! next->isEnabled()
|| ! next->acceptFocus()
|| ! next->isVisible()
|| ! next->isShown()
|| next->isWindowWidget() );
bool accpt = changeFocus (next, parent, fc::FocusNextWidget);
@ -1716,7 +1762,7 @@ bool FWidget::focusPrevChild()
} while ( ! prev
|| ! prev->isEnabled()
|| ! prev->acceptFocus()
|| ! prev->isVisible()
|| ! prev->isShown()
|| prev->isWindowWidget() );
bool accpt = changeFocus (prev, parent, fc::FocusPreviousWidget);
@ -2140,7 +2186,7 @@ void FWidget::drawWindows()
while ( iter != last )
{
if ( (*iter)->isVisible() )
if ( (*iter)->isShown() )
{
auto win = (*iter)->getVWin();
int w = win->width + win->right_shadow;
@ -2170,7 +2216,7 @@ void FWidget::drawChildren()
{
auto widget = static_cast<FWidget*>(*iter);
if ( widget->isVisible() && ! widget->isWindowWidget() )
if ( widget->isShown() && ! widget->isWindowWidget() )
widget->redraw();
}
@ -2182,9 +2228,9 @@ void FWidget::drawChildren()
void FWidget::drawTransparentShadow (int x1, int y1, int x2, int y2)
{
// transparent shadow
setPrintPos (x2 + 1, y1);
setTransparent();
print (" ");
print() << FPoint(x2 + 1, y1) << " ";
unsetTransparent();
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++)
{
setPrintPos (x2 + 1, y1 + int(y));
print (" ");
print() << FPoint(x2 + 1, y1 + int(y)) << " ";
}
unsetTransShadow();
setPrintPos (x1, y2 + 1);
setTransparent();
print (" ");
print() << FPoint(x1, y2 + 1) << " ";
unsetTransparent();
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)
{
// non-transparent shadow
int block;
wchar_t block;
if ( ! hasShadowCharacter() )
return;
setPrintPos (x2 + 1, y1);
print() << FPoint(x2 + 1, y1);
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++)
{
setPrintPos (x2 + 1, y1 + int(y));
print (block); // █
print() << FPoint(x2 + 1, y1 + int(y)) << block; // █
}
setPrintPos (x1 + 1, y2 + 1);
print() << FPoint(x1 + 1, y2 + 1);
if ( isWindowWidget() )
setInheritBackground();
@ -2262,36 +2305,34 @@ inline void FWidget::drawBox (int x1, int y1, int x2, int y2)
{
// Use box-drawing characters to draw a border
setPrintPos (x1, y1);
print (fc::BoxDrawingsDownAndRight); // ┌
print() << FPoint(x1, y1) << fc::BoxDrawingsDownAndRight; // ┌
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsDownAndLeft); // ┐
print (fc::BoxDrawingsDownAndLeft); // ┐
for (int y = y1 + 1; y < y2; y++)
{
setPrintPos (x1, y);
print (fc::BoxDrawingsVertical); // │
setPrintPos (x2, y);
print (fc::BoxDrawingsVertical); // │
print() << FPoint(x1, y)
<< fc::BoxDrawingsVertical // │
<< FPoint(x2, y)
<< fc::BoxDrawingsVertical; // │
}
setPrintPos (x1, y2);
print (fc::BoxDrawingsUpAndRight); // └
print() << FPoint(x1, y2) << fc::BoxDrawingsUpAndRight; // └
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsUpAndLeft); // ┘
print (fc::BoxDrawingsUpAndLeft); // ┘
for (int x = x1 + 1; x < x2; x++)
{
setPrintPos (x, y1);
print (fc::BoxDrawingsHorizontal); // ─
setPrintPos (x, y2);
print (fc::BoxDrawingsHorizontal); // ─
print() << FPoint(x, y1)
<< fc::BoxDrawingsHorizontal // ─
<< FPoint(x, y2)
<< fc::BoxDrawingsHorizontal; // ─
}
}
@ -2300,24 +2341,24 @@ inline void FWidget::drawNewFontBox (int x1, int y1, int x2, int y2)
{
// Use new graphical font characters to draw a border
setPrintPos (x1, y1);
print (fc::NF_border_corner_middle_upper_left); // ┌
print() << FPoint(x1, y1)
<< fc::NF_border_corner_middle_upper_left; // ┌
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
print (fc::BoxDrawingsHorizontal); // ─
print (fc::NF_border_corner_middle_upper_right); // ┐
print (fc::NF_border_corner_middle_upper_right); // ┐
for (int y = y1 + 1; y <= y2; y++)
{
setPrintPos (x1, y);
print (fc::NF_border_line_left); // border left ⎸
setPrintPos (x2, y);
print (fc::NF_rev_border_line_right); // border right⎹
print() << FPoint(x1, y)
<< fc::NF_border_line_left // border left ⎸
<< FPoint(x2, y)
<< fc::NF_rev_border_line_right; // border right⎹
}
setPrintPos (x1, y2);
print (fc::NF_border_corner_middle_lower_left); // └
print() << FPoint(x1, y2)
<< fc::NF_border_corner_middle_lower_left; // └
for (int x = x1 + 1; x < x2; x++)
print (fc::BoxDrawingsHorizontal); // ─
@ -2331,16 +2372,9 @@ void FWidget::setColorTheme()
// Sets the default color theme
if ( getMaxColor() < 16 ) // for 8 color mode
{
wc.set8ColorTheme();
}
else
{
wc.set16ColorTheme();
if ( isKdeTerminal() )
wc.term_bg = fc::SkyBlue2;
}
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -20,6 +20,7 @@
* <http://www.gnu.org/licenses/>. *
***********************************************************************/
#include "final/fterm.h"
#include "final/fwidgetcolors.h"
namespace finalcut
@ -206,6 +207,9 @@ void FWidgetColors::set16ColorTheme()
scrollbar_button_bg = fc::LightGray;
progressbar_fg = fc::DarkGray;
progressbar_bg = fc::LightBlue;
if ( ! FTerm::canChangeColorPalette() && FTerm::getMaxColor() > 16 )
term_bg = fc::SkyBlue2;
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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;
if ( enable )
setShadowSize (2, 1);
setShadowSize (FSize(2, 1));
else
setShadowSize (0, 0);
setShadowSize (FSize(0, 0));
return enable;
}
@ -196,13 +196,13 @@ bool FWindow::setShadow (bool enable)
{
flags.shadow = true;
flags.trans_shadow = false;
setShadowSize (1, 1);
setShadowSize (FSize(1, 1));
}
else
{
flags.shadow = false;
flags.trans_shadow = false;
setShadowSize (0, 0);
setShadowSize (FSize(0, 0));
}
return enable;
@ -251,8 +251,7 @@ void FWindow::drawBorder()
, y1 = 1
, y2 = 1 + int(getHeight()) - 1;
setPrintPos (x1, y1);
print (fc::NF_border_corner_upper_left); // ⎡
print() << FPoint(x1, y1) << fc::NF_border_corner_upper_left; // ⎡
for (int x = x1 + 1; x < x2; x++)
print (fc::NF_border_line_upper); // ¯
@ -261,24 +260,20 @@ void FWindow::drawBorder()
for (int y = y1 + 1; y < y2; y++)
{
setPrintPos (x1, y);
// border left ⎸
print (fc::NF_border_line_left);
setPrintPos (x2, y);
// border right⎹
print (fc::NF_rev_border_line_right);
print() << FPoint(x1, y) // border left ⎸
<< fc::NF_border_line_left
<< FPoint(x2, y) // border right⎹
<< fc::NF_rev_border_line_right;
}
setPrintPos (x1, y2);
// lower left corner border ⎣
print (fc::NF_border_corner_lower_left);
print() << FPoint(x1, y2) // lower left corner border ⎣
<< fc::NF_border_corner_lower_left;
for (std::size_t x = 2; x < getWidth(); x++) // low line _
print (fc::NF_border_line_bottom);
setPrintPos (x2, y2);
// lower right corner border ⎦
print (fc::NF_rev_border_corner_lower_right);
print() << FPoint(x2, y2) // lower right corner border ⎦
<< fc::NF_rev_border_corner_lower_right;
}
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 )
y = 1;
FPoint pos = p;
FWidget::setPos (x, y, adjust);
if ( pos.getY() < 1 )
pos.setY(1);
FWidget::setPos (pos, adjust);
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_height = getHeight();
FWidget::setSize (w, h, adjust);
FWidget::setSize (size, adjust);
if ( isVirtualWindow()
&& (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
, std::size_t w, std::size_t h
, bool adjust )
void FWindow::setGeometry ( const FPoint& p, const FSize& size, bool adjust)
{
// Sets the geometry of the widget
int old_x = getX();
int old_y = getY();
std::size_t old_width = getWidth();
std::size_t old_height = getHeight();
FPoint pos = p;
FSize old_size = getSize();
if ( y < 1 )
y = 1;
if ( pos.getY() < 1 )
pos.setY(1);
FWidget::setGeometry (x, y, w, h, adjust);
FWidget::setGeometry (pos, size, adjust);
if ( ! isVirtualWindow() )
return;
if ( getWidth() != old_width || getHeight() != old_height )
if ( getSize() != old_size )
{
FRect geometry = getTermGeometry();
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() )
{
@ -676,7 +671,7 @@ bool FWindow::zoomWindow()
// save the current geometry
normalGeometry = getGeometry();
FRect oldGeometry = getTermGeometryWithShadow();
setGeometry (1, 1, getMaxWidth(), getMaxHeight());
setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()));
restoreVTerm (oldGeometry);
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()
, old_bottom = getShadow().getY();
const FSize& old_shadow = getShadow();
FWidget::setShadowSize (size);
const FSize& new_shadow = getShadow();
FWidget::setShadowSize (right, bottom);
int new_right = getShadow().getX()
, new_bottom = getShadow().getY();
if ( isVirtualWindow()
&& (new_right != old_right || new_bottom != old_bottom) )
if ( isVirtualWindow() && (new_shadow != old_shadow) )
{
auto geometry = getTermGeometry();
geometry.move(-1, -1);
@ -796,7 +786,7 @@ void FWindow::adjustSize()
FWidget::adjustSize();
if ( zoomed )
setGeometry (1, 1, getMaxWidth(), getMaxHeight(), false);
setGeometry (FPoint(1, 1), FSize(getMaxWidth(), getMaxHeight()), false);
else if ( isVirtualWindow() )
{
if ( getX() != old_x )

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -42,7 +42,7 @@ namespace fc
#pragma pack(push)
#pragma pack(1)
class emptyFString
class emptyFString final
{
public:
// Constructors

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -144,7 +144,6 @@ class FButton : public FWidget
// Methods
void init();
uChar getHotkey();
void setHotkeyAccelerator();
void detectHotkey();
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;
protected:
// Accessor
uChar getHotkey();
// Mutator
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 *
* *
* Copyright 2018 Markus Gans *
* Copyright 2018-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 *
@ -47,7 +47,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FColorPalette
class FColorPalette final
{
public:
// Constructor

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -76,8 +76,6 @@ class FDialog : public FWindow
public:
// Using-declaration
using FWindow::setResizeable;
using FWindow::move;
using FWindow::setPos;
// Enumeration
enum DialogCode
@ -124,13 +122,13 @@ class FDialog : public FWindow
virtual void show() override;
virtual void hide() override;
int exec();
virtual void setPos (int, int, bool = true) override;
virtual void move (int, int) override;
virtual void setPos (const FPoint&, bool = true) override;
virtual void move (const FPoint&) override;
bool moveUp (int);
bool moveDown (int);
bool moveLeft (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 expandHeight (int);
bool reduceWidth (int);
@ -207,6 +205,7 @@ class FDialog : public FWindow
void moveSizeKey (FKeyEvent*);
void raiseActivateDialog();
void lowerActivateDialog();
bool isOutsideTerminal (const FPoint&);
bool isLowerRightResizeCorner (const mouseStates&);
void resizeMouseDown (const mouseStates&);
void resizeMouseUpMove (const mouseStates&, bool = false);

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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;
protected:
int id;
int id{0};
};
#pragma pack(pop)
@ -353,15 +353,22 @@ class FUserEvent : public FEvent // timer event
{
public:
FUserEvent() = default;
// Disable copy constructor
FUserEvent (const FUserEvent&) = delete;
FUserEvent (fc::events, int);
~FUserEvent();
// Disable assignment operator (=)
FUserEvent& operator = (const FUserEvent&) = delete;
int getUserId() const;
FDataPtr getData() const;
void setData (FDataPtr);
protected:
int uid;
int uid{0};
FDataPtr data_pointer{nullptr};
};

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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*
, const FString& = FString()
, const FString& = FString() );
// Friend function
friend const FString fileChooser ( FWidget*
, const FString&
, const FString&
, FFileDialog::DialogType);
protected:
// Method
@ -164,7 +169,7 @@ class FFileDialog : public FDialog
// Method
void init();
void widgetSettings (int, int);
void widgetSettings (const FPoint&);
void initCallbacks();
bool pattern_match (const char* const, char[]);
void clear();

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -56,7 +56,7 @@ class FApplication;
#pragma pack(push)
#pragma pack(1)
class FKeyboardCommand
class FKeyboardCommand final
{
public:
// Constructor
@ -81,7 +81,7 @@ class FKeyboardCommand
#pragma pack(push)
#pragma pack(1)
class FKeyboard
class FKeyboard final
{
public:
// Constants

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -143,7 +143,6 @@ class FLabel : public FWidget
// Methods
void init();
uChar getHotkey();
std::size_t getHotkeyPos (wchar_t[], wchar_t[], std::size_t);
void setHotkeyAccelerator();
std::size_t getAlignOffset (std::size_t);

View File

@ -3,7 +3,7 @@
* *
* 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 *
* 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 showNoBrackets (std::size_t);
void showNoBrackets (listBoxItems::iterator);
virtual void setGeometry ( int, int
, std::size_t, std::size_t
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void setMultiSelection (bool);
void setMultiSelection ();
@ -211,6 +210,11 @@ class FListBox : public FWidget
template <typename Container, typename LazyConverter>
void insert (Container, LazyConverter);
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>
void insert ( const ItemT&
, fc::brackets_type = fc::NoBrackets
@ -238,6 +242,7 @@ class FListBox : public FWidget
private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FListBox::*FListBoxCallback)(FWidget*, FDataPtr);
// Enumeration
enum convert_type
@ -250,8 +255,15 @@ class FListBox : public FWidget
// Accessors
static FString& getString (listBoxItems::iterator);
// Inquiry
bool isHorizontallyScrollable();
bool isVerticallyScrollable();
// Methods
void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FListBoxCallback );
virtual void draw() override;
void drawHeadline();
void drawList();
@ -489,6 +501,22 @@ void FListBox::insert (Container container, LazyConverter convert)
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>
void FListBox::insert ( const ItemT& item
@ -502,6 +530,14 @@ void FListBox::insert ( const ItemT& item
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 \
FListBox::index2iterator (std::size_t index)

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -172,6 +172,7 @@ class FMenuItem : public FWidget
// Methods
void init (FWidget*);
uChar hotKey();
void updateSuperMenuDimensions();
void processActivate();
void processDeactivate();
void createDialogList (FMenu*);

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -75,7 +75,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FOptiMove
class FOptiMove final
{
public:
// Typedef

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -64,8 +64,8 @@ class FPoint
FPoint& operator += (const FPoint&);
FPoint& operator -= (const FPoint&);
friend bool operator == (const FPoint&, const FPoint&);
friend bool operator != (const FPoint&, const FPoint&);
friend bool operator == (const FPoint&, const FPoint&);
friend bool operator != (const FPoint&, const FPoint&);
friend FPoint operator + (const FPoint&, const FPoint&);
friend FPoint operator - (const FPoint&, const FPoint&);
friend FPoint operator - (const FPoint&);
@ -78,10 +78,11 @@ class FPoint
int getY() const;
void setX (int);
void setY (int);
void setPoint (const FPoint&);
void setPoint (int, int);
// Inquiry
bool isNull() const;
bool isOrigin() const;
// Point references
int& x_ref();
@ -140,6 +141,10 @@ inline int FPoint::getX() const
inline int FPoint::getY() const
{ return ypos; }
//----------------------------------------------------------------------
inline void FPoint::setPoint (const FPoint& p)
{ setPoint(p.xpos, p.ypos); }
//----------------------------------------------------------------------
inline int& FPoint::x_ref()
{ return xpos; }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -82,9 +82,8 @@ class FProgressbar : public FWidget
// Mutators
void setPercentage (std::size_t);
virtual void setGeometry ( int, int
, std::size_t, std::size_t
, bool = true) override;
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setShadow (bool);
bool setShadow();
bool unsetShadow();
@ -102,8 +101,10 @@ class FProgressbar : public FWidget
// Methods
virtual void draw() override;
void drawPercentage();
void drawBar();
void drawProgressLabel();
void drawProgressBar();
std::size_t drawProgressIndicator();
void drawProgressBackground (std::size_t);
// Data Members
std::size_t percentage{NOT_SET};

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -85,7 +85,7 @@ class FScrollbar : public FWidget
// Constructors
explicit FScrollbar (FWidget* = nullptr);
explicit FScrollbar (int = fc::vertical, FWidget* = nullptr);
explicit FScrollbar (fc::orientation = fc::vertical, FWidget* = nullptr);
// Disable copy constructor
FScrollbar (const FScrollbar&) = delete;
@ -108,10 +108,9 @@ class FScrollbar : public FWidget
void setValue (int);
void setSteps (double);
void setPageSize (int, int);
void setOrientation (int);
virtual void setGeometry ( int, int
, std::size_t, std::size_t
, bool = true) override;
void setOrientation (fc::orientation);
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
// Methods
virtual void resize() override;
@ -143,24 +142,24 @@ class FScrollbar : public FWidget
void processScroll();
// Data Members
sType scroll_type{FScrollbar::noScroll};
bool threshold_reached{false};
int threshold_time{500};
int repeat_time{10};
int slider_click_pos{-1};
int slider_click_stop_pos{-1};
int current_slider_pos{-1};
int slider_pos{0};
std::size_t slider_length{18}; // = bar_length
std::size_t bar_length{18}; // = length - 2
int val{0};
int min{0};
int max{99};
double steps{1};
int pagesize{0};
std::size_t length{20};
int bar_orientation{fc::vertical};
int max_color{getMaxColor()};
sType scroll_type{FScrollbar::noScroll};
bool threshold_reached{false};
int threshold_time{500};
int repeat_time{10};
int slider_click_pos{-1};
int slider_click_stop_pos{-1};
int current_slider_pos{-1};
int slider_pos{0};
std::size_t slider_length{18}; // = bar_length
std::size_t bar_length{18}; // = length - 2
int val{0};
int min{0};
int max{99};
double steps{1};
int pagesize{0};
std::size_t length{20};
fc::orientation bar_orientation{fc::vertical};
int max_color{getMaxColor()};
};
#pragma pack(pop)

View File

@ -73,8 +73,6 @@ class FScrollView : public FWidget
public:
// Using-declaration
using FWidget::setGeometry;
using FWidget::setPrintPos;
using FWidget::setPos;
// Constructor
explicit FScrollView (FWidget* = nullptr);
@ -92,8 +90,10 @@ class FScrollView : public FWidget
virtual const char* getClassName() const override;
std::size_t getViewportWidth() const;
std::size_t getViewportHeight() const;
const FSize getViewportSize();
std::size_t getScrollWidth() const;
std::size_t getScrollHeight() const;
const FSize getScrollSize() const;
const FPoint getScrollPos() const;
int getScrollX() const;
int getScrollY() const;
@ -101,18 +101,17 @@ class FScrollView : public FWidget
// Mutator
virtual void setScrollWidth (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 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 setHeight (std::size_t, bool = true) override;
virtual void setSize (std::size_t, std::size_t, bool = true) override;
virtual void setGeometry ( int, int
, std::size_t, std::size_t
virtual void setSize (const FSize&, bool = true) override;
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void setCursorPos (int, int);
void setPrintPos (int, int);
void setCursorPos (const FPoint&);
void setPrintPos (const FPoint&);
bool setViewportPrint (bool);
bool setViewportPrint();
bool unsetViewportPrint();
@ -156,6 +155,7 @@ class FScrollView : public FWidget
private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FScrollView::*FScrollViewCallback)(FWidget*, FDataPtr);
// Constants
static constexpr int vertical_border_spacing = 2;
@ -166,15 +166,13 @@ class FScrollView : public FWidget
// Methods
void init (FWidget*);
void init_scrollbar();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FScrollViewCallback );
void calculateScrollbarPos();
void setHorizontalScrollBarVisibility();
void setVerticalScrollBarVisibility();
void setViewportCursor();
void redrawHBar();
void redrawVBar();
void drawHBar();
void drawVBar();
// Callback methods
void cb_VBarChange (FWidget*, FDataPtr);
@ -209,6 +207,10 @@ inline std::size_t FScrollView::getViewportWidth() const
inline std::size_t FScrollView::getViewportHeight() const
{ return getHeight() - horizontal_border_spacing; }
//----------------------------------------------------------------------
inline const FSize FScrollView::getViewportSize()
{ return FSize(getViewportWidth(), getViewportHeight()); }
//----------------------------------------------------------------------
inline std::size_t FScrollView::getScrollWidth() const
{ return scroll_geometry.getWidth(); }
@ -217,6 +219,10 @@ inline std::size_t FScrollView::getScrollWidth() const
inline std::size_t FScrollView::getScrollHeight() const
{ return scroll_geometry.getHeight(); }
//----------------------------------------------------------------------
inline const FSize FScrollView::getScrollSize() const
{ return scroll_geometry.getSize(); }
//----------------------------------------------------------------------
inline const FPoint FScrollView::getScrollPos() const
{ 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(1)
class FTerm
class FTerm final
{
public:
// Typedefs
@ -224,6 +224,7 @@ class FTerm
static bool hasShadowCharacter();
static bool hasHalfBlockCharacter();
static bool hasAlternateScreen();
static bool canChangeColorPalette();
// Mutators
static void setTermType (const char[]);
@ -246,7 +247,7 @@ class FTerm
static char* enableCursor();
static char* disableCursor();
static void detectTermSize();
static void setTermSize (std::size_t, std::size_t);
static void setTermSize (const FSize&);
static void setTermTitle (const FString&);
static void setKDECursor (fc::kdeKonsoleCursorShape);
static void saveColorMap();
@ -364,7 +365,6 @@ class FTerm
static void init_tab_quirks();
static void init_captureFontAndTitle();
static bool hasNoFontSettingOption();
static bool canChangeColorPalette();
static void redefineColorPalette();
static void restoreColorPalette();
static void setInsertCursorStyle();

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -67,6 +67,8 @@ class FTermBuffer
// Overloaded operators
template <typename type>
FTermBuffer& operator << (const type&);
FTermBuffer& operator << (const FColorPair&);
// Non-member operators
friend std::vector<charData>& operator << ( std::vector<charData>&
, const FTermBuffer& );
@ -82,7 +84,8 @@ class FTermBuffer
void clear();
int writef (const FString, ...);
int write (const FString&);
int write (int);
int write (wchar_t);
void write (const FColorPair&);
FTermBuffer& write ();
std::vector<charData> getBuffer();
@ -104,6 +107,13 @@ inline FTermBuffer& FTermBuffer::operator << (const type& s)
return *this;
}
//----------------------------------------------------------------------
inline FTermBuffer& FTermBuffer::operator << (const FColorPair& pair)
{
write (pair);
return *this;
}
//----------------------------------------------------------------------
inline const char* FTermBuffer::getClassName() const
{ return "FTermBuffer"; }

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -51,7 +51,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermcapQuirks
class FTermcapQuirks final
{
public:
// Constructors
@ -85,6 +85,7 @@ class FTermcapQuirks
static void sunConsole();
static void screen();
static void general();
static void ecma48();
// Data Members
static FTermcap::tcap_map* tcap;

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -43,7 +43,7 @@ namespace finalcut
// class FTermDebugData
//----------------------------------------------------------------------
class FTermDebugData
class FTermDebugData final
{
public:
// Constructors

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -57,7 +57,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermDetection
class FTermDetection final
{
public:
// Typedefs

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -56,7 +56,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermFreeBSD
class FTermFreeBSD final
{
public:
// Typedef

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -50,7 +50,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermios
class FTermios final
{
public:
// Constructors

View File

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

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -52,7 +52,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermOpenBSD
class FTermOpenBSD final
{
public:
// Constructors

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -50,7 +50,7 @@ namespace finalcut
#pragma pack(push)
#pragma pack(1)
class FTermXTerminal
class FTermXTerminal final
{
public:
// Constructors
@ -65,7 +65,7 @@ class FTermXTerminal
static void setCursorStyle (fc::xtermCursorStyle);
static void setFont (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 setBackground (const FString&);
static void setCursorColor (const FString&);
@ -126,6 +126,7 @@ class FTermXTerminal
static void resetXTermMouseForeground();
static void resetXTermMouseBackground();
static void resetXTermHighlightBackground();
static bool canResetColor();
static void oscPrefix();
static void oscPostfix();
static const FString* captureXTermFont();

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -97,8 +97,7 @@ class FTextView : public FWidget
const FStringList& getLines() const;
// Mutators
virtual void setGeometry ( int, int
, std::size_t, std::size_t
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void setText (const FString&);
void scrollToX (int);
@ -109,7 +108,11 @@ class FTextView : public FWidget
// Methods
virtual void hide() override;
template<typename T>
void append (const std::initializer_list<T>&);
void append (const FString&);
template<typename T>
void insert (const std::initializer_list<T>&, int);
void insert (const FString&, int);
void replaceRange (const FString&, int, int);
void deleteRange (int, int);
@ -132,6 +135,7 @@ class FTextView : public FWidget
private:
// Typedef
typedef std::shared_ptr<FScrollbar> FScrollbarPtr;
typedef void (FTextView::*FTextViewCallback)(FWidget*, FDataPtr);
// Accessors
std::size_t getTextHeight();
@ -143,11 +147,12 @@ class FTextView : public FWidget
// Methods
void init();
void initScrollbar ( FScrollbarPtr&
, fc::orientation
, FTextViewCallback );
virtual void draw() override;
void drawText();
void processChanged();
void drawHBar();
void drawVBar();
// Callback methods
void cb_VBarChange (FWidget*, FDataPtr);
@ -187,6 +192,25 @@ inline const FStringList& FTextView::getLines() const
inline void FTextView::scrollTo (const FPoint& pos)
{ 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)
{ replaceRange (FString(), from, to); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* modify it under the terms of the GNU Lesser General Public License *
@ -91,9 +91,8 @@ class FToggleButton : public FWidget
FString& getText();
// Mutators
virtual void setGeometry ( int, int
, std::size_t, std::size_t
, bool = true) override;
virtual void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setNoUnderline (bool);
bool setNoUnderline();
bool unsetNoUnderline();
@ -125,7 +124,6 @@ class FToggleButton : public FWidget
protected:
// Accessor
uChar getHotkey();
FButtonGroup* getGroup() const;
// Mutator

View File

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

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