commit
54e4dec4a2
4
.github/workflows/codeql-analysis.yml
vendored
4
.github/workflows/codeql-analysis.yml
vendored
@ -7,10 +7,10 @@ name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches: [main]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [master]
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 7 * * 2'
|
||||
|
||||
|
33
.travis.yml
33
.travis.yml
@ -67,7 +67,7 @@ jobs:
|
||||
notification_email: guru.mail@muenster.de
|
||||
build_command_prepend: "autoreconf -v --install --force && ./configure --prefix=/usr CPPFLAGS='-DDEBUG' CXXFLAGS='-g -O0 -DDEBUG -DUNIT_TEST' --with-unit-test && make clean"
|
||||
build_command: "make V=1 -j10"
|
||||
branch_pattern: master
|
||||
branch_pattern: main
|
||||
before_install:
|
||||
- lsb_release -a
|
||||
- uname -a
|
||||
@ -154,3 +154,34 @@ jobs:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
||||
#
|
||||
# FreeBSD
|
||||
#
|
||||
- os: freebsd
|
||||
env:
|
||||
- TEST="FreeBSD"
|
||||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
- sudo pkg install -y autoconf-archive
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
||||
#
|
||||
# Linux ARM64 build
|
||||
#
|
||||
- arch: arm64
|
||||
os: linux
|
||||
env:
|
||||
- TEST="ARM64"
|
||||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
- make -j10
|
||||
|
||||
|
85
ChangeLog
85
ChangeLog
@ -1,10 +1,91 @@
|
||||
2019-11-14 Markus Gans <guru.mail@muenster.de>
|
||||
2021-05-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Some pointers were replaced by references
|
||||
|
||||
2021-05-04 Markus Gans <guru.mail@muenster.de>
|
||||
* Prevent flickering when resizing terminals or redrawing
|
||||
the screen via ctrl-l
|
||||
|
||||
2021-05-02 Markus Gans <guru.mail@muenster.de>
|
||||
* Bugfix for sending multiple SIGWINCH signals from
|
||||
gnome-terminal under Wayland
|
||||
|
||||
2021-05-01 Markus Gans <guru.mail@muenster.de>
|
||||
* Replace some std::bind with lambda functions
|
||||
|
||||
2021-04-30 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes Linux console bug from February 20, 2021
|
||||
|
||||
2021-04-27 Markus Gans <guru.mail@muenster.de>
|
||||
* Code optimization at widget focus
|
||||
|
||||
2021-04-24 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixed mutex deadlock in FLogger
|
||||
|
||||
2021-04-21 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixes the detection of the terminal size after a SIGWINCH signal
|
||||
|
||||
2021-04-18 Markus Gans <guru.mail@muenster.de>
|
||||
* Decoupling the FWidget and FWindow classes from FVTerm
|
||||
* Avoid redrawing widgets when show() is called multiple times
|
||||
* Readjustment of the root widget when the terminal size is changed
|
||||
|
||||
2021-04-11 Markus Gans <guru.mail@muenster.de>
|
||||
* Better support for kitty terminals
|
||||
|
||||
2021-03-31 Markus Gans <guru.mail@muenster.de>
|
||||
* argv is now stored internally as a std::vector container
|
||||
|
||||
2021-03-30 Markus Gans <guru.mail@muenster.de>
|
||||
* Stops terminal refresh during dialog resizing until all
|
||||
child widgets have been redrawn
|
||||
|
||||
2021-03-28 Markus Gans <guru.mail@muenster.de>
|
||||
* Widget now have the virtual method initLayout() to set
|
||||
the widget layouts automatically before the first drawing
|
||||
on the terminal is done. Also texts in full-width characters,
|
||||
whose character width is determined automatically, should be
|
||||
calculated here.
|
||||
|
||||
2021-03-15 Markus Gans <guru.mail@muenster.de>
|
||||
* Dynamic adjustment of the terminal refresh rate between
|
||||
5 and 60 Hz
|
||||
|
||||
2021-03-09 Markus Gans <guru.mail@muenster.de>
|
||||
* Implementation of an own padding print method for sending
|
||||
control codes to the terminal
|
||||
|
||||
2021-02-28 Markus Gans <guru.mail@muenster.de>
|
||||
* Removing the termcap library from the header files so
|
||||
that FINAL CUT programs are not affected by the preprocessor
|
||||
#define macros.
|
||||
Many thanks to Zhenyu Zhang for this optimization suggestion
|
||||
|
||||
2021-02-24 Markus Gans <guru.mail@muenster.de>
|
||||
* Fixed the incorrect display on terminals without
|
||||
UTF-8 character encoding
|
||||
|
||||
2021-02-20 Markus Gans <guru.mail@muenster.de>
|
||||
* Optimize terminal output buffer queue with differencing
|
||||
for strings, and control characters and control sequences
|
||||
|
||||
2021-02-09 Markus Gans <guru.mail@muenster.de>
|
||||
* Added support for combined unicode characters
|
||||
* Added a unit test for the FTermBuffer class
|
||||
* Added a unit test for the FTterm functions
|
||||
|
||||
2020-12-31 Markus Gans <guru.mail@muenster.de>
|
||||
* Refactoring to scoped enumerations
|
||||
|
||||
2020-11-18 Markus Gans <guru.mail@muenster.de>
|
||||
* The terminal update rate is now limited to 60 Hz
|
||||
|
||||
2020-11-14 Markus Gans <guru.mail@muenster.de>
|
||||
* Version 0.7.1
|
||||
* Bugfix: The cursor position was not changed anymore
|
||||
if there was no change to the content
|
||||
* Forcing a direct update for faster terminal output
|
||||
|
||||
2019-11-07 Markus Gans <guru.mail@muenster.de>
|
||||
2020-11-07 Markus Gans <guru.mail@muenster.de>
|
||||
* Version 0.7.0
|
||||
|
||||
2020-11-04 Markus Gans <guru.mail@muenster.de>
|
||||
|
103
Contributing.md
Normal file
103
Contributing.md
Normal file
@ -0,0 +1,103 @@
|
||||
# Contributing
|
||||
|
||||
Thank you for your interest in FINAL CUT!
|
||||
|
||||
We welcome contributions of all kinds, including patches to code and
|
||||
documentation, bug reports, or just neat feedback. If you ever think that
|
||||
something could be better or different, please give us feedback on it. Do
|
||||
you have problems with FINAL CUT, or are you looking for support in using
|
||||
the library in your project? Feel free to open a new issue if there is not
|
||||
already one on your topic. If you have problems with an application that
|
||||
uses FINAL CUT and have no idea of the cause, please contact the author
|
||||
first.
|
||||
|
||||
Github hosts the source code of FINAL CUT. You can make a local copy from
|
||||
the repository using git clone:
|
||||
|
||||
```bash
|
||||
> git clone git://github.com/gansm/finalcut.git
|
||||
```
|
||||
|
||||
|
||||
## Submitting patches
|
||||
|
||||
The FINAL CUT project accepts both
|
||||
[GitHub pull requests](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)
|
||||
and patches that reach me via other channels. GitHub pull requests are
|
||||
preferred. Please follow our [coding style](doc/coding-style.txt) standard.
|
||||
|
||||
|
||||
### Explain your work
|
||||
|
||||
When submitting a patch, you should include a description of the problem
|
||||
you are trying to solve, how you solved it, and why you chose the solution
|
||||
you implemented. When you submit a bug fix, it is often helpful to include
|
||||
a reproducible description for the problem in your explanation. Important
|
||||
would be instructions on how to test the error and verify its elimination.
|
||||
|
||||
|
||||
### Test your code
|
||||
|
||||
Run the FINAL CUT unit tests if you have installed
|
||||
[CppUnit](https://freedesktop.org/wiki/Software/cppunit/).
|
||||
Proceed as follows:
|
||||
|
||||
The easy way
|
||||
|
||||
```bash
|
||||
> make distclean
|
||||
> ./build.sh unit-test
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
> make distclean
|
||||
> ./configure --prefix=/usr CXXFLAGS="-g -O0 -DDEBUG -DUNIT_TEST" --with-unit-test
|
||||
> make test
|
||||
```
|
||||
|
||||
If you have created uncovered code, I would be very grateful for
|
||||
complementary test code in the existing unit tests.
|
||||
|
||||
|
||||
## Issue Tracking
|
||||
|
||||
We currently use the
|
||||
[issue tracker on Github](https://github.com/gansm/finalcut/issues).
|
||||
|
||||
|
||||
## How to help
|
||||
|
||||
### What FINAL CUT needs
|
||||
|
||||
* We want your feedback, your opinion, your advice, and to hear what you
|
||||
think!
|
||||
* Help make FINAL CUT better known. Tell others about this project. A large
|
||||
user base also means a better and more stable codebase.
|
||||
* Help maintain and improve the library.
|
||||
* Write unit tests for untested code.
|
||||
|
||||
### What would be helpful
|
||||
|
||||
* **Improve documentation:** <br />
|
||||
Fix typos or grammar mistakes. Revise sections that need improvement or
|
||||
add missing sections.
|
||||
* **Translations into other languages:** <br />
|
||||
For many people, reading the documentary in their native language will
|
||||
certainly make getting started with FINAL CUT much easier and more
|
||||
attractive.
|
||||
* **Better tests:** <br />
|
||||
High code coverage gives us a stable base that prevents breaking code due
|
||||
to a small patch.
|
||||
* **Publication in repositories:** <br />
|
||||
Advocate for the inclusion of FINAL CUT in your preferred distribution.
|
||||
* **Support for other platforms:** <br />
|
||||
There are still platforms on which FINAL CUT is not yet executable.
|
||||
* **Do you like to help other people?** <br />
|
||||
Answer questions in open issues or help moderate discussion forums or
|
||||
other communication channels.
|
||||
|
||||
Please help us make the FINAL CUT widget toolkit the best library for
|
||||
text-based user interfaces.
|
||||
|
@ -13,7 +13,7 @@ The structure of the Qt framework was originally the inspiration for the C++ cla
|
||||
| *Latest release* | [](https://github.com/gansm/finalcut/releases) |
|
||||
| *License* | [](COPYING) |
|
||||
| *Class Reference* | [](https://codedocs.xyz/gansm/finalcut/hierarchy.html) |
|
||||
| *Travis CI* | [](https://travis-ci.org/gansm/finalcut)
|
||||
| *Travis CI* | [](https://travis-ci.org/gansm/finalcut)
|
||||
| *Coverity Scan* | [](https://scan.coverity.com/projects/6508 )|
|
||||
| *LGTM* | [](https://lgtm.com/projects/g/gansm/finalcut/context:cpp) |
|
||||
| *SonarCloud* | [](https://sonarcloud.io/dashboard?id=gansm_finalcut) |
|
||||
|
2
build.sh
2
build.sh
@ -43,7 +43,7 @@ fi
|
||||
# Build commands
|
||||
case "$1" in
|
||||
"--release"|"release")
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O2" # "-O3 -fno-rtti"
|
||||
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-fno-rtti"
|
||||
then
|
||||
echo "${RED}Configure failed!${NORMAL}" 1>&2
|
||||
exit 255
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([finalcut], [0.7.1])
|
||||
AC_INIT([finalcut], [0.7.2])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
AX_PREFIX_CONFIG_H([src/include/final/fconfig.h], [F])
|
||||
AC_CONFIG_SRCDIR([src/fobject.cpp])
|
||||
@ -64,7 +64,7 @@ LT_OUTPUT
|
||||
### This defines the version number of the installed .so files
|
||||
### Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
|
||||
### using libtool's versioning system.
|
||||
AC_SUBST(SO_VERSION, ["7:1:7"])
|
||||
AC_SUBST(SO_VERSION, ["7:2:7"])
|
||||
|
||||
AC_SUBST([LIBTOOL_DEPS])
|
||||
|
||||
@ -123,7 +123,6 @@ else
|
||||
AM_CONDITIONAL(CPPUNIT_TEST, [test "1" = "0"])
|
||||
fi
|
||||
|
||||
|
||||
# code coverage
|
||||
AC_ARG_WITH([gcov],
|
||||
[AS_HELP_STRING([--with-gcov], [build for code coverage testing])],
|
||||
|
2
debian/libfinal0.shlibs
vendored
2
debian/libfinal0.shlibs
vendored
@ -1 +1 @@
|
||||
libfinal 0 libfinal0 (>= 0.7.1)
|
||||
libfinal 0 libfinal0 (>= 0.7.2)
|
||||
|
7580
debian/libfinal0.symbols
vendored
7580
debian/libfinal0.symbols
vendored
File diff suppressed because it is too large
Load Diff
@ -330,32 +330,32 @@ types and send them to other objects and widgets.
|
||||
|
||||
### Available event types ###
|
||||
```cpp
|
||||
enum events
|
||||
enum class Event
|
||||
{
|
||||
None_Event, // invalid event
|
||||
KeyPress_Event, // key pressed
|
||||
KeyUp_Event, // key released
|
||||
KeyDown_Event, // key pressed
|
||||
MouseDown_Event, // mouse button pressed
|
||||
MouseUp_Event, // mouse button released
|
||||
MouseDoubleClick_Event, // mouse button double click
|
||||
MouseWheel_Event, // mouse wheel rolled
|
||||
MouseMove_Event, // mouse move
|
||||
FocusIn_Event, // focus in
|
||||
FocusOut_Event, // focus out
|
||||
ChildFocusIn_Event, // child focus in
|
||||
ChildFocusOut_Event, // child focus out
|
||||
WindowActive_Event, // activate window
|
||||
WindowInactive_Event, // deactivate window
|
||||
WindowRaised_Event, // raise window
|
||||
WindowLowered_Event, // lower window
|
||||
Accelerator_Event, // keyboard accelerator
|
||||
Resize_Event, // terminal resize
|
||||
Show_Event, // widget is shown
|
||||
Hide_Event, // widget is hidden
|
||||
Close_Event, // widget close
|
||||
Timer_Event, // timer event occur
|
||||
User_Event // user defined event
|
||||
None, // invalid event
|
||||
KeyPress, // key pressed
|
||||
KeyUp, // key released
|
||||
KeyDown, // key pressed
|
||||
MouseDown, // mouse button pressed
|
||||
MouseUp, // mouse button released
|
||||
MouseDoubleClick, // mouse button double click
|
||||
MouseWheel, // mouse wheel rolled
|
||||
MouseMove, // mouse move
|
||||
FocusIn, // focus in
|
||||
FocusOut, // focus out
|
||||
ChildFocusIn, // child focus in
|
||||
ChildFocusOut, // child focus out
|
||||
WindowActive, // activate window
|
||||
WindowInactive, // deactivate window
|
||||
WindowRaised, // raise window
|
||||
WindowLowered, // lower window
|
||||
Accelerator, // keyboard accelerator
|
||||
Resize, // terminal resize
|
||||
Show, // widget is shown
|
||||
Hide, // widget is hidden
|
||||
Close, // widget close
|
||||
Timer, // timer event occur
|
||||
User // user defined event
|
||||
};
|
||||
```
|
||||
|
||||
@ -378,15 +378,20 @@ class dialogWidget : public FDialog
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{25, 5}, FSize{23, 4});
|
||||
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
|
||||
label.setAlignment (fc::alignRight);
|
||||
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
|
||||
label.setAlignment (Align::Right);
|
||||
id = addTimer(100);
|
||||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{25, 5}, FSize{23, 4});
|
||||
label.setGeometry (FPoint{1, 1}, FSize{10, 1});
|
||||
value.setGeometry (FPoint{11, 1}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void onTimer (FTimerEvent* ev) override
|
||||
{
|
||||
if ( id == ev->getTimerId() && n < 9999999999 )
|
||||
@ -475,7 +480,7 @@ class extendedApplication : public FApplication
|
||||
|| last_avg[1] != load_avg[1]
|
||||
|| last_avg[2] != load_avg[2] )
|
||||
{
|
||||
FUserEvent user_event(fc::User_Event, 0);
|
||||
FUserEvent user_event(Event::User, 0);
|
||||
user_event.setData (load_avg);
|
||||
FApplication::sendEvent (getMainWidget(), &user_event);
|
||||
}
|
||||
@ -495,12 +500,16 @@ class dialogWidget final : public FDialog
|
||||
public:
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{"User event", parent}
|
||||
{ }
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{40, 6});
|
||||
loadavg_label.setGeometry (FPoint{2, 2}, FSize{36, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
private:
|
||||
void onUserEvent (FUserEvent* ev) override
|
||||
{
|
||||
const auto& lavg = ev->getData<LoadAvg>();
|
||||
@ -891,10 +900,6 @@ class dialogWidget : public FDialog
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Callback method");
|
||||
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
|
||||
(
|
||||
@ -906,6 +911,14 @@ class dialogWidget : public FDialog
|
||||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Callback method");
|
||||
setGeometry (FPoint{25, 5}, FSize{25, 7});
|
||||
button.setGeometry (FPoint{7, 3}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
FButton button{"&Quit", this};
|
||||
};
|
||||
|
||||
@ -954,14 +967,8 @@ class dialogWidget : public FDialog
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setGeometry (FPoint{25, 5}, FSize{22, 7});
|
||||
setText ("Emit signal");
|
||||
const FSize size{5, 1};
|
||||
label.setGeometry (FPoint{8, 1}, size);
|
||||
label.setAlignment (fc::alignRight);
|
||||
label.setForegroundColor (fc::Black);
|
||||
plus.setGeometry (FPoint{3, 3}, size);
|
||||
minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
|
||||
label.setAlignment (Align::Right);
|
||||
label.setForegroundColor (FColor::Black);
|
||||
plus.setNoUnderline();
|
||||
minus.setNoUnderline();
|
||||
|
||||
@ -976,6 +983,17 @@ class dialogWidget : public FDialog
|
||||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setGeometry (FPoint{25, 5}, FSize{22, 7});
|
||||
setText ("Emit signal");
|
||||
const FSize size{5, 1};
|
||||
label.setGeometry (FPoint{8, 1}, size);
|
||||
plus.setGeometry (FPoint{3, 3}, size);
|
||||
minus.setGeometry (FPoint{3, 3} + FPoint{10, 0}, size);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_plus()
|
||||
{
|
||||
if ( t < 100 )
|
||||
@ -1004,17 +1022,17 @@ class dialogWidget : public FDialog
|
||||
|
||||
void cb_set_blue()
|
||||
{
|
||||
label.setForegroundColor (fc::Blue);
|
||||
label.setForegroundColor (FColor::Blue);
|
||||
}
|
||||
|
||||
void cb_set_black()
|
||||
{
|
||||
label.setForegroundColor (fc::Black);
|
||||
label.setForegroundColor (FColor::Black);
|
||||
}
|
||||
|
||||
void cb_set_red()
|
||||
{
|
||||
label.setForegroundColor (fc::Red);
|
||||
label.setForegroundColor (FColor::Red);
|
||||
}
|
||||
|
||||
void setTemperature()
|
||||
@ -1291,9 +1309,9 @@ class dialogWidget : public FDialog
|
||||
FDialog::draw();
|
||||
|
||||
print() << FPoint{3, 3}
|
||||
<< FColorPair{fc::Black, fc::White}
|
||||
<< FColorPair{FColor::Black, FColor::White}
|
||||
<< "Text on "
|
||||
<< FColorPair{fc::Blue, fc::Yellow}
|
||||
<< FColorPair{FColor::Blue, FColor::Yellow}
|
||||
<< "top";
|
||||
}
|
||||
|
||||
@ -1337,15 +1355,15 @@ requires it. You can controll this behavior by the two methods
|
||||
`setHorizontalScrollBarMode()` and `setVerticalScrollBarMode()`.
|
||||
|
||||
```cpp
|
||||
setHorizontalScrollBarMode (fc::scrollBarMode);
|
||||
setVerticalScrollBarMode (fc::scrollBarMode);
|
||||
setHorizontalScrollBarMode (finalcut::ScrollBarMode);
|
||||
setVerticalScrollBarMode (finalcut::ScrollBarMode);
|
||||
```
|
||||
|
||||
You pass the scroll bar visibility mode as a value of the enum type
|
||||
`fc::scrollBarMode`.
|
||||
`finalcut::ScrollBarMode`.
|
||||
|
||||
```cpp
|
||||
enum scrollBarMode
|
||||
enum class ScrollBarMode
|
||||
{
|
||||
Auto = 0, // Shows a scroll bar when area is larger than viewport
|
||||
Hidden = 1, // Never shows a scroll bar
|
||||
@ -1375,17 +1393,15 @@ class dialogWidget : public FDialog
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{parent}
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{28, 2}, FSize{24, 21});
|
||||
scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11});
|
||||
scrollview.setScrollSize(FSize{60, 27});
|
||||
// Attention: getColorTheme() requires an initialized terminal
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->label_inactive_fg, wc->dialog_bg);
|
||||
scrollview.clearArea();
|
||||
FColorPair red (fc::LightRed, wc->dialog_bg);
|
||||
FColorPair black (fc::Black, wc->dialog_bg);
|
||||
FColorPair cyan (fc::Cyan, wc->dialog_bg);
|
||||
FColorPair red (FColor::LightRed, wc->dialog_bg);
|
||||
FColorPair black (FColor::Black, wc->dialog_bg);
|
||||
FColorPair cyan (FColor::Cyan, wc->dialog_bg);
|
||||
|
||||
static std::vector<direction> d
|
||||
{
|
||||
@ -1420,6 +1436,13 @@ class dialogWidget : public FDialog
|
||||
private:
|
||||
typedef std::tuple<FString, FPoint, FPoint, FColorPair> direction;
|
||||
|
||||
void initLayout()
|
||||
{
|
||||
setText ("Dialog");
|
||||
setGeometry (FPoint{28, 2}, FSize{24, 21});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_button (const FPoint& p)
|
||||
{
|
||||
scrollview.scrollTo(p);
|
||||
|
@ -75,92 +75,92 @@ class BeeColorTheme final : public finalcut::FWidgetColors
|
||||
|
||||
void setColorTheme() override
|
||||
{
|
||||
term_fg = finalcut::fc::Black;
|
||||
term_bg = finalcut::fc::LightBlue;
|
||||
list_fg = finalcut::fc::Black;
|
||||
list_bg = finalcut::fc::LightGray;
|
||||
selected_list_fg = finalcut::fc::LightRed;
|
||||
selected_list_bg = finalcut::fc::LightGray;
|
||||
dialog_fg = finalcut::fc::Black;
|
||||
dialog_resize_fg = finalcut::fc::Red;
|
||||
dialog_emphasis_fg = finalcut::fc::Blue;
|
||||
dialog_bg = finalcut::fc::LightGray;
|
||||
error_box_fg = finalcut::fc::Black;
|
||||
error_box_emphasis_fg = finalcut::fc::Red;
|
||||
error_box_bg = finalcut::fc::Yellow;
|
||||
tooltip_fg = finalcut::fc::Black;
|
||||
tooltip_bg = finalcut::fc::Yellow;
|
||||
shadow_fg = finalcut::fc::Black;
|
||||
shadow_bg = finalcut::fc::LightGray;
|
||||
current_element_focus_fg = finalcut::fc::White;
|
||||
current_element_focus_bg = finalcut::fc::Green;
|
||||
current_element_fg = finalcut::fc::LightGray;
|
||||
current_element_bg = finalcut::fc::DarkGray;
|
||||
current_inc_search_element_fg = finalcut::fc::Brown;
|
||||
selected_current_element_focus_fg = finalcut::fc::LightRed;
|
||||
selected_current_element_focus_bg = finalcut::fc::Green;
|
||||
selected_current_element_fg = finalcut::fc::LightRed;
|
||||
selected_current_element_bg = finalcut::fc::DarkGray;
|
||||
label_fg = finalcut::fc::Black;
|
||||
label_bg = finalcut::fc::LightGray;
|
||||
label_inactive_fg = finalcut::fc::LightGray;
|
||||
label_inactive_bg = finalcut::fc::DarkGray;
|
||||
label_hotkey_fg = finalcut::fc::Red;
|
||||
label_hotkey_bg = finalcut::fc::LightGray;
|
||||
label_emphasis_fg = finalcut::fc::Blue;
|
||||
label_ellipsis_fg = finalcut::fc::DarkGray;
|
||||
inputfield_active_focus_fg = finalcut::fc::LightGray;
|
||||
inputfield_active_focus_bg = finalcut::fc::Green;
|
||||
inputfield_active_fg = finalcut::fc::Black;
|
||||
inputfield_active_bg = finalcut::fc::Cyan ;
|
||||
inputfield_inactive_fg = finalcut::fc::Black;
|
||||
inputfield_inactive_bg = finalcut::fc::LightGray;
|
||||
toggle_button_active_focus_fg = finalcut::fc::White;
|
||||
toggle_button_active_focus_bg = finalcut::fc::Green;
|
||||
toggle_button_active_fg = finalcut::fc::Black;
|
||||
toggle_button_active_bg = finalcut::fc::LightGray;
|
||||
toggle_button_inactive_fg = finalcut::fc::DarkGray;
|
||||
toggle_button_inactive_bg = finalcut::fc::LightGray;
|
||||
button_active_focus_fg = finalcut::fc::White;
|
||||
button_active_focus_bg = finalcut::fc::Green;
|
||||
button_active_fg = finalcut::fc::Black;
|
||||
button_active_bg = finalcut::fc::Cyan;
|
||||
button_inactive_fg = finalcut::fc::Cyan;
|
||||
button_inactive_bg = finalcut::fc::LightGray;
|
||||
button_hotkey_fg = finalcut::fc::Red;
|
||||
titlebar_active_fg = finalcut::fc::White;
|
||||
titlebar_active_bg = finalcut::fc::Blue;
|
||||
titlebar_inactive_fg = finalcut::fc::LightGray;
|
||||
titlebar_inactive_bg = finalcut::fc::DarkGray;
|
||||
titlebar_button_fg = finalcut::fc::Black;
|
||||
titlebar_button_bg = finalcut::fc::LightGray;
|
||||
titlebar_button_focus_fg = finalcut::fc::LightGray;
|
||||
titlebar_button_focus_bg = finalcut::fc::Black;
|
||||
menu_active_focus_fg = finalcut::fc::White;
|
||||
menu_active_focus_bg = finalcut::fc::Blue;
|
||||
menu_active_fg = finalcut::fc::Black;
|
||||
menu_active_bg = finalcut::fc::Yellow;
|
||||
menu_inactive_fg = finalcut::fc::Cyan;
|
||||
menu_inactive_bg = finalcut::fc::Yellow;
|
||||
menu_hotkey_fg = finalcut::fc::Red;
|
||||
menu_hotkey_bg = finalcut::fc::Yellow;
|
||||
statusbar_fg = finalcut::fc::White;
|
||||
statusbar_bg = finalcut::fc::DarkGray;
|
||||
statusbar_hotkey_fg = finalcut::fc::LightRed;
|
||||
statusbar_hotkey_bg = finalcut::fc::DarkGray;
|
||||
statusbar_separator_fg = finalcut::fc::Black;
|
||||
statusbar_active_fg = finalcut::fc::White;
|
||||
statusbar_active_bg = finalcut::fc::Green;
|
||||
statusbar_active_hotkey_fg = finalcut::fc::LightRed;
|
||||
statusbar_active_hotkey_bg = finalcut::fc::Green;
|
||||
scrollbar_fg = finalcut::fc::Black;
|
||||
scrollbar_bg = finalcut::fc::Green;
|
||||
scrollbar_button_fg = finalcut::fc::Black;
|
||||
scrollbar_button_bg = finalcut::fc::Green;
|
||||
scrollbar_button_inactive_fg = finalcut::fc::Cyan;
|
||||
scrollbar_button_inactive_bg = finalcut::fc::LightGray;
|
||||
progressbar_fg = finalcut::fc::Green;
|
||||
progressbar_bg = finalcut::fc::DarkGray;
|
||||
term_fg = finalcut::FColor::Black;
|
||||
term_bg = finalcut::FColor::LightBlue;
|
||||
list_fg = finalcut::FColor::Black;
|
||||
list_bg = finalcut::FColor::LightGray;
|
||||
selected_list_fg = finalcut::FColor::LightRed;
|
||||
selected_list_bg = finalcut::FColor::LightGray;
|
||||
dialog_fg = finalcut::FColor::Black;
|
||||
dialog_resize_fg = finalcut::FColor::Red;
|
||||
dialog_emphasis_fg = finalcut::FColor::Blue;
|
||||
dialog_bg = finalcut::FColor::LightGray;
|
||||
error_box_fg = finalcut::FColor::Black;
|
||||
error_box_emphasis_fg = finalcut::FColor::Red;
|
||||
error_box_bg = finalcut::FColor::Yellow;
|
||||
tooltip_fg = finalcut::FColor::Black;
|
||||
tooltip_bg = finalcut::FColor::Yellow;
|
||||
shadow_fg = finalcut::FColor::Black;
|
||||
shadow_bg = finalcut::FColor::LightGray;
|
||||
current_element_focus_fg = finalcut::FColor::White;
|
||||
current_element_focus_bg = finalcut::FColor::Green;
|
||||
current_element_fg = finalcut::FColor::LightGray;
|
||||
current_element_bg = finalcut::FColor::DarkGray;
|
||||
current_inc_search_element_fg = finalcut::FColor::Brown;
|
||||
selected_current_element_focus_fg = finalcut::FColor::LightRed;
|
||||
selected_current_element_focus_bg = finalcut::FColor::Green;
|
||||
selected_current_element_fg = finalcut::FColor::LightRed;
|
||||
selected_current_element_bg = finalcut::FColor::DarkGray;
|
||||
label_fg = finalcut::FColor::Black;
|
||||
label_bg = finalcut::FColor::LightGray;
|
||||
label_inactive_fg = finalcut::FColor::LightGray;
|
||||
label_inactive_bg = finalcut::FColor::DarkGray;
|
||||
label_hotkey_fg = finalcut::FColor::Red;
|
||||
label_hotkey_bg = finalcut::FColor::LightGray;
|
||||
label_emphasis_fg = finalcut::FColor::Blue;
|
||||
label_ellipsis_fg = finalcut::FColor::DarkGray;
|
||||
inputfield_active_focus_fg = finalcut::FColor::LightGray;
|
||||
inputfield_active_focus_bg = finalcut::FColor::Green;
|
||||
inputfield_active_fg = finalcut::FColor::Black;
|
||||
inputfield_active_bg = finalcut::FColor::Cyan ;
|
||||
inputfield_inactive_fg = finalcut::FColor::Black;
|
||||
inputfield_inactive_bg = finalcut::FColor::LightGray;
|
||||
toggle_button_active_focus_fg = finalcut::FColor::White;
|
||||
toggle_button_active_focus_bg = finalcut::FColor::Green;
|
||||
toggle_button_active_fg = finalcut::FColor::Black;
|
||||
toggle_button_active_bg = finalcut::FColor::LightGray;
|
||||
toggle_button_inactive_fg = finalcut::FColor::DarkGray;
|
||||
toggle_button_inactive_bg = finalcut::FColor::LightGray;
|
||||
button_active_focus_fg = finalcut::FColor::White;
|
||||
button_active_focus_bg = finalcut::FColor::Green;
|
||||
button_active_fg = finalcut::FColor::Black;
|
||||
button_active_bg = finalcut::FColor::Cyan;
|
||||
button_inactive_fg = finalcut::FColor::Cyan;
|
||||
button_inactive_bg = finalcut::FColor::LightGray;
|
||||
button_hotkey_fg = finalcut::FColor::Red;
|
||||
titlebar_active_fg = finalcut::FColor::White;
|
||||
titlebar_active_bg = finalcut::FColor::Blue;
|
||||
titlebar_inactive_fg = finalcut::FColor::LightGray;
|
||||
titlebar_inactive_bg = finalcut::FColor::DarkGray;
|
||||
titlebar_button_fg = finalcut::FColor::Black;
|
||||
titlebar_button_bg = finalcut::FColor::LightGray;
|
||||
titlebar_button_focus_fg = finalcut::FColor::LightGray;
|
||||
titlebar_button_focus_bg = finalcut::FColor::Black;
|
||||
menu_active_focus_fg = finalcut::FColor::White;
|
||||
menu_active_focus_bg = finalcut::FColor::Blue;
|
||||
menu_active_fg = finalcut::FColor::Black;
|
||||
menu_active_bg = finalcut::FColor::Yellow;
|
||||
menu_inactive_fg = finalcut::FColor::Cyan;
|
||||
menu_inactive_bg = finalcut::FColor::Yellow;
|
||||
menu_hotkey_fg = finalcut::FColor::Red;
|
||||
menu_hotkey_bg = finalcut::FColor::Yellow;
|
||||
statusbar_fg = finalcut::FColor::White;
|
||||
statusbar_bg = finalcut::FColor::DarkGray;
|
||||
statusbar_hotkey_fg = finalcut::FColor::LightRed;
|
||||
statusbar_hotkey_bg = finalcut::FColor::DarkGray;
|
||||
statusbar_separator_fg = finalcut::FColor::Black;
|
||||
statusbar_active_fg = finalcut::FColor::White;
|
||||
statusbar_active_bg = finalcut::FColor::Green;
|
||||
statusbar_active_hotkey_fg = finalcut::FColor::LightRed;
|
||||
statusbar_active_hotkey_bg = finalcut::FColor::Green;
|
||||
scrollbar_fg = finalcut::FColor::Black;
|
||||
scrollbar_bg = finalcut::FColor::Green;
|
||||
scrollbar_button_fg = finalcut::FColor::Black;
|
||||
scrollbar_button_bg = finalcut::FColor::Green;
|
||||
scrollbar_button_inactive_fg = finalcut::FColor::Cyan;
|
||||
scrollbar_button_inactive_bg = finalcut::FColor::LightGray;
|
||||
progressbar_fg = finalcut::FColor::Green;
|
||||
progressbar_bg = finalcut::FColor::DarkGray;
|
||||
}
|
||||
};
|
||||
|
||||
@ -175,24 +175,24 @@ FINAL CUT has four color tables for the 16 standard colors in the terminal.
|
||||
These are a redefinition of the 16 ANSI colors. You can address the colors
|
||||
via indexes values from 0 to 15. They correspond to the following colors:
|
||||
|
||||
| Index | Color name |
|
||||
|:------:|:---------------------------|
|
||||
| 0 | finalcut::fc::Black |
|
||||
| 1 | finalcut::fc::Blue |
|
||||
| 2 | finalcut::fc::Green |
|
||||
| 3 | finalcut::fc::Cyan |
|
||||
| 4 | finalcut::fc::Red |
|
||||
| 5 | finalcut::fc::Magenta |
|
||||
| 6 | finalcut::fc::Brown |
|
||||
| 7 | finalcut::fc::LightGray |
|
||||
| 8 | finalcut::fc::DarkGray |
|
||||
| 9 | finalcut::fc::LightBlue |
|
||||
| 10 | finalcut::fc::LightGreen |
|
||||
| 11 | finalcut::fc::LightCyan |
|
||||
| 12 | finalcut::fc::LightRed |
|
||||
| 13 | finalcut::fc::LightMagenta |
|
||||
| 14 | finalcut::fc::Yellow |
|
||||
| 15 | finalcut::fc::White |
|
||||
| Index | Color name |
|
||||
|:------:|:-------------------------------|
|
||||
| 0 | finalcut::FColor::Black |
|
||||
| 1 | finalcut::FColor::Blue |
|
||||
| 2 | finalcut::FColor::Green |
|
||||
| 3 | finalcut::FColor::Cyan |
|
||||
| 4 | finalcut::FColor::Red |
|
||||
| 5 | finalcut::FColor::Magenta |
|
||||
| 6 | finalcut::FColor::Brown |
|
||||
| 7 | finalcut::FColor::LightGray |
|
||||
| 8 | finalcut::FColor::DarkGray |
|
||||
| 9 | finalcut::FColor::LightBlue |
|
||||
| 10 | finalcut::FColor::LightGreen |
|
||||
| 11 | finalcut::FColor::LightCyan |
|
||||
| 12 | finalcut::FColor::LightRed |
|
||||
| 13 | finalcut::FColor::LightMagenta |
|
||||
| 14 | finalcut::FColor::Yellow |
|
||||
| 15 | finalcut::FColor::White |
|
||||
|
||||
You can define your color as an 8-bit value based on its red, green, and
|
||||
blue components. To create a color palette, create a derived class of
|
||||
@ -306,22 +306,22 @@ class BeeColorPalette final : public finalcut::FColorPalette
|
||||
|
||||
void setColorPalette() override
|
||||
{
|
||||
setPalette (finalcut::fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (finalcut::fc::Blue, 0x23, 0x21, 0x2c);
|
||||
setPalette (finalcut::fc::Green, 0x26, 0x93, 0x7c);
|
||||
setPalette (finalcut::fc::Cyan, 0xcf, 0xb3, 0xa8);
|
||||
setPalette (finalcut::fc::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (finalcut::fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (finalcut::fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (finalcut::fc::LightGray, 0xff, 0xfb, 0xe4);
|
||||
setPalette (finalcut::fc::DarkGray, 0x3a, 0x36, 0x37);
|
||||
setPalette (finalcut::fc::LightBlue, 0xa5, 0xa5, 0xb1);
|
||||
setPalette (finalcut::fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (finalcut::fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (finalcut::fc::LightRed, 0xee, 0x44, 0x44);
|
||||
setPalette (finalcut::fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (finalcut::fc::Yellow, 0xf8, 0xef, 0xa6);
|
||||
setPalette (finalcut::fc::White, 0xff, 0xff, 0xff);
|
||||
setPalette (finalcut::FColor::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (finalcut::FColor::Blue, 0x23, 0x21, 0x2c);
|
||||
setPalette (finalcut::FColor::Green, 0x26, 0x93, 0x7c);
|
||||
setPalette (finalcut::FColor::Cyan, 0xcf, 0xb3, 0xa8);
|
||||
setPalette (finalcut::FColor::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (finalcut::FColor::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (finalcut::FColor::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (finalcut::FColor::LightGray, 0xff, 0xfb, 0xe4);
|
||||
setPalette (finalcut::FColor::DarkGray, 0x3a, 0x36, 0x37);
|
||||
setPalette (finalcut::FColor::LightBlue, 0xa5, 0xa5, 0xb1);
|
||||
setPalette (finalcut::FColor::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (finalcut::FColor::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (finalcut::FColor::LightRed, 0xee, 0x44, 0x44);
|
||||
setPalette (finalcut::FColor::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (finalcut::FColor::Yellow, 0xf8, 0xef, 0xa6);
|
||||
setPalette (finalcut::FColor::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
void resetColorPalette() override
|
||||
@ -361,20 +361,15 @@ class dialogWidget final : public FDialog
|
||||
explicit dialogWidget (FWidget* parent = nullptr)
|
||||
: FDialog{"Theming test application", parent}
|
||||
{
|
||||
FDialog::setGeometry (FPoint{15, 5}, FSize{50, 9});
|
||||
Input.setGeometry (FPoint{2, 2}, FSize{39, 1});
|
||||
Input.setLabelText("File name:");
|
||||
Input.setLabelOrientation(FLineEdit::label_above);
|
||||
Input.setLabelOrientation(FLineEdit::LabelOrientation::Above);
|
||||
Input.setStatusbarMessage("Enter a file name");
|
||||
Browse.setGeometry (FPoint{43, 2}, FSize{4, 1});
|
||||
Browse.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &dialogWidget::cb_FileBrowse
|
||||
);
|
||||
Apply.setGeometry (FPoint{24, 5}, FSize{10, 1});
|
||||
Apply.setStatusbarMessage("Apply settings");
|
||||
Quit.setGeometry (FPoint{37, 5}, FSize{10, 1});
|
||||
Quit.setStatusbarMessage("Exit the program");
|
||||
Quit.addCallback
|
||||
(
|
||||
@ -391,6 +386,16 @@ class dialogWidget final : public FDialog
|
||||
}
|
||||
|
||||
private:
|
||||
void initLayout()
|
||||
{
|
||||
setGeometry (FPoint{15, 5}, FSize{50, 9});
|
||||
Input.setGeometry (FPoint{2, 2}, FSize{39, 1});
|
||||
Browse.setGeometry (FPoint{43, 2}, FSize{4, 1});
|
||||
Apply.setGeometry (FPoint{24, 5}, FSize{10, 1});
|
||||
Quit.setGeometry (FPoint{37, 5}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
void cb_FileBrowse()
|
||||
{
|
||||
auto filename = FFileDialog::fileOpenChooser(this);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2020 Markus Gans *
|
||||
* Copyright 2012-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -26,13 +26,12 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class SegmentView
|
||||
//----------------------------------------------------------------------
|
||||
@ -44,8 +43,7 @@ class SegmentView final : public finalcut::FDialog
|
||||
explicit SegmentView (finalcut::FWidget* = nullptr);
|
||||
|
||||
private:
|
||||
// Typedef
|
||||
typedef struct
|
||||
struct sevenSegment
|
||||
{
|
||||
unsigned char a : 1;
|
||||
unsigned char b : 1;
|
||||
@ -55,12 +53,13 @@ class SegmentView final : public finalcut::FDialog
|
||||
unsigned char f : 1;
|
||||
unsigned char g : 1;
|
||||
unsigned char : 1; // padding bit
|
||||
} sevenSegment;
|
||||
};
|
||||
|
||||
// Methods
|
||||
void hexEncoding();
|
||||
void get7Segment (const wchar_t);
|
||||
void draw() override;
|
||||
void initLayout() override;
|
||||
|
||||
// Data members
|
||||
std::map<wchar_t, sevenSegment> code{};
|
||||
@ -73,26 +72,16 @@ class SegmentView final : public finalcut::FDialog
|
||||
SegmentView::SegmentView (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Seven-segment display");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{42, 15});
|
||||
|
||||
// Set encoding
|
||||
hexEncoding();
|
||||
|
||||
// Input field
|
||||
input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
||||
input.setLabelText (L"&Hex value");
|
||||
input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
|
||||
input.setLabelOrientation(finalcut::FLineEdit::label_above);
|
||||
input.setLabelOrientation(finalcut::FLineEdit::LabelOrientation::Above);
|
||||
input.setMaxLength(9);
|
||||
input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
|
||||
|
||||
// Exit button
|
||||
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
||||
|
||||
// Add some function callbacks
|
||||
input.addCallback
|
||||
(
|
||||
@ -200,12 +189,12 @@ void SegmentView::draw()
|
||||
finalcut::FTermBuffer left_space{};
|
||||
|
||||
FDialog::draw();
|
||||
setColor(fc::LightGray, fc::Black);
|
||||
setColor(FColor::LightGray, FColor::Black);
|
||||
finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
|
||||
|
||||
for (auto&& ch : input.getText().toUpper())
|
||||
{
|
||||
const FColorPair color{fc::LightRed, fc::Black};
|
||||
const FColorPair color{FColor::LightRed, FColor::Black};
|
||||
get7Segment(ch);
|
||||
|
||||
for (std::size_t i{0}; i < 3; i++)
|
||||
@ -223,6 +212,19 @@ void SegmentView::draw()
|
||||
<< FPoint {4, 10} << finalcut::FString{36, ' '};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SegmentView::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Seven-segment display");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{42, 15});
|
||||
// Input field
|
||||
input.setGeometry (FPoint(2, 2), FSize{12, 1});
|
||||
// Exit button
|
||||
exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -29,6 +29,7 @@
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColor;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -38,8 +39,8 @@ using finalcut::FSize;
|
||||
class Background final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Typedef
|
||||
typedef std::tuple<uChar, uChar, uChar> RGB;
|
||||
// Using-declaration
|
||||
using RGB = std::tuple<uChar, uChar, uChar>;
|
||||
|
||||
// Constructor
|
||||
explicit Background (finalcut::FWidget* = nullptr);
|
||||
@ -48,12 +49,15 @@ class Background final : public finalcut::FDialog
|
||||
Background (const Background&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Background();
|
||||
~Background() noexcept override;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Background& operator = (const Background&) = delete;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
|
||||
// Callback method
|
||||
void cb_changed();
|
||||
void cb_choice();
|
||||
@ -91,15 +95,8 @@ class Background final : public finalcut::FDialog
|
||||
Background::Background (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Background color palette");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{32, 12});
|
||||
|
||||
// Combobox
|
||||
color_choice.setGeometry (FPoint{2, 2}, FSize{18, 1});
|
||||
color_choice.setLabelOrientation (finalcut::FLineEdit::label_above);
|
||||
color_choice.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
color_choice.setLabelText ("Color choice");
|
||||
color_choice.unsetEditable();
|
||||
|
||||
@ -110,20 +107,17 @@ Background::Background (finalcut::FWidget* parent)
|
||||
}
|
||||
|
||||
// Spin boxes
|
||||
red.setGeometry (FPoint{2, 5}, FSize{7, 1});
|
||||
red.setLabelOrientation (finalcut::FLineEdit::label_above);
|
||||
red.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
red.setLabelText ("Red");
|
||||
red.setRange (0, 255);
|
||||
red.setValue (0x80);
|
||||
|
||||
green.setGeometry (FPoint{12, 5}, FSize{7, 1});
|
||||
green.setLabelOrientation (finalcut::FLineEdit::label_above);
|
||||
green.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
green.setLabelText ("Green");
|
||||
green.setRange (0, 255);
|
||||
green.setValue (0xa4);
|
||||
|
||||
blue.setGeometry (FPoint{22, 5}, FSize{7, 1});
|
||||
blue.setLabelOrientation (finalcut::FLineEdit::label_above);
|
||||
blue.setLabelOrientation (finalcut::FLineEdit::LabelOrientation::Above);
|
||||
blue.setLabelText ("Blue");
|
||||
blue.setRange (0, 255);
|
||||
blue.setValue (0xec);
|
||||
@ -131,15 +125,12 @@ Background::Background (finalcut::FWidget* parent)
|
||||
// Set the initial palette values
|
||||
if ( finalcut::FTerm::canChangeColorPalette() )
|
||||
{
|
||||
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
|
||||
finalcut::FTerm::setPalette ( FColor::LightMagenta
|
||||
, int(red.getValue())
|
||||
, int(green.getValue())
|
||||
, int(blue.getValue()) );
|
||||
}
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{19, 8}, FSize{10, 1});
|
||||
|
||||
// Add some function callbacks
|
||||
quit.addCallback
|
||||
(
|
||||
@ -169,8 +160,20 @@ Background::Background (finalcut::FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Background::~Background() // destructor
|
||||
{ }
|
||||
Background::~Background() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Background::initLayout()
|
||||
{
|
||||
FDialog::setText ("Background color palette");
|
||||
FDialog::setGeometry (FPoint{25, 5}, FSize{32, 12});
|
||||
color_choice.setGeometry (FPoint{2, 2}, FSize{18, 1});
|
||||
red.setGeometry (FPoint{2, 5}, FSize{7, 1});
|
||||
green.setGeometry (FPoint{12, 5}, FSize{7, 1});
|
||||
blue.setGeometry (FPoint{22, 5}, FSize{7, 1});
|
||||
quit.setGeometry(FPoint{19, 8}, FSize{10, 1}); // Quit button
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Background::cb_changed()
|
||||
@ -178,7 +181,7 @@ void Background::cb_changed()
|
||||
if ( ! finalcut::FTerm::canChangeColorPalette() )
|
||||
return;
|
||||
|
||||
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
|
||||
finalcut::FTerm::setPalette ( FColor::LightMagenta
|
||||
, int(red.getValue())
|
||||
, int(green.getValue())
|
||||
, int(blue.getValue()) );
|
||||
@ -199,7 +202,7 @@ void Background::cb_choice()
|
||||
red.setValue(r);
|
||||
green.setValue(g);
|
||||
blue.setValue(b);
|
||||
finalcut::FTerm::setPalette ( finalcut::fc::LightMagenta
|
||||
finalcut::FTerm::setPalette ( FColor::LightMagenta
|
||||
, int(red.getValue())
|
||||
, int(green.getValue())
|
||||
, int(blue.getValue()) );
|
||||
@ -220,7 +223,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
// The following lines require an initialized terminal
|
||||
if ( finalcut::FTerm::canChangeColorPalette() )
|
||||
app.setBackgroundColor(finalcut::fc::LightMagenta);
|
||||
app.setBackgroundColor(FColor::LightMagenta);
|
||||
|
||||
Background dialog(&app);
|
||||
finalcut::FWidget::setMainWidget(&dialog);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -35,6 +35,7 @@ class Dialog final : public finalcut::FDialog
|
||||
explicit Dialog (FWidget* parent = nullptr);
|
||||
|
||||
private:
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
@ -54,14 +55,9 @@ class Dialog final : public finalcut::FDialog
|
||||
Dialog::Dialog (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Dialog");
|
||||
finalcut::FDialog::setGeometry (FPoint{26, 5}, FSize{28, 10});
|
||||
seconds.setGeometry (FPoint{10, 2}, FSize{10, 1});
|
||||
seconds.setLabelText ("Seconds");
|
||||
seconds.setRange (0, 60);
|
||||
seconds.setValue (3);
|
||||
start.setGeometry (FPoint{2, 6}, FSize{10, 1});
|
||||
quit.setGeometry (FPoint{15, 6}, FSize{10, 1});
|
||||
|
||||
// Add button callbacks
|
||||
seconds.addCallback
|
||||
@ -85,6 +81,17 @@ Dialog::Dialog (FWidget* parent)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Dialog::initLayout()
|
||||
{
|
||||
FDialog::setText ("Dialog");
|
||||
FDialog::setGeometry (FPoint{26, 5}, FSize{28, 10});
|
||||
seconds.setGeometry (FPoint{10, 2}, FSize{10, 1});
|
||||
start.setGeometry (FPoint{2, 6}, FSize{10, 1});
|
||||
quit.setGeometry (FPoint{15, 6}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Dialog::adjustSize()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -31,11 +31,12 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using FKey = finalcut::FKey;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColorPair;
|
||||
|
||||
constexpr lDouble pi_value{3.141592653589793238L};
|
||||
|
||||
@ -76,9 +77,9 @@ void Button::setChecked (bool enable)
|
||||
|
||||
if ( checked )
|
||||
{
|
||||
setBackgroundColor(fc::Cyan);
|
||||
setFocusForegroundColor(fc::White);
|
||||
setFocusBackgroundColor(fc::Cyan);
|
||||
setBackgroundColor(FColor::Cyan);
|
||||
setFocusForegroundColor(FColor::White);
|
||||
setFocusBackgroundColor(FColor::Cyan);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,7 +98,7 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
const FKey key = ev->key();
|
||||
|
||||
// catch the enter key
|
||||
if ( key == fc::Fkey_return || key == fc::Fkey_enter )
|
||||
if ( key == FKey::Return || key == FKey::Enter )
|
||||
return;
|
||||
|
||||
finalcut::FButton::onKeyPress(ev);
|
||||
@ -111,20 +112,17 @@ void Button::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
class Calc final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit Calc (finalcut::FWidget* parent = nullptr);
|
||||
|
||||
// Destructor
|
||||
~Calc() override;
|
||||
~Calc() override = default;
|
||||
|
||||
private:
|
||||
// Typedef and Enumeration
|
||||
typedef std::function<void(lDouble&)> keyFunction; // Member function
|
||||
using keyFunction = std::function<void(lDouble&)>; // Member function
|
||||
|
||||
enum button
|
||||
enum class ButtonName
|
||||
{
|
||||
Sine,
|
||||
Cosine,
|
||||
@ -201,15 +199,16 @@ class Calc final : public finalcut::FDialog
|
||||
void sine (lDouble&);
|
||||
void cosine (lDouble&);
|
||||
void tangent (lDouble&);
|
||||
bool isDataEntryKey (int) const;
|
||||
bool isOperatorKey (int) const;
|
||||
bool isDataEntryKey (const ButtonName&) const;
|
||||
bool isOperatorKey (const ButtonName&) const;
|
||||
lDouble& getValue();
|
||||
void setDisplay (lDouble);
|
||||
void setInfixOperator (char);
|
||||
void clearInfixOperator();
|
||||
void calcInfixOperator();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
const wchar_t* getButtonText (const std::size_t) const;
|
||||
const wchar_t* getButtonText (const ButtonName&) const;
|
||||
void mapKeyFunctions();
|
||||
|
||||
// Event handlers
|
||||
@ -218,7 +217,14 @@ class Calc final : public finalcut::FDialog
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Callback method
|
||||
void cb_buttonClicked (Calc::button);
|
||||
void cb_buttonClicked (ButtonName);
|
||||
|
||||
// Overloaded operators
|
||||
friend bool operator < (const ButtonName& c, const int n) noexcept;
|
||||
friend bool operator <= (const ButtonName& c, const int n) noexcept;
|
||||
friend ButtonName operator + (const ButtonName& c, const int n) noexcept;
|
||||
friend ButtonName& operator ++ (ButtonName& c) noexcept; // prefix
|
||||
friend ButtonName operator ++ (ButtonName& c, int) noexcept; // postfix
|
||||
|
||||
// Data members
|
||||
bool error{false};
|
||||
@ -228,11 +234,11 @@ class Calc final : public finalcut::FDialog
|
||||
lDouble b{0.0L};
|
||||
lDouble infinity{std::numeric_limits<lDouble>::infinity()};
|
||||
uInt max_char{33};
|
||||
int last_key{-1};
|
||||
ButtonName last_key{ButtonName(-1)};
|
||||
char infix_operator{'\0'};
|
||||
char last_infix_operator{'\0'};
|
||||
finalcut::FString input{""};
|
||||
std::array<button, Calc::NUM_OF_BUTTONS> button_no{};
|
||||
std::array<ButtonName, std::size_t(ButtonName::NUM_OF_BUTTONS)> button_no{};
|
||||
|
||||
struct StackData
|
||||
{
|
||||
@ -241,43 +247,27 @@ class Calc final : public finalcut::FDialog
|
||||
};
|
||||
|
||||
std::stack<StackData> bracket_stack{};
|
||||
std::map<Calc::button, std::shared_ptr<Button> > calculator_buttons{};
|
||||
std::map<Calc::button, keyFunction> key_map{};
|
||||
std::map<ButtonName, std::shared_ptr<Button> > calculator_buttons{};
|
||||
std::map<ButtonName, keyFunction> key_map{};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Calc::Calc (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Calculator");
|
||||
FDialog::setGeometry (FPoint{19, 6}, FSize{37, 18});
|
||||
|
||||
mapKeyFunctions();
|
||||
clearInfixOperator();
|
||||
|
||||
for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
|
||||
for (ButtonName key{ButtonName::Sine}; key < ButtonName::NUM_OF_BUTTONS; key++)
|
||||
{
|
||||
auto btn = std::make_shared<Button>(this);
|
||||
button_no[key] = key;
|
||||
|
||||
if ( key == Equals )
|
||||
btn->setGeometry(FPoint{30, 15}, FSize{5, 3});
|
||||
else
|
||||
{
|
||||
const std::size_t n = ( key <= Three ) ? 0 : 1;
|
||||
const int x = int(key + n) % 5 * 7 + 2;
|
||||
const int y = int(key + n) / 5 * 2 + 3;
|
||||
btn->setGeometry(FPoint{x, y}, FSize{5, 1});
|
||||
}
|
||||
|
||||
auto index = std::size_t(key);
|
||||
button_no[index] = key;
|
||||
btn->setFlat();
|
||||
btn->setNoUnderline();
|
||||
btn->setText(getButtonText(key));
|
||||
btn->setDoubleFlatLine(fc::top);
|
||||
btn->setDoubleFlatLine(fc::bottom);
|
||||
btn->setDoubleFlatLine(finalcut::Side::Top);
|
||||
btn->setDoubleFlatLine(finalcut::Side::Bottom);
|
||||
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
btn->unsetClickAnimation();
|
||||
@ -286,75 +276,65 @@ Calc::Calc (FWidget* parent)
|
||||
(
|
||||
"clicked",
|
||||
this, &Calc::cb_buttonClicked,
|
||||
button_no[key]
|
||||
button_no[index]
|
||||
);
|
||||
|
||||
calculator_buttons[button(key)] = btn;
|
||||
calculator_buttons[ButtonName(key)] = btn;
|
||||
}
|
||||
|
||||
calculator_buttons[On]->addAccelerator(fc::Fkey_dc); // Del key
|
||||
calculator_buttons[On]->setFocus();
|
||||
calculator_buttons[Pi]->addAccelerator('p');
|
||||
calculator_buttons[Power]->addAccelerator('^');
|
||||
calculator_buttons[Divide]->addAccelerator('/');
|
||||
calculator_buttons[Powers_of_ten]->addAccelerator('d');
|
||||
calculator_buttons[Multiply]->addAccelerator('*');
|
||||
calculator_buttons[Decimal_point]->addAccelerator(',');
|
||||
calculator_buttons[Change_sign]->addAccelerator('#');
|
||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_return);
|
||||
calculator_buttons[Equals]->addAccelerator(fc::Fkey_enter);
|
||||
calculator_buttons[ButtonName::On]->addAccelerator(FKey::Del_char);
|
||||
calculator_buttons[ButtonName::On]->setFocus();
|
||||
calculator_buttons[ButtonName::Pi]->addAccelerator(FKey('p'));
|
||||
calculator_buttons[ButtonName::Power]->addAccelerator(FKey('^'));
|
||||
calculator_buttons[ButtonName::Divide]->addAccelerator(FKey('/'));
|
||||
calculator_buttons[ButtonName::Powers_of_ten]->addAccelerator(FKey('d'));
|
||||
calculator_buttons[ButtonName::Multiply]->addAccelerator(FKey('*'));
|
||||
calculator_buttons[ButtonName::Decimal_point]->addAccelerator(FKey(','));
|
||||
calculator_buttons[ButtonName::Change_sign]->addAccelerator(FKey('#'));
|
||||
calculator_buttons[ButtonName::Equals]->addAccelerator(FKey::Return);
|
||||
calculator_buttons[ButtonName::Equals]->addAccelerator(FKey::Enter);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Calc::~Calc()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const std::size_t len = input.getLength();
|
||||
const FKey key = ev->key();
|
||||
|
||||
switch ( key )
|
||||
if ( key == FKey::Erase || key == FKey::Backspace )
|
||||
{
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
if ( len > 0 )
|
||||
if ( len > 0 )
|
||||
{
|
||||
lDouble& x = getValue();
|
||||
|
||||
if ( len == 1 )
|
||||
{
|
||||
lDouble& x = getValue();
|
||||
|
||||
if ( len == 1 )
|
||||
{
|
||||
input = "";
|
||||
x = 0.0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
input = input.left(input.getLength() - 1);
|
||||
x = std::strtold(input.c_str(), nullptr);
|
||||
}
|
||||
|
||||
drawDispay();
|
||||
input = "";
|
||||
x = 0.0L;
|
||||
}
|
||||
else
|
||||
{
|
||||
input = input.left(input.getLength() - 1);
|
||||
x = std::strtold(input.c_str(), nullptr);
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
break;
|
||||
drawDispay();
|
||||
}
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
sendOnButtonAccelerator();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
close();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
finalcut::FDialog::onKeyPress(ev);
|
||||
break;
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
|
||||
{
|
||||
sendOnButtonAccelerator();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
finalcut::FDialog::onKeyPress(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -371,7 +351,7 @@ void Calc::onClose (finalcut::FCloseEvent* ev)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::cb_buttonClicked (Calc::button key)
|
||||
void Calc::cb_buttonClicked (ButtonName key)
|
||||
{
|
||||
lDouble& x = getValue();
|
||||
|
||||
@ -430,7 +410,7 @@ void Calc::drawDispay()
|
||||
setReverse(false);
|
||||
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FColorPair{fc::Black, fc::LightGray}
|
||||
print() << FColorPair{FColor::Black, FColor::LightGray}
|
||||
<< FPoint{3, 3} << display << ' '
|
||||
<< FColorPair{wc->dialog_fg, wc->dialog_bg};
|
||||
|
||||
@ -439,11 +419,11 @@ void Calc::drawDispay()
|
||||
|
||||
if ( finalcut::FTerm::isNewFont() )
|
||||
{
|
||||
const wchar_t bottom_line {fc::NF_border_line_bottom};
|
||||
const wchar_t top_bottom_line {fc::NF_border_line_up_and_down};
|
||||
const wchar_t top_line {fc::NF_border_line_upper};
|
||||
const wchar_t right_line {fc::NF_rev_border_line_right};
|
||||
const wchar_t left_line {fc::NF_border_line_left};
|
||||
const auto bottom_line {finalcut::UniChar::NF_border_line_bottom};
|
||||
const auto top_bottom_line {finalcut::UniChar::NF_border_line_up_and_down};
|
||||
const auto top_line {finalcut::UniChar::NF_border_line_upper};
|
||||
const auto right_line {finalcut::UniChar::NF_rev_border_line_right};
|
||||
const auto left_line {finalcut::UniChar::NF_border_line_left};
|
||||
print() << FPoint{3, 2} << finalcut::FString{33, bottom_line};
|
||||
print() << FPoint{2, 3} << right_line;
|
||||
print() << FPoint{36, 3} << left_line;
|
||||
@ -458,9 +438,9 @@ void Calc::drawDispay()
|
||||
}
|
||||
else
|
||||
{
|
||||
const wchar_t vertical_and_right {fc::BoxDrawingsVerticalAndRight};
|
||||
const wchar_t horizontal {fc::BoxDrawingsHorizontal};
|
||||
const wchar_t vertical_and_left {fc::BoxDrawingsVerticalAndLeft};
|
||||
const auto vertical_and_right {finalcut::UniChar::BoxDrawingsVerticalAndRight};
|
||||
const auto horizontal {finalcut::UniChar::BoxDrawingsHorizontal};
|
||||
const auto vertical_and_left {finalcut::UniChar::BoxDrawingsVerticalAndLeft};
|
||||
finalcut::FString separator ( finalcut::FString{vertical_and_right}
|
||||
+ finalcut::FString{35, horizontal}
|
||||
+ finalcut::FString{vertical_and_left} );
|
||||
@ -471,8 +451,8 @@ void Calc::drawDispay()
|
||||
//----------------------------------------------------------------------
|
||||
inline void Calc::sendOnButtonAccelerator()
|
||||
{
|
||||
finalcut::FAccelEvent a_ev(fc::Accelerator_Event, getFocusWidget());
|
||||
calculator_buttons[On]->onAccel(&a_ev);
|
||||
finalcut::FAccelEvent a_ev(finalcut::Event::Accelerator, getFocusWidget());
|
||||
calculator_buttons[ButtonName::On]->onAccel(&a_ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -481,8 +461,8 @@ void Calc::clear (const lDouble&)
|
||||
error = false;
|
||||
arcus_mode = false;
|
||||
hyperbolic_mode = false;
|
||||
calculator_buttons[Arcus]->setChecked(false);
|
||||
calculator_buttons[Hyperbolic]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Arcus]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
|
||||
input = "";
|
||||
clearInfixOperator();
|
||||
last_infix_operator = '\0';
|
||||
@ -801,7 +781,7 @@ void Calc::square_root (lDouble& x)
|
||||
void Calc::hyperbolic (const lDouble& x)
|
||||
{
|
||||
hyperbolic_mode = ! hyperbolic_mode;
|
||||
calculator_buttons[Hyperbolic]->setChecked(hyperbolic_mode);
|
||||
calculator_buttons[ButtonName::Hyperbolic]->setChecked(hyperbolic_mode);
|
||||
setDisplay(x);
|
||||
}
|
||||
|
||||
@ -809,7 +789,7 @@ void Calc::hyperbolic (const lDouble& x)
|
||||
void Calc::arcus (const lDouble& x)
|
||||
{
|
||||
arcus_mode = ! arcus_mode;
|
||||
calculator_buttons[Arcus]->setChecked(arcus_mode);
|
||||
calculator_buttons[ButtonName::Arcus]->setChecked(arcus_mode);
|
||||
setDisplay(x);
|
||||
}
|
||||
|
||||
@ -847,8 +827,8 @@ void Calc::sine (lDouble& x)
|
||||
setDisplay(x);
|
||||
arcus_mode = false;
|
||||
hyperbolic_mode = false;
|
||||
calculator_buttons[Arcus]->setChecked(false);
|
||||
calculator_buttons[Hyperbolic]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Arcus]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -885,8 +865,8 @@ void Calc::cosine (lDouble& x)
|
||||
setDisplay(x);
|
||||
arcus_mode = false;
|
||||
hyperbolic_mode = false;
|
||||
calculator_buttons[Arcus]->setChecked(false);
|
||||
calculator_buttons[Hyperbolic]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Arcus]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -930,38 +910,38 @@ void Calc::tangent (lDouble& x)
|
||||
setDisplay(x);
|
||||
arcus_mode = false;
|
||||
hyperbolic_mode = false;
|
||||
calculator_buttons[Arcus]->setChecked(false);
|
||||
calculator_buttons[Hyperbolic]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Arcus]->setChecked(false);
|
||||
calculator_buttons[ButtonName::Hyperbolic]->setChecked(false);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::draw()
|
||||
{
|
||||
setBold();
|
||||
setColor (fc::LightBlue, fc::Cyan);
|
||||
clearArea (getVirtualDesktop(), fc::MediumShade);
|
||||
setColor (FColor::LightBlue, FColor::Cyan);
|
||||
clearArea (getVirtualDesktop(), wchar_t(finalcut::UniChar::MediumShade));
|
||||
unsetBold();
|
||||
finalcut::FDialog::draw();
|
||||
drawDispay();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool Calc::isDataEntryKey (int key) const
|
||||
bool Calc::isDataEntryKey (const ButtonName& key) const
|
||||
{
|
||||
// Test if key is in {'.', '0'..'9'}
|
||||
constexpr std::array<int, 11> key_list =
|
||||
constexpr std::array<ButtonName, 11> key_list =
|
||||
{{
|
||||
Decimal_point,
|
||||
Zero,
|
||||
One,
|
||||
Two,
|
||||
Three,
|
||||
Four,
|
||||
Five,
|
||||
Six,
|
||||
Seven,
|
||||
Eight,
|
||||
Nine
|
||||
ButtonName::Decimal_point,
|
||||
ButtonName::Zero,
|
||||
ButtonName::One,
|
||||
ButtonName::Two,
|
||||
ButtonName::Three,
|
||||
ButtonName::Four,
|
||||
ButtonName::Five,
|
||||
ButtonName::Six,
|
||||
ButtonName::Seven,
|
||||
ButtonName::Eight,
|
||||
ButtonName::Nine
|
||||
}};
|
||||
|
||||
const auto& iter = std::find (key_list.begin(), key_list.end(), key);
|
||||
@ -973,17 +953,17 @@ bool Calc::isDataEntryKey (int key) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool Calc::isOperatorKey(int key) const
|
||||
bool Calc::isOperatorKey(const ButtonName& key) const
|
||||
{
|
||||
// Test if key is in {'*', '/', '+', '-', '^', '='}
|
||||
constexpr std::array<int, 6> operators =
|
||||
constexpr std::array<ButtonName, 6> operators =
|
||||
{{
|
||||
Multiply,
|
||||
Divide,
|
||||
Add,
|
||||
Subtract,
|
||||
Power,
|
||||
Equals
|
||||
ButtonName::Multiply,
|
||||
ButtonName::Divide,
|
||||
ButtonName::Add,
|
||||
ButtonName::Subtract,
|
||||
ButtonName::Power,
|
||||
ButtonName::Equals
|
||||
}};
|
||||
|
||||
const auto& iter = std::find (operators.begin(), operators.end(), key);
|
||||
@ -1085,6 +1065,31 @@ void Calc::calcInfixOperator()
|
||||
clearInfixOperator();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Calculator");
|
||||
FDialog::setGeometry (FPoint{19, 6}, FSize{37, 18});
|
||||
|
||||
for (ButtonName key{ButtonName::Sine}; key < ButtonName::NUM_OF_BUTTONS; key++)
|
||||
{
|
||||
auto btn = calculator_buttons[ButtonName(key)];
|
||||
|
||||
if ( key == ButtonName::Equals )
|
||||
btn->setGeometry(FPoint{30, 15}, FSize{5, 3});
|
||||
else
|
||||
{
|
||||
const int n = ( key <= ButtonName::Three ) ? 0 : 1;
|
||||
const int x = (int(key) + n) % 5 * 7 + 2;
|
||||
const int y = (int(key) + n) / 5 * 2 + 3;
|
||||
btn->setGeometry(FPoint{x, y}, FSize{5, 1});
|
||||
}
|
||||
}
|
||||
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::adjustSize()
|
||||
{
|
||||
@ -1096,9 +1101,10 @@ void Calc::adjustSize()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const wchar_t* Calc::getButtonText (const std::size_t key) const
|
||||
const wchar_t* Calc::getButtonText (const ButtonName& key) const
|
||||
{
|
||||
constexpr std::array<const wchar_t*, Calc::NUM_OF_BUTTONS> button_text =
|
||||
constexpr auto num_of_buttons = std::size_t(ButtonName::NUM_OF_BUTTONS);
|
||||
constexpr std::array<const wchar_t*, num_of_buttons> button_text =
|
||||
{{
|
||||
L"&Sin",
|
||||
L"&Cos",
|
||||
@ -1136,47 +1142,81 @@ const wchar_t* Calc::getButtonText (const std::size_t key) const
|
||||
L"&="
|
||||
}};
|
||||
|
||||
return button_text[key];
|
||||
return button_text[std::size_t(key)];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Calc::mapKeyFunctions()
|
||||
{
|
||||
#define B(f) std::bind((f), this, std::placeholders::_1) // Bind macro
|
||||
key_map[Sine] = B(&Calc::sine); // sin
|
||||
key_map[Cosine] = B(&Calc::cosine); // cos
|
||||
key_map[Tangent] = B(&Calc::tangent); // tan
|
||||
key_map[Reciprocal] = B(&Calc::reciprocal); // 1/x
|
||||
key_map[On] = B(&Calc::clear); // On
|
||||
key_map[Natural_logarithm] = B(&Calc::log_e); // ln
|
||||
key_map[Powers_of_e] = B(&Calc::power_e); // eˣ
|
||||
key_map[Power] = B(&Calc::power); // yˣ
|
||||
key_map[Square_root] = B(&Calc::square_root); // sqrt
|
||||
key_map[Divide] = B(&Calc::divide); // ÷
|
||||
key_map[Common_logarithm] = B(&Calc::log_10); // lg
|
||||
key_map[Powers_of_ten] = B(&Calc::power_10); // 10ˣ
|
||||
key_map[Parenthese_l] = B(&Calc::open_bracket); // (
|
||||
key_map[Parenthese_r] = B(&Calc::close_bracket); // )
|
||||
key_map[Multiply] = B(&Calc::multiply); // *
|
||||
key_map[Hyperbolic] = B(&Calc::hyperbolic); // hyp
|
||||
key_map[Seven] = B(&Calc::seven); // 7
|
||||
key_map[Eight] = B(&Calc::eight); // 8
|
||||
key_map[Nine] = B(&Calc::nine); // 9
|
||||
key_map[Subtract] = B(&Calc::subtract); // -
|
||||
key_map[Arcus] = B(&Calc::arcus); // arc
|
||||
key_map[Four] = B(&Calc::four); // 4
|
||||
key_map[Five] = B(&Calc::five); // 5
|
||||
key_map[Six] = B(&Calc::six); // 6
|
||||
key_map[Add] = B(&Calc::add); // +
|
||||
key_map[Pi] = B(&Calc::pi); // π
|
||||
key_map[One] = B(&Calc::one); // 1
|
||||
key_map[Two] = B(&Calc::two); // 2
|
||||
key_map[Three] = B(&Calc::three); // 3
|
||||
key_map[Percent] = B(&Calc::percent); // %
|
||||
key_map[Zero] = B(&Calc::zero); // 0
|
||||
key_map[Decimal_point] = B(&Calc::radix_point); // .
|
||||
key_map[Change_sign] = B(&Calc::change_sign); // ±
|
||||
key_map[Equals] = B(&Calc::equals); // =
|
||||
key_map[ButtonName::Sine] = B(&Calc::sine); // sin
|
||||
key_map[ButtonName::Cosine] = B(&Calc::cosine); // cos
|
||||
key_map[ButtonName::Tangent] = B(&Calc::tangent); // tan
|
||||
key_map[ButtonName::Reciprocal] = B(&Calc::reciprocal); // 1/x
|
||||
key_map[ButtonName::On] = B(&Calc::clear); // On
|
||||
key_map[ButtonName::Natural_logarithm] = B(&Calc::log_e); // ln
|
||||
key_map[ButtonName::Powers_of_e] = B(&Calc::power_e); // eˣ
|
||||
key_map[ButtonName::Power] = B(&Calc::power); // yˣ
|
||||
key_map[ButtonName::Square_root] = B(&Calc::square_root); // sqrt
|
||||
key_map[ButtonName::Divide] = B(&Calc::divide); // ÷
|
||||
key_map[ButtonName::Common_logarithm] = B(&Calc::log_10); // lg
|
||||
key_map[ButtonName::Powers_of_ten] = B(&Calc::power_10); // 10ˣ
|
||||
key_map[ButtonName::Parenthese_l] = B(&Calc::open_bracket); // (
|
||||
key_map[ButtonName::Parenthese_r] = B(&Calc::close_bracket); // )
|
||||
key_map[ButtonName::Multiply] = B(&Calc::multiply); // *
|
||||
key_map[ButtonName::Hyperbolic] = B(&Calc::hyperbolic); // hyp
|
||||
key_map[ButtonName::Seven] = B(&Calc::seven); // 7
|
||||
key_map[ButtonName::Eight] = B(&Calc::eight); // 8
|
||||
key_map[ButtonName::Nine] = B(&Calc::nine); // 9
|
||||
key_map[ButtonName::Subtract] = B(&Calc::subtract); // -
|
||||
key_map[ButtonName::Arcus] = B(&Calc::arcus); // arc
|
||||
key_map[ButtonName::Four] = B(&Calc::four); // 4
|
||||
key_map[ButtonName::Five] = B(&Calc::five); // 5
|
||||
key_map[ButtonName::Six] = B(&Calc::six); // 6
|
||||
key_map[ButtonName::Add] = B(&Calc::add); // +
|
||||
key_map[ButtonName::Pi] = B(&Calc::pi); // π
|
||||
key_map[ButtonName::One] = B(&Calc::one); // 1
|
||||
key_map[ButtonName::Two] = B(&Calc::two); // 2
|
||||
key_map[ButtonName::Three] = B(&Calc::three); // 3
|
||||
key_map[ButtonName::Percent] = B(&Calc::percent); // %
|
||||
key_map[ButtonName::Zero] = B(&Calc::zero); // 0
|
||||
key_map[ButtonName::Decimal_point] = B(&Calc::radix_point); // .
|
||||
key_map[ButtonName::Change_sign] = B(&Calc::change_sign); // ±
|
||||
key_map[ButtonName::Equals] = B(&Calc::equals); // =
|
||||
}
|
||||
|
||||
// Overloaded operators
|
||||
//----------------------------------------------------------------------
|
||||
inline bool operator < (const Calc::ButtonName& c, const int n) noexcept
|
||||
{
|
||||
return int(c) < n;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool operator <= (const Calc::ButtonName& c, const int n) noexcept
|
||||
{
|
||||
return int(c) <= n;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline Calc::ButtonName operator + (const Calc::ButtonName& c, const int n) noexcept
|
||||
{
|
||||
return Calc::ButtonName(int(c) + n);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline Calc::ButtonName& operator ++ (Calc::ButtonName& c) noexcept // prefix
|
||||
{
|
||||
c = ( c < Calc::ButtonName::NUM_OF_BUTTONS ) ? Calc::ButtonName(int(c) + 1) : Calc::ButtonName::Equals;
|
||||
return c;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline Calc::ButtonName operator ++ (Calc::ButtonName& c, int) noexcept // postfix
|
||||
{
|
||||
Calc::ButtonName tmp = c;
|
||||
++c;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -28,7 +28,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FSize;
|
||||
@ -41,9 +40,6 @@ using finalcut::FSize;
|
||||
class CheckList final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit CheckList (finalcut::FWidget* = nullptr);
|
||||
|
||||
@ -51,7 +47,7 @@ class CheckList final : public finalcut::FDialog
|
||||
CheckList (const CheckList&) = delete;
|
||||
|
||||
// Destructor
|
||||
~CheckList() override;
|
||||
~CheckList() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
CheckList& operator = (const CheckList&) = delete;
|
||||
@ -59,6 +55,7 @@ class CheckList final : public finalcut::FDialog
|
||||
private:
|
||||
// Method
|
||||
void populate();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
@ -77,28 +74,20 @@ class CheckList final : public finalcut::FDialog
|
||||
CheckList::CheckList (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText (L"Shopping list");
|
||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||
FDialog::setSize (FSize{28 + nf_offset, 13} );
|
||||
setShadow(); // Instead of the transparent window shadow
|
||||
listview.ignorePadding();
|
||||
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
||||
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("Item");
|
||||
listview.addColumn ("Priority", 9);
|
||||
|
||||
// Set the type of sorting
|
||||
listview.setColumnSortType (1, fc::by_name);
|
||||
listview.setColumnSortType (2, fc::by_name);
|
||||
listview.setColumnSortType (1, finalcut::SortType::Name);
|
||||
listview.setColumnSortType (2, finalcut::SortType::Name);
|
||||
|
||||
// Statusbar at the bottom
|
||||
finalcut::FString separator{};
|
||||
separator << ' ' << fc::BoxDrawingsVertical << ' ';
|
||||
separator << ' ' << finalcut::UniChar::BoxDrawingsVertical << ' ';
|
||||
listview.setStatusbarMessage ( finalcut::FString{}
|
||||
<< "<Q> exit" << separator
|
||||
<< "<Space> select an item" << separator
|
||||
@ -115,10 +104,6 @@ CheckList::CheckList (finalcut::FWidget* parent)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
CheckList::~CheckList() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void CheckList::populate()
|
||||
{
|
||||
@ -145,6 +130,17 @@ void CheckList::populate()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void CheckList::initLayout()
|
||||
{
|
||||
FDialog::setText (L"Shopping list");
|
||||
const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0;
|
||||
FDialog::setSize (FSize{28 + nf_offset, 13} );
|
||||
listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
|
||||
, FSize{getWidth() - nf_offset, getHeight() - 1} );
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void CheckList::adjustSize()
|
||||
{
|
||||
@ -158,9 +154,9 @@ void CheckList::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q'
|
||||
|| ev->key() == fc::Fkey_escape
|
||||
|| ev->key() == fc::Fkey_escape_mintty )
|
||||
if ( ev->key() == finalcut::FKey('q')
|
||||
|| ev->key() == finalcut::FKey::Escape
|
||||
|| ev->key() == finalcut::FKey::Escape_mintty )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -183,7 +179,7 @@ void CheckList::cb_showList()
|
||||
for (auto item : listview.getData())
|
||||
{
|
||||
if ( item->isChecked() )
|
||||
shopping_list << fc::Bullet << ' ' << item->getText(1) << '\n';
|
||||
shopping_list << finalcut::UniChar::Bullet << ' ' << item->getText(1) << '\n';
|
||||
}
|
||||
|
||||
if ( shopping_list.isEmpty() )
|
||||
|
@ -27,8 +27,8 @@
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
// Typedef
|
||||
typedef std::shared_ptr<finalcut::FRadioButton> FRadioButtonPtr;
|
||||
// Using-declaration
|
||||
using FRadioButtonPtr = std::shared_ptr<finalcut::FRadioButton>;
|
||||
|
||||
// Function prototypes
|
||||
void cb_quit (finalcut::FDialog&);
|
||||
@ -128,7 +128,7 @@ int main (int argc, char* argv[])
|
||||
preset(os);
|
||||
|
||||
// Scroll to the focused child element
|
||||
finalcut::FFocusEvent cfi (finalcut::fc::ChildFocusIn_Event);
|
||||
finalcut::FFocusEvent cfi (finalcut::Event::ChildFocusIn);
|
||||
app.queueEvent(&checkButtonGroup, &cfi);
|
||||
|
||||
// Create a OK button
|
||||
|
@ -55,10 +55,10 @@ int main (int argc, char* argv[])
|
||||
finalcut::FLabel label_1{&dgl};
|
||||
finalcut::FLabel label_2{&dgl};
|
||||
|
||||
label_1 << finalcut::fc::BlackUpPointingTriangle
|
||||
label_1 << finalcut::UniChar::BlackUpPointingTriangle
|
||||
<< std::wstring{L"\n"}
|
||||
<< finalcut::fc::BoxDrawingsUpAndRight
|
||||
<< finalcut::FString{2, finalcut::fc::BoxDrawingsHorizontal}
|
||||
<< finalcut::UniChar::BoxDrawingsUpAndRight
|
||||
<< finalcut::FString{2, finalcut::UniChar::BoxDrawingsHorizontal}
|
||||
<< " Double click the title bar button,";
|
||||
label_2 << "press Q on the keyboard,\n"
|
||||
<< "or push the button below to exit\n"
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -41,9 +41,6 @@ class EventLog; // class forward declaration
|
||||
class EventDialog final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventDialog (finalcut::FWidget* = nullptr);
|
||||
|
||||
@ -51,14 +48,15 @@ class EventDialog final : public finalcut::FDialog
|
||||
EventDialog (const EventDialog&) = delete;
|
||||
|
||||
// Destructor
|
||||
~EventDialog() override;
|
||||
~EventDialog() noexcept override;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
EventDialog& operator = (const EventDialog&) = delete;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
finalcut::FString getMouseButtonName (int) const;
|
||||
void initLayout() override;
|
||||
finalcut::FString getMouseButtonName (const finalcut::MouseButton&) const;
|
||||
void logMouseEvent ( const finalcut::FString&
|
||||
, const finalcut::FMouseEvent& );
|
||||
|
||||
@ -85,37 +83,45 @@ class EventDialog final : public finalcut::FDialog
|
||||
EventDialog::EventDialog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event dialog");
|
||||
FDialog::setGeometry (FPoint{15, 2}, FSize{53, 12});
|
||||
setShadow();
|
||||
label.setText("\n\nUse the keyboard or mouse\n"
|
||||
"in this dialog to create events");
|
||||
label.setAlignment(finalcut::fc::alignCenter);
|
||||
label.setGeometry (FPoint(1, 1), getClientSize(), false);
|
||||
label.setAlignment(finalcut::Align::Center);
|
||||
addTimer(60000); // Starts the timer every minute
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventDialog::~EventDialog() // destructor
|
||||
{ }
|
||||
EventDialog::~EventDialog() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
finalcut::FString EventDialog::getMouseButtonName (int btn_state) const
|
||||
void EventDialog::initLayout()
|
||||
{
|
||||
switch ( btn_state )
|
||||
{
|
||||
case finalcut::fc::LeftButton:
|
||||
return "left";
|
||||
FDialog::setText ("Event dialog");
|
||||
FDialog::setGeometry (FPoint{15, 2}, FSize{53, 12});
|
||||
label.setGeometry (FPoint(1, 1), getClientSize(), false);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
case finalcut::fc::RightButton:
|
||||
return "right";
|
||||
//----------------------------------------------------------------------
|
||||
finalcut::FString EventDialog::getMouseButtonName (const finalcut::MouseButton& btn_state) const
|
||||
{
|
||||
const auto& empty = finalcut::fc::emptyFString::get();
|
||||
auto S = bool(btn_state & finalcut::MouseButton::Shift);
|
||||
auto C = bool(btn_state & finalcut::MouseButton::Control);
|
||||
auto M = bool(btn_state & finalcut::MouseButton::Meta);
|
||||
auto l = bool(btn_state & finalcut::MouseButton::Left);
|
||||
auto r = bool(btn_state & finalcut::MouseButton::Right);
|
||||
auto m = bool(btn_state & finalcut::MouseButton::Middle);
|
||||
auto prefix = (S ? finalcut::FString("Shift+") : empty)
|
||||
+ (C ? finalcut::FString("Control+") : empty)
|
||||
+ (M ? finalcut::FString("Meta+") : empty);
|
||||
|
||||
case finalcut::fc::MiddleButton:
|
||||
return "middle";
|
||||
}
|
||||
if ( l )
|
||||
return prefix + "left";
|
||||
else if ( r )
|
||||
return prefix + "right";
|
||||
else if ( m )
|
||||
return prefix + "middle";
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
@ -127,7 +133,7 @@ void EventDialog::logMouseEvent ( const finalcut::FString& state
|
||||
const int mouse_x = ev.getX();
|
||||
const int mouse_y = ev.getY();
|
||||
|
||||
log << finalcut::FLog::Info
|
||||
log << finalcut::FLog::LogLevel::Info
|
||||
<< getMouseButtonName(ev.getButton())
|
||||
<< " mouse button " << state << " at ("
|
||||
<< mouse_x << ", " << mouse_y << ")" << std::flush;
|
||||
@ -156,16 +162,16 @@ void EventDialog::onTimer (finalcut::FTimerEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const FKey key_id = ev->key();
|
||||
const finalcut::FKey key_id = ev->key();
|
||||
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
|
||||
|
||||
if ( key_name.isEmpty() )
|
||||
key_name = wchar_t(key_id);
|
||||
|
||||
// std::clog redirects all stream data to FLogger
|
||||
std::clog << finalcut::FLog::Info
|
||||
std::clog << finalcut::FLog::LogLevel::Info
|
||||
<< "Key " << key_name
|
||||
<< " (id " << key_id << ")" << std::flush;
|
||||
<< " (id " << uInt32(key_id) << ")" << std::flush;
|
||||
|
||||
finalcut::FDialog::onKeyPress(ev);
|
||||
}
|
||||
@ -235,9 +241,6 @@ void EventDialog::onWindowLowered (finalcut::FEvent* ev)
|
||||
class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit EventLog (finalcut::FWidget* = nullptr);
|
||||
|
||||
@ -245,7 +248,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
EventLog (const EventLog&) = delete;
|
||||
|
||||
// Destructor
|
||||
~EventLog() override;
|
||||
~EventLog() noexcept override;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
EventLog& operator = (const EventLog&) = delete;
|
||||
@ -256,6 +259,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
@ -267,34 +271,26 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
|
||||
EventLog::EventLog (finalcut::FWidget* parent)
|
||||
: FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Event log");
|
||||
FDialog::setGeometry (FPoint{4, 16}, FSize{75, 8});
|
||||
FDialog::setResizeable();
|
||||
setMinimumSize (FSize{75, 5});
|
||||
setShadow();
|
||||
scrolltext.ignorePadding();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
event_dialog->setFocus();
|
||||
addTimer(250); // Starts the timer every 250 milliseconds
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
EventLog::~EventLog() // destructor
|
||||
{ }
|
||||
EventLog::~EventLog() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::onTimer (finalcut::FTimerEvent*)
|
||||
{
|
||||
if ( ! str().empty() )
|
||||
{
|
||||
scrolltext.append(str());
|
||||
str("");
|
||||
scrolltext.scrollToEnd();
|
||||
redraw();
|
||||
}
|
||||
if ( str().empty() )
|
||||
return;
|
||||
|
||||
scrolltext.append(str());
|
||||
str("");
|
||||
scrolltext.scrollToEnd();
|
||||
redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -303,6 +299,16 @@ void EventLog::onClose (finalcut::FCloseEvent* ev)
|
||||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::initLayout()
|
||||
{
|
||||
FDialog::setText ("Event log");
|
||||
FDialog::setGeometry (FPoint{4, 16}, FSize{75, 8});
|
||||
FDialog::setResizeable();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void EventLog::adjustSize()
|
||||
{
|
||||
@ -324,7 +330,7 @@ int main (int argc, char* argv[])
|
||||
finalcut::FLog& log = *finalcut::FApplication::getLog();
|
||||
|
||||
// Set the line endings (default = CRLF)
|
||||
log.setLineEnding (finalcut::FLog::LF);
|
||||
log.setLineEnding (finalcut::FLog::LineEnding::LF);
|
||||
|
||||
// Write a timestamp before each output line
|
||||
log.enableTimestamp();
|
||||
|
@ -85,7 +85,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
// Create the status bar
|
||||
finalcut::FStatusBar sbar {&dgl};
|
||||
finalcut::FStatusKey key_F1 (finalcut::fc::Fkey_f1, "Info", &sbar);
|
||||
finalcut::FStatusKey key_F1 (finalcut::FKey::F1, "Info", &sbar);
|
||||
|
||||
// Create the menu bar
|
||||
finalcut::FMenuBar Menubar {&dgl};
|
||||
@ -101,7 +101,7 @@ int main (int argc, char* argv[])
|
||||
finalcut::FMenuItem Line{&File};
|
||||
Line.setSeparator();
|
||||
finalcut::FMenuItem Quit{"&Quit", &File};
|
||||
Quit.addAccelerator (finalcut::fc::Fckey_q); // Ctrl + Q
|
||||
Quit.addAccelerator (finalcut::FKey::Ctrl_q); // Ctrl + Q
|
||||
|
||||
// Callback lambda expressions
|
||||
auto cb_exit = \
|
||||
|
@ -76,7 +76,7 @@ int main (int argc, char* argv[])
|
||||
finalcut::FLineEdit c_field {&dgl};
|
||||
|
||||
// Set input type to password
|
||||
pw_field.setInputType (finalcut::FLineEdit::password);
|
||||
pw_field.setInputType (finalcut::FLineEdit::InputType::Password);
|
||||
|
||||
name_field.setLabelText (L"&Name");
|
||||
pw_field.setLabelText (L"&Password");
|
||||
|
@ -46,14 +46,14 @@ class Keyboard final : public finalcut::FWidget
|
||||
Keyboard::Keyboard (finalcut::FWidget* parent)
|
||||
: finalcut::FWidget{parent}
|
||||
{
|
||||
getColorTheme()->term_fg = finalcut::fc::Default;
|
||||
getColorTheme()->term_bg = finalcut::fc::Default;
|
||||
getColorTheme()->term_fg = finalcut::FColor::Default;
|
||||
getColorTheme()->term_bg = finalcut::FColor::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
{
|
||||
const FKey key_id = ev->key();
|
||||
const finalcut::FKey key_id = ev->key();
|
||||
finalcut::FString key_name = finalcut::FTerm::getKeyName(key_id);
|
||||
bool is_last_line{false};
|
||||
|
||||
@ -63,7 +63,7 @@ void Keyboard::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
is_last_line = true;
|
||||
|
||||
print() << "Key " << key_name << " (id " << key_id << ")\n";
|
||||
print() << "Key " << key_name << " (id " << uInt32(key_id) << ")\n";
|
||||
|
||||
if ( is_last_line )
|
||||
scrollAreaForward (getVirtualDesktop());
|
||||
@ -98,12 +98,12 @@ int main (int argc, char* argv[])
|
||||
|
||||
// Force terminal initialization without calling show()
|
||||
app.initTerminal();
|
||||
app.setForegroundColor(finalcut::fc::Default);
|
||||
app.setBackgroundColor(finalcut::fc::Default);
|
||||
app.setForegroundColor(finalcut::FColor::Default);
|
||||
app.setBackgroundColor(finalcut::FColor::Default);
|
||||
|
||||
// Create a keyboard object
|
||||
Keyboard key{&app};
|
||||
key.addAccelerator('q');
|
||||
key.addAccelerator(finalcut::FKey('q'));
|
||||
|
||||
// Set the keyboard object as main widget
|
||||
finalcut::FWidget::setMainWidget(&key);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -50,7 +50,7 @@ void doubleToItem ( FListBoxItem& item
|
||||
, FDataAccess* container
|
||||
, std::size_t index )
|
||||
{
|
||||
typedef std::list<double> DblList;
|
||||
using DblList = std::list<double>;
|
||||
DblList& dbl_list = flistboxhelper::getContainer<DblList>(container);
|
||||
std::list<double>::iterator iter = dbl_list.begin();
|
||||
std::advance (iter, index);
|
||||
@ -87,12 +87,15 @@ class Listbox final : public FDialog
|
||||
Listbox (const Listbox&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Listbox() override;
|
||||
~Listbox() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Listbox& operator = (const Listbox&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onClose (FCloseEvent*) override;
|
||||
|
||||
@ -113,7 +116,6 @@ Listbox::Listbox (FWidget* parent)
|
||||
|
||||
// listbox 1
|
||||
//----------
|
||||
list1.setGeometry(FPoint{2, 1}, FSize{18, 10});
|
||||
list1.setText ("FListBoxItem");
|
||||
|
||||
for (auto i{1}; i < 30; i++)
|
||||
@ -124,7 +126,6 @@ Listbox::Listbox (FWidget* parent)
|
||||
for (auto i{1}; i <= 15; i++)
|
||||
double_list.push_back(2 * double(i) + (double(i) / 100));
|
||||
|
||||
list2.setGeometry(FPoint{21, 1}, FSize{10, 10});
|
||||
list2.setText ("double");
|
||||
|
||||
//
|
||||
@ -147,11 +148,9 @@ Listbox::Listbox (FWidget* parent)
|
||||
TLD["gov"] = "Government";
|
||||
|
||||
list3.insert (TLD.begin(), TLD.end(), mapToString);
|
||||
list3.setGeometry(FPoint{32, 1}, FSize{21, 10});
|
||||
list3.setText ("key: value");
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Add quit button function callback
|
||||
@ -165,8 +164,14 @@ Listbox::Listbox (FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Listbox::~Listbox() // destructor
|
||||
{ }
|
||||
void Listbox::initLayout()
|
||||
{
|
||||
list1.setGeometry(FPoint{2, 1}, FSize{18, 10});
|
||||
list2.setGeometry(FPoint{21, 1}, FSize{10, 10});
|
||||
list3.setGeometry(FPoint{32, 1}, FSize{21, 10});
|
||||
quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listbox::onClose (FCloseEvent* ev)
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -28,7 +28,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -47,7 +46,7 @@ class Listview final : public finalcut::FDialog
|
||||
Listview (const Listview&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Listview() override;
|
||||
~Listview() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Listview& operator = (const Listview&) = delete;
|
||||
@ -55,6 +54,7 @@ class Listview final : public finalcut::FDialog
|
||||
private:
|
||||
// Method
|
||||
void populate();
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
@ -71,9 +71,6 @@ class Listview final : public finalcut::FDialog
|
||||
Listview::Listview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("City");
|
||||
listview.addColumn ("Condition");
|
||||
@ -82,19 +79,19 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||
listview.addColumn ("Pressure", 10);
|
||||
|
||||
// Set right alignment for the third, fourth, and fifth column
|
||||
listview.setColumnAlignment (3, fc::alignRight);
|
||||
listview.setColumnAlignment (4, fc::alignRight);
|
||||
listview.setColumnAlignment (5, fc::alignRight);
|
||||
listview.setColumnAlignment (3, finalcut::Align::Right);
|
||||
listview.setColumnAlignment (4, finalcut::Align::Right);
|
||||
listview.setColumnAlignment (5, finalcut::Align::Right);
|
||||
|
||||
// Set the type of sorting
|
||||
listview.setColumnSortType (1, fc::by_name);
|
||||
listview.setColumnSortType (2, fc::by_name);
|
||||
listview.setColumnSortType (3, fc::by_number);
|
||||
listview.setColumnSortType (4, fc::by_number);
|
||||
listview.setColumnSortType (5, fc::by_number);
|
||||
listview.setColumnSortType (1, finalcut::SortType::Name);
|
||||
listview.setColumnSortType (2, finalcut::SortType::Name);
|
||||
listview.setColumnSortType (3, finalcut::SortType::Number);
|
||||
listview.setColumnSortType (4, finalcut::SortType::Number);
|
||||
listview.setColumnSortType (5, finalcut::SortType::Number);
|
||||
|
||||
// Sort in ascending order by the 1st column
|
||||
listview.setColumnSort (1, fc::ascending);
|
||||
listview.setColumnSort (1, finalcut::SortOrder::Ascending);
|
||||
// Sorting follows later automatically on insert().
|
||||
// Otherwise you could start the sorting directly with sort()
|
||||
|
||||
@ -105,7 +102,6 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||
populate();
|
||||
|
||||
// Quit button
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Add some function callbacks
|
||||
@ -124,10 +120,6 @@ Listview::Listview (finalcut::FWidget* parent)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Listview::~Listview() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::populate()
|
||||
{
|
||||
@ -183,6 +175,16 @@ void Listview::populate()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::initLayout()
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Listview::onClose (finalcut::FCloseEvent* ev)
|
||||
{
|
||||
@ -198,9 +200,9 @@ void Listview::cb_showInMessagebox()
|
||||
"Temperature: " + item->getText(3) + "\n"
|
||||
" Humidity: " + item->getText(4) + "\n"
|
||||
" Pressure: " + item->getText(5)
|
||||
, finalcut::FMessageBox::Ok
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Ok
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, this );
|
||||
info.show();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -38,7 +38,7 @@ class Mandelbrot final : public finalcut::FDialog
|
||||
explicit Mandelbrot (finalcut::FWidget* = nullptr);
|
||||
|
||||
// Destructor
|
||||
~Mandelbrot() override;
|
||||
~Mandelbrot() override = default;
|
||||
|
||||
// Event handlers
|
||||
void onKeyPress (finalcut::FKeyEvent*) override;
|
||||
@ -46,6 +46,7 @@ class Mandelbrot final : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
void adjustSize() override;
|
||||
};
|
||||
@ -54,13 +55,15 @@ class Mandelbrot final : public finalcut::FDialog
|
||||
//----------------------------------------------------------------------
|
||||
Mandelbrot::Mandelbrot (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Mandelbrot set");
|
||||
}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Mandelbrot::~Mandelbrot()
|
||||
{ }
|
||||
void Mandelbrot::initLayout()
|
||||
{
|
||||
FDialog::setText ("Mandelbrot set");
|
||||
FDialog::setGeometry (FPoint{6, 1}, FSize{70, 23});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Mandelbrot::draw()
|
||||
@ -107,9 +110,9 @@ void Mandelbrot::draw()
|
||||
}
|
||||
|
||||
if ( iter < max_iter )
|
||||
setColor(fc::Black, iter % 16);
|
||||
setColor(FColor::Black, FColor(iter % 16));
|
||||
else
|
||||
setColor(fc::Black, 0);
|
||||
setColor(FColor::Black, FColor::Black);
|
||||
|
||||
print(' ');
|
||||
x0 += dX;
|
||||
@ -125,7 +128,7 @@ void Mandelbrot::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' )
|
||||
if ( ev->key() == finalcut::FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -166,7 +169,6 @@ int main (int argc, char* argv[])
|
||||
|
||||
// Create a simple dialog box
|
||||
Mandelbrot mb{&app};
|
||||
mb.setGeometry (FPoint{6, 1}, FSize{70, 23});
|
||||
mb.setShadow(); // Instead of the transparent window shadow
|
||||
|
||||
// Set the mandelbrot object as main widget
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using FKey = finalcut::FKey;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -41,7 +41,7 @@ class Menu final : public finalcut::FDialog
|
||||
Menu (const Menu&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Menu() override;
|
||||
~Menu() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Menu& operator = (const Menu&) = delete;
|
||||
@ -55,6 +55,7 @@ class Menu final : public finalcut::FDialog
|
||||
void configureStyleMenuItems();
|
||||
void configureBorderMenuItems();
|
||||
void defaultCallback (const finalcut::FMenuList*);
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
@ -64,7 +65,7 @@ class Menu final : public finalcut::FDialog
|
||||
void cb_message (const finalcut::FMenuItem*);
|
||||
|
||||
// Data members
|
||||
finalcut::FString line{13, fc::BoxDrawingsHorizontal};
|
||||
finalcut::FString line{13, finalcut::UniChar::BoxDrawingsHorizontal};
|
||||
finalcut::FMenuBar Menubar{this};
|
||||
finalcut::FMenu File{"&File", &Menubar};
|
||||
finalcut::FMenu Edit{"&Edit", &Menubar};
|
||||
@ -80,17 +81,17 @@ class Menu final : public finalcut::FDialog
|
||||
finalcut::FMenuItem Print{"&Print", &File};
|
||||
finalcut::FMenuItem Line2{&File};
|
||||
finalcut::FMenuItem Quit{"&Quit", &File};
|
||||
finalcut::FMenuItem Undo{fc::Fckey_z, "&Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{fc::Fckey_y, "&Redo", &Edit};
|
||||
finalcut::FMenuItem Undo{FKey::Ctrl_z, "&Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{FKey::Ctrl_y, "&Redo", &Edit};
|
||||
finalcut::FMenuItem Line3{&Edit};
|
||||
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Cut{FKey::Ctrl_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{FKey::Ctrl_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{FKey::Ctrl_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Line4{&Edit};
|
||||
finalcut::FMenuItem Search{fc::Fckey_f, "&Search", &Edit};
|
||||
finalcut::FMenuItem Next{fc::Fkey_f3, "Search &next", &Edit};
|
||||
finalcut::FMenuItem Search{FKey::Ctrl_f, "&Search", &Edit};
|
||||
finalcut::FMenuItem Next{FKey::F3, "Search &next", &Edit};
|
||||
finalcut::FMenuItem Line5{&Edit};
|
||||
finalcut::FMenuItem SelectAll{fc::Fckey_a, "Select &all", &Edit};
|
||||
finalcut::FMenuItem SelectAll{FKey::Ctrl_a, "Select &all", &Edit};
|
||||
finalcut::FMenu Color{"&Color", &Choice};
|
||||
finalcut::FMenu Style{"&Style", &Choice};
|
||||
finalcut::FMenu Border{"&Border", &Choice};
|
||||
@ -140,12 +141,10 @@ Menu::Menu (finalcut::FWidget* parent)
|
||||
// Headline labels
|
||||
Headline1 << " Key ";
|
||||
Headline1.ignorePadding();
|
||||
Headline1.setGeometry(FPoint{3, 2}, FSize{5, 1});
|
||||
Headline1.setEmphasis();
|
||||
|
||||
Headline2 << " Function ";
|
||||
Headline2.ignorePadding();
|
||||
Headline2.setGeometry(FPoint{19, 2}, FSize{10, 1});
|
||||
Headline2.setEmphasis();
|
||||
|
||||
// Info label
|
||||
@ -154,31 +153,26 @@ Menu::Menu (finalcut::FWidget* parent)
|
||||
<< "<Menu> Activate menu bar\n"
|
||||
<< "<Shift>+<Menu> Open dialog menu\n"
|
||||
<< "<Meta>+<X> Exit";
|
||||
Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Menu::~Menu()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::configureFileMenuItems()
|
||||
{
|
||||
// "File" menu items
|
||||
New.addAccelerator (fc::Fckey_n); // Ctrl + N
|
||||
New.addAccelerator (FKey::Ctrl_n); // Ctrl + N
|
||||
New.setStatusbarMessage ("Create a new file");
|
||||
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
|
||||
Open.addAccelerator (FKey::Ctrl_o); // Ctrl + O
|
||||
Open.setStatusbarMessage ("Locate and open a text file");
|
||||
Save.addAccelerator (fc::Fckey_s); // Ctrl + S
|
||||
Save.addAccelerator (FKey::Ctrl_s); // Ctrl + S
|
||||
Save.setStatusbarMessage ("Save the file");
|
||||
SaveAs.setStatusbarMessage ("Save the current file under a different name");
|
||||
Close.addAccelerator (fc::Fckey_w); // Ctrl + W
|
||||
Close.addAccelerator (FKey::Ctrl_w); // Ctrl + W
|
||||
Close.setStatusbarMessage ("Close the current file");
|
||||
Line1.setSeparator();
|
||||
Print.addAccelerator (fc::Fckey_p); // Ctrl + P
|
||||
Print.addAccelerator (FKey::Ctrl_p); // Ctrl + P
|
||||
Print.setStatusbarMessage ("Print the current file");
|
||||
Line2.setSeparator();
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (FKey::Meta_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// Add quit menu item callback
|
||||
@ -198,8 +192,8 @@ void Menu::configureEditMenuItems()
|
||||
Undo.setStatusbarMessage ("Undo the previous operation");
|
||||
Redo.setDisable();
|
||||
Line3.setSeparator();
|
||||
Cut.setStatusbarMessage ( "Remove the input text "
|
||||
"and put it in the clipboard" );
|
||||
Cut.setStatusbarMessage ("Remove the input text "
|
||||
"and put it in the clipboard");
|
||||
Copy.setStatusbarMessage ("Copy the input text into the clipboad");
|
||||
Paste.setStatusbarMessage ("Insert text form clipboard");
|
||||
Line4.setSeparator();
|
||||
@ -290,6 +284,15 @@ void Menu::defaultCallback (const finalcut::FMenuList* mb)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::initLayout()
|
||||
{
|
||||
Headline1.setGeometry (FPoint{3, 2}, FSize{5, 1});
|
||||
Headline2.setGeometry (FPoint{19, 2}, FSize{10, 1});
|
||||
Info.setGeometry(FPoint{2, 1}, FSize{36, 5});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Menu::adjustSize()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,8 +22,8 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
@ -43,7 +43,7 @@ class ColorChooser final : public finalcut::FWidget
|
||||
ColorChooser (const ColorChooser&) = delete;
|
||||
|
||||
// Destructor
|
||||
~ColorChooser() override;
|
||||
~ColorChooser() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
ColorChooser& operator = (const ColorChooser&) = delete;
|
||||
@ -54,6 +54,7 @@ class ColorChooser final : public finalcut::FWidget
|
||||
|
||||
private:
|
||||
// Mutator
|
||||
void initLayout() override;
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
|
||||
// Method
|
||||
@ -64,8 +65,8 @@ class ColorChooser final : public finalcut::FWidget
|
||||
void onMouseDown (finalcut::FMouseEvent*) override;
|
||||
|
||||
// Data members
|
||||
FColor fg_color{fc::White};
|
||||
FColor bg_color{fc::Black};
|
||||
FColor fg_color{FColor::White};
|
||||
FColor bg_color{FColor::Black};
|
||||
finalcut::FLabel headline{this};
|
||||
};
|
||||
|
||||
@ -74,21 +75,14 @@ class ColorChooser final : public finalcut::FWidget
|
||||
ColorChooser::ColorChooser (finalcut::FWidget* parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 12});
|
||||
setFixedSize (FSize{8, 12});
|
||||
unsetFocusable();
|
||||
|
||||
// Text label
|
||||
headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline << "Color";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
ColorChooser::~ColorChooser()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FColor ColorChooser::getForeground() const
|
||||
{
|
||||
@ -101,6 +95,15 @@ inline FColor ColorChooser::getBackground() const
|
||||
return bg_color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ColorChooser::initLayout()
|
||||
{
|
||||
FWidget::setSize (FSize{8, 12});
|
||||
setFixedSize (FSize{8, 12});
|
||||
headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
|
||||
FWidget::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ColorChooser::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
@ -117,20 +120,20 @@ void ColorChooser::draw()
|
||||
setColor();
|
||||
drawBorder();
|
||||
|
||||
for (FColor c{0}; c < 16; c++)
|
||||
for (FColor c{FColor::Black}; c < 16; ++c)
|
||||
{
|
||||
print() << FPoint{2 + (c / 8) * 3, 3 + c % 8};
|
||||
print() << FPoint{2 + (int(c) / 8) * 3, 3 + int(c) % 8};
|
||||
|
||||
if ( c < 6 )
|
||||
setColor (fc::LightGray, c);
|
||||
setColor (FColor::LightGray, c);
|
||||
else if ( c > 8 )
|
||||
setColor (fc::DarkGray, c);
|
||||
setColor (FColor::DarkGray, c);
|
||||
else
|
||||
setColor (fc::White, c);
|
||||
setColor (FColor::White, c);
|
||||
|
||||
if ( c == bg_color )
|
||||
{
|
||||
print() << L' ' << wchar_t(fc::Times) << L' ';
|
||||
print() << L' ' << wchar_t(finalcut::UniChar::Times) << L' ';
|
||||
}
|
||||
else
|
||||
print (" ");
|
||||
@ -149,7 +152,7 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
if ( ev->getButton() == finalcut::MouseButton::Middle )
|
||||
return;
|
||||
|
||||
for (auto c{0}; c < 16; c++)
|
||||
@ -160,9 +163,9 @@ void ColorChooser::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
|
||||
if ( mouse_x >= xmin && mouse_x <= xmax && mouse_y == y )
|
||||
{
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
if ( ev->getButton() == finalcut::MouseButton::Left )
|
||||
bg_color = FColor(c);
|
||||
else if ( ev->getButton() == fc::RightButton )
|
||||
else if ( ev->getButton() == finalcut::MouseButton::Right )
|
||||
fg_color = FColor(c);
|
||||
|
||||
redraw();
|
||||
@ -186,7 +189,7 @@ class Brushes final : public finalcut::FWidget
|
||||
Brushes (const Brushes&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Brushes() override;
|
||||
~Brushes() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Brushes& operator = (const Brushes&) = delete;
|
||||
@ -200,6 +203,7 @@ class Brushes final : public finalcut::FWidget
|
||||
|
||||
private:
|
||||
// Mutator
|
||||
void initLayout() override;
|
||||
void setSize (const FSize&, bool = true) override;
|
||||
|
||||
// Method
|
||||
@ -211,8 +215,8 @@ class Brushes final : public finalcut::FWidget
|
||||
|
||||
// Data members
|
||||
wchar_t brush{L' '};
|
||||
FColor fg_color{fc::White};
|
||||
FColor bg_color{fc::Black};
|
||||
FColor fg_color{FColor::White};
|
||||
FColor bg_color{FColor::Black};
|
||||
finalcut::FLabel headline{this};
|
||||
};
|
||||
|
||||
@ -220,20 +224,22 @@ class Brushes final : public finalcut::FWidget
|
||||
Brushes::Brushes (finalcut::FWidget* parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
FWidget::setSize (FSize{8, 4});
|
||||
setFixedSize (FSize{8, 4});
|
||||
unsetFocusable();
|
||||
|
||||
// Text label
|
||||
headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline << "Brush";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Brushes::~Brushes()
|
||||
{ }
|
||||
void Brushes::initLayout()
|
||||
{
|
||||
FWidget::setSize (FSize{8, 4});
|
||||
setFixedSize (FSize{8, 4});
|
||||
headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
|
||||
FWidget::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Brushes::setSize (const FSize& size, bool adjust)
|
||||
@ -253,16 +259,16 @@ void Brushes::draw()
|
||||
drawBorder();
|
||||
print() << FPoint{2, 3}
|
||||
<< FColorPair{fg_color, bg_color} << " "
|
||||
<< finalcut::FString{3, fc::MediumShade};
|
||||
<< finalcut::FString{3, finalcut::UniChar::MediumShade};
|
||||
|
||||
if ( brush != L' ' )
|
||||
pos = 3;
|
||||
|
||||
setColor();
|
||||
print() << FPoint{3 + pos, 2}
|
||||
<< fc::BlackDownPointingTriangle
|
||||
<< finalcut::UniChar::BlackDownPointingTriangle
|
||||
<< FPoint{3 + pos, 4}
|
||||
<< fc::BlackUpPointingTriangle;
|
||||
<< finalcut::UniChar::BlackUpPointingTriangle;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -277,7 +283,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != finalcut::MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( mouse_x >= 2 && mouse_x <= 4 && mouse_y == 3 )
|
||||
@ -287,7 +293,7 @@ void Brushes::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
}
|
||||
else if ( mouse_x >= 5 && mouse_x <= 7 && mouse_y == 3 )
|
||||
{
|
||||
brush = fc::MediumShade;
|
||||
brush = wchar_t(finalcut::UniChar::MediumShade);
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
@ -328,7 +334,7 @@ class MouseDraw final : public finalcut::FDialog
|
||||
MouseDraw (const MouseDraw&) = delete;
|
||||
|
||||
// Destructor
|
||||
~MouseDraw() override;
|
||||
~MouseDraw() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
MouseDraw& operator = (const MouseDraw&) = delete;
|
||||
@ -346,6 +352,7 @@ class MouseDraw final : public finalcut::FDialog
|
||||
void drawBrush (int, int, bool = false);
|
||||
void drawCanvas();
|
||||
void createCanvas();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
@ -367,20 +374,14 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setText ("Drawing with the mouse");
|
||||
c_chooser.setPos (FPoint{1, 1});
|
||||
|
||||
c_chooser.addCallback
|
||||
(
|
||||
"clicked",
|
||||
this, &MouseDraw::cb_colorChanged
|
||||
);
|
||||
|
||||
brush.setPos (FPoint{1, 12});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MouseDraw::~MouseDraw()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust)
|
||||
{
|
||||
@ -410,7 +411,7 @@ void MouseDraw::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' )
|
||||
if ( ev->key() == finalcut::FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -437,24 +438,24 @@ void MouseDraw::draw()
|
||||
for (auto y{2}; y < y_max; y++)
|
||||
{
|
||||
print() << FPoint{10, y}
|
||||
<< fc::NF_rev_border_line_right;
|
||||
<< finalcut::UniChar::NF_rev_border_line_right;
|
||||
}
|
||||
|
||||
print() << FPoint{10, y_max}
|
||||
<< fc::NF_rev_border_corner_lower_right;
|
||||
<< finalcut::UniChar::NF_rev_border_corner_lower_right;
|
||||
}
|
||||
else
|
||||
{
|
||||
print() << FPoint{10, 2}
|
||||
<< fc::BoxDrawingsDownAndHorizontal;
|
||||
<< finalcut::UniChar::BoxDrawingsDownAndHorizontal;
|
||||
|
||||
for (auto y{3}; y < y_max; y++)
|
||||
{
|
||||
print() << FPoint{10, y} << fc::BoxDrawingsVertical;
|
||||
print() << FPoint{10, y} << finalcut::UniChar::BoxDrawingsVertical;
|
||||
}
|
||||
|
||||
print() << FPoint{10, y_max}
|
||||
<< fc::BoxDrawingsUpAndHorizontal;
|
||||
<< finalcut::UniChar::BoxDrawingsUpAndHorizontal;
|
||||
}
|
||||
|
||||
drawCanvas();
|
||||
@ -535,6 +536,14 @@ void MouseDraw::createCanvas()
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::initLayout()
|
||||
{
|
||||
c_chooser.setPos (FPoint{1, 1});
|
||||
brush.setPos (FPoint{1, 12});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MouseDraw::adjustSize()
|
||||
{
|
||||
@ -551,13 +560,13 @@ void MouseDraw::onMouseDown (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
finalcut::FDialog::onMouseDown(ev);
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
if ( ev->getButton() != finalcut::MouseButton::Left
|
||||
&& ev->getButton() != finalcut::MouseButton::Right )
|
||||
return;
|
||||
|
||||
drawBrush ( ev->getX()
|
||||
, ev->getY()
|
||||
, ev->getButton() == fc::RightButton );
|
||||
, ev->getButton() == finalcut::MouseButton::Right );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -565,13 +574,13 @@ void MouseDraw::onMouseMove (finalcut::FMouseEvent* ev)
|
||||
{
|
||||
FDialog::onMouseMove(ev);
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
if ( ev->getButton() != finalcut::MouseButton::Left
|
||||
&& ev->getButton() != finalcut::MouseButton::Right )
|
||||
return;
|
||||
|
||||
drawBrush ( ev->getX()
|
||||
, ev->getY()
|
||||
, ev->getButton() == fc::RightButton);
|
||||
, ev->getButton() == finalcut::MouseButton::Right );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -136,10 +136,10 @@ class DirectLogger final : public finalcut::FLog
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
DirectLogger();
|
||||
DirectLogger() = default;
|
||||
|
||||
// Destructor
|
||||
~DirectLogger() override;
|
||||
~DirectLogger() noexcept override;
|
||||
|
||||
void info (const std::string& entry) override
|
||||
{
|
||||
@ -194,12 +194,7 @@ class DirectLogger final : public finalcut::FLog
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
DirectLogger::DirectLogger() // constructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
DirectLogger::~DirectLogger() // destructor
|
||||
{ }
|
||||
DirectLogger::~DirectLogger() noexcept = default; // destructor
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -270,7 +265,7 @@ int main (int argc, char* argv[])
|
||||
std::cout << "\r" << line << std::flush;
|
||||
// Generation of a logger in a shared_ptr via a pointer
|
||||
finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
|
||||
const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove();
|
||||
const auto& opti_move = finalcut::FTerm::getFOptiMove();
|
||||
finalcut::printDurations(opti_move);
|
||||
|
||||
// Waiting for keypress
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -28,13 +28,13 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::system_clock;
|
||||
using std::chrono::time_point;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColor;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// This rotozoomer demo is based on the code of Robert Dörfler
|
||||
@ -53,7 +53,7 @@ class RotoZoomer final : public finalcut::FDialog
|
||||
explicit RotoZoomer (finalcut::FWidget* = nullptr, bool = false, int = 314);
|
||||
|
||||
// Destructor
|
||||
~RotoZoomer() override;
|
||||
~RotoZoomer() override = default;
|
||||
|
||||
// Accessors
|
||||
finalcut::FString getReport() const;
|
||||
@ -123,10 +123,6 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
RotoZoomer::~RotoZoomer()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void RotoZoomer::draw()
|
||||
{
|
||||
@ -168,11 +164,11 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a)
|
||||
auto ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)];
|
||||
|
||||
if ( ch == '+' )
|
||||
print() << finalcut::FColorPair{fc::Black, fc::Red};
|
||||
print() << finalcut::FColorPair{FColor::Black, FColor::Red};
|
||||
else if ( ch == 'x' )
|
||||
print() << finalcut::FColorPair{fc::Black, fc::Cyan};
|
||||
print() << finalcut::FColorPair{FColor::Black, FColor::Cyan};
|
||||
else
|
||||
print() << finalcut::FColorPair{fc::Black, fc::White};
|
||||
print() << finalcut::FColorPair{FColor::Black, FColor::White};
|
||||
|
||||
print() << ch;
|
||||
Cx += dxdx;
|
||||
@ -253,7 +249,7 @@ void RotoZoomer::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' )
|
||||
if ( ev->key() == finalcut::FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -318,7 +314,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
{ // Create the application object in this scope
|
||||
finalcut::FApplication app{argc, argv};
|
||||
app.setNonBlockingRead();
|
||||
finalcut::FVTerm::setNonBlockingRead();
|
||||
|
||||
// Create a simple dialog box
|
||||
constexpr int iterations = 314;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,7 +22,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -41,7 +40,7 @@ class Scrollview final : public finalcut::FScrollView
|
||||
Scrollview (const Scrollview&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Scrollview() override;
|
||||
~Scrollview() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Scrollview& operator = (const Scrollview&) = delete;
|
||||
@ -50,7 +49,8 @@ class Scrollview final : public finalcut::FScrollView
|
||||
void setScrollSize (const FSize&) override;
|
||||
|
||||
private:
|
||||
// Method
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
|
||||
// Callback methods
|
||||
@ -60,10 +60,10 @@ class Scrollview final : public finalcut::FScrollView
|
||||
void cb_goNorth();
|
||||
|
||||
// Data members
|
||||
wchar_t pointer_right{fc::BlackRightPointingPointer};
|
||||
wchar_t pointer_down{fc::BlackDownPointingTriangle};
|
||||
wchar_t pointer_left{fc::BlackLeftPointingPointer};
|
||||
wchar_t pointer_up{fc::BlackUpPointingTriangle};
|
||||
finalcut::UniChar pointer_right{finalcut::UniChar::BlackRightPointingPointer};
|
||||
finalcut::UniChar pointer_down{finalcut::UniChar::BlackDownPointingTriangle};
|
||||
finalcut::UniChar pointer_left{finalcut::UniChar::BlackLeftPointingPointer};
|
||||
finalcut::UniChar pointer_up{finalcut::UniChar::BlackUpPointingTriangle};
|
||||
finalcut::FButton go_east{pointer_right, this};
|
||||
finalcut::FButton go_south{pointer_down, this};
|
||||
finalcut::FButton go_west{pointer_left, this};
|
||||
@ -74,16 +74,6 @@ class Scrollview final : public finalcut::FScrollView
|
||||
Scrollview::Scrollview (finalcut::FWidget* parent)
|
||||
: finalcut::FScrollView{parent}
|
||||
{
|
||||
// Sets the navigation button geometry
|
||||
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
|
||||
(
|
||||
@ -111,9 +101,19 @@ Scrollview::Scrollview (finalcut::FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Scrollview::~Scrollview()
|
||||
{ }
|
||||
|
||||
void Scrollview::initLayout()
|
||||
{
|
||||
// Sets the navigation button geometry
|
||||
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} );
|
||||
FScrollView::initLayout();
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollview::setScrollSize (const FSize& size)
|
||||
{
|
||||
@ -197,7 +197,11 @@ class Scrollviewdemo final : public finalcut::FDialog
|
||||
explicit Scrollviewdemo (finalcut::FWidget* = nullptr);
|
||||
|
||||
// Destructor
|
||||
~Scrollviewdemo() override;
|
||||
~Scrollviewdemo() override = default;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handler
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
@ -216,13 +220,6 @@ class Scrollviewdemo final : public finalcut::FDialog
|
||||
Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19});
|
||||
FDialog::setText ("Scrolling viewport example");
|
||||
|
||||
// The scrolling viewport widget
|
||||
sview.setGeometry(FPoint{3, 2}, FSize{44, 12});
|
||||
sview.setScrollSize(FSize{188, 124});
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{37, 15}, FSize{10, 1});
|
||||
|
||||
@ -241,13 +238,15 @@ Scrollviewdemo::Scrollviewdemo (finalcut::FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Scrollviewdemo::~Scrollviewdemo()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollviewdemo::cb_quit()
|
||||
void Scrollviewdemo::initLayout()
|
||||
{
|
||||
close();
|
||||
FDialog::setGeometry (FPoint{16, 3}, FSize{50, 19});
|
||||
FDialog::setText ("Scrolling viewport example");
|
||||
|
||||
// The scrolling viewport widget
|
||||
sview.setGeometry(FPoint{3, 2}, FSize{44, 12});
|
||||
sview.setScrollSize(FSize{188, 124});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -256,6 +255,12 @@ void Scrollviewdemo::onClose (finalcut::FCloseEvent* ev)
|
||||
finalcut::FApplication::closeConfirmationDialog (this, ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Scrollviewdemo::cb_quit()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// main part
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -24,10 +24,10 @@
|
||||
#include <vector>
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FColor;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -44,7 +44,7 @@ class AttribDlg final : public finalcut::FDialog
|
||||
AttribDlg (const AttribDlg&) = delete;
|
||||
|
||||
// Destructor
|
||||
~AttribDlg() override;
|
||||
~AttribDlg() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
AttribDlg& operator = (const AttribDlg&) = delete;
|
||||
@ -62,15 +62,13 @@ class AttribDlg final : public finalcut::FDialog
|
||||
void cb_back();
|
||||
|
||||
private:
|
||||
// Constants
|
||||
static constexpr auto UNDEFINED = static_cast<FColor>(-2);
|
||||
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
void draw() override;
|
||||
|
||||
// Data members
|
||||
FColor bgcolor{UNDEFINED};
|
||||
FColor bgcolor{FColor::Undefined};
|
||||
finalcut::FButton next_button{"&Next >", this};
|
||||
finalcut::FButton back_button{"< &Back", this};
|
||||
};
|
||||
@ -79,12 +77,8 @@ class AttribDlg final : public finalcut::FDialog
|
||||
AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
next_button.addAccelerator (fc::Fkey_right);
|
||||
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
back_button.addAccelerator (fc::Fkey_left);
|
||||
next_button.addAccelerator (finalcut::FKey::Right);
|
||||
back_button.addAccelerator (finalcut::FKey::Left);
|
||||
|
||||
// Add function callbacks
|
||||
next_button.addCallback
|
||||
@ -100,10 +94,6 @@ AttribDlg::AttribDlg (finalcut::FWidget* parent)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
AttribDlg::~AttribDlg()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FColor AttribDlg::getBGColor() const
|
||||
{
|
||||
@ -116,7 +106,7 @@ void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' )
|
||||
if ( ev->key() == finalcut::FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -128,11 +118,11 @@ void AttribDlg::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::onWheel (finalcut::FWheelEvent* ev)
|
||||
{
|
||||
const int wheel = ev->getWheel();
|
||||
const finalcut::MouseWheel wheel = ev->getWheel();
|
||||
|
||||
if ( wheel == fc::WheelUp )
|
||||
if ( wheel == finalcut::MouseWheel::Up )
|
||||
cb_next();
|
||||
else if ( wheel == fc::WheelDown )
|
||||
else if ( wheel == finalcut::MouseWheel::Down )
|
||||
cb_back();
|
||||
}
|
||||
|
||||
@ -149,11 +139,11 @@ void AttribDlg::cb_next()
|
||||
return;
|
||||
|
||||
if ( bgcolor == FColor(finalcut::FTerm::getMaxColor() - 1) )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = 0;
|
||||
bgcolor = FColor::Default;
|
||||
else if ( bgcolor == FColor::Default )
|
||||
bgcolor = FColor::Black;
|
||||
else
|
||||
bgcolor++;
|
||||
++bgcolor;
|
||||
|
||||
redraw();
|
||||
}
|
||||
@ -165,15 +155,25 @@ void AttribDlg::cb_back()
|
||||
return;
|
||||
|
||||
if ( bgcolor == 0 )
|
||||
bgcolor = fc::Default;
|
||||
else if ( bgcolor == fc::Default )
|
||||
bgcolor = FColor::Default;
|
||||
else if ( bgcolor == FColor::Default )
|
||||
bgcolor = FColor(finalcut::FTerm::getMaxColor() - 1);
|
||||
else
|
||||
bgcolor--;
|
||||
--bgcolor;
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::initLayout()
|
||||
{
|
||||
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
back_button.setGeometry ( FPoint{int(getWidth()) - 25, int(getHeight()) - 4}
|
||||
, FSize{10, 1} );
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::adjustSize()
|
||||
{
|
||||
@ -197,11 +197,11 @@ void AttribDlg::adjustSize()
|
||||
//----------------------------------------------------------------------
|
||||
void AttribDlg::draw()
|
||||
{
|
||||
if ( bgcolor == UNDEFINED )
|
||||
if ( bgcolor == FColor::Undefined )
|
||||
{
|
||||
// Get the color after initializing the color theme in show()
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
bgcolor = fc::Default;
|
||||
bgcolor = FColor::Default;
|
||||
else
|
||||
bgcolor = getColorTheme()->label_bg;
|
||||
|
||||
@ -226,8 +226,7 @@ class AttribDemo final : public finalcut::FWidget
|
||||
explicit AttribDemo (FWidget* = nullptr);
|
||||
|
||||
// Destructor
|
||||
~AttribDemo() override
|
||||
{ }
|
||||
~AttribDemo() override = default;
|
||||
|
||||
// Event handler
|
||||
void onWheel (finalcut::FWheelEvent* ev) override
|
||||
@ -258,7 +257,7 @@ class AttribDemo final : public finalcut::FWidget
|
||||
void draw() override;
|
||||
|
||||
// Data member
|
||||
FColor last_color{1};
|
||||
FColor last_color{FColor::Blue};
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -273,7 +272,7 @@ void AttribDemo::printColorLine()
|
||||
{
|
||||
const auto& parent = static_cast<AttribDlg*>(getParent());
|
||||
|
||||
for (FColor color{0}; color < last_color; color++)
|
||||
for (FColor color{FColor::Black}; color < last_color; ++color)
|
||||
{
|
||||
print() << FColorPair{color, parent->getBGColor()} << " # ";
|
||||
}
|
||||
@ -290,9 +289,9 @@ void AttribDemo::printAltCharset()
|
||||
|
||||
print() << FPoint{1, 1} << "alternate charset: ";
|
||||
|
||||
if ( parent->getBGColor() == fc::Default )
|
||||
if ( parent->getBGColor() == FColor::Default )
|
||||
{
|
||||
setColor (fc::Default, fc::Default);
|
||||
setColor (FColor::Default, FColor::Default);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -300,9 +299,9 @@ void AttribDemo::printAltCharset()
|
||||
|| (parent->getBGColor() >= 16 && parent->getBGColor() <= 231
|
||||
&& (parent->getBGColor() - 16) % 36 <= 17)
|
||||
|| (parent->getBGColor() >= 232 && parent->getBGColor() <= 243) )
|
||||
setColor (fc::White, parent->getBGColor());
|
||||
setColor (FColor::White, parent->getBGColor());
|
||||
else
|
||||
setColor (fc::Black, parent->getBGColor());
|
||||
setColor (FColor::Black, parent->getBGColor());
|
||||
}
|
||||
|
||||
setAltCharset();
|
||||
@ -436,9 +435,9 @@ void AttribDemo::draw()
|
||||
last_color = FColor(finalcut::FTerm::getMaxColor());
|
||||
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
last_color = 1;
|
||||
last_color = FColor(1);
|
||||
else if ( last_color > 16 )
|
||||
last_color = 16;
|
||||
last_color = FColor(16);
|
||||
|
||||
// test alternate character set
|
||||
printAltCharset();
|
||||
@ -477,10 +476,10 @@ void AttribDemo::draw()
|
||||
const FColor bg = static_cast<AttribDlg*>(getParent())->getBGColor();
|
||||
print (" Background color:");
|
||||
|
||||
if ( bg == fc::Default )
|
||||
if ( bg == FColor::Default )
|
||||
print (" default");
|
||||
else
|
||||
printf ( " %d", bg);
|
||||
printf ( " %u", bg);
|
||||
|
||||
print() << FPoint{16, 17} << "Change background color ->";
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -27,7 +27,7 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::Termcap;
|
||||
|
||||
// Function prototype
|
||||
void tcapBoolean (const std::string&, bool);
|
||||
@ -48,100 +48,102 @@ struct Data
|
||||
struct alignas(alignof(std::string)) TermcapString
|
||||
{
|
||||
const std::string name;
|
||||
const fc::termcaps cap;
|
||||
const Termcap cap;
|
||||
};
|
||||
|
||||
static std::array<TermcapString, 83> strings;
|
||||
static std::array<TermcapString, 85> strings;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// struct data - string data array
|
||||
//----------------------------------------------------------------------
|
||||
std::array<Data::TermcapString, 83> Data::strings =
|
||||
std::array<Data::TermcapString, 85> Data::strings =
|
||||
{{
|
||||
{ "t_bell", fc::t_bell },
|
||||
{ "t_erase_chars", fc::t_erase_chars },
|
||||
{ "t_clear_screen", fc::t_clear_screen },
|
||||
{ "t_clr_eos", fc::t_clr_eos },
|
||||
{ "t_clr_eol", fc::t_clr_eol },
|
||||
{ "t_clr_bol", fc::t_clr_bol },
|
||||
{ "t_cursor_home", fc::t_cursor_home },
|
||||
{ "t_cursor_to_ll", fc::t_cursor_to_ll },
|
||||
{ "t_carriage_return", fc::t_carriage_return },
|
||||
{ "t_tab", fc::t_tab },
|
||||
{ "t_back_tab", fc::t_back_tab },
|
||||
{ "t_insert_padding", fc::t_insert_padding },
|
||||
{ "t_insert_character", fc::t_insert_character },
|
||||
{ "t_parm_ich", fc::t_parm_ich },
|
||||
{ "t_repeat_char", fc::t_repeat_char },
|
||||
{ "t_initialize_color", fc::t_initialize_color },
|
||||
{ "t_initialize_pair", fc::t_initialize_pair },
|
||||
{ "t_set_a_foreground", fc::t_set_a_foreground },
|
||||
{ "t_set_a_background", fc::t_set_a_background },
|
||||
{ "t_set_foreground", fc::t_set_foreground },
|
||||
{ "t_set_background", fc::t_set_background },
|
||||
{ "t_set_color_pair", fc::t_set_color_pair },
|
||||
{ "t_orig_pair", fc::t_orig_pair },
|
||||
{ "t_orig_colors", fc::t_orig_colors },
|
||||
{ "t_no_color_video", fc::t_no_color_video },
|
||||
{ "t_cursor_address", fc::t_cursor_address },
|
||||
{ "t_column_address", fc::t_column_address },
|
||||
{ "t_row_address", fc::t_row_address },
|
||||
{ "t_cursor_visible", fc::t_cursor_visible },
|
||||
{ "t_cursor_invisible", fc::t_cursor_invisible },
|
||||
{ "t_cursor_normal", fc::t_cursor_normal },
|
||||
{ "t_cursor_up", fc::t_cursor_up },
|
||||
{ "t_cursor_down", fc::t_cursor_down },
|
||||
{ "t_cursor_left", fc::t_cursor_left },
|
||||
{ "t_cursor_right", fc::t_cursor_right },
|
||||
{ "t_parm_up_cursor", fc::t_parm_up_cursor },
|
||||
{ "t_parm_down_cursor", fc::t_parm_down_cursor },
|
||||
{ "t_parm_left_cursor", fc::t_parm_left_cursor },
|
||||
{ "t_parm_right_cursor", fc::t_parm_right_cursor },
|
||||
{ "t_save_cursor", fc::t_save_cursor },
|
||||
{ "t_restore_cursor", fc::t_restore_cursor },
|
||||
{ "t_cursor_style", fc::t_cursor_style },
|
||||
{ "t_scroll_forward", fc::t_scroll_forward },
|
||||
{ "t_scroll_reverse", fc::t_scroll_reverse },
|
||||
{ "t_enter_ca_mode", fc::t_enter_ca_mode },
|
||||
{ "t_exit_ca_mode", fc::t_exit_ca_mode },
|
||||
{ "t_enable_acs", fc::t_enable_acs },
|
||||
{ "t_enter_bold_mode", fc::t_enter_bold_mode },
|
||||
{ "t_exit_bold_mode", fc::t_exit_bold_mode },
|
||||
{ "t_enter_dim_mode", fc::t_enter_dim_mode },
|
||||
{ "t_exit_dim_mode", fc::t_exit_dim_mode },
|
||||
{ "t_enter_italics_mode", fc::t_enter_italics_mode },
|
||||
{ "t_exit_italics_mode", fc::t_exit_italics_mode },
|
||||
{ "t_enter_underline_mode", fc::t_enter_underline_mode },
|
||||
{ "t_exit_underline_mode", fc::t_exit_underline_mode },
|
||||
{ "t_enter_blink_mode", fc::t_enter_blink_mode },
|
||||
{ "t_exit_blink_mode", fc::t_exit_blink_mode },
|
||||
{ "t_enter_reverse_mode", fc::t_enter_reverse_mode },
|
||||
{ "t_exit_reverse_mode", fc::t_exit_reverse_mode },
|
||||
{ "t_enter_standout_mode", fc::t_enter_standout_mode },
|
||||
{ "t_exit_standout_mode", fc::t_exit_standout_mode },
|
||||
{ "t_enter_secure_mode", fc::t_enter_secure_mode },
|
||||
{ "t_exit_secure_mode", fc::t_exit_secure_mode },
|
||||
{ "t_enter_protected_mode", fc::t_enter_protected_mode },
|
||||
{ "t_exit_protected_mode", fc::t_exit_protected_mode },
|
||||
{ "t_enter_crossed_out_mode", fc::t_enter_crossed_out_mode },
|
||||
{ "t_exit_crossed_out_mode", fc::t_exit_crossed_out_mode },
|
||||
{ "t_enter_dbl_underline_mode", fc::t_enter_dbl_underline_mode },
|
||||
{ "t_exit_dbl_underline_mode", fc::t_exit_dbl_underline_mode },
|
||||
{ "t_set_attributes", fc::t_set_attributes },
|
||||
{ "t_exit_attribute_mode", fc::t_exit_attribute_mode },
|
||||
{ "t_enter_alt_charset_mode", fc::t_enter_alt_charset_mode },
|
||||
{ "t_exit_alt_charset_mode", fc::t_exit_alt_charset_mode },
|
||||
{ "t_enter_pc_charset_mode", fc::t_enter_pc_charset_mode },
|
||||
{ "t_exit_pc_charset_mode", fc::t_exit_pc_charset_mode },
|
||||
{ "t_enter_insert_mode", fc::t_enter_insert_mode },
|
||||
{ "t_exit_insert_mode", fc::t_exit_insert_mode },
|
||||
{ "t_enter_am_mode", fc::t_enter_am_mode },
|
||||
{ "t_exit_am_mode", fc::t_exit_am_mode },
|
||||
{ "t_acs_chars", fc::t_acs_chars },
|
||||
{ "t_keypad_xmit", fc::t_keypad_xmit },
|
||||
{ "t_keypad_local", fc::t_keypad_local },
|
||||
{ "t_key_mouse", fc::t_key_mouse }
|
||||
{ "t_bell", Termcap::t_bell },
|
||||
{ "t_flash_screen", Termcap::t_flash_screen },
|
||||
{ "t_erase_chars", Termcap::t_erase_chars },
|
||||
{ "t_clear_screen", Termcap::t_clear_screen },
|
||||
{ "t_clr_eos", Termcap::t_clr_eos },
|
||||
{ "t_clr_eol", Termcap::t_clr_eol },
|
||||
{ "t_clr_bol", Termcap::t_clr_bol },
|
||||
{ "t_cursor_home", Termcap::t_cursor_home },
|
||||
{ "t_cursor_to_ll", Termcap::t_cursor_to_ll },
|
||||
{ "t_carriage_return", Termcap::t_carriage_return },
|
||||
{ "t_tab", Termcap::t_tab },
|
||||
{ "t_back_tab", Termcap::t_back_tab },
|
||||
{ "t_pad_char", Termcap::t_pad_char },
|
||||
{ "t_insert_padding", Termcap::t_insert_padding },
|
||||
{ "t_insert_character", Termcap::t_insert_character },
|
||||
{ "t_parm_ich", Termcap::t_parm_ich },
|
||||
{ "t_repeat_char", Termcap::t_repeat_char },
|
||||
{ "t_initialize_color", Termcap::t_initialize_color },
|
||||
{ "t_initialize_pair", Termcap::t_initialize_pair },
|
||||
{ "t_set_a_foreground", Termcap::t_set_a_foreground },
|
||||
{ "t_set_a_background", Termcap::t_set_a_background },
|
||||
{ "t_set_foreground", Termcap::t_set_foreground },
|
||||
{ "t_set_background", Termcap::t_set_background },
|
||||
{ "t_set_color_pair", Termcap::t_set_color_pair },
|
||||
{ "t_orig_pair", Termcap::t_orig_pair },
|
||||
{ "t_orig_colors", Termcap::t_orig_colors },
|
||||
{ "t_no_color_video", Termcap::t_no_color_video },
|
||||
{ "t_cursor_address", Termcap::t_cursor_address },
|
||||
{ "t_column_address", Termcap::t_column_address },
|
||||
{ "t_row_address", Termcap::t_row_address },
|
||||
{ "t_cursor_visible", Termcap::t_cursor_visible },
|
||||
{ "t_cursor_invisible", Termcap::t_cursor_invisible },
|
||||
{ "t_cursor_normal", Termcap::t_cursor_normal },
|
||||
{ "t_cursor_up", Termcap::t_cursor_up },
|
||||
{ "t_cursor_down", Termcap::t_cursor_down },
|
||||
{ "t_cursor_left", Termcap::t_cursor_left },
|
||||
{ "t_cursor_right", Termcap::t_cursor_right },
|
||||
{ "t_parm_up_cursor", Termcap::t_parm_up_cursor },
|
||||
{ "t_parm_down_cursor", Termcap::t_parm_down_cursor },
|
||||
{ "t_parm_left_cursor", Termcap::t_parm_left_cursor },
|
||||
{ "t_parm_right_cursor", Termcap::t_parm_right_cursor },
|
||||
{ "t_save_cursor", Termcap::t_save_cursor },
|
||||
{ "t_restore_cursor", Termcap::t_restore_cursor },
|
||||
{ "t_cursor_style", Termcap::t_cursor_style },
|
||||
{ "t_scroll_forward", Termcap::t_scroll_forward },
|
||||
{ "t_scroll_reverse", Termcap::t_scroll_reverse },
|
||||
{ "t_enter_ca_mode", Termcap::t_enter_ca_mode },
|
||||
{ "t_exit_ca_mode", Termcap::t_exit_ca_mode },
|
||||
{ "t_enable_acs", Termcap::t_enable_acs },
|
||||
{ "t_enter_bold_mode", Termcap::t_enter_bold_mode },
|
||||
{ "t_exit_bold_mode", Termcap::t_exit_bold_mode },
|
||||
{ "t_enter_dim_mode", Termcap::t_enter_dim_mode },
|
||||
{ "t_exit_dim_mode", Termcap::t_exit_dim_mode },
|
||||
{ "t_enter_italics_mode", Termcap::t_enter_italics_mode },
|
||||
{ "t_exit_italics_mode", Termcap::t_exit_italics_mode },
|
||||
{ "t_enter_underline_mode", Termcap::t_enter_underline_mode },
|
||||
{ "t_exit_underline_mode", Termcap::t_exit_underline_mode },
|
||||
{ "t_enter_blink_mode", Termcap::t_enter_blink_mode },
|
||||
{ "t_exit_blink_mode", Termcap::t_exit_blink_mode },
|
||||
{ "t_enter_reverse_mode", Termcap::t_enter_reverse_mode },
|
||||
{ "t_exit_reverse_mode", Termcap::t_exit_reverse_mode },
|
||||
{ "t_enter_standout_mode", Termcap::t_enter_standout_mode },
|
||||
{ "t_exit_standout_mode", Termcap::t_exit_standout_mode },
|
||||
{ "t_enter_secure_mode", Termcap::t_enter_secure_mode },
|
||||
{ "t_exit_secure_mode", Termcap::t_exit_secure_mode },
|
||||
{ "t_enter_protected_mode", Termcap::t_enter_protected_mode },
|
||||
{ "t_exit_protected_mode", Termcap::t_exit_protected_mode },
|
||||
{ "t_enter_crossed_out_mode", Termcap::t_enter_crossed_out_mode },
|
||||
{ "t_exit_crossed_out_mode", Termcap::t_exit_crossed_out_mode },
|
||||
{ "t_enter_dbl_underline_mode", Termcap::t_enter_dbl_underline_mode },
|
||||
{ "t_exit_dbl_underline_mode", Termcap::t_exit_dbl_underline_mode },
|
||||
{ "t_set_attributes", Termcap::t_set_attributes },
|
||||
{ "t_exit_attribute_mode", Termcap::t_exit_attribute_mode },
|
||||
{ "t_enter_alt_charset_mode", Termcap::t_enter_alt_charset_mode },
|
||||
{ "t_exit_alt_charset_mode", Termcap::t_exit_alt_charset_mode },
|
||||
{ "t_enter_pc_charset_mode", Termcap::t_enter_pc_charset_mode },
|
||||
{ "t_exit_pc_charset_mode", Termcap::t_exit_pc_charset_mode },
|
||||
{ "t_enter_insert_mode", Termcap::t_enter_insert_mode },
|
||||
{ "t_exit_insert_mode", Termcap::t_exit_insert_mode },
|
||||
{ "t_enter_am_mode", Termcap::t_enter_am_mode },
|
||||
{ "t_exit_am_mode", Termcap::t_exit_am_mode },
|
||||
{ "t_acs_chars", Termcap::t_acs_chars },
|
||||
{ "t_keypad_xmit", Termcap::t_keypad_xmit },
|
||||
{ "t_keypad_local", Termcap::t_keypad_local },
|
||||
{ "t_key_mouse", Termcap::t_key_mouse }
|
||||
}};
|
||||
|
||||
|
||||
@ -213,8 +215,8 @@ void debug (const finalcut::FApplication& TermApp)
|
||||
{
|
||||
const auto& fterm = TermApp.getFTerm();
|
||||
auto& debug_data = fterm.getFTermDebugData();
|
||||
const finalcut::FString& ab_s = debug_data.getAnswerbackString();
|
||||
const finalcut::FString& sec_da = debug_data.getSecDAString();
|
||||
const auto& ab_s = debug_data.getAnswerbackString();
|
||||
const auto& sec_da = debug_data.getSecDAString();
|
||||
std::cout << "\n.------------------- debug -------------------\r\n";
|
||||
|
||||
#if defined(__linux__)
|
||||
@ -238,7 +240,7 @@ void debug (const finalcut::FApplication& TermApp)
|
||||
std::cout << "`------------------- debug -------------------\r\n";
|
||||
}
|
||||
#else
|
||||
void debug (finalcut::FApplication&)
|
||||
void debug (const finalcut::FApplication&)
|
||||
{
|
||||
// FINAL CUT was compiled without debug option
|
||||
}
|
||||
@ -266,6 +268,10 @@ void booleans()
|
||||
, finalcut::FTermcap::osc_support );
|
||||
tcapBoolean ( "no_utf8_acs_chars"
|
||||
, finalcut::FTermcap::no_utf8_acs_chars );
|
||||
tcapBoolean ( "no_padding_char"
|
||||
, finalcut::FTermcap::no_padding_char );
|
||||
tcapBoolean ( "xon_xoff_flow_control"
|
||||
, finalcut::FTermcap::xon_xoff_flow_control );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -276,6 +282,8 @@ void numeric()
|
||||
, finalcut::FTermcap::max_color);
|
||||
tcapNumeric ("tabstop"
|
||||
, finalcut::FTermcap::tabstop);
|
||||
tcapNumeric ("padding_baudrate"
|
||||
, finalcut::FTermcap::padding_baudrate);
|
||||
tcapNumeric ("attr_without_color"
|
||||
, finalcut::FTermcap::attr_without_color);
|
||||
}
|
||||
@ -289,7 +297,7 @@ void string()
|
||||
for (const auto& entry : Data::strings)
|
||||
{
|
||||
const std::string name = entry.name;
|
||||
const fc::termcaps cap = entry.cap;
|
||||
const auto cap = std::size_t(entry.cap);
|
||||
tcapString (name, tcap_strings[cap].string);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,8 +22,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Timer
|
||||
@ -54,8 +52,8 @@ Timer::Timer (finalcut::FWidget* parent)
|
||||
delTimer (id);
|
||||
addTimer (250); // 250-millisecond timer
|
||||
|
||||
getColorTheme()->term_fg = fc::Default;
|
||||
getColorTheme()->term_bg = fc::Default;
|
||||
getColorTheme()->term_fg = finalcut::FColor::Default;
|
||||
getColorTheme()->term_bg = finalcut::FColor::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -77,7 +75,7 @@ void Timer::onTimer (finalcut::FTimerEvent* ev)
|
||||
if ( getPrintPos().getY() == int(getDesktopHeight()) )
|
||||
is_last_line = true;
|
||||
|
||||
print() << finalcut::FColorPair {FColor(1 + timer_id)}
|
||||
print() << finalcut::FColorPair {finalcut::FColor(1 + timer_id)}
|
||||
<< "Timer event, id " << timer_id << '\n';
|
||||
|
||||
if ( is_last_line )
|
||||
@ -104,12 +102,12 @@ int main (int argc, char* argv[])
|
||||
|
||||
// Force terminal initialization without calling show()
|
||||
app.initTerminal();
|
||||
app.setForegroundColor(fc::Default);
|
||||
app.setBackgroundColor(fc::Default);
|
||||
app.setForegroundColor(finalcut::FColor::Default);
|
||||
app.setBackgroundColor(finalcut::FColor::Default);
|
||||
|
||||
// Create a timer object t
|
||||
Timer t{&app};
|
||||
t.addAccelerator('q');
|
||||
t.addAccelerator(finalcut::FKey('q'));
|
||||
|
||||
// Set the timer object t as main widget
|
||||
finalcut::FWidget::setMainWidget(&t);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -22,8 +22,8 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FColorPair;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
using finalcut::FStyle;
|
||||
@ -36,54 +36,56 @@ using finalcut::FStyle;
|
||||
class Transparent final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Typedef and Enumeration
|
||||
typedef enum ttype
|
||||
// Enumeration
|
||||
enum class Type
|
||||
{
|
||||
transparent = 0,
|
||||
shadow = 1,
|
||||
inherit_background = 2
|
||||
} trans_type;
|
||||
Transparent = 0,
|
||||
Shadow = 1,
|
||||
InheritBackground = 2
|
||||
};
|
||||
|
||||
// Constructor
|
||||
explicit Transparent ( finalcut::FWidget* = nullptr
|
||||
, trans_type = transparent );
|
||||
, Type = Type::Transparent );
|
||||
|
||||
// Disable copy constructor
|
||||
Transparent (const Transparent&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Transparent() override;
|
||||
~Transparent() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Transparent& operator = (const Transparent&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
// Methods
|
||||
void initLayout() override;
|
||||
void draw() override;
|
||||
|
||||
// Event handlers
|
||||
void onKeyPress (finalcut::FKeyEvent* ev) override;
|
||||
|
||||
// Data members
|
||||
trans_type type;
|
||||
Type type;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Transparent::Transparent ( finalcut::FWidget* parent
|
||||
, Transparent::trans_type tt )
|
||||
, Transparent::Type tt )
|
||||
: finalcut::FDialog{parent}
|
||||
, type{tt}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Transparent::initLayout()
|
||||
{
|
||||
// Set statusbar text for this window
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FWidget::setStatusbarMessage("Press Q to quit");
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Transparent::~Transparent()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Transparent::draw()
|
||||
{
|
||||
@ -92,23 +94,23 @@ void Transparent::draw()
|
||||
if ( finalcut::FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( type == shadow )
|
||||
if ( type == Type::Shadow )
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
print() << FColorPair {wc->shadow_bg, wc->shadow_fg}
|
||||
<< FStyle {fc::ColorOverlay};
|
||||
<< FStyle {finalcut::Style::ColorOverlay};
|
||||
}
|
||||
else if ( type == inherit_background )
|
||||
else if ( type == Type::InheritBackground )
|
||||
{
|
||||
if ( finalcut::FTerm::getMaxColor() > 8 )
|
||||
print() << FColorPair {fc::Blue, fc::Black};
|
||||
print() << FColorPair {FColor::Blue, FColor::Black};
|
||||
else
|
||||
print() << FColorPair {fc::Green, fc::Black};
|
||||
print() << FColorPair {FColor::Green, FColor::Black};
|
||||
|
||||
print() << FStyle {fc::InheritBackground};
|
||||
print() << FStyle {finalcut::Style::InheritBackground};
|
||||
}
|
||||
else
|
||||
print() << FStyle {fc::Transparent};
|
||||
print() << FStyle {finalcut::Style::Transparent};
|
||||
|
||||
const finalcut::FString line{getClientWidth(), '.'};
|
||||
|
||||
@ -119,7 +121,7 @@ void Transparent::draw()
|
||||
<< line;
|
||||
}
|
||||
|
||||
print() << FStyle{fc::Reset};
|
||||
print() << FStyle{finalcut::Style::None};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -128,7 +130,7 @@ void Transparent::onKeyPress (finalcut::FKeyEvent* ev)
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' && getParentWidget() )
|
||||
if ( ev->key() == finalcut::FKey('q') && getParentWidget() )
|
||||
{
|
||||
getParentWidget()->close();
|
||||
ev->accept();
|
||||
@ -152,7 +154,7 @@ class MainWindow final : public finalcut::FDialog
|
||||
MainWindow (const MainWindow&) = delete;
|
||||
|
||||
// Destructor
|
||||
~MainWindow() override;
|
||||
~MainWindow() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
MainWindow& operator = (const MainWindow&) = delete;
|
||||
@ -170,7 +172,7 @@ class MainWindow final : public finalcut::FDialog
|
||||
if ( ! ev )
|
||||
return;
|
||||
|
||||
if ( ev->key() == 'q' )
|
||||
if ( ev->key() == finalcut::FKey('q') )
|
||||
{
|
||||
close();
|
||||
ev->accept();
|
||||
@ -202,12 +204,12 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
|
||||
transpwin->setGeometry (FPoint{6, 3}, FSize{29, 12});
|
||||
transpwin->unsetTransparentShadow();
|
||||
|
||||
shadowwin = new Transparent(this, Transparent::shadow);
|
||||
shadowwin = new Transparent(this, Transparent::Type::Shadow);
|
||||
shadowwin->setText("shadow");
|
||||
shadowwin->setGeometry (FPoint{46, 11}, FSize{29, 12});
|
||||
shadowwin->unsetTransparentShadow();
|
||||
|
||||
ibg = new Transparent(this, Transparent::inherit_background);
|
||||
ibg = new Transparent(this, Transparent::Type::InheritBackground);
|
||||
ibg->setText("inherit background");
|
||||
ibg->setGeometry (FPoint{42, 3}, FSize{29, 7});
|
||||
ibg->unsetTransparentShadow();
|
||||
@ -219,10 +221,6 @@ MainWindow::MainWindow (finalcut::FWidget* parent)
|
||||
activateDialog();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MainWindow::~MainWindow()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MainWindow::draw()
|
||||
{
|
||||
@ -248,7 +246,7 @@ void MainWindow::onClose (finalcut::FCloseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void MainWindow::onShow (finalcut::FShowEvent*)
|
||||
{
|
||||
addTimer(100); // Call onTimer() every 100 ms
|
||||
addTimer(90); // Call onTimer() every 90 ms
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -271,7 +269,7 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
// Create the application object
|
||||
finalcut::FApplication app {argc, argv};
|
||||
app.setNonBlockingRead();
|
||||
finalcut::FVTerm::setNonBlockingRead();
|
||||
|
||||
// Create main dialog object
|
||||
MainWindow main_dlg {&app};
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -27,7 +27,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -60,7 +59,7 @@ inline bool isLessThanInteger ( const finalcut::FString& lhs
|
||||
{
|
||||
const sInt64 l_number = stringToNumber(lhs);
|
||||
const sInt64 r_number = stringToNumber(rhs);
|
||||
return bool( l_number < r_number ); // lhs < rhs
|
||||
return l_number < r_number; // lhs < rhs
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -70,7 +69,7 @@ inline bool isLessThanDouble ( const finalcut::FString& lhs
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
const double l_number = lhs.toDouble();
|
||||
const double r_number = rhs.toDouble();
|
||||
return bool( l_number < r_number ); // lhs < rhs
|
||||
return l_number < r_number; // lhs < rhs
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -79,7 +78,7 @@ inline bool isGreaterThanInteger ( const finalcut::FString& lhs
|
||||
{
|
||||
const sInt64 l_number = stringToNumber(lhs);
|
||||
const sInt64 r_number = stringToNumber(rhs);
|
||||
return bool( l_number > r_number ); // lhs > rhs
|
||||
return l_number > r_number; // lhs > rhs
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -89,7 +88,7 @@ inline bool isGreaterThanDouble ( const finalcut::FString& lhs
|
||||
std::setlocale(LC_NUMERIC, "C");
|
||||
const double l_number = lhs.toDouble();
|
||||
const double r_number = rhs.toDouble();
|
||||
return bool( l_number > r_number ); // lhs > rhs
|
||||
return l_number > r_number; // lhs > rhs
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -151,7 +150,7 @@ class Treeview final : public finalcut::FDialog
|
||||
Treeview (const Treeview&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Treeview() override;
|
||||
~Treeview() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Treeview& operator = (const Treeview&) = delete;
|
||||
@ -161,21 +160,28 @@ class Treeview final : public finalcut::FDialog
|
||||
struct TreeItem; // forward declaration
|
||||
|
||||
// Methods
|
||||
auto initAfrica() const -> std::initializer_list<TreeItem>;
|
||||
auto initAsia() const -> std::initializer_list<TreeItem>;
|
||||
auto initEurope() const -> std::initializer_list<TreeItem>;
|
||||
auto initNorthAmerica() const -> std::initializer_list<TreeItem>;
|
||||
auto initSouthAmerica() const -> std::initializer_list<TreeItem>;
|
||||
auto initOceania() const -> std::initializer_list<TreeItem>;
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handler
|
||||
void onClose (finalcut::FCloseEvent*) override;
|
||||
|
||||
// Data members
|
||||
bool initialized{false};
|
||||
finalcut::FListView listview{this};
|
||||
finalcut::FButton quit{this};
|
||||
static TreeItem africa[];
|
||||
static TreeItem asia[];
|
||||
static TreeItem europe[];
|
||||
static TreeItem north_america[];
|
||||
static TreeItem south_america[];
|
||||
static TreeItem oceania[];
|
||||
bool initialized{false};
|
||||
finalcut::FListView listview{this};
|
||||
finalcut::FButton quit{this};
|
||||
std::vector<TreeItem> africa{initAfrica()};
|
||||
std::vector<TreeItem> asia{initAsia()};
|
||||
std::vector<TreeItem> europe{initEurope()};
|
||||
std::vector<TreeItem> north_america{initNorthAmerica()};
|
||||
std::vector<TreeItem> south_america{initSouthAmerica()};
|
||||
std::vector<TreeItem> oceania{initOceania()};
|
||||
};
|
||||
|
||||
|
||||
@ -185,165 +191,40 @@ class Treeview final : public finalcut::FDialog
|
||||
|
||||
struct Treeview::TreeItem
|
||||
{
|
||||
const char* const* begin() const
|
||||
using const_iterator = const char* const*;
|
||||
|
||||
const_iterator begin() const noexcept
|
||||
{ return &name; }
|
||||
|
||||
const char* const* end() const
|
||||
{ return reinterpret_cast<const char* const*>(&child_element); }
|
||||
const_iterator end() const noexcept
|
||||
{ return std::next(&density); }
|
||||
|
||||
// Data members
|
||||
const char* name;
|
||||
const char* population;
|
||||
const char* density;
|
||||
TreeItem* child_element;
|
||||
std::vector<TreeItem> child_element;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class Treeview - array data
|
||||
//----------------------------------------------------------------------
|
||||
Treeview::TreeItem Treeview::africa[] =
|
||||
{
|
||||
{ "Algeria", "40,400,000", "15.9", nullptr },
|
||||
{ "Angola", "25,789,024", "20.69", nullptr },
|
||||
{ "Botswana", "2,250,260", "3.7", nullptr },
|
||||
{ "Cameroon", "22,534,532", "39.7", nullptr },
|
||||
{ "Chad", "13,670,084", "8.6", nullptr },
|
||||
{ "Egypt", "94,666,000", "87", nullptr },
|
||||
{ "Ethiopia", "102,374,044", "92.7", nullptr },
|
||||
{ "Ivory Coast", "23,740,424", "63.9", nullptr },
|
||||
{ "Libya", "6,541,948", "3.55", nullptr },
|
||||
{ "Madagascar", "24,430,325", "35.2", nullptr },
|
||||
{ "Mali", "14,517,176", "11.7", nullptr },
|
||||
{ "Mauritania", "4,301,018", "3.4", nullptr },
|
||||
{ "Mozambique", "24,692,144", "28.7", nullptr },
|
||||
{ "Namibia", "2,113,077", "2.54", nullptr },
|
||||
{ "Niger", "20,672,987", "12.1", nullptr },
|
||||
{ "Nigeria", "185,989,640", "197.2", nullptr },
|
||||
{ "Somalia", "14,317,996", "19.31", nullptr },
|
||||
{ "South Africa", "54,956,900", "42.4", nullptr },
|
||||
{ "South Sudan", "12,340,000", "13.33", nullptr },
|
||||
{ "Sudan", "39,578,828", "21.3", nullptr },
|
||||
{ "Tanzania", "51,820,00", "47.5", nullptr },
|
||||
{ "Zambia", "16,212,000", "17.2", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
Treeview::TreeItem Treeview::asia[] =
|
||||
{
|
||||
{ "Afghanistan", "34,656,032", "49.88", nullptr },
|
||||
{ "China", "1,403,500,365", "145.0", nullptr },
|
||||
{ "India", "1,324,171,354", "393.9", nullptr },
|
||||
{ "Indonesia", "261,115,456", "124.66", nullptr },
|
||||
{ "Iran", "80,829,192", "48.0", nullptr },
|
||||
{ "Iraq", "37,202,572", "82.7", nullptr },
|
||||
{ "Japan", "126,740,000", "336.0", nullptr },
|
||||
{ "Kazakhstan", "17,987,736", "6.49", nullptr },
|
||||
{ "Mongolia", "3,081,677", "1.97", nullptr },
|
||||
{ "Myanmar", "51,486,253", "76.0", nullptr },
|
||||
{ "Pakistan", "207,774,520", "244.4", nullptr },
|
||||
{ "Russia", "144,463,451", "8.4", nullptr },
|
||||
{ "Saudi Arabia", "33,000,000", "15.0", nullptr },
|
||||
{ "Thailand", "68,863,514", "132.1", nullptr },
|
||||
{ "Turkey", "79,814,871", "102.0", nullptr },
|
||||
{ "Turkmenistan", "5,662,544", "10.5", nullptr },
|
||||
{ "Uzbekistan", "32,979,000", "70.5", nullptr },
|
||||
{ "Vietnam", "94,569,072", "276.03", nullptr },
|
||||
{ "Yemen", "27,584,213", "44.7", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
Treeview::TreeItem Treeview::europe[] =
|
||||
{
|
||||
{ "Austria", "8,794,267", "104.0", nullptr },
|
||||
{ "Belarus", "9,498,700", "45.8", nullptr },
|
||||
{ "Bulgaria", "7,101,859", "64.9", nullptr },
|
||||
{ "Czech Republic", "10,610,947", "134.0", nullptr },
|
||||
{ "Finland", "5,506,312", "16.0", nullptr },
|
||||
{ "France", "66,991,000", "103.0", nullptr },
|
||||
{ "Germany", "82,175,700", "227.0", nullptr },
|
||||
{ "Greece", "11,183,716", "82.0", nullptr },
|
||||
{ "Hungary", "9,797,561", "105.3", nullptr },
|
||||
{ "Iceland", "332,529", "3.2", nullptr },
|
||||
{ "Italy", "60,589,445", "201.3", nullptr },
|
||||
{ "Norway", "5,267,146", "15.8", nullptr },
|
||||
{ "Poland", "38,634,007", "123.0", nullptr },
|
||||
{ "Portugal", "10,309,573", "115.0", nullptr },
|
||||
{ "Romania", "19,638,000", "84.4", nullptr },
|
||||
{ "Serbia", "7,058,322", "91.1", nullptr },
|
||||
{ "Spain", "46,468,102", "92.0", nullptr },
|
||||
{ "Sweden", "10,065,389", "22.0", nullptr },
|
||||
{ "United Kingdom", "65,648,000", "270.7", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
|
||||
Treeview::TreeItem Treeview::north_america[] =
|
||||
{
|
||||
{ "Canada", "35,151,728", "3.92", nullptr },
|
||||
{ "Cuba", "11,239,224", "102.3", nullptr },
|
||||
{ "Greenland", "56,483", "0.028", nullptr },
|
||||
{ "Guatemala", "16,582,469", "129.0", nullptr },
|
||||
{ "Honduras", "9,112,867", "64.0", nullptr },
|
||||
{ "Mexico", "119,530,753", "61.0", nullptr },
|
||||
{ "Nicaragua", "6,167,237", "51.0", nullptr },
|
||||
{ "USA", "325,365,189", "35.0", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
Treeview::TreeItem Treeview::south_america[] =
|
||||
{
|
||||
{ "Argentina", "43,847,430", "14.4", nullptr },
|
||||
{ "Bolivia", "11,410,651", "10.4", nullptr },
|
||||
{ "Brazil", "208,064,000", "24.35", nullptr },
|
||||
{ "Chile", "18,006,407", "24.0", nullptr },
|
||||
{ "Colombia", "49,364,592", "40.74", nullptr },
|
||||
{ "Ecuador", "16,385,068", "58.95", nullptr },
|
||||
{ "Guyana", "773,303", "3.502", nullptr },
|
||||
{ "Paraguay", "6,725,308", "17.2", nullptr },
|
||||
{ "Peru", "31,826,018", "23.0", nullptr },
|
||||
{ "Venezuela", "31,568,179", "33.75", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
Treeview::TreeItem Treeview::oceania[] =
|
||||
{
|
||||
{ "Australia", "24,675,900", "3.2", nullptr },
|
||||
{ "Papua New Guinea", "7,059,653", "15.0", nullptr },
|
||||
{ "Papua", "3,486,432", "11.0", nullptr },
|
||||
{ "New Zealand", "4,823,090", "17.5", nullptr },
|
||||
{ "West Papua", "877,437", "6.3", nullptr },
|
||||
{ "Solomon Islands", "599,419", "18.1", nullptr },
|
||||
{ "New Caledonia", "268,767", "14.5", nullptr },
|
||||
{ "Fiji", "898,76", "46.4", nullptr },
|
||||
{ "Hawaii", "1,428,557", "82.6", nullptr },
|
||||
{ "Vanuatu", "270,402", "19.7", nullptr },
|
||||
{ "French Polynesia", "280,208", "76.0", nullptr },
|
||||
{ "Samoa", "192,342", "68.0", nullptr },
|
||||
{ "Kiribati", "110,136", "152.0", nullptr },
|
||||
{ nullptr, nullptr, nullptr, nullptr }
|
||||
};
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
Treeview::Treeview (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||
|
||||
// Add columns to the view
|
||||
listview.addColumn ("Name", 23);
|
||||
listview.addColumn ("Population");
|
||||
listview.addColumn ("Density/km²");
|
||||
|
||||
// Set right alignment for the second and third column
|
||||
listview.setColumnAlignment (2, fc::alignRight);
|
||||
listview.setColumnAlignment (3, fc::alignRight);
|
||||
listview.setColumnAlignment (2, finalcut::Align::Right);
|
||||
listview.setColumnAlignment (3, finalcut::Align::Right);
|
||||
|
||||
// Set the type of sorting
|
||||
listview.setColumnSortType (1, fc::by_name);
|
||||
listview.setColumnSortType (2, fc::user_defined);
|
||||
listview.setColumnSortType (3, fc::user_defined);
|
||||
listview.setColumnSortType (1, finalcut::SortType::Name);
|
||||
listview.setColumnSortType (2, finalcut::SortType::UserDefined);
|
||||
listview.setColumnSortType (3, finalcut::SortType::UserDefined);
|
||||
listview.setUserAscendingCompare(sortAscending);
|
||||
listview.setUserDescendingCompare(sortDescending);
|
||||
|
||||
@ -351,35 +232,32 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
||||
listview.setTreeView();
|
||||
|
||||
// Populate FListView with a list of items
|
||||
static TreeItem continent_list[] =
|
||||
const std::vector<TreeItem> continent_list
|
||||
{
|
||||
{ "Africa", "944,000,000", "31.2", africa },
|
||||
{ "Asia", "4,010,000,000", "90.3", asia },
|
||||
{ "Europe", "733,000,000", "69.9", europe },
|
||||
{ "North America", "523,000,000", "21", north_america },
|
||||
{ "South America", "381,000,000", "21.4", south_america },
|
||||
{ "Antarctica", "1000", "0", nullptr },
|
||||
{ "Antarctica", "1000", "0", {} },
|
||||
{ "Australia/Oceania", "34,000,000", "4", oceania }
|
||||
};
|
||||
|
||||
for (const auto& continent : continent_list)
|
||||
{
|
||||
const TreeItem* country_list = continent.child_element;
|
||||
finalcut::FStringList continent_line ( continent.begin()
|
||||
, continent.end() );
|
||||
auto iter = listview.insert (continent_line);
|
||||
|
||||
while ( country_list && country_list->name )
|
||||
for (const auto& country : continent.child_element)
|
||||
{
|
||||
finalcut::FStringList country_line ( country_list->begin()
|
||||
, country_list->end() );
|
||||
finalcut::FStringList country_line ( country.begin()
|
||||
, country.end() );
|
||||
listview.insert (country_line, iter);
|
||||
country_list++;
|
||||
}
|
||||
}
|
||||
|
||||
// quit button
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
// Quit button text
|
||||
quit.setText (L"&Quit");
|
||||
|
||||
// Callback function
|
||||
@ -395,8 +273,159 @@ Treeview::Treeview (finalcut::FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Treeview::~Treeview() // destructor
|
||||
{ }
|
||||
auto Treeview::initAfrica() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Algeria", "40,400,000", "15.9", {} },
|
||||
{ "Angola", "25,789,024", "20.69", {} },
|
||||
{ "Botswana", "2,250,260", "3.7", {} },
|
||||
{ "Cameroon", "22,534,532", "39.7", {} },
|
||||
{ "Chad", "13,670,084", "8.6", {} },
|
||||
{ "Egypt", "94,666,000", "87", {} },
|
||||
{ "Ethiopia", "102,374,044", "92.7", {} },
|
||||
{ "Ivory Coast", "23,740,424", "63.9", {} },
|
||||
{ "Libya", "6,541,948", "3.55", {} },
|
||||
{ "Madagascar", "24,430,325", "35.2", {} },
|
||||
{ "Mali", "14,517,176", "11.7", {} },
|
||||
{ "Mauritania", "4,301,018", "3.4", {} },
|
||||
{ "Mozambique", "24,692,144", "28.7", {} },
|
||||
{ "Namibia", "2,113,077", "2.54", {} },
|
||||
{ "Niger", "20,672,987", "12.1", {} },
|
||||
{ "Nigeria", "185,989,640", "197.2", {} },
|
||||
{ "Somalia", "14,317,996", "19.31", {} },
|
||||
{ "South Africa", "54,956,900", "42.4", {} },
|
||||
{ "South Sudan", "12,340,000", "13.33", {} },
|
||||
{ "Sudan", "39,578,828", "21.3", {} },
|
||||
{ "Tanzania", "51,820,00", "47.5", {} },
|
||||
{ "Zambia", "16,212,000", "17.2", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto Treeview::initAsia() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Afghanistan", "34,656,032", "49.88", {} },
|
||||
{ "China", "1,403,500,365", "145.0", {} },
|
||||
{ "India", "1,324,171,354", "393.9", {} },
|
||||
{ "Indonesia", "261,115,456", "124.66", {} },
|
||||
{ "Iran", "80,829,192", "48.0", {} },
|
||||
{ "Iraq", "37,202,572", "82.7", {} },
|
||||
{ "Japan", "126,740,000", "336.0", {} },
|
||||
{ "Kazakhstan", "17,987,736", "6.49", {} },
|
||||
{ "Mongolia", "3,081,677", "1.97", {} },
|
||||
{ "Myanmar", "51,486,253", "76.0", {} },
|
||||
{ "Pakistan", "207,774,520", "244.4", {} },
|
||||
{ "Russia", "144,463,451", "8.4", {} },
|
||||
{ "Saudi Arabia", "33,000,000", "15.0", {} },
|
||||
{ "Thailand", "68,863,514", "132.1", {} },
|
||||
{ "Turkey", "79,814,871", "102.0", {} },
|
||||
{ "Turkmenistan", "5,662,544", "10.5", {} },
|
||||
{ "Uzbekistan", "32,979,000", "70.5", {} },
|
||||
{ "Vietnam", "94,569,072", "276.03", {} },
|
||||
{ "Yemen", "27,584,213", "44.7", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto Treeview::initEurope() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Austria", "8,794,267", "104.0", {} },
|
||||
{ "Belarus", "9,498,700", "45.8", {} },
|
||||
{ "Bulgaria", "7,101,859", "64.9", {} },
|
||||
{ "Czech Republic", "10,610,947", "134.0", {} },
|
||||
{ "Finland", "5,506,312", "16.0", {} },
|
||||
{ "France", "66,991,000", "103.0", {} },
|
||||
{ "Germany", "82,175,700", "227.0", {} },
|
||||
{ "Greece", "11,183,716", "82.0", {} },
|
||||
{ "Hungary", "9,797,561", "105.3", {} },
|
||||
{ "Iceland", "332,529", "3.2", {} },
|
||||
{ "Italy", "60,589,445", "201.3", {} },
|
||||
{ "Norway", "5,267,146", "15.8", {} },
|
||||
{ "Poland", "38,634,007", "123.0", {} },
|
||||
{ "Portugal", "10,309,573", "115.0", {} },
|
||||
{ "Romania", "19,638,000", "84.4", {} },
|
||||
{ "Serbia", "7,058,322", "91.1", {} },
|
||||
{ "Spain", "46,468,102", "92.0", {} },
|
||||
{ "Sweden", "10,065,389", "22.0", {} },
|
||||
{ "United Kingdom", "65,648,000", "270.7", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto Treeview::initNorthAmerica() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Canada", "35,151,728", "3.92", {} },
|
||||
{ "Cuba", "11,239,224", "102.3", {} },
|
||||
{ "Greenland", "56,483", "0.028", {} },
|
||||
{ "Guatemala", "16,582,469", "129.0", {} },
|
||||
{ "Honduras", "9,112,867", "64.0", {} },
|
||||
{ "Mexico", "119,530,753", "61.0", {} },
|
||||
{ "Nicaragua", "6,167,237", "51.0", {} },
|
||||
{ "USA", "325,365,189", "35.0", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto Treeview::initSouthAmerica() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Argentina", "43,847,430", "14.4", {} },
|
||||
{ "Bolivia", "11,410,651", "10.4", {} },
|
||||
{ "Brazil", "208,064,000", "24.35", {} },
|
||||
{ "Chile", "18,006,407", "24.0", {} },
|
||||
{ "Colombia", "49,364,592", "40.74", {} },
|
||||
{ "Ecuador", "16,385,068", "58.95", {} },
|
||||
{ "Guyana", "773,303", "3.502", {} },
|
||||
{ "Paraguay", "6,725,308", "17.2", {} },
|
||||
{ "Peru", "31,826,018", "23.0", {} },
|
||||
{ "Venezuela", "31,568,179", "33.75", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto Treeview::initOceania() const -> std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
static const auto list = std::initializer_list<Treeview::TreeItem>
|
||||
{
|
||||
{ "Australia", "24,675,900", "3.2", {} },
|
||||
{ "Papua New Guinea", "7,059,653", "15.0", {} },
|
||||
{ "Papua", "3,486,432", "11.0", {} },
|
||||
{ "New Zealand", "4,823,090", "17.5", {} },
|
||||
{ "West Papua", "877,437", "6.3", {} },
|
||||
{ "Solomon Islands", "599,419", "18.1", {} },
|
||||
{ "New Caledonia", "268,767", "14.5", {} },
|
||||
{ "Fiji", "898,76", "46.4", {} },
|
||||
{ "Hawaii", "1,428,557", "82.6", {} },
|
||||
{ "Vanuatu", "270,402", "19.7", {} },
|
||||
{ "French Polynesia", "280,208", "76.0", {} },
|
||||
{ "Samoa", "192,342", "68.0", {} },
|
||||
{ "Kiribati", "110,136", "152.0", {} }
|
||||
};
|
||||
return list;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Treeview::initLayout()
|
||||
{
|
||||
// Set FListView geometry
|
||||
listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
|
||||
// Set quit button geometry
|
||||
quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Treeview::adjustSize()
|
||||
|
195
examples/ui.cpp
195
examples/ui.cpp
@ -22,14 +22,14 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using FKey = finalcut::FKey;
|
||||
using finalcut::FColor;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FRect;
|
||||
using finalcut::FSize;
|
||||
@ -42,9 +42,6 @@ using finalcut::FSize;
|
||||
class ProgressDialog final : public finalcut::FDialog
|
||||
{
|
||||
public:
|
||||
// Using-declaration
|
||||
using FDialog::setGeometry;
|
||||
|
||||
// Constructor
|
||||
explicit ProgressDialog (finalcut::FWidget* = nullptr);
|
||||
|
||||
@ -58,6 +55,9 @@ class ProgressDialog final : public finalcut::FDialog
|
||||
ProgressDialog& operator = (const ProgressDialog&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
|
||||
// Event handlers
|
||||
void onShow (finalcut::FShowEvent*) override;
|
||||
void onTimer (finalcut::FTimerEvent*) override;
|
||||
@ -78,29 +78,18 @@ class ProgressDialog final : public finalcut::FDialog
|
||||
ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setGeometry ( FPoint{int((getParentWidget()->getWidth() - 40) / 2), 7}
|
||||
, FSize{40, 10} );
|
||||
FDialog::setText("Progress bar");
|
||||
//setModal();
|
||||
|
||||
reset.setText("&Reset");
|
||||
reset.setStatusbarMessage ("Reset the progress bar");
|
||||
reset.setGeometry(FPoint{2, 6}, FSize{8, 1}, false);
|
||||
reset.setDisable();
|
||||
|
||||
more.setText("&More");
|
||||
more.setStatusbarMessage ("Increases the progress bar position");
|
||||
more.setGeometry(FPoint{15, 6}, FSize{8, 1}, false);
|
||||
more.setDisable();
|
||||
|
||||
quit.setText("E&xit");
|
||||
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
||||
quit.setDisable();
|
||||
|
||||
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
||||
//progressbar.setPercentage(78);
|
||||
|
||||
reset.addCallback
|
||||
@ -131,6 +120,19 @@ ProgressDialog::~ProgressDialog() // destructor
|
||||
delCallback(&reset);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ProgressDialog::initLayout()
|
||||
{
|
||||
FDialog::setGeometry ( FPoint{int((getParentWidget()->getWidth() - 40) / 2), 7}
|
||||
, FSize{40, 10} );
|
||||
FDialog::setText("Progress bar");
|
||||
reset.setGeometry(FPoint{2, 6}, FSize{8, 1}, false);
|
||||
more.setGeometry(FPoint{15, 6}, FSize{8, 1}, false);
|
||||
quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
|
||||
progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void ProgressDialog::onShow (finalcut::FShowEvent*)
|
||||
{
|
||||
@ -196,7 +198,7 @@ class TextWindow final : public finalcut::FDialog
|
||||
TextWindow (const TextWindow&) = delete;
|
||||
|
||||
// Destructor
|
||||
~TextWindow() override;
|
||||
~TextWindow() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
TextWindow& operator = (const TextWindow&) = delete;
|
||||
@ -206,6 +208,7 @@ class TextWindow final : public finalcut::FDialog
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Data members
|
||||
@ -217,8 +220,6 @@ TextWindow::TextWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
scrolltext.ignorePadding();
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
setMinimumSize (FSize{51, 6});
|
||||
scrolltext.setFocus();
|
||||
scrolltext.insert(" -----------------------------------------------\n"
|
||||
" line 1\n"
|
||||
@ -230,16 +231,20 @@ TextWindow::TextWindow (finalcut::FWidget* parent)
|
||||
scrolltext.deleteRange(3, 4);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
TextWindow::~TextWindow() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void TextWindow::append (const finalcut::FString& str)
|
||||
{
|
||||
scrolltext.append(str);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void TextWindow::initLayout()
|
||||
{
|
||||
scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
|
||||
setMinimumSize (FSize{51, 6});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void TextWindow::adjustSize()
|
||||
{
|
||||
@ -262,7 +267,7 @@ class MyDialog final : public finalcut::FDialog
|
||||
MyDialog (const MyDialog&) = delete;
|
||||
|
||||
// Destructor
|
||||
~MyDialog() override;
|
||||
~MyDialog() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
MyDialog& operator = (const MyDialog&) = delete;
|
||||
@ -283,6 +288,7 @@ class MyDialog final : public finalcut::FDialog
|
||||
void initButtons();
|
||||
void initLabels();
|
||||
void initWidgetsCallbacks();
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
@ -328,13 +334,13 @@ class MyDialog final : public finalcut::FDialog
|
||||
finalcut::FMenuItem File2{"/etc/fstab", &Recent};
|
||||
finalcut::FMenuItem File3{"/etc/passwd", &Recent};
|
||||
// "Edit" menu items
|
||||
finalcut::FMenuItem Undo{fc::Fckey_z, "Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{fc::Fckey_y, "Redo", &Edit};
|
||||
finalcut::FMenuItem Undo{FKey::Ctrl_z, "Undo", &Edit};
|
||||
finalcut::FMenuItem Redo{FKey::Ctrl_y, "Redo", &Edit};
|
||||
finalcut::FMenuItem Line2{&Edit};
|
||||
finalcut::FMenuItem Cut{fc::Fckey_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{fc::Fckey_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{fc::Fckey_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Clear{fc::Fkey_dc, "C&lear", &Edit};
|
||||
finalcut::FMenuItem Cut{FKey::Ctrl_x, "Cu&t", &Edit};
|
||||
finalcut::FMenuItem Copy{FKey::Ctrl_c, "&Copy", &Edit};
|
||||
finalcut::FMenuItem Paste{FKey::Ctrl_v, "&Paste", &Edit};
|
||||
finalcut::FMenuItem Clear{FKey::Del_char, "C&lear", &Edit};
|
||||
// "View" menu items
|
||||
finalcut::FMenuItem Env{"&Terminal...", &View};
|
||||
finalcut::FMenuItem Drive{"&Drive symbols...", &View};
|
||||
@ -342,9 +348,9 @@ class MyDialog final : public finalcut::FDialog
|
||||
finalcut::FCheckMenuItem Theme{"Dark &mode", &View};
|
||||
// Statusbar
|
||||
finalcut::FStatusBar Statusbar{this};
|
||||
finalcut::FStatusKey key_F1{fc::Fkey_f1, "About", &Statusbar};
|
||||
finalcut::FStatusKey key_F2{fc::Fkey_f2, "View", &Statusbar};
|
||||
finalcut::FStatusKey key_F3{fc::Fkey_f3, "Quit", &Statusbar};
|
||||
finalcut::FStatusKey key_F1{FKey::F1, "About", &Statusbar};
|
||||
finalcut::FStatusKey key_F2{FKey::F2, "View", &Statusbar};
|
||||
finalcut::FStatusKey key_F3{FKey::F3, "Quit", &Statusbar};
|
||||
// Dialog widgets
|
||||
finalcut::FButton MyButton1{this};
|
||||
finalcut::FButton MyButton2{this};
|
||||
@ -375,10 +381,6 @@ MyDialog::MyDialog (finalcut::FWidget* parent)
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
MyDialog::~MyDialog() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::init()
|
||||
{
|
||||
@ -403,11 +405,11 @@ void MyDialog::initMenu()
|
||||
Help.setStatusbarMessage ("Show version and copyright information");
|
||||
|
||||
// "File" menu items
|
||||
Open.addAccelerator (fc::Fckey_o); // Ctrl + O
|
||||
Open.addAccelerator (FKey::Ctrl_o); // Ctrl + O
|
||||
Open.setStatusbarMessage ("Locate and open a text file");
|
||||
Recent.setStatusbarMessage ("View text file");
|
||||
Line1.setSeparator();
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (FKey::Meta_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// "Edit" menu items
|
||||
@ -581,7 +583,6 @@ void MyDialog::initWidgets()
|
||||
initToggleButtons();
|
||||
|
||||
// A text input field
|
||||
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();
|
||||
@ -590,9 +591,8 @@ void MyDialog::initWidgets()
|
||||
initButtons();
|
||||
|
||||
// A multiple selection listbox
|
||||
myList.setGeometry(FPoint{38, 1}, FSize{14, 17});
|
||||
myList.setText ("Items");
|
||||
|
||||
myList.setText ("Items");
|
||||
myList.setStatusbarMessage ("99 items in a list");
|
||||
myList.setMultiSelection();
|
||||
myList.reserve(100);
|
||||
@ -608,21 +608,18 @@ void MyDialog::initWidgets()
|
||||
void MyDialog::initFlatButtons()
|
||||
{
|
||||
// Flat buttons
|
||||
MyButton1.setGeometry(FPoint{3, 3}, FSize{5, 1});
|
||||
MyButton1.setText (L"&SIN");
|
||||
MyButton1.setStatusbarMessage ("Sine function");
|
||||
MyButton1.setNoUnderline();
|
||||
MyButton1.setFlat();
|
||||
MyButton1.setDoubleFlatLine (fc::bottom);
|
||||
MyButton1.setDoubleFlatLine (finalcut::Side::Bottom);
|
||||
|
||||
MyButton2.setGeometry(FPoint{3, 5}, FSize{5, 1});
|
||||
MyButton2.setText (L"&COS");
|
||||
MyButton2.setStatusbarMessage ("Cosine function");
|
||||
MyButton2.setNoUnderline();
|
||||
MyButton2.setFlat();
|
||||
MyButton2.setDoubleFlatLine (fc::top);
|
||||
MyButton2.setDoubleFlatLine (finalcut::Side::Top);
|
||||
|
||||
MyButton3.setGeometry(FPoint{10, 3}, FSize{5, 3});
|
||||
MyButton3.setText (L"&=");
|
||||
MyButton3.setStatusbarMessage ("Equal");
|
||||
MyButton3.setNoUnderline();
|
||||
@ -655,25 +652,16 @@ void MyDialog::initFlatButtons()
|
||||
void MyDialog::initToggleButtons()
|
||||
{
|
||||
// Radio buttons in a group
|
||||
radioButtonGroup.setGeometry(FPoint{3, 8}, FSize{14, 4});
|
||||
|
||||
//radioButtonGroup->unsetBorder();
|
||||
|
||||
radio1.setGeometry(FPoint{1, 1}, FSize{10, 1});
|
||||
radio1.setStatusbarMessage ("Enable button Test");
|
||||
|
||||
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(FPoint{3, 12}, FSize{14, 4});
|
||||
|
||||
check1.setGeometry(FPoint{1, 1}, FSize{11, 1});
|
||||
check1.setNoUnderline();
|
||||
|
||||
check2.setGeometry(FPoint{1, 2}, FSize{9, 1});
|
||||
check2.setChecked();
|
||||
check2.setNoUnderline();
|
||||
}
|
||||
@ -682,20 +670,18 @@ void MyDialog::initToggleButtons()
|
||||
void MyDialog::initButtons()
|
||||
{
|
||||
// Buttons
|
||||
MyButton4.setGeometry(FPoint{20, 8}, FSize{12, 1});
|
||||
|
||||
MyButton4.setText (L"&Get input");
|
||||
MyButton4.setStatusbarMessage ("Take text from input field");
|
||||
MyButton4.setFocus();
|
||||
|
||||
MyButton5.setGeometry(FPoint{20, 11}, FSize{12, 1});
|
||||
MyButton5.setText (L"&Test");
|
||||
MyButton5.setStatusbarMessage ("Progressbar testing dialog");
|
||||
MyButton5.setDisable();
|
||||
|
||||
MyButton6.setGeometry(FPoint{20, 14}, FSize{12, 1});
|
||||
MyButton6.setText (L"&Quit");
|
||||
MyButton6.setStatusbarMessage ("Exit the program");
|
||||
MyButton6.addAccelerator('x');
|
||||
MyButton6.addAccelerator(FKey('x'));
|
||||
|
||||
// Add button callback functions
|
||||
MyButton4.addCallback
|
||||
@ -724,20 +710,12 @@ void MyDialog::initButtons()
|
||||
void MyDialog::initLabels()
|
||||
{
|
||||
// Text labels
|
||||
headline.setGeometry(FPoint{21, 3}, FSize{10, 1});
|
||||
|
||||
headline.setEmphasis();
|
||||
headline.setAlignment (fc::alignCenter);
|
||||
headline.setAlignment (finalcut::Align::Center);
|
||||
headline = L"List items";
|
||||
|
||||
tagged.setGeometry(FPoint{21, 4}, FSize{7, 1});
|
||||
|
||||
tagged_count.setGeometry(FPoint{29, 4}, FSize{5, 1});
|
||||
tagged_count << 0;
|
||||
|
||||
sum.setGeometry(FPoint{21, 5}, FSize{7, 3});
|
||||
sum.setAlignment (fc::alignRight);
|
||||
|
||||
sum_count.setGeometry(FPoint{29, 5}, FSize{5, 3});
|
||||
sum.setAlignment (finalcut::Align::Right);
|
||||
sum_count << myList.getCount();
|
||||
}
|
||||
|
||||
@ -774,10 +752,39 @@ void MyDialog::initWidgetsCallbacks()
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::initLayout()
|
||||
{
|
||||
MyButton1.setGeometry(FPoint{3, 3}, FSize{5, 1});
|
||||
MyButton2.setGeometry(FPoint{3, 5}, FSize{5, 1});
|
||||
MyButton3.setGeometry(FPoint{10, 3}, FSize{5, 3});
|
||||
MyButton4.setGeometry(FPoint{20, 8}, FSize{12, 1});
|
||||
MyButton5.setGeometry(FPoint{20, 11}, FSize{12, 1});
|
||||
MyButton6.setGeometry(FPoint{20, 14}, FSize{12, 1});
|
||||
radioButtonGroup.setGeometry(FPoint{3, 8}, FSize{14, 4});
|
||||
radio1.setGeometry(FPoint{1, 1}, FSize{10, 1});
|
||||
radio2.setGeometry(FPoint{1, 2}, FSize{11, 1});
|
||||
checkButtonGroup.setGeometry(FPoint{3, 12}, FSize{14, 4});
|
||||
check1.setGeometry(FPoint{1, 1}, FSize{11, 1});
|
||||
check2.setGeometry(FPoint{1, 2}, FSize{9, 1});
|
||||
headline.setGeometry(FPoint{21, 3}, FSize{10, 1});
|
||||
tagged.setGeometry(FPoint{21, 4}, FSize{7, 1});
|
||||
tagged_count.setGeometry(FPoint{29, 4}, FSize{5, 1});
|
||||
sum.setGeometry(FPoint{21, 5}, FSize{7, 3});
|
||||
sum_count.setGeometry(FPoint{29, 5}, FSize{5, 3});
|
||||
myLineEdit.setGeometry(FPoint{22, 1}, FSize{10, 1});
|
||||
myList.setGeometry(FPoint{38, 1}, FSize{14, 17});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::adjustSize()
|
||||
{
|
||||
const auto h = getDesktopHeight() - 4;
|
||||
auto h = getDesktopHeight();
|
||||
|
||||
if ( h > 4 )
|
||||
h -= 4;
|
||||
|
||||
setHeight (h, false);
|
||||
finalcut::FDialog::adjustSize(); // with new client area size
|
||||
auto x = int((getDesktopWidth() - getWidth()) / 2);
|
||||
@ -787,7 +794,7 @@ void MyDialog::adjustSize()
|
||||
|
||||
setPos (FPoint{x, 2}, false);
|
||||
|
||||
if ( initialized )
|
||||
if ( initialized && h > 3 )
|
||||
myList.setHeight (h - 3, true);
|
||||
}
|
||||
|
||||
@ -811,15 +818,15 @@ void MyDialog::cb_noFunctionMsg (const finalcut::FButton& button)
|
||||
void MyDialog::cb_about()
|
||||
{
|
||||
constexpr char libver[] = F_VERSION;
|
||||
const finalcut::FString line(2, fc::BoxDrawingsHorizontal);
|
||||
const finalcut::FString line(2, finalcut::UniChar::BoxDrawingsHorizontal);
|
||||
|
||||
finalcut::FMessageBox info ( "About"
|
||||
, line + L" FINAL CUT " + line + L"\n\n"
|
||||
L"Version " + libver + L"\n\n"
|
||||
L"(c) 2020 by Markus Gans"
|
||||
, finalcut::FMessageBox::Ok
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::Reject
|
||||
L"(c) 2021 by Markus Gans"
|
||||
, finalcut::FMessageBox::ButtonType::Ok
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, this );
|
||||
info.setCenterText();
|
||||
info.show();
|
||||
@ -837,12 +844,12 @@ void MyDialog::cb_terminfo()
|
||||
<< " Type: " << finalcut::FTerm::getTermType() << "\n"
|
||||
<< " Name: " << finalcut::FTerm::getTermFileName() << "\n"
|
||||
<< " Mode: " << finalcut::FTerm::getEncodingString() << "\n"
|
||||
<< " Size: " << x << fc::Times
|
||||
<< " Size: " << x << finalcut::UniChar::Times
|
||||
<< y << "\n"
|
||||
<< "Colors: " << finalcut::FTerm::getMaxColor()
|
||||
, finalcut::FMessageBox::Ok
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Ok
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, this
|
||||
);
|
||||
info1.setHeadline("Terminal:");
|
||||
@ -858,9 +865,9 @@ void MyDialog::cb_drives()
|
||||
, "Generic: \n\n"
|
||||
"Network: \n\n"
|
||||
" CD:"
|
||||
, finalcut::FMessageBox::Ok
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Ok
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, finalcut::FMessageBox::ButtonType::Reject
|
||||
, this
|
||||
);
|
||||
|
||||
@ -891,12 +898,12 @@ void MyDialog::cb_drives()
|
||||
}
|
||||
else
|
||||
{
|
||||
net.setForegroundColor (fc::White);
|
||||
net.setBackgroundColor (fc::DarkGray);
|
||||
drive.setForegroundColor (fc::White);
|
||||
drive.setBackgroundColor (fc::DarkGray);
|
||||
cd.setForegroundColor (fc::White);
|
||||
cd.setBackgroundColor (fc::DarkGray);
|
||||
net.setForegroundColor (FColor::White);
|
||||
net.setBackgroundColor (FColor::DarkGray);
|
||||
drive.setForegroundColor (FColor::White);
|
||||
drive.setBackgroundColor (FColor::DarkGray);
|
||||
cd.setForegroundColor (FColor::White);
|
||||
cd.setBackgroundColor (FColor::DarkGray);
|
||||
}
|
||||
|
||||
info2.exec();
|
||||
@ -1049,11 +1056,11 @@ int main (int argc, char* argv[])
|
||||
{
|
||||
const finalcut::FString ver{F_VERSION}; // Library version
|
||||
const finalcut::FString title { "FINAL CUT " + ver
|
||||
+ " (C) 2020 by Markus Gans" };
|
||||
+ " (C) 2021 by Markus Gans" };
|
||||
|
||||
// Create the application object app
|
||||
finalcut::FApplication app{argc, argv};
|
||||
app.setNonBlockingRead();
|
||||
finalcut::FVTerm::setNonBlockingRead();
|
||||
|
||||
// Create main dialog object d
|
||||
MyDialog d{&app};
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -41,7 +41,7 @@ class Watch final : public finalcut::FDialog
|
||||
Watch (const Watch&) = delete;
|
||||
|
||||
// Destructor
|
||||
~Watch() override;
|
||||
~Watch() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
Watch& operator = (const Watch&) = delete;
|
||||
@ -59,6 +59,7 @@ class Watch final : public finalcut::FDialog
|
||||
|
||||
protected:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
private:
|
||||
@ -75,25 +76,12 @@ class Watch final : public finalcut::FDialog
|
||||
Watch::Watch (FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
// Dialog settings
|
||||
// Avoids calling a virtual function from the constructor
|
||||
// (CERT, OOP50-CPP)
|
||||
FDialog::setText ("Watch");
|
||||
FDialog::setSize ({22, 13});
|
||||
|
||||
// Labels
|
||||
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
||||
time_label.setEmphasis();
|
||||
time_str.setGeometry(FPoint{10, 2}, FSize{8, 1});
|
||||
|
||||
// Checkbox buttons
|
||||
clock_sw.setGeometry(FPoint{4, 4}, FSize{9, 1});
|
||||
seconds_sw.setGeometry(FPoint{2, 6}, FSize{11, 1});
|
||||
// Switch
|
||||
sec = seconds_sw.setChecked();
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{6, 9}, FSize{9, 1});
|
||||
|
||||
// Connect switch signal "toggled" with a callback member function
|
||||
clock_sw.addCallback
|
||||
(
|
||||
@ -118,10 +106,6 @@ Watch::Watch (FWidget* parent)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
Watch::~Watch()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::printTime()
|
||||
{
|
||||
@ -189,6 +173,27 @@ void Watch::cb_seconds()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::initLayout()
|
||||
{
|
||||
// Dialog settings
|
||||
FDialog::setText ("Watch");
|
||||
FDialog::setSize ({22, 13}, false);
|
||||
|
||||
// Labels
|
||||
time_label.setGeometry(FPoint{5, 2}, FSize{5, 1});
|
||||
time_str.setGeometry(FPoint{10, 2}, FSize{8, 1});
|
||||
|
||||
// Switches
|
||||
clock_sw.setGeometry(FPoint{4, 4}, FSize{9, 1});
|
||||
seconds_sw.setGeometry(FPoint{2, 6}, FSize{11, 1});
|
||||
|
||||
// Quit button
|
||||
quit_btn.setGeometry(FPoint{6, 9}, FSize{9, 1});
|
||||
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Watch::adjustSize()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
#include <final/final.h>
|
||||
|
||||
namespace fc = finalcut::fc;
|
||||
using finalcut::FPoint;
|
||||
using finalcut::FSize;
|
||||
|
||||
@ -44,13 +43,14 @@ class SmallWindow final : public finalcut::FDialog
|
||||
SmallWindow (const SmallWindow&) = delete;
|
||||
|
||||
// Destructor
|
||||
~SmallWindow() override;
|
||||
~SmallWindow() override = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
SmallWindow& operator = (const SmallWindow&) = delete;
|
||||
|
||||
private:
|
||||
// Method
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
|
||||
// Event handlers
|
||||
@ -71,45 +71,47 @@ SmallWindow::SmallWindow (finalcut::FWidget* parent)
|
||||
: finalcut::FDialog{parent}
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
const wchar_t arrow_up = fc::BlackUpPointingTriangle;
|
||||
const wchar_t arrow_down = fc::BlackDownPointingTriangle;
|
||||
const auto arrow_up = finalcut::UniChar::BlackUpPointingTriangle;
|
||||
const auto arrow_down = finalcut::UniChar::BlackDownPointingTriangle;
|
||||
|
||||
left_arrow = arrow_up;
|
||||
left_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
left_arrow.setEmphasis();
|
||||
left_arrow.ignorePadding();
|
||||
left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1});
|
||||
|
||||
right_arrow = arrow_up;
|
||||
right_arrow.setForegroundColor (wc->label_inactive_fg);
|
||||
right_arrow.setEmphasis();
|
||||
right_arrow.ignorePadding();
|
||||
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
|
||||
|
||||
top_left_label.setText("menu");
|
||||
top_left_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_left_label.setEmphasis();
|
||||
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
|
||||
|
||||
top_right_label.setText("zoom");
|
||||
top_right_label.setAlignment (fc::alignRight);
|
||||
top_right_label.setAlignment (finalcut::Align::Right);
|
||||
top_right_label.setForegroundColor (wc->label_inactive_fg);
|
||||
top_right_label.setEmphasis();
|
||||
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
|
||||
|
||||
finalcut::FString bottom_label_text { "resize\n"
|
||||
"corner\n" };
|
||||
bottom_label_text += arrow_down;
|
||||
bottom_label = bottom_label_text;
|
||||
bottom_label.setAlignment (fc::alignRight);
|
||||
bottom_label.setAlignment (finalcut::Align::Right);
|
||||
bottom_label.setForegroundColor (wc->label_inactive_fg);
|
||||
bottom_label.setEmphasis();
|
||||
bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3});
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
SmallWindow::~SmallWindow()
|
||||
{ }
|
||||
void SmallWindow::initLayout()
|
||||
{
|
||||
left_arrow.setGeometry (FPoint{2, 2}, FSize{1, 1});
|
||||
right_arrow.setGeometry (FPoint{int(getWidth()) - 1, 2}, FSize{1, 1});
|
||||
top_left_label.setGeometry (FPoint{1, 1}, FSize{6, 1});
|
||||
top_right_label.setGeometry (FPoint{int(getClientWidth()) - 5, 1}, FSize{6, 1});
|
||||
bottom_label.setGeometry (FPoint{13, 3}, FSize{6, 3});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void SmallWindow::adjustSize()
|
||||
@ -177,15 +179,22 @@ class Window final : public finalcut::FDialog
|
||||
Window& operator = (const Window&) = delete;
|
||||
|
||||
private:
|
||||
struct win_data
|
||||
struct WinData
|
||||
{
|
||||
// Constructor
|
||||
win_data() = default;
|
||||
// Disable copy constructor
|
||||
win_data (const win_data&) = delete;
|
||||
WinData() = default;
|
||||
|
||||
// Disable copy assignment operator (=)
|
||||
win_data& operator = (const win_data&) = delete;
|
||||
// copy constructor
|
||||
WinData (const WinData&) = default;
|
||||
|
||||
// move constructor
|
||||
WinData (WinData&&) noexcept = default;
|
||||
|
||||
// copy assignment operator (=)
|
||||
WinData& operator = (const WinData&) = default;
|
||||
|
||||
// move assignment operator (=)
|
||||
WinData& operator = (WinData&&) noexcept = default;
|
||||
|
||||
// Data members
|
||||
bool is_open{false};
|
||||
@ -197,6 +206,8 @@ class Window final : public finalcut::FDialog
|
||||
void configureFileMenuItems();
|
||||
void configureDialogButtons();
|
||||
void activateWindow (finalcut::FDialog*) const;
|
||||
|
||||
void initLayout() override;
|
||||
void adjustSize() override;
|
||||
template <typename InstanceT
|
||||
, typename CallbackT
|
||||
@ -216,11 +227,11 @@ class Window final : public finalcut::FDialog
|
||||
void cb_closeWindows();
|
||||
void cb_next();
|
||||
void cb_previous();
|
||||
void cb_destroyWindow (win_data*) const;
|
||||
void cb_destroyWindow (WinData&) const;
|
||||
|
||||
// Data members
|
||||
std::vector<win_data*> windows{};
|
||||
finalcut::FString drop_down_symbol{fc::BlackDownPointingTriangle};
|
||||
std::vector<WinData> windows{};
|
||||
finalcut::FString drop_down_symbol{finalcut::UniChar::BlackDownPointingTriangle};
|
||||
finalcut::FMenuBar Menubar{this};
|
||||
finalcut::FMenu File{"&File", &Menubar};
|
||||
finalcut::FDialogListMenu DglList{drop_down_symbol, &Menubar};
|
||||
@ -262,9 +273,9 @@ Window::Window (finalcut::FWidget* parent)
|
||||
// Generate data vector for the windows
|
||||
for (uInt n{1}; n < 7; n++)
|
||||
{
|
||||
auto win_dat = new win_data;
|
||||
win_dat->title.sprintf("Window %1u", n);
|
||||
windows.push_back(win_dat);
|
||||
WinData win_dat;
|
||||
win_dat.title.sprintf("Window %1u", n);
|
||||
windows.emplace_back(std::move(win_dat));
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,13 +286,12 @@ Window::~Window()
|
||||
|
||||
while ( iter != windows.end() )
|
||||
{
|
||||
auto win_dat = *iter;
|
||||
auto& win_dat = *iter;
|
||||
|
||||
// Remove all callbacks before Window::cb_destroyWindow() will be called
|
||||
if ( win_dat->is_open && win_dat->dgl )
|
||||
win_dat->dgl->delCallback();
|
||||
if ( win_dat.is_open && win_dat.dgl )
|
||||
win_dat.dgl->delCallback();
|
||||
|
||||
delete win_dat;
|
||||
iter = windows.erase(iter);
|
||||
}
|
||||
}
|
||||
@ -293,12 +303,12 @@ void Window::configureFileMenuItems()
|
||||
New.setStatusbarMessage ("Create the windows");
|
||||
Close.setStatusbarMessage ("Close the windows");
|
||||
Line1.setSeparator();
|
||||
Next.addAccelerator (fc::Fmkey_npage); // Meta/Alt + PgDn
|
||||
Next.addAccelerator (finalcut::FKey::Meta_page_down); // Meta/Alt + PgDn
|
||||
Next.setStatusbarMessage ("Switch to the next window");
|
||||
Previous.addAccelerator (fc::Fmkey_ppage); // Meta/Alt + PgUp
|
||||
Previous.addAccelerator (finalcut::FKey::Meta_page_up); // Meta/Alt + PgUp
|
||||
Previous.setStatusbarMessage ("Switch to the previous window");
|
||||
Line2.setSeparator();
|
||||
Quit.addAccelerator (fc::Fmkey_x); // Meta/Alt + X
|
||||
Quit.addAccelerator (finalcut::FKey::Meta_x); // Meta/Alt + X
|
||||
Quit.setStatusbarMessage ("Exit the program");
|
||||
|
||||
// Add menu item callback
|
||||
@ -316,11 +326,8 @@ void Window::configureFileMenuItems()
|
||||
void Window::configureDialogButtons()
|
||||
{
|
||||
// Dialog buttons
|
||||
CreateButton.setGeometry (FPoint{2, 2}, FSize{9, 1});
|
||||
CreateButton.setText (L"&Create");
|
||||
CloseButton.setGeometry (FPoint{15, 2}, FSize{9, 1});
|
||||
CloseButton.setText (L"C&lose");
|
||||
QuitButton.setGeometry (FPoint{28, 2}, FSize{9, 1});
|
||||
QuitButton.setText (L"&Quit");
|
||||
|
||||
// Add button callback
|
||||
@ -345,6 +352,15 @@ void Window::activateWindow (finalcut::FDialog* win) const
|
||||
win->redraw();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Window::initLayout()
|
||||
{
|
||||
CreateButton.setGeometry (FPoint{2, 2}, FSize{9, 1});
|
||||
CloseButton.setGeometry (FPoint{15, 2}, FSize{9, 1});
|
||||
QuitButton.setGeometry (FPoint{28, 2}, FSize{9, 1});
|
||||
FDialog::initLayout();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Window::adjustSize()
|
||||
{
|
||||
@ -366,12 +382,12 @@ void Window::adjustSize()
|
||||
|
||||
while ( iter != windows.end() )
|
||||
{
|
||||
if ( (*iter)->is_open )
|
||||
if ( (*iter).is_open )
|
||||
{
|
||||
const auto n = int(std::distance(first, iter));
|
||||
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
||||
const int y = dy + 11 + int(n / 3) * 3;
|
||||
(*iter)->dgl->setPos (FPoint{x, y});
|
||||
(*iter).dgl->setPos (FPoint{x, y});
|
||||
}
|
||||
|
||||
++iter;
|
||||
@ -459,13 +475,13 @@ void Window::cb_createWindows()
|
||||
|
||||
while ( iter != windows.end() )
|
||||
{
|
||||
if ( ! (*iter)->is_open )
|
||||
if ( ! (*iter).is_open )
|
||||
{
|
||||
auto win_dat = *iter;
|
||||
auto& win_dat = *iter;
|
||||
auto win = new SmallWindow(this);
|
||||
win_dat->dgl = win;
|
||||
win_dat->is_open = true;
|
||||
win->setText(win_dat->title);
|
||||
win_dat.dgl = win;
|
||||
win_dat.is_open = true;
|
||||
win->setText(win_dat.title);
|
||||
const auto n = int(std::distance(first, iter));
|
||||
const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3;
|
||||
const int y = dy + 11 + int(n / 3) * 3;
|
||||
@ -478,7 +494,7 @@ void Window::cb_createWindows()
|
||||
(
|
||||
"destroy",
|
||||
this, &Window::cb_destroyWindow,
|
||||
win_dat
|
||||
std::ref(win_dat)
|
||||
);
|
||||
}
|
||||
|
||||
@ -551,13 +567,10 @@ void Window::cb_previous()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void Window::cb_destroyWindow (win_data* win_dat) const
|
||||
void Window::cb_destroyWindow (WinData& win_dat) const
|
||||
{
|
||||
if ( win_dat )
|
||||
{
|
||||
win_dat->is_open = false;
|
||||
win_dat->dgl = nullptr;
|
||||
}
|
||||
win_dat.is_open = false;
|
||||
win_dat.dgl = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package finalcut
|
||||
#
|
||||
# Copyright (c) 2020 by Markus Gans
|
||||
# Copyright (c) 2021 by Markus Gans
|
||||
#
|
||||
|
||||
%define sover 0
|
||||
|
@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
luit -encoding POSIX ../examples/ui
|
||||
luit -encoding C ../examples/ui $@
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
sonar.projectKey=gansm_finalcut
|
||||
sonar.projectName=finalcut
|
||||
sonar.projectVersion=0.7.1
|
||||
sonar.projectVersion=0.7.2
|
||||
sonar.projectDescription=A text-based widget toolkit
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -19,3 +19,7 @@ sonar.cfamily.build-wrapper-output=bw-output
|
||||
sonar.exclusions=src/include/final/fconfig.h
|
||||
sonar.coverage.exclusions=**/**
|
||||
|
||||
# Workaround: https://community.sonarsource.com/t/sonarcloud-pipeline-working-for-4months-but-today-i-get-info-0-files-indexed/42622/7
|
||||
sonar.javascript.exclusions=
|
||||
sonar.typescript.exclusions=
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
# Makefile.am - FINAL CUT library
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
AM_CPPFLAGS = -Iinclude -Wall -Werror -DCOMPILE_FINAL_CUT -std=c++11
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src/include -Wall -Werror -DCOMPILE_FINAL_CUT -std=c++11
|
||||
|
||||
SUBDIRS = .
|
||||
|
||||
@ -79,7 +79,7 @@ libfinal_la_SOURCES = \
|
||||
fwidget_functions.cpp \
|
||||
fobject.cpp
|
||||
|
||||
libfinal_la_LDFLAGS = -version-info @SO_VERSION@
|
||||
libfinal_la_LDFLAGS = -no-undefined -version-info @SO_VERSION@
|
||||
|
||||
finalcutincludedir = $(includedir)/final
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# This is where make install will install the library
|
||||
VERSION = "0.7.1"
|
||||
VERSION = "0.7.2"
|
||||
MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
|
||||
LIBDIR = /usr/local/lib
|
||||
INCLUDEDIR1 = include/final
|
||||
|
@ -3,7 +3,7 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
# This is where make install will install the library
|
||||
VERSION = "0.7.1"
|
||||
VERSION = "0.7.2"
|
||||
MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
|
||||
LIBDIR = /usr/local/lib
|
||||
INCLUDEDIR1 = include/final
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2013-2020 Markus Gans *
|
||||
* Copyright 2013-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -68,12 +68,9 @@ FWidget* FWidget::clicked_widget {nullptr}; // is focused by click
|
||||
FWidget* FWidget::open_menu {nullptr}; // currently open menu
|
||||
FWidget* FWidget::move_size_widget {nullptr}; // move/size by keyboard
|
||||
FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard focus
|
||||
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
|
||||
FMouseControl* FApplication::mouse {nullptr}; // mouse control
|
||||
int FApplication::loop_level {0}; // event loop level
|
||||
int FApplication::quit_code {EXIT_SUCCESS};
|
||||
bool FApplication::quit_now {false};
|
||||
bool FApplication::pending_updates {false};
|
||||
uInt64 FApplication::next_event_wait {5000}; // 5 ms (200 Hz)
|
||||
struct timeval FApplication::time_last_event {};
|
||||
|
||||
@ -84,18 +81,17 @@ struct timeval FApplication::time_last_event {};
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FApplication::FApplication (const int& _argc, char* _argv[])
|
||||
: FWidget{processParameters(_argc, _argv)}
|
||||
, app_argc{_argc}
|
||||
, app_argv{_argv}
|
||||
FApplication::FApplication (const int& arg_c, char* arg_v[])
|
||||
: FWidget{processParameters(Args(arg_v, arg_v + arg_c))}
|
||||
, app_args{arg_v, arg_v + arg_c}
|
||||
{
|
||||
if ( quit_now )
|
||||
return;
|
||||
|
||||
if ( internal::var::app_object )
|
||||
{
|
||||
auto ftermdata = FTerm::getFTermData();
|
||||
ftermdata->setExitMessage("FApplication: There should be "
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage("FApplication: There should be "
|
||||
"only one application object");
|
||||
FApplication::exit(EXIT_FAILURE);
|
||||
return;
|
||||
@ -104,14 +100,6 @@ FApplication::FApplication (const int& _argc, char* _argv[])
|
||||
// First define the application object
|
||||
internal::var::app_object = this;
|
||||
|
||||
if ( ! (_argc && _argv) )
|
||||
{
|
||||
typedef char* CString;
|
||||
static std::array<CString, 1> empty{{CString("")}};
|
||||
app_argc = 0;
|
||||
app_argv = empty.data();
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@ -171,7 +159,7 @@ void FApplication::setLog (const FLogPtr& log)
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::isQuit()
|
||||
{
|
||||
return ( internal::var::app_object ) ? quit_now : true;
|
||||
return internal::var::app_object ? quit_now : true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -347,12 +335,12 @@ void FApplication::setLogFile (const FString& filename)
|
||||
FLog& log = *FApplication::getLog();
|
||||
log.setOutputStream(log_stream);
|
||||
log.enableTimestamp();
|
||||
log.setLineEnding (finalcut::FLog::LF);
|
||||
log.setLineEnding (FLog::LineEnding::LF);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ftermdata = FTerm::getFTermData();
|
||||
ftermdata->setExitMessage ( "Could not open log file \""
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage ( "Could not open log file \""
|
||||
+ filename + "\"" );
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -368,12 +356,14 @@ void FApplication::setKeyboardWidget (FWidget* widget)
|
||||
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||
{
|
||||
internal::var::app_object->unsetMoveSizeMode();
|
||||
const int ret = FMessageBox::info ( w, "Quit"
|
||||
, "Do you really want\n"
|
||||
"to quit the program ?"
|
||||
, FMessageBox::Yes
|
||||
, FMessageBox::No );
|
||||
if ( ret == FMessageBox::Yes )
|
||||
const FMessageBox::ButtonType ret = \
|
||||
FMessageBox::info ( w, "Quit"
|
||||
, "Do you really want\n"
|
||||
"to quit the program ?"
|
||||
, FMessageBox::ButtonType::Yes
|
||||
, FMessageBox::ButtonType::No );
|
||||
|
||||
if ( ret == FMessageBox::ButtonType::Yes )
|
||||
ev->accept();
|
||||
else
|
||||
{
|
||||
@ -391,9 +381,6 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
|
||||
void FApplication::processExternalUserEvent()
|
||||
{
|
||||
// This method can be overloaded and replaced by own code
|
||||
|
||||
if ( FKeyboard::getReadBlockingTime() < 10000 )
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
}
|
||||
|
||||
|
||||
@ -409,45 +396,35 @@ void FApplication::init()
|
||||
time_last_event.tv_usec = 0;
|
||||
|
||||
// Initialize keyboard
|
||||
keyboard = FTerm::getFKeyboard();
|
||||
|
||||
|
||||
if ( keyboard )
|
||||
{
|
||||
auto cmd1 = std::bind(&FApplication::keyPressed, this);
|
||||
auto cmd2 = std::bind(&FApplication::keyReleased, this);
|
||||
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
|
||||
auto cmd4 = std::bind(&FApplication::mouseTracking, this);
|
||||
FKeyboardCommand key_cmd1 (cmd1);
|
||||
FKeyboardCommand key_cmd2 (cmd2);
|
||||
FKeyboardCommand key_cmd3 (cmd3);
|
||||
FKeyboardCommand key_cmd4 (cmd4);
|
||||
keyboard->setPressCommand (key_cmd1);
|
||||
keyboard->setReleaseCommand (key_cmd2);
|
||||
keyboard->setEscPressedCommand (key_cmd3);
|
||||
keyboard->setMouseTrackingCommand (key_cmd4);
|
||||
// Set the keyboard keypress timeout
|
||||
keyboard->setKeypressTimeout (key_timeout);
|
||||
}
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
auto cmd1 = [this] () { this->keyPressed(); };
|
||||
auto cmd2 = [this] () { this->keyReleased(); };
|
||||
auto cmd3 = [this] () { this->escapeKeyPressed(); };
|
||||
auto cmd4 = [this] () { this->mouseTracking(); };
|
||||
FKeyboardCommand key_cmd1 (cmd1);
|
||||
FKeyboardCommand key_cmd2 (cmd2);
|
||||
FKeyboardCommand key_cmd3 (cmd3);
|
||||
FKeyboardCommand key_cmd4 (cmd4);
|
||||
keyboard.setPressCommand (key_cmd1);
|
||||
keyboard.setReleaseCommand (key_cmd2);
|
||||
keyboard.setEscPressedCommand (key_cmd3);
|
||||
keyboard.setMouseTrackingCommand (key_cmd4);
|
||||
// Set the keyboard keypress timeout
|
||||
keyboard.setKeypressTimeout (key_timeout);
|
||||
|
||||
// Initialize mouse control
|
||||
mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( mouse )
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
auto cmd = std::bind(&FApplication::mouseEvent, this, _1);
|
||||
FMouseCommand mouse_cmd (cmd);
|
||||
mouse->setEventCommand (mouse_cmd);
|
||||
// Set stdin number for a gpm-mouse
|
||||
mouse->setStdinNo (FTermios::getStdIn());
|
||||
// Set the default double click interval
|
||||
mouse->setDblclickInterval (dblclick_interval);
|
||||
}
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
|
||||
FMouseCommand mouse_cmd (cmd);
|
||||
mouse.setEventCommand (mouse_cmd);
|
||||
// Set stdin number for a gpm-mouse
|
||||
mouse.setStdinNo (FTermios::getStdIn());
|
||||
// Set the default double click interval
|
||||
mouse.setDblclickInterval (dblclick_interval);
|
||||
|
||||
// Initialize logging
|
||||
if ( ! getStartOptions().logfile_stream.is_open() )
|
||||
getLog()->setLineEnding(FLog::CRLF);
|
||||
getLog()->setLineEnding(FLog::LineEnding::CRLF);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -456,19 +433,19 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
||||
const FString& enc = enc_str.toLower();
|
||||
|
||||
if ( enc.includes("utf8") )
|
||||
getStartOptions().encoding = fc::UTF8;
|
||||
getStartOptions().encoding = Encoding::UTF8;
|
||||
else if ( enc.includes("vt100") )
|
||||
getStartOptions().encoding = fc::VT100;
|
||||
getStartOptions().encoding = Encoding::VT100;
|
||||
else if ( enc.includes("pc") )
|
||||
getStartOptions().encoding = fc::PC;
|
||||
getStartOptions().encoding = Encoding::PC;
|
||||
else if ( enc.includes("ascii") )
|
||||
getStartOptions().encoding = fc::ASCII;
|
||||
getStartOptions().encoding = Encoding::ASCII;
|
||||
else if ( enc.includes("help") )
|
||||
showParameterUsage();
|
||||
else
|
||||
{
|
||||
auto ftermdata = FTerm::getFTermData();
|
||||
ftermdata->setExitMessage ( "Unknown encoding \"" + enc_str
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
|
||||
+ "\"\n(Valid encodings are utf8, "
|
||||
+ "vt100, pc and ascii)" );
|
||||
exit(EXIT_FAILURE);
|
||||
@ -506,9 +483,8 @@ inline void FApplication::setLongOptions (std::vector<CmdOption>& long_options)
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::setCmdOptionsMap (CmdMap& cmd_map)
|
||||
{
|
||||
using std::placeholders::_1;
|
||||
auto enc = std::bind(&FApplication::setTerminalEncoding, _1);
|
||||
auto log = std::bind(&FApplication::setLogFile, _1);
|
||||
auto enc = [] (const FString& s) { FApplication::setTerminalEncoding(s); };
|
||||
auto log = [] (const FString& s) { FApplication::setLogFile(s); };
|
||||
auto opt = &FApplication::getStartOptions;
|
||||
|
||||
// --encoding
|
||||
@ -545,12 +521,22 @@ inline void FApplication::setCmdOptionsMap (CmdMap& cmd_map)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::cmdOptions (const int& argc, char* argv[])
|
||||
void FApplication::cmdOptions (const Args& args)
|
||||
{
|
||||
// Interpret the command line options
|
||||
|
||||
CmdMap cmd_map{};
|
||||
setCmdOptionsMap(cmd_map);
|
||||
auto argc = args.size();
|
||||
std::vector<const char*> argv(argc);
|
||||
std::transform ( args.begin()
|
||||
, args.end()
|
||||
, argv.begin()
|
||||
, [] (const std::string& str)
|
||||
{
|
||||
return str.data();
|
||||
}
|
||||
);
|
||||
|
||||
while ( true )
|
||||
{
|
||||
@ -559,13 +545,16 @@ void FApplication::cmdOptions (const int& argc, char* argv[])
|
||||
std::vector<CmdOption> long_options{};
|
||||
setLongOptions(long_options);
|
||||
auto p = reinterpret_cast<const struct option*>(long_options.data());
|
||||
const int opt = getopt_long (argc, argv, "", p, &idx);
|
||||
auto argv_data = const_cast<char* const*>(argv.data());
|
||||
const int opt = getopt_long (int(argc), argv_data, "", p, &idx);
|
||||
|
||||
if ( opt == -1 )
|
||||
break;
|
||||
|
||||
if ( cmd_map.find(opt) != cmd_map.end() )
|
||||
cmd_map[opt](optarg);
|
||||
const auto& entry = cmd_map[opt];
|
||||
|
||||
if ( entry )
|
||||
entry(optarg);
|
||||
}
|
||||
|
||||
cmd_map.clear();
|
||||
@ -669,10 +658,13 @@ inline void FApplication::findKeyboardWidget() const
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::isKeyPressed() const
|
||||
{
|
||||
if ( mouse && mouse->isGpmMouseEnabled() )
|
||||
return mouse->getGpmKeyPressed(keyboard->hasUnprocessedInput());
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
return (keyboard->isKeyPressed() || keyboard->hasPendingInput());
|
||||
if ( mouse.isGpmMouseEnabled() )
|
||||
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
|
||||
|
||||
return (keyboard.isKeyPressed() || keyboard.hasPendingInput());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -702,7 +694,9 @@ void FApplication::mouseTracking() const
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performKeyboardAction()
|
||||
{
|
||||
if ( keyboard->getKey() == fc::Fckey_l ) // Ctrl-L (redraw the screen)
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
|
||||
{
|
||||
redraw();
|
||||
}
|
||||
@ -719,30 +713,25 @@ inline void FApplication::performKeyboardAction()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::performMouseAction() const
|
||||
{
|
||||
if ( ! mouse )
|
||||
return;
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto key = keyboard.getKey();
|
||||
auto& buffer = keyboard.getKeyBuffer();
|
||||
|
||||
auto& buffer = keyboard->getKeyBuffer();
|
||||
|
||||
switch ( keyboard->getKey() )
|
||||
if ( key == FKey::X11mouse )
|
||||
{
|
||||
case fc::Fkey_mouse:
|
||||
mouse->setRawData (FMouse::x11, buffer);
|
||||
break;
|
||||
|
||||
case fc::Fkey_extended_mouse:
|
||||
mouse->setRawData (FMouse::sgr, buffer);
|
||||
break;
|
||||
|
||||
case fc::Fkey_urxvt_mouse:
|
||||
mouse->setRawData (FMouse::urxvt, buffer);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
mouse.setRawData (FMouse::MouseType::X11, buffer);
|
||||
}
|
||||
else if ( key == FKey::Extended_mouse )
|
||||
{
|
||||
mouse.setRawData (FMouse::MouseType::Sgr, buffer);
|
||||
}
|
||||
else if ( key == FKey::Urxvt_mouse )
|
||||
{
|
||||
mouse.setRawData (FMouse::MouseType::Urxvt, buffer);
|
||||
}
|
||||
|
||||
keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput();
|
||||
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
||||
queuingMouseInput();
|
||||
}
|
||||
|
||||
@ -758,16 +747,13 @@ void FApplication::mouseEvent (const FMouseData& md)
|
||||
unselectMenubarItems (md);
|
||||
sendMouseEvent (md);
|
||||
}
|
||||
|
||||
if ( mouse )
|
||||
mouse->drawGpmPointer();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::sendEscapeKeyPressEvent() const
|
||||
{
|
||||
// Send an escape key press event
|
||||
FKeyEvent k_press_ev (fc::KeyPress_Event, fc::Fkey_escape);
|
||||
FKeyEvent k_press_ev (Event::KeyPress, FKey::Escape);
|
||||
sendEvent (keyboard_widget, &k_press_ev);
|
||||
}
|
||||
|
||||
@ -775,7 +761,8 @@ inline void FApplication::sendEscapeKeyPressEvent() const
|
||||
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key down event
|
||||
FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey());
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
|
||||
sendEvent (widget, &k_down_ev);
|
||||
return k_down_ev.isAccepted();
|
||||
}
|
||||
@ -784,7 +771,8 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
|
||||
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key press event
|
||||
FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey());
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
|
||||
sendEvent (widget, &k_press_ev);
|
||||
return k_press_ev.isAccepted();
|
||||
}
|
||||
@ -793,7 +781,8 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
|
||||
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
|
||||
{
|
||||
// Send key up event
|
||||
FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey());
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
|
||||
sendEvent (widget, &k_up_ev);
|
||||
return k_up_ev.isAccepted();
|
||||
}
|
||||
@ -829,9 +818,12 @@ inline void FApplication::sendKeyboardAccelerator()
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FApplication::hasDataInQueue() const
|
||||
{
|
||||
if ( keyboard && keyboard->hasDataInQueue() )
|
||||
return true;
|
||||
else if ( mouse && mouse->hasDataInQueue() )
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( keyboard.hasDataInQueue()
|
||||
|| mouse.hasDataInQueue()
|
||||
|| FTerm::hasChangedTermSize() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -840,56 +832,71 @@ inline bool FApplication::hasDataInQueue() const
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::queuingKeyboardInput() const
|
||||
{
|
||||
if ( quit_now || internal::var::exit_loop || ! keyboard )
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
findKeyboardWidget();
|
||||
keyboard->escapeKeyHandling(); // special case: Esc key
|
||||
keyboard->clearKeyBufferOnTimeout();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.escapeKeyHandling(); // special case: Esc key
|
||||
keyboard.clearKeyBufferOnTimeout();
|
||||
|
||||
if ( isKeyPressed() )
|
||||
keyboard->fetchKeyCode();
|
||||
keyboard.fetchKeyCode();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::queuingMouseInput() const
|
||||
{
|
||||
if ( quit_now || internal::var::exit_loop
|
||||
|| ! mouse || ! mouse->hasData() )
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|| ! mouse.hasData()
|
||||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
struct timeval* time_keypressed = keyboard->getKeyPressedTime();
|
||||
mouse->processEvent (time_keypressed);
|
||||
keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput();
|
||||
mouse->clearEvent();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
struct timeval* time_keypressed = keyboard.getKeyPressedTime();
|
||||
mouse.processEvent (time_keypressed);
|
||||
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
|
||||
mouse.clearEvent();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::processKeyboardEvent() const
|
||||
{
|
||||
if ( quit_now || internal::var::exit_loop || ! keyboard )
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
keyboard->processQueuedInput();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.processQueuedInput();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::processMouseEvent() const
|
||||
{
|
||||
if ( quit_now || internal::var::exit_loop || ! mouse )
|
||||
if ( quit_now
|
||||
|| internal::var::exit_loop
|
||||
|| FTerm::hasChangedTermSize() )
|
||||
return;
|
||||
|
||||
mouse->processQueuedInput();
|
||||
FTerm::getFMouseControl().processQueuedInput();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FApplication::processDialogSwitchAccelerator() const
|
||||
{
|
||||
if ( keyboard->getKey() >= fc::Fmkey_1
|
||||
&& keyboard->getKey() <= fc::Fmkey_9 )
|
||||
const auto& keyboard = FTerm::getFKeyboard();
|
||||
|
||||
if ( keyboard.getKey() >= FKey::Meta_1
|
||||
&& keyboard.getKey() <= FKey::Meta_9 )
|
||||
{
|
||||
const FKey key = keyboard->getKey();
|
||||
const std::size_t n = key - fc::Fmkey_0;
|
||||
const FKey key = keyboard.getKey();
|
||||
const auto n = std::size_t(key - FKey::Meta_0);
|
||||
const std::size_t s = getDialogList()->size();
|
||||
|
||||
if ( s > 0 && s >= n )
|
||||
@ -904,7 +911,7 @@ bool FApplication::processDialogSwitchAccelerator() const
|
||||
w->redraw();
|
||||
}
|
||||
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
||||
FAccelEvent a_ev (Event::Accelerator, getFocusWidget());
|
||||
sendEvent (getDialogList()->at(n - 1), &a_ev);
|
||||
return true;
|
||||
}
|
||||
@ -921,7 +928,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
|
||||
|
||||
for (auto&& item : widget.getAcceleratorList())
|
||||
{
|
||||
if ( item.key == keyboard->getKey() )
|
||||
if ( item.key == FTerm::getFKeyboard().getKey() )
|
||||
{
|
||||
// unset the move/size mode
|
||||
auto move_size = getMoveSizeWidget();
|
||||
@ -932,7 +939,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
|
||||
move_size->redraw();
|
||||
}
|
||||
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
||||
FAccelEvent a_ev (Event::Accelerator, getFocusWidget());
|
||||
sendEvent (item.object, &a_ev);
|
||||
return a_ev.isAccepted();
|
||||
}
|
||||
@ -1038,16 +1045,16 @@ void FApplication::unselectMenubarItems (const FMouseData& md) const
|
||||
void FApplication::sendMouseEvent (const FMouseData& md) const
|
||||
{
|
||||
const auto& mouse_position = md.getPos();
|
||||
int key_state{0};
|
||||
MouseButton key_state{MouseButton::None};
|
||||
|
||||
if ( md.isShiftKeyPressed() )
|
||||
key_state |= fc::ShiftButton;
|
||||
key_state |= MouseButton::Shift;
|
||||
|
||||
if ( md.isControlKeyPressed() )
|
||||
key_state |= fc::ControlButton;
|
||||
key_state |= MouseButton::Control;
|
||||
|
||||
if ( md.isMetaKeyPressed() )
|
||||
key_state |= fc::MetaButton;
|
||||
key_state |= MouseButton::Meta;
|
||||
|
||||
const auto& widgetMousePos = clicked_widget->termToWidgetPos(mouse_position);
|
||||
|
||||
@ -1069,32 +1076,32 @@ void FApplication::sendMouseEvent (const FMouseData& md) const
|
||||
void FApplication::sendMouseMoveEvent ( const FMouseData& md
|
||||
, const FPoint& widgetMousePos
|
||||
, const FPoint& mouse_position
|
||||
, int key_state ) const
|
||||
, MouseButton key_state ) const
|
||||
{
|
||||
if ( md.isLeftButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseMove
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::LeftButton | key_state );
|
||||
, MouseButton::Left | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
|
||||
if ( md.isRightButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseMove
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::RightButton | key_state );
|
||||
, MouseButton::Right | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
|
||||
if ( md.isMiddleButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseMove_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseMove
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::MiddleButton | key_state );
|
||||
, MouseButton::Middle | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
}
|
||||
@ -1103,30 +1110,30 @@ void FApplication::sendMouseMoveEvent ( const FMouseData& md
|
||||
void FApplication::sendMouseLeftClickEvent ( const FMouseData& md
|
||||
, const FPoint& widgetMousePos
|
||||
, const FPoint& mouse_position
|
||||
, int key_state ) const
|
||||
, MouseButton key_state ) const
|
||||
{
|
||||
if ( md.isLeftButtonDoubleClick() )
|
||||
{
|
||||
FMouseEvent m_dblclick_ev ( fc::MouseDoubleClick_Event
|
||||
FMouseEvent m_dblclick_ev ( Event::MouseDoubleClick
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::LeftButton | key_state );
|
||||
, MouseButton::Left | key_state );
|
||||
sendEvent (clicked_widget, &m_dblclick_ev);
|
||||
}
|
||||
else if ( md.isLeftButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseDown
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::LeftButton | key_state );
|
||||
, MouseButton::Left | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
else if ( md.isLeftButtonReleased() )
|
||||
{
|
||||
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
||||
FMouseEvent m_up_ev ( Event::MouseUp
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::LeftButton | key_state );
|
||||
, MouseButton::Left | key_state );
|
||||
auto released_widget = clicked_widget;
|
||||
|
||||
if ( ! md.isRightButtonPressed()
|
||||
@ -1141,22 +1148,22 @@ void FApplication::sendMouseLeftClickEvent ( const FMouseData& md
|
||||
void FApplication::sendMouseRightClickEvent ( const FMouseData& md
|
||||
, const FPoint& widgetMousePos
|
||||
, const FPoint& mouse_position
|
||||
, int key_state ) const
|
||||
, MouseButton key_state ) const
|
||||
{
|
||||
if ( md.isRightButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseDown
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::RightButton | key_state );
|
||||
, MouseButton::Right | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
}
|
||||
else if ( md.isRightButtonReleased() )
|
||||
{
|
||||
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
||||
FMouseEvent m_up_ev ( Event::MouseUp
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::RightButton | key_state );
|
||||
, MouseButton::Right | key_state );
|
||||
auto released_widget = clicked_widget;
|
||||
|
||||
if ( ! md.isLeftButtonPressed()
|
||||
@ -1171,14 +1178,14 @@ void FApplication::sendMouseRightClickEvent ( const FMouseData& md
|
||||
void FApplication::sendMouseMiddleClickEvent ( const FMouseData& md
|
||||
, const FPoint& widgetMousePos
|
||||
, const FPoint& mouse_position
|
||||
, int key_state ) const
|
||||
, MouseButton key_state ) const
|
||||
{
|
||||
if ( md.isMiddleButtonPressed() )
|
||||
{
|
||||
FMouseEvent m_down_ev ( fc::MouseDown_Event
|
||||
FMouseEvent m_down_ev ( Event::MouseDown
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::MiddleButton | key_state );
|
||||
, MouseButton::Middle | key_state );
|
||||
sendEvent (clicked_widget, &m_down_ev);
|
||||
|
||||
// gnome-terminal sends no released on middle click
|
||||
@ -1187,10 +1194,10 @@ void FApplication::sendMouseMiddleClickEvent ( const FMouseData& md
|
||||
}
|
||||
else if ( md.isMiddleButtonReleased() )
|
||||
{
|
||||
FMouseEvent m_up_ev ( fc::MouseUp_Event
|
||||
FMouseEvent m_up_ev ( Event::MouseUp
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::MiddleButton | key_state );
|
||||
, MouseButton::Middle | key_state );
|
||||
auto released_widget = clicked_widget;
|
||||
|
||||
if ( ! md.isLeftButtonPressed()
|
||||
@ -1210,10 +1217,10 @@ void FApplication::sendWheelEvent ( const FMouseData& md
|
||||
{
|
||||
if ( md.isWheelUp() )
|
||||
{
|
||||
FWheelEvent wheel_ev ( fc::MouseWheel_Event
|
||||
FWheelEvent wheel_ev ( Event::MouseWheel
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::WheelUp );
|
||||
, MouseWheel::Up );
|
||||
auto scroll_over_widget = clicked_widget;
|
||||
setClickedWidget(nullptr);
|
||||
sendEvent(scroll_over_widget, &wheel_ev);
|
||||
@ -1221,10 +1228,10 @@ void FApplication::sendWheelEvent ( const FMouseData& md
|
||||
|
||||
if ( md.isWheelDown() )
|
||||
{
|
||||
FWheelEvent wheel_ev ( fc::MouseWheel_Event
|
||||
FWheelEvent wheel_ev ( Event::MouseWheel
|
||||
, widgetMousePos
|
||||
, mouse_position
|
||||
, fc::WheelDown );
|
||||
, MouseWheel::Down );
|
||||
auto scroll_over_widget = clicked_widget;
|
||||
setClickedWidget(nullptr);
|
||||
sendEvent (scroll_over_widget, &wheel_ev);
|
||||
@ -1232,49 +1239,29 @@ void FApplication::sendWheelEvent ( const FMouseData& md
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FApplication::flushTerminal()
|
||||
FWidget* FApplication::processParameters (const Args& args)
|
||||
{
|
||||
if ( ! pending_updates )
|
||||
return;
|
||||
|
||||
if ( flush_count < 4 )
|
||||
{
|
||||
flush_count++;
|
||||
return;
|
||||
}
|
||||
|
||||
flush();
|
||||
flush_count = 0;
|
||||
pending_updates = false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||
{
|
||||
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|
||||
|| std::strcmp(argv[1], "-h") == 0 ) )
|
||||
if ( args.size() > 1 && (args[1] == "--help" || args[1] == "-h") )
|
||||
{
|
||||
showParameterUsage();
|
||||
FApplication::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
cmdOptions (argc, argv);
|
||||
cmdOptions (args);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FApplication::processResizeEvent() const
|
||||
{
|
||||
if ( ! FTerm::hasChangedTermSize() )
|
||||
if ( ! FTerm::hasChangedTermSize() ) // A SIGWINCH signal was received
|
||||
return;
|
||||
|
||||
if ( mouse )
|
||||
{
|
||||
mouse->setMaxWidth (uInt16(getDesktopWidth()));
|
||||
mouse->setMaxHeight (uInt16(getDesktopHeight()));
|
||||
}
|
||||
|
||||
FResizeEvent r_ev(fc::Resize_Event);
|
||||
FTerm::detectTermSize(); // Detect and save the current terminal size
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
mouse.setMaxWidth (uInt16(getDesktopWidth()));
|
||||
mouse.setMaxHeight (uInt16(getDesktopHeight()));
|
||||
FResizeEvent r_ev(Event::Resize);
|
||||
sendEvent(internal::var::app_object, &r_ev);
|
||||
|
||||
if ( r_ev.isAccepted() )
|
||||
@ -1287,7 +1274,7 @@ void FApplication::processCloseWidget()
|
||||
if ( ! getWidgetCloseList() || getWidgetCloseList()->empty() )
|
||||
return;
|
||||
|
||||
setTerminalUpdates (FVTerm::stop_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Stop);
|
||||
auto iter = getWidgetCloseList()->begin();
|
||||
|
||||
while ( iter != getWidgetCloseList()->end() && *iter )
|
||||
@ -1297,7 +1284,7 @@ void FApplication::processCloseWidget()
|
||||
}
|
||||
|
||||
getWidgetCloseList()->clear();
|
||||
setTerminalUpdates (FVTerm::start_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Start);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1328,11 +1315,8 @@ bool FApplication::processNextEvent()
|
||||
processMouseEvent();
|
||||
processResizeEvent();
|
||||
processCloseWidget();
|
||||
|
||||
if ( processTerminalUpdate() ) // after terminal changes
|
||||
pending_updates = true;
|
||||
|
||||
flushTerminal();
|
||||
processTerminalUpdate(); // after terminal changes
|
||||
flush();
|
||||
processLogger();
|
||||
}
|
||||
|
||||
@ -1342,8 +1326,6 @@ bool FApplication::processNextEvent()
|
||||
{
|
||||
sendQueuedEvents();
|
||||
num_events += processTimerEvent();
|
||||
uInt64 wait{next_event_wait / 2};
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(wait));
|
||||
}
|
||||
|
||||
return ( num_events > 0 );
|
||||
@ -1378,32 +1360,38 @@ bool FApplication::isEventProcessable ( FObject* receiver
|
||||
&& ! window->getFlags().modal
|
||||
&& ! window->isMenuWidget() )
|
||||
{
|
||||
switch ( uInt(event->getType()) )
|
||||
{
|
||||
case fc::KeyPress_Event:
|
||||
case fc::KeyUp_Event:
|
||||
case fc::KeyDown_Event:
|
||||
case fc::MouseDown_Event:
|
||||
case fc::MouseUp_Event:
|
||||
case fc::MouseDoubleClick_Event:
|
||||
case fc::MouseWheel_Event:
|
||||
case fc::MouseMove_Event:
|
||||
case fc::FocusIn_Event:
|
||||
case fc::FocusOut_Event:
|
||||
case fc::ChildFocusIn_Event:
|
||||
case fc::ChildFocusOut_Event:
|
||||
case fc::Accelerator_Event:
|
||||
return false;
|
||||
constexpr std::array<const Event, 13> blocked_events
|
||||
{{
|
||||
Event::KeyPress,
|
||||
Event::KeyUp,
|
||||
Event::KeyDown,
|
||||
Event::MouseDown,
|
||||
Event::MouseUp,
|
||||
Event::MouseDoubleClick,
|
||||
Event::MouseWheel,
|
||||
Event::MouseMove,
|
||||
Event::FocusIn,
|
||||
Event::FocusOut,
|
||||
Event::ChildFocusIn,
|
||||
Event::ChildFocusOut,
|
||||
Event::Accelerator
|
||||
}};
|
||||
|
||||
default:
|
||||
break;
|
||||
if ( std::any_of( blocked_events.cbegin()
|
||||
, blocked_events.cend()
|
||||
, [&event](const Event& ev)
|
||||
{
|
||||
return ev == event->getType();
|
||||
} ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Throw away mouse events for disabled widgets
|
||||
if ( event->getType() >= fc::MouseDown_Event
|
||||
&& event->getType() <= fc::MouseMove_Event
|
||||
if ( event->getType() >= Event::MouseDown
|
||||
&& event->getType() <= Event::MouseMove
|
||||
&& ! widget->isEnabled() )
|
||||
return false;
|
||||
|
||||
|
@ -39,8 +39,7 @@ FBusyIndicator::FBusyIndicator (FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FBusyIndicator::~FBusyIndicator() // destructor
|
||||
{ }
|
||||
FBusyIndicator::~FBusyIndicator() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FBusyIndicator
|
||||
@ -74,7 +73,7 @@ void FBusyIndicator::createIndicatorText()
|
||||
{
|
||||
std::array<FString, 4> line{};
|
||||
|
||||
if ( FTerm::getEncoding() == fc::UTF8 )
|
||||
if ( FTerm::getEncoding() == Encoding::UTF8 )
|
||||
{
|
||||
const auto& p = uni_pattern;
|
||||
line[0] << " " << p[7] << " " << p[0] << " \n";
|
||||
@ -99,7 +98,7 @@ void FBusyIndicator::createIndicatorText()
|
||||
void FBusyIndicator::onTimer (finalcut::FTimerEvent*)
|
||||
{
|
||||
// Rotate pattern
|
||||
if ( FTerm::getEncoding() == fc::UTF8 )
|
||||
if ( FTerm::getEncoding() == Encoding::UTF8 )
|
||||
{
|
||||
const wchar_t last = uni_pattern[7];
|
||||
std::memmove(uni_pattern + 1, uni_pattern , sizeof(wchar_t) * 7);
|
||||
|
@ -83,7 +83,7 @@ void FButton::setBackgroundColor (FColor color)
|
||||
void FButton::setHotkeyForegroundColor (FColor color)
|
||||
{
|
||||
// valid colors -1..254
|
||||
if ( color == fc::Default || color >> 8 == 0 )
|
||||
if ( color == FColor::Default || (color >> 8) == FColor::Black )
|
||||
button_hotkey_fg = color;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ void FButton::setHotkeyForegroundColor (FColor color)
|
||||
void FButton::setFocusForegroundColor (FColor color)
|
||||
{
|
||||
// valid colors -1..254
|
||||
if ( color == fc::Default || color >> 8 == 0 )
|
||||
if ( color == FColor::Default || (color >> 8) == FColor::Black )
|
||||
button_focus_fg = color;
|
||||
|
||||
updateButtonColor();
|
||||
@ -101,7 +101,7 @@ void FButton::setFocusForegroundColor (FColor color)
|
||||
void FButton::setFocusBackgroundColor (FColor color)
|
||||
{
|
||||
// valid colors -1..254
|
||||
if ( color == fc::Default || color >> 8 == 0 )
|
||||
if ( color == FColor::Default || (color >> 8) == FColor::Black )
|
||||
button_focus_bg = color;
|
||||
|
||||
updateButtonColor();
|
||||
@ -111,7 +111,7 @@ void FButton::setFocusBackgroundColor (FColor color)
|
||||
void FButton::setInactiveForegroundColor (FColor color)
|
||||
{
|
||||
// valid colors -1..254
|
||||
if ( color == fc::Default || color >> 8 == 0 )
|
||||
if ( color == FColor::Default || (color >> 8) == FColor::Black )
|
||||
button_inactive_fg = color;
|
||||
|
||||
updateButtonColor();
|
||||
@ -121,7 +121,7 @@ void FButton::setInactiveForegroundColor (FColor color)
|
||||
void FButton::setInactiveBackgroundColor (FColor color)
|
||||
{
|
||||
// valid colors -1..254
|
||||
if ( color == fc::Default || color >> 8 == 0 )
|
||||
if ( color == FColor::Default || (color >> 8) == FColor::Black )
|
||||
button_inactive_bg = color;
|
||||
|
||||
updateButtonColor();
|
||||
@ -179,8 +179,8 @@ bool FButton::setFlat (bool enable)
|
||||
bool FButton::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != Encoding::VT100
|
||||
&& FTerm::getEncoding() != Encoding::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
@ -260,46 +260,31 @@ void FButton::onKeyPress (FKeyEvent* ev)
|
||||
|
||||
const FKey key = ev->key();
|
||||
|
||||
switch ( key )
|
||||
if ( key == FKey::Return
|
||||
|| key == FKey::Enter
|
||||
|| key == FKey::Space )
|
||||
{
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
case fc::Fkey_space:
|
||||
if ( click_animation )
|
||||
{
|
||||
setDown();
|
||||
addTimer(click_time);
|
||||
}
|
||||
processClick();
|
||||
ev->accept();
|
||||
break;
|
||||
if ( click_animation )
|
||||
{
|
||||
setDown();
|
||||
addTimer(click_time);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
processClick();
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
setUp();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
const FPoint tPos{ev->getTermPos()};
|
||||
|
||||
if ( getTermGeometry().contains(tPos) )
|
||||
@ -309,7 +294,7 @@ void FButton::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( button_down )
|
||||
@ -324,7 +309,7 @@ void FButton::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FButton::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
const FPoint tPos{ev->getTermPos()};
|
||||
@ -486,7 +471,7 @@ inline void FButton::drawMarginLeft()
|
||||
print() << FPoint{1 + int(indent), 1 + int(y)};
|
||||
|
||||
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
print (UniChar::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (space_char); // full block █
|
||||
}
|
||||
@ -502,7 +487,7 @@ inline void FButton::drawMarginRight()
|
||||
print() << FPoint{int(getWidth() + indent), 1 + int(y)};
|
||||
|
||||
if ( FTerm::isMonochron() && active_focus && y == vcenter_offset )
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
print (UniChar::BlackLeftPointingPointer); // ◄
|
||||
else
|
||||
print (space_char); // full block █
|
||||
}
|
||||
@ -616,7 +601,7 @@ void FButton::draw()
|
||||
FString button_text{};
|
||||
const auto& parent_widget = getParentWidget();
|
||||
column_width = getColumnWidth(text);
|
||||
space_char = int(' ');
|
||||
space_char = L' ';
|
||||
active_focus = getFlags().active && getFlags().focus;
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
@ -629,7 +614,7 @@ void FButton::draw()
|
||||
clearRightMargin (parent_widget);
|
||||
|
||||
if ( ! getFlags().active && FTerm::isMonochron() )
|
||||
space_char = fc::MediumShade; // ▒ simulates greyed out at Monochron
|
||||
space_char = wchar_t(UniChar::MediumShade); // ▒ simulates greyed out at Monochron
|
||||
|
||||
if ( FTerm::isMonochron() && (getFlags().active || getFlags().focus) )
|
||||
setReverse(false); // Dark background
|
||||
|
@ -4,7 +4,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -293,7 +293,7 @@ void FButtonGroup::checkScrollSize (const FRect& r)
|
||||
//----------------------------------------------------------------------
|
||||
void FButtonGroup::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
directFocus();
|
||||
@ -316,9 +316,9 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||
in_ev->accept();
|
||||
auto prev_element = getFocusWidget();
|
||||
|
||||
if ( in_ev->getFocusType() == fc::FocusNextWidget )
|
||||
if ( in_ev->getFocusType() == FocusTypes::NextWidget )
|
||||
focusFirstChild();
|
||||
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
|
||||
else if ( in_ev->getFocusType() == FocusTypes::PreviousWidget )
|
||||
focusLastChild();
|
||||
|
||||
if ( prev_element )
|
||||
@ -386,7 +386,7 @@ bool FButtonGroup::isRadioButton (const FToggleButton* button) const
|
||||
if ( ! button )
|
||||
return false;
|
||||
|
||||
return bool( button->getClassName() == "FRadioButton" );
|
||||
return button->getClassName() == "FRadioButton";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -516,10 +516,10 @@ void FButtonGroup::focusCheckedRadioButton ( FToggleButton* toggle_button
|
||||
|
||||
toggle_button->setFocus();
|
||||
|
||||
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
||||
FFocusEvent cfi (Event::ChildFocusIn);
|
||||
FApplication::sendEvent(this, &cfi);
|
||||
|
||||
FFocusEvent in (fc::FocusIn_Event);
|
||||
FFocusEvent in (Event::FocusIn);
|
||||
FApplication::sendEvent(toggle_button, &in);
|
||||
|
||||
if ( in.isAccepted() )
|
||||
|
@ -29,16 +29,6 @@ namespace finalcut
|
||||
// class FCallback
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FCallback::FCallback()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCallback::~FCallback() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FCallback
|
||||
//----------------------------------------------------------------------
|
||||
void FCallback::delCallback (const FString& cb_signal)
|
||||
|
313
src/fcharmap.cpp
313
src/fcharmap.cpp
@ -32,128 +32,128 @@ namespace finalcut
|
||||
namespace fc
|
||||
{
|
||||
|
||||
std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character =
|
||||
std::array<CharEncodeMap, 115> character =
|
||||
{{
|
||||
// .--------------------- Unicode (UTF-8)
|
||||
// | .--------------- VT100
|
||||
// | | .--------- PC (IBM-437)
|
||||
// | | | .---- ASCII (7-Bit)
|
||||
// | | | |
|
||||
{{0x20ac, 0, 0xee, 'E'}}, // € - Euro
|
||||
{{0x00a3, '}', 0x9c, 'P'}}, // £ - Pound
|
||||
{{0x00a7, '$', 0x15, '$'}}, // § - Section
|
||||
{{0x25d8, '*', 0x08, '*'}}, // ◘ - InverseBullet
|
||||
{{0x25d9, '*', 0x0a, '*'}}, // ◙ - InverseWhiteCircle
|
||||
{{0x203c, '!', 0x13, '!'}}, // ‼ - DoubleExclamationMark
|
||||
{{0x2195, 'I', 0x12, 'I'}}, // ↕ - UpDownArrow
|
||||
{{0x2194, '-', 0x1d, '-'}}, // ↔ - LeftRightArrow
|
||||
{{0x25ac, '_', 0x16, '_'}}, // ▬ - BlackRectangle
|
||||
{{0x2191, '^', 0x18, '^'}}, // ↑ - UpwardsArrow
|
||||
{{0x2193, 'v', 0x19, 'v'}}, // ↓ - DownwardsArrow
|
||||
{{0x2192, '>', 0x1a, '>'}}, // → - RightwardsArrow
|
||||
{{0x2190, '<', 0x1b, '<'}}, // ← - LeftwardsArrow
|
||||
{{0x203a, '>', 0xaf, '>'}}, // › - SingleRightAngleQuotationMark
|
||||
{{0x2039, '<', 0xae, '<'}}, // ‹ - SingleLeftAngleQuotationMark
|
||||
{{0x2026, '.', '.', '.'}}, // … - HorizontalEllipsis
|
||||
{{0x03c0, '{', 0xe3, 'n'}}, // π - Pi
|
||||
{{0x207F, 'I', 0xfc, ' '}}, // ⁿ - SuperscriptLatinSmallLetterN
|
||||
{{0x2265, 'z', 0xf2, '>'}}, // ≥ - GreaterThanOrEqualTo
|
||||
{{0x2264, 'y', 0xf3, '<'}}, // ≤ - LessThanOrEqualTo
|
||||
{{0x2260, 0, 0xd8, '#'}}, // ≠ - NotEqualTo
|
||||
{{0x00b1, 'g', 0xf1, '#'}}, // ± - PlusMinus
|
||||
{{0x00f7, '/', 0xf6, '/'}}, // ÷ - Division sign
|
||||
{{0x00d7, 0, 'x', 'x'}}, // × - Multiplication sign
|
||||
{{0x02e3, '~', 0xfc, '`'}}, // ˣ - Modifier letter small x
|
||||
{{0x00b0, 'f', 0xb0, 'o'}}, // ° - Degree
|
||||
{{0x2022, '`', 0x04, '*'}}, // • - Bullet
|
||||
{{0x00b7, '`', 0xfa, '.'}}, // · - small Bullet
|
||||
{{0x25cf, '`', 0x04, '*'}}, // ● - BlackCircle
|
||||
{{0x2666, '`', 0x04, '*'}}, // ◆ - BlackDiamondSuit
|
||||
{{0x2424, 'h', ' ', ' '}}, //  - SymbolForNewline (1)
|
||||
{{0x240b, 'i', ' ', ' '}}, // ␋ - SymbolForVerticalTab (1)
|
||||
{{0x2409, 'b', ' ', ' '}}, // ␉ - SymbolForHorizontalTab (1)
|
||||
{{0x240c, 'c', ' ', ' '}}, // ␌ - SymbolForFormFeed (1)
|
||||
{{0x240d, 'd', ' ', ' '}}, // ␍ - SymbolForCarriageReturn (1)
|
||||
{{0x240a, 'e', ' ', ' '}}, // ␊ - SymbolForLineFeed (1)
|
||||
{{0x2592, 'a', 0xb0, '#'}}, // ▒ - MediumShade
|
||||
{{0x2588, '0', 0xdb, '#'}}, // █ - FullBlock
|
||||
{{0x25ae, '_', 0xfe, '#'}}, // ▮ - BlackVerticalRectangle (1)
|
||||
{{0x258c, 0, 0xdd, ' '}}, // ▌ - LeftHalfBlock
|
||||
{{0x2590, 0, 0xde, ' '}}, // ▐ - RightHalfBlock
|
||||
{{0x2584, 0, 0xdc, ' '}}, // ▄ - LowerHalfBlock
|
||||
{{0x2580, 0, 0xdf, ' '}}, // ▀ - UpperHalfBlock
|
||||
{{0x2500, 'q', 0xc4, '-'}}, // ─ - BoxDrawingsHorizontal
|
||||
{{0x2502, 'x', 0xb3, '|'}}, // │ - BoxDrawingsVertical
|
||||
{{0x250c, 'l', 0xda, '.'}}, // ┌ - BoxDrawingsDownAndRight
|
||||
{{0x2510, 'k', 0xbf, '.'}}, // ┐ - BoxDrawingsDownAndLeft
|
||||
{{0x2514, 'm', 0xc0, '`'}}, // └ - BoxDrawingsUpAndRight
|
||||
{{0x2518, 'j', 0xd9, '\''}}, // ┘ - BoxDrawingsUpAndLeft
|
||||
{{0x253c, 'n', 0xc5, '+'}}, // ┼ - BoxDrawingsCross
|
||||
{{0x252c, 'w', 0xc2, '+'}}, // ┬ - BoxDrawingsDownAndHorizontal
|
||||
{{0x2524, 'u', 0xb4, '+'}}, // ┤ - BoxDrawingsVerticalAndLeft
|
||||
{{0x251c, 't', 0xc3, '+'}}, // ├ - BoxDrawingsVerticalAndRight
|
||||
{{0x2534, 'v', 0xc1, '+'}}, // ┴ - BoxDrawingsUpAndHorizontal
|
||||
{{0x23ba, 'o', '~', '~'}}, // ⎺ - HorizontalScanLine1 (1)
|
||||
{{0x23bb, 'p', 0xc4, '-'}}, // ⎻ - HorizontalScanLine3 (1)
|
||||
{{0x23bc, 'r', 0xc4, '-'}}, // ⎼ - HorizontalScanLine7 (1)
|
||||
{{0x23bd, 's', '_', '_'}}, // ⎽ - HorizontalScanLine9 (1)
|
||||
{{0x25b2, '-', 0x1e, '^'}}, // ▲ - BlackUpPointingTriangle
|
||||
{{0x25bc, '.', 0x1f, 'v'}}, // ▼ - BlackDownPointingTriangle
|
||||
{{0x25b6, '+', 0x10, '>'}}, // ▶ - BlackRightPointingTriangle
|
||||
{{0x25c0, ',', 0x11, '<'}}, // ◀ - BlackLeftPointingTriangle (1)
|
||||
{{0x25ba, '+', 0x10, '>'}}, // ► - BlackRightPointingPointer (1)
|
||||
{{0x25c4, ',', 0x11, '<'}}, // ◄ - BlackLeftPointingPointer
|
||||
{{0xe1b3, 'x', 0xb3, '|'}}, // │ - NF_border_line_vertical (2)
|
||||
{{0xe1b4, 0, 0xb4, 0}}, // ⊐ - NF_rev_left_arrow2 (2)
|
||||
{{0xe1b5, 0, 0xb5, 0}}, // ► - NF_rev_right_arrow2 (2)
|
||||
{{0xe1b6, 0, 0xb6, 0}}, // ╵ - NF_border_line_left_up (2)
|
||||
{{0xe1b7, 0, 0xb7, 0}}, // ) - NF_radio_button3 (2)
|
||||
{{0xe1b8, 0, 0xb8, 0}}, // ⎤ - NF_rev_border_corner_upper_right (2)
|
||||
{{0xe1b9, 0, 0xb9, 0}}, // ⎹ - NF_rev_border_line_right (2)
|
||||
{{0xe1ba, 0, 0xba, 0}}, // ┤ - NF_rev_border_line_vertical_left (2)
|
||||
{{0xe1bb, 0, 0xbb, 0}}, // ⎦ - NF_rev_border_corner_lower_right (2)
|
||||
{{0xe1bc, 0, 0xbc, 0}}, // ⎸ - NF_border_line_left (2)
|
||||
{{0xe1bd, 0, 0xbd, 0}}, //⎹◣ - NF_rev_up_arrow2 (2)
|
||||
{{0xe1be, 0, 0xbe, 0}}, //⎹◤ - NF_rev_down_arrow2 (2)
|
||||
{{0xe1bf, 0, 0xbf, 0}}, // ╷ - NF_border_line_left_down (2)
|
||||
{{0xe1c0, 0, 0xc0, 0}}, // └ - NF_border_corner_middle_lower_left (2)
|
||||
{{0xe1c1, 0, 0xc1, 0}}, // ◢⎸ - NF_rev_up_arrow1 (2)
|
||||
{{0xe1c2, 0, 0xc2, 0}}, // ◥⎸ - NF_rev_down_arrow1 (2)
|
||||
{{0xe1c3, 0, 0xc3, 0}}, // ├ - NF_border_line_vertical_right (2)
|
||||
{{0xe1c4, 'q', 0xc4, '-'}}, // ─ - NF_border_line_horizontal (2)
|
||||
{{0xe1c5, 0, 0xc5, 0}}, // = - NF_border_line_up_and_down (2)
|
||||
{{0xe1c6, 0, 0xc6, 0}}, // = - NF_shadow_box_middle (2)
|
||||
{{0xe1c7, 0, 0xc7, 0}}, // = - NF_shadow_box_hdd (2)
|
||||
{{0xe1c8, 0, 0xc8, 0}}, // ◄ - NF_rev_left_arrow1 (2)
|
||||
{{0xe1c9, 0, 0xc9, 0}}, // ⊏ - NF_rev_right_arrow1 (2)
|
||||
{{0xe1ca, 0, 0xca, 0}}, // [ - NF_rev_menu_button1 (2)
|
||||
{{0xe1cb, 0, 0xcb, 0}}, // - - NF_rev_menu_button2 (2)
|
||||
{{0xe1cc, 0, 0xcc, 0}}, // ┌ - NF_border_corner_middle_upper_left (2)
|
||||
{{0xe1cd, 0, 0xcd, 0}}, // = - NF_shadow_box_cd (2)
|
||||
{{0xe1ce, 0, 0xce, 0}}, // [ - NF_shadow_box_left (2)
|
||||
{{0xe1cf, 0, 0xcf, 0}}, // ┌ - NF_border_line_middle_left_down (2)
|
||||
{{0xe1d0, 0, 0xd0, 0}}, // └ - NF_border_line_middle_right_up (2)
|
||||
{{0xe1d1, 0, 0xd1, 0}}, // = - NF_shadow_box_net (2)
|
||||
{{0xe1d2, 0, 0xd2, 0}}, // ◢ - NF_rev_up_pointing_triangle1 (2)
|
||||
{{0xe1d3, 0, 0xd3, 0}}, // ⎣ - NF_border_corner_lower_left (2)
|
||||
{{0xe1d4, 0, 0xd4, 0}}, // _ - NF_border_line_bottom (2)
|
||||
{{0xe1d5, 0, 0xd5, 0}}, // O - NF_radio_button2 (2)
|
||||
{{0xe1d6, 0, 0xd6, 0}}, // ● - NF_radio_button2_checked (2)
|
||||
{{0xe1d7, 0, 0xd7, 0}}, // ◥ - NF_rev_down_pointing_triangle1 (2)
|
||||
{{0xe1d8, 0, 0xd8, 0}}, // ¯ - NF_border_line_upper (2)
|
||||
{{0xe1d9, 0, 0xd9, 0}}, // ( - NF_radio_button1 (2)
|
||||
{{0xe1da, 0, 0xda, 0}}, // ⎡ - NF_border_corner_upper_left (2)
|
||||
{{0xe1dc, 0, 0xdc, 0}}, // ✓ - NF_shadow_box_checked (2)
|
||||
{{0xe1e7, 0, 0xe7, 0}}, // ║ - NF_rev_border_line_right_and_left (2)
|
||||
{{0xe1e8, 0, 0xe8, 0}}, // ◣ - NF_rev_up_pointing_triangle2 (2)
|
||||
{{0xe1e9, 0, 0xe9, 0}}, // ◤ - NF_rev_down_pointing_triangle2 (2)
|
||||
{{0xe1ea, 0, 0xea, 0}}, // ┘ - NF_border_corner_middle_lower_right (2)
|
||||
{{0xe1eb, 0, 0xeb, 0}}, // ┐ - NF_border_corner_middle_upper_right (2)
|
||||
{{0xe1f4, 0, 0xf4, 0}}, // ] - NF_rev_menu_button3 (2)
|
||||
{{0xe1f5, 0, 0xf5, 0}}, // ] - NF_shadow_box_right (2)
|
||||
{{0xe1fb, 0, 0xfb, 0}}, // ✓ - NF_check_mark (2)
|
||||
{{0xe1fc, '~', 0xfc, '`'}}, // ˣ - NF_xsuperior (2)
|
||||
{{0x221a, 0, 0xfb, 'x'}} // √ - square root
|
||||
{0x20ac, 0, 0xee, 'E'}, // € - Euro
|
||||
{0x00a3, '}', 0x9c, 'P'}, // £ - Pound
|
||||
{0x00a7, '$', 0x15, '$'}, // § - Section
|
||||
{0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet
|
||||
{0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle
|
||||
{0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark
|
||||
{0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow
|
||||
{0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow
|
||||
{0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle
|
||||
{0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow
|
||||
{0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow
|
||||
{0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow
|
||||
{0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow
|
||||
{0x203a, '>', 0xaf, '>'}, // › - SingleRightAngleQuotationMark
|
||||
{0x2039, '<', 0xae, '<'}, // ‹ - SingleLeftAngleQuotationMark
|
||||
{0x2026, '.', '.', '.'}, // … - HorizontalEllipsis
|
||||
{0x03c0, '{', 0xe3, 'n'}, // π - Pi
|
||||
{0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN
|
||||
{0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo
|
||||
{0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo
|
||||
{0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo
|
||||
{0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus
|
||||
{0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign
|
||||
{0x00d7, 0, 'x', 'x'}, // × - Multiplication sign
|
||||
{0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x
|
||||
{0x00b0, 'f', 0xb0, 'o'}, // ° - Degree
|
||||
{0x2022, '`', 0x04, '*'}, // • - Bullet
|
||||
{0x00b7, '`', 0xfa, '.'}, // · - small Bullet
|
||||
{0x25cf, '`', 0x04, '*'}, // ● - BlackCircle
|
||||
{0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit
|
||||
{0x2424, 'h', ' ', ' '}, //  - SymbolForNewline (1)
|
||||
{0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1)
|
||||
{0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1)
|
||||
{0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1)
|
||||
{0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1)
|
||||
{0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1)
|
||||
{0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade
|
||||
{0x2588, '0', 0xdb, '#'}, // █ - FullBlock
|
||||
{0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1)
|
||||
{0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock
|
||||
{0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock
|
||||
{0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock
|
||||
{0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock
|
||||
{0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal
|
||||
{0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical
|
||||
{0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight
|
||||
{0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft
|
||||
{0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight
|
||||
{0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft
|
||||
{0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross
|
||||
{0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal
|
||||
{0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft
|
||||
{0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight
|
||||
{0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal
|
||||
{0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1)
|
||||
{0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1)
|
||||
{0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1)
|
||||
{0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1)
|
||||
{0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle
|
||||
{0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle
|
||||
{0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle
|
||||
{0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1)
|
||||
{0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1)
|
||||
{0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer
|
||||
{0xe1b3, 'x', 0xb3, '|'}, // │ - NF_border_line_vertical (2)
|
||||
{0xe1b4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2)
|
||||
{0xe1b5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2)
|
||||
{0xe1b6, 0, 0xb6, 0}, // ╵ - NF_border_line_left_up (2)
|
||||
{0xe1b7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2)
|
||||
{0xe1b8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2)
|
||||
{0xe1b9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2)
|
||||
{0xe1ba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2)
|
||||
{0xe1bb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2)
|
||||
{0xe1bc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2)
|
||||
{0xe1bd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2)
|
||||
{0xe1be, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2)
|
||||
{0xe1bf, 0, 0xbf, 0}, // ╷ - NF_border_line_left_down (2)
|
||||
{0xe1c0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2)
|
||||
{0xe1c1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2)
|
||||
{0xe1c2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2)
|
||||
{0xe1c3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2)
|
||||
{0xe1c4, 'q', 0xc4, '-'}, // ─ - NF_border_line_horizontal (2)
|
||||
{0xe1c5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2)
|
||||
{0xe1c6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2)
|
||||
{0xe1c7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2)
|
||||
{0xe1c8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2)
|
||||
{0xe1c9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2)
|
||||
{0xe1ca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2)
|
||||
{0xe1cb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2)
|
||||
{0xe1cc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2)
|
||||
{0xe1cd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2)
|
||||
{0xe1ce, 0, 0xce, 0}, // [ - NF_shadow_box_left (2)
|
||||
{0xe1cf, 0, 0xcf, 0}, // ┌ - NF_border_line_middle_left_down (2)
|
||||
{0xe1d0, 0, 0xd0, 0}, // └ - NF_border_line_middle_right_up (2)
|
||||
{0xe1d1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2)
|
||||
{0xe1d2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2)
|
||||
{0xe1d3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2)
|
||||
{0xe1d4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2)
|
||||
{0xe1d5, 0, 0xd5, 0}, // O - NF_radio_button2 (2)
|
||||
{0xe1d6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2)
|
||||
{0xe1d7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2)
|
||||
{0xe1d8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2)
|
||||
{0xe1d9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2)
|
||||
{0xe1da, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2)
|
||||
{0xe1dc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2)
|
||||
{0xe1e7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2)
|
||||
{0xe1e8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2)
|
||||
{0xe1e9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2)
|
||||
{0xe1ea, 0, 0xea, 0}, // ┘ - NF_border_corner_middle_lower_right (2)
|
||||
{0xe1eb, 0, 0xeb, 0}, // ┐ - NF_border_corner_middle_upper_right (2)
|
||||
{0xe1f4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2)
|
||||
{0xe1f5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2)
|
||||
{0xe1fb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2)
|
||||
{0xe1fc, '~', 0xfc, '`'}, // ˣ - NF_xsuperior (2)
|
||||
{0x221a, 0, 0xfb, 'x'} // √ - square root
|
||||
}};
|
||||
|
||||
/*
|
||||
@ -161,47 +161,48 @@ std::array<std::array<uInt, fc::NUM_OF_ENCODINGS>, 115> character =
|
||||
* (2) Only supported in use with newfont
|
||||
*/
|
||||
|
||||
constexpr std::array<std::array<int, 2>, 39> vt100_key_to_utf8 =
|
||||
|
||||
constexpr std::array<DECSpecialGraphics, 39> dec_special_graphics =
|
||||
{{
|
||||
{{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}}, // ►
|
||||
{{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}}, // ◄
|
||||
{{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}}, // ▲
|
||||
{{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}}, // ▼
|
||||
{{fc::vt100_key_block , fc::FullBlock}}, // █
|
||||
{{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}}, // ⁿ
|
||||
{{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}}, // ▮
|
||||
{{fc::vt100_key_diamond , fc::BlackDiamondSuit}}, // ◆
|
||||
{{fc::vt100_key_ckboard , fc::MediumShade}}, // ▒
|
||||
{{fc::vt100_key_htab , fc::SymbolForHorizontalTab}}, // ␉
|
||||
{{fc::vt100_key_ff , fc::SymbolForFormFeed}}, // ␌
|
||||
{{fc::vt100_key_cr , fc::SymbolForCarriageReturn}}, // ␍
|
||||
{{fc::vt100_key_lf , fc::SymbolForLineFeed}}, // ␊
|
||||
{{fc::vt100_key_degree , fc::Degree}}, // °
|
||||
{{fc::vt100_key_plminus , fc::PlusMinus}}, // ±
|
||||
{{fc::vt100_key_board , fc::SymbolForNewline}}, // 
|
||||
{{fc::vt100_key_lantern , fc::SymbolForVerticalTab}}, // ␋
|
||||
{{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}}, // ┘
|
||||
{{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}}, // ┐
|
||||
{{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}}, // ┌
|
||||
{{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}}, // └
|
||||
{{fc::vt100_key_plus , fc::BoxDrawingsCross}}, // ┼
|
||||
{{fc::vt100_key_s1 , fc::HorizontalScanLine1}}, // ⎺
|
||||
{{fc::vt100_key_s3 , fc::HorizontalScanLine3}}, // ⎻
|
||||
{{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}}, // ─
|
||||
{{fc::vt100_key_s7 , fc::HorizontalScanLine7}}, // ⎼
|
||||
{{fc::vt100_key_s9 , fc::HorizontalScanLine9}}, // ⎽
|
||||
{{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}}, // ├
|
||||
{{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}}, // ┤
|
||||
{{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}}, // ┴
|
||||
{{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}}, // ┬
|
||||
{{fc::vt100_key_vline , fc::BoxDrawingsVertical}}, // │
|
||||
{{fc::vt100_key_lequal , fc::LessThanOrEqualTo}}, // ≤
|
||||
{{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}}, // ≥
|
||||
{{fc::vt100_key_pi , fc::Pi}}, // π
|
||||
{{fc::vt100_key_nequal , fc::NotEqualTo}}, // ≠
|
||||
{{fc::vt100_key_sterling , fc::Pound}}, // £
|
||||
{{fc::vt100_key_bullet , fc::SmallBullet}}, // ·
|
||||
{{fc::vt100_key_diamond , fc::Bullet}} // ◆
|
||||
{VT100Key::rarrow , UniChar::BlackRightPointingPointer}, // ►
|
||||
{VT100Key::larrow , UniChar::BlackLeftPointingPointer}, // ◄
|
||||
{VT100Key::uarrow , UniChar::BlackUpPointingTriangle}, // ▲
|
||||
{VT100Key::darrow , UniChar::BlackDownPointingTriangle}, // ▼
|
||||
{VT100Key::block , UniChar::FullBlock}, // █
|
||||
{VT100Key::nsup , UniChar::SuperscriptLatinSmallLetterN}, // ⁿ
|
||||
{VT100Key::blackrect, UniChar::BlackVerticalRectangle}, // ▮
|
||||
{VT100Key::diamond , UniChar::BlackDiamondSuit}, // ◆
|
||||
{VT100Key::ckboard , UniChar::MediumShade}, // ▒
|
||||
{VT100Key::htab , UniChar::SymbolForHorizontalTab}, // ␉
|
||||
{VT100Key::ff , UniChar::SymbolForFormFeed}, // ␌
|
||||
{VT100Key::cr , UniChar::SymbolForCarriageReturn}, // ␍
|
||||
{VT100Key::lf , UniChar::SymbolForLineFeed}, // ␊
|
||||
{VT100Key::degree , UniChar::Degree}, // °
|
||||
{VT100Key::plminus , UniChar::PlusMinus}, // ±
|
||||
{VT100Key::board , UniChar::SymbolForNewline}, // 
|
||||
{VT100Key::lantern , UniChar::SymbolForVerticalTab}, // ␋
|
||||
{VT100Key::lrcorner , UniChar::BoxDrawingsUpAndLeft}, // ┘
|
||||
{VT100Key::urcorner , UniChar::BoxDrawingsDownAndLeft}, // ┐
|
||||
{VT100Key::ulcorner , UniChar::BoxDrawingsDownAndRight}, // ┌
|
||||
{VT100Key::llcorner , UniChar::BoxDrawingsUpAndRight}, // └
|
||||
{VT100Key::plus , UniChar::BoxDrawingsCross}, // ┼
|
||||
{VT100Key::s1 , UniChar::HorizontalScanLine1}, // ⎺
|
||||
{VT100Key::s3 , UniChar::HorizontalScanLine3}, // ⎻
|
||||
{VT100Key::hline , UniChar::BoxDrawingsHorizontal}, // ─
|
||||
{VT100Key::s7 , UniChar::HorizontalScanLine7}, // ⎼
|
||||
{VT100Key::s9 , UniChar::HorizontalScanLine9}, // ⎽
|
||||
{VT100Key::ltee , UniChar::BoxDrawingsVerticalAndRight}, // ├
|
||||
{VT100Key::rtee , UniChar::BoxDrawingsVerticalAndLeft}, // ┤
|
||||
{VT100Key::btee , UniChar::BoxDrawingsUpAndHorizontal}, // ┴
|
||||
{VT100Key::ttee , UniChar::BoxDrawingsDownAndHorizontal}, // ┬
|
||||
{VT100Key::vline , UniChar::BoxDrawingsVertical}, // │
|
||||
{VT100Key::lequal , UniChar::LessThanOrEqualTo}, // ≤
|
||||
{VT100Key::gequal , UniChar::GreaterThanOrEqualTo}, // ≥
|
||||
{VT100Key::pi , UniChar::Pi}, // π
|
||||
{VT100Key::nequal , UniChar::NotEqualTo}, // ≠
|
||||
{VT100Key::sterling , UniChar::Pound}, // £
|
||||
{VT100Key::bullet , UniChar::SmallBullet}, // ·
|
||||
{VT100Key::diamond , UniChar::Bullet} // ◆
|
||||
}};
|
||||
|
||||
constexpr std::array<std::array<wchar_t, 2>, 256> cp437_ucs =
|
||||
|
@ -46,9 +46,7 @@ FCheckBox::FCheckBox (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCheckBox::~FCheckBox() // destructor
|
||||
{ }
|
||||
|
||||
FCheckBox::~FCheckBox() noexcept = default; // destructor
|
||||
|
||||
// private methods of FCheckBox
|
||||
//----------------------------------------------------------------------
|
||||
@ -101,7 +99,7 @@ inline void FCheckBox::drawChecked()
|
||||
else
|
||||
{
|
||||
print ('[');
|
||||
print (fc::Times); // Times ×
|
||||
print (UniChar::Times); // Times ×
|
||||
print (']');
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ FCheckMenuItem::FCheckMenuItem (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCheckMenuItem::~FCheckMenuItem() // destructor
|
||||
{ }
|
||||
FCheckMenuItem::~FCheckMenuItem() noexcept = default; // destructor
|
||||
|
||||
|
||||
// private methods of FCheckMenuItem
|
||||
|
@ -36,8 +36,7 @@ FColorPalette::FColorPalette (const FSetPalette& f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FColorPalette::~FColorPalette() // destructor
|
||||
{ }
|
||||
FColorPalette::~FColorPalette() noexcept = default; // destructor
|
||||
|
||||
|
||||
// protected methods of FColorPalette
|
||||
@ -50,22 +49,22 @@ void FColorPalette::setPalette (FColor index, int r, int g, int b) const
|
||||
//----------------------------------------------------------------------
|
||||
void FColorPalette::setVGAdefaultPalette() const
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x00, 0x00, 0xaa);
|
||||
setPalette (fc::Green, 0x00, 0xaa, 0x00);
|
||||
setPalette (fc::Cyan, 0x00, 0xaa, 0xaa);
|
||||
setPalette (fc::Red, 0xaa, 0x00, 0x00);
|
||||
setPalette (fc::Magenta, 0xaa, 0x00, 0xaa);
|
||||
setPalette (fc::Brown, 0xaa, 0x55, 0x00);
|
||||
setPalette (fc::LightGray, 0xaa, 0xaa, 0xaa);
|
||||
setPalette (fc::DarkGray, 0x55, 0x55, 0x55);
|
||||
setPalette (fc::LightBlue, 0x55, 0x55, 0xff);
|
||||
setPalette (fc::LightGreen, 0x55, 0xff, 0x55);
|
||||
setPalette (fc::LightCyan, 0x55, 0xff, 0xff);
|
||||
setPalette (fc::LightRed, 0xff, 0x55, 0x55);
|
||||
setPalette (fc::LightMagenta, 0xff, 0x55, 0xff);
|
||||
setPalette (fc::Yellow, 0xff, 0xff, 0x55);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
setPalette (FColor::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (FColor::Blue, 0x00, 0x00, 0xaa);
|
||||
setPalette (FColor::Green, 0x00, 0xaa, 0x00);
|
||||
setPalette (FColor::Cyan, 0x00, 0xaa, 0xaa);
|
||||
setPalette (FColor::Red, 0xaa, 0x00, 0x00);
|
||||
setPalette (FColor::Magenta, 0xaa, 0x00, 0xaa);
|
||||
setPalette (FColor::Brown, 0xaa, 0x55, 0x00);
|
||||
setPalette (FColor::LightGray, 0xaa, 0xaa, 0xaa);
|
||||
setPalette (FColor::DarkGray, 0x55, 0x55, 0x55);
|
||||
setPalette (FColor::LightBlue, 0x55, 0x55, 0xff);
|
||||
setPalette (FColor::LightGreen, 0x55, 0xff, 0x55);
|
||||
setPalette (FColor::LightCyan, 0x55, 0xff, 0xff);
|
||||
setPalette (FColor::LightRed, 0xff, 0x55, 0x55);
|
||||
setPalette (FColor::LightMagenta, 0xff, 0x55, 0xff);
|
||||
setPalette (FColor::Yellow, 0xff, 0xff, 0x55);
|
||||
setPalette (FColor::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -79,30 +78,30 @@ default8ColorPalette::default8ColorPalette (const FSetPalette& f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default8ColorPalette::~default8ColorPalette()
|
||||
{ }
|
||||
default8ColorPalette::~default8ColorPalette() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of default8ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default8ColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::Red, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xe0, 0xe0, 0xe0);
|
||||
setPalette (FColor::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (FColor::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (FColor::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (FColor::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (FColor::Red, 0xb2, 0x18, 0x18);
|
||||
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (FColor::LightGray, 0xe0, 0xe0, 0xe0);
|
||||
// The same colors again...
|
||||
setPalette (fc::DarkGray, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::LightBlue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::LightGreen, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (fc::LightRed, 0xb2, 0x18, 0x18);
|
||||
setPalette (fc::LightMagenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Yellow, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::White, 0xe0, 0xe0, 0xe0);
|
||||
setPalette (FColor::DarkGray, 0x00, 0x00, 0x00);
|
||||
setPalette (FColor::LightBlue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (FColor::LightGreen, 0x18, 0x78, 0x18);
|
||||
setPalette (FColor::Cyan, 0xa0, 0xb2, 0xb2);
|
||||
setPalette (FColor::LightRed, 0xb2, 0x18, 0x18);
|
||||
setPalette (FColor::LightMagenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (FColor::Yellow, 0xe8, 0x87, 0x1f);
|
||||
setPalette (FColor::White, 0xe0, 0xe0, 0xe0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -123,29 +122,29 @@ default16ColorPalette::default16ColorPalette (const FSetPalette& f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16ColorPalette::~default16ColorPalette()
|
||||
{ }
|
||||
default16ColorPalette::~default16ColorPalette() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of default16ColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default16ColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x55, 0x6a, 0xcf);
|
||||
setPalette (fc::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xbc, 0xbc, 0xbc);
|
||||
setPalette (fc::DarkGray, 0x50, 0x50, 0x50);
|
||||
setPalette (fc::LightBlue, 0x80, 0xa4, 0xec);
|
||||
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (fc::LightRed, 0xee, 0x44, 0x44);
|
||||
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
setPalette (FColor::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (FColor::Blue, 0x10, 0x3b, 0x9e);
|
||||
setPalette (FColor::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (FColor::Cyan, 0x55, 0x6a, 0xcf);
|
||||
setPalette (FColor::Red, 0xba, 0x1a, 0x1a);
|
||||
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (FColor::LightGray, 0xbc, 0xbc, 0xbc);
|
||||
setPalette (FColor::DarkGray, 0x50, 0x50, 0x50);
|
||||
setPalette (FColor::LightBlue, 0x80, 0xa4, 0xec);
|
||||
setPalette (FColor::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (FColor::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (FColor::LightRed, 0xee, 0x44, 0x44);
|
||||
setPalette (FColor::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (FColor::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (FColor::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -166,29 +165,29 @@ default16DarkColorPalette::default16DarkColorPalette (const FSetPalette& f)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
default16DarkColorPalette::~default16DarkColorPalette()
|
||||
{ }
|
||||
default16DarkColorPalette::~default16DarkColorPalette() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of default16DarkColorPalette
|
||||
//----------------------------------------------------------------------
|
||||
void default16DarkColorPalette::setColorPalette()
|
||||
{
|
||||
setPalette (fc::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (fc::Blue, 0x41, 0x58, 0xb3);
|
||||
setPalette (fc::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (fc::Cyan, 0x4e, 0x66, 0x72);
|
||||
setPalette (fc::Red, 0xa5, 0x40, 0x40);
|
||||
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (fc::LightGray, 0xdc, 0xdc, 0xdc);
|
||||
setPalette (fc::DarkGray, 0x27, 0x33, 0x39);
|
||||
setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8);
|
||||
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (fc::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (fc::LightRed, 0xdd, 0x51, 0x45);
|
||||
setPalette (fc::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (fc::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (fc::White, 0xff, 0xff, 0xff);
|
||||
setPalette (FColor::Black, 0x00, 0x00, 0x00);
|
||||
setPalette (FColor::Blue, 0x41, 0x58, 0xb3);
|
||||
setPalette (FColor::Green, 0x18, 0x78, 0x18);
|
||||
setPalette (FColor::Cyan, 0x4e, 0x66, 0x72);
|
||||
setPalette (FColor::Red, 0xa5, 0x40, 0x40);
|
||||
setPalette (FColor::Magenta, 0xb2, 0x18, 0xb2);
|
||||
setPalette (FColor::Brown, 0xe8, 0x87, 0x1f);
|
||||
setPalette (FColor::LightGray, 0xdc, 0xdc, 0xdc);
|
||||
setPalette (FColor::DarkGray, 0x27, 0x33, 0x39);
|
||||
setPalette (FColor::LightBlue, 0xb0, 0xb0, 0xb8);
|
||||
setPalette (FColor::LightGreen, 0x5e, 0xeb, 0x5c);
|
||||
setPalette (FColor::LightCyan, 0x62, 0xbf, 0xf8);
|
||||
setPalette (FColor::LightRed, 0xdd, 0x51, 0x45);
|
||||
setPalette (FColor::LightMagenta, 0xe9, 0xad, 0xff);
|
||||
setPalette (FColor::Yellow, 0xfb, 0xe8, 0x67);
|
||||
setPalette (FColor::White, 0xff, 0xff, 0xff);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -145,7 +145,7 @@ void FDropDownListBox::drawShadow()
|
||||
const auto& wc = getColorTheme();
|
||||
finalcut::drawShadow(this);
|
||||
setColor (wc->shadow_fg, wc->shadow_bg);
|
||||
print() << FPoint{int(getWidth()) + 1, 1} << fc::FullBlock; // █
|
||||
print() << FPoint{int(getWidth()) + 1, 1} << UniChar::FullBlock; // █
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -177,9 +177,7 @@ FComboBox::FComboBox (FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FComboBox::~FComboBox() // destructor
|
||||
{ }
|
||||
|
||||
FComboBox::~FComboBox() noexcept = default; // destructor
|
||||
|
||||
// public methods of FComboBox
|
||||
//----------------------------------------------------------------------
|
||||
@ -221,8 +219,8 @@ bool FComboBox::setFocus (bool enable)
|
||||
bool FComboBox::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != Encoding::VT100
|
||||
&& FTerm::getEncoding() != Encoding::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
@ -355,72 +353,58 @@ void FComboBox::onKeyPress (FKeyEvent* ev)
|
||||
if ( ! isEnabled() )
|
||||
return;
|
||||
|
||||
switch ( ev->key() )
|
||||
const auto key = ev->key();
|
||||
|
||||
if ( key == FKey::Tab )
|
||||
{
|
||||
case fc::Fkey_tab:
|
||||
focusNextChild();
|
||||
break;
|
||||
|
||||
case fc::Fkey_btab:
|
||||
focusPrevChild();
|
||||
break;
|
||||
|
||||
case fc::Fkey_up:
|
||||
onePosUp();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
onePosDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_up:
|
||||
case fc::Fckey_up:
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
hideDropDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_f4:
|
||||
case fc::Fmkey_down:
|
||||
case fc::Fckey_down:
|
||||
showDropDown();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
focusNextChild();
|
||||
}
|
||||
else if ( key == FKey::Back_tab )
|
||||
{
|
||||
focusPrevChild();
|
||||
}
|
||||
else if ( key == FKey::Up )
|
||||
{
|
||||
onePosUp();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Down )
|
||||
{
|
||||
onePosDown();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Meta_up
|
||||
|| key == FKey::Ctrl_up
|
||||
|| key == FKey::Escape
|
||||
|| key == FKey::Escape_mintty )
|
||||
{
|
||||
hideDropDown();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::F4
|
||||
|| key == FKey::Meta_down
|
||||
|| key == FKey::Ctrl_down )
|
||||
{
|
||||
showDropDown();
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FComboBox::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
|
||||
if ( mouse_x >= int(getWidth()) - nf
|
||||
&& mouse_x <= int(getWidth()) && mouse_y == 1 )
|
||||
{
|
||||
redraw();
|
||||
|
||||
if ( list_window.isHidden() )
|
||||
showDropDown();
|
||||
else
|
||||
@ -431,7 +415,7 @@ void FComboBox::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FComboBox::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( isMouseOverListWindow(ev->getTermPos()) )
|
||||
@ -444,19 +428,10 @@ void FComboBox::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FComboBox::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
switch ( ev->getWheel() )
|
||||
{
|
||||
case fc::WheelUp:
|
||||
onePosUp();
|
||||
break;
|
||||
|
||||
case fc::WheelDown:
|
||||
onePosDown();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( ev->getWheel() == MouseWheel::Up )
|
||||
onePosUp();
|
||||
else if ( ev->getWheel() == MouseWheel::Down )
|
||||
onePosDown();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -551,7 +526,7 @@ void FComboBox::draw()
|
||||
if ( FTerm::isNewFont() )
|
||||
print() << NF_button_arrow_down;
|
||||
else
|
||||
print() << fc::BlackDownPointingTriangle; // ▼
|
||||
print() << UniChar::BlackDownPointingTriangle; // ▼
|
||||
|
||||
if ( getFlags().shadow )
|
||||
drawShadow(this);
|
||||
@ -596,20 +571,12 @@ void FComboBox::passEventToListWindow (const FMouseEvent& ev)
|
||||
|
||||
const auto& t = ev.getTermPos();
|
||||
const auto& p = list_window.list.termToWidgetPos(t);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
setClickedWidget(&list_window.list);
|
||||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const auto b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
setClickedWidget(&list_window.list);
|
||||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -644,9 +611,9 @@ void FComboBox::cb_closeComboBox()
|
||||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldSwitch()
|
||||
{
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( mouse && ! mouse->isLeftButtonPressed() )
|
||||
if ( ! mouse.isLeftButtonPressed() )
|
||||
return;
|
||||
|
||||
if ( list_window.isShown() )
|
||||
@ -655,20 +622,7 @@ void FComboBox::cb_inputFieldSwitch()
|
||||
}
|
||||
else if ( ! is_editable )
|
||||
{
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
showDropDown();
|
||||
}
|
||||
}
|
||||
@ -676,27 +630,19 @@ void FComboBox::cb_inputFieldSwitch()
|
||||
//----------------------------------------------------------------------
|
||||
void FComboBox::cb_inputFieldHandOver()
|
||||
{
|
||||
const auto& mouse = FTerm::getFMouseControl();
|
||||
auto& mouse = FTerm::getFMouseControl();
|
||||
|
||||
if ( ! mouse || list_window.isHidden() )
|
||||
if ( list_window.isHidden() )
|
||||
return;
|
||||
|
||||
const auto& t = mouse->getPos();
|
||||
const auto& t = mouse.getPos();
|
||||
const auto& p = list_window.list.termToWidgetPos(t);
|
||||
const int b = ( mouse->isLeftButtonPressed() ) ? fc::LeftButton : 0;
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
setClickedWidget(&list_window.list);
|
||||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const auto b = ( mouse.isLeftButtonPressed() ) ? MouseButton::Left : MouseButton::None;
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
setClickedWidget(&list_window.list);
|
||||
list_window.list.setFocus();
|
||||
list_window.list.onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
// non-member functions
|
||||
|
@ -31,12 +31,7 @@ namespace finalcut
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FDataAccess::FDataAccess()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FDataAccess::~FDataAccess() // destructor
|
||||
{ }
|
||||
FDataAccess::~FDataAccess() noexcept = default; // destructor
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
201
src/fdialog.cpp
201
src/fdialog.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2020 Markus Gans *
|
||||
* Copyright 2012-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -27,6 +27,7 @@
|
||||
#include "final/fdialog.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fkeyboard.h"
|
||||
#include "final/fmenubar.h"
|
||||
#include "final/fmenuitem.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/ftooltip.h"
|
||||
@ -99,7 +100,7 @@ bool FDialog::setModal (bool enable)
|
||||
if ( enable )
|
||||
{
|
||||
setModalDialogCounter()++;
|
||||
FTerm::getFKeyboard()->clearKeyBuffer();
|
||||
FTerm::getFKeyboard().clearKeyBuffer();
|
||||
}
|
||||
else
|
||||
setModalDialogCounter()--;
|
||||
@ -111,7 +112,7 @@ bool FDialog::setModal (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
bool FDialog::setScrollable (bool enable)
|
||||
{
|
||||
return (setFlags().scrollable = enable);
|
||||
return ( setFlags().scrollable = enable );
|
||||
}
|
||||
|
||||
|
||||
@ -133,7 +134,7 @@ bool FDialog::setBorder (bool enable)
|
||||
setRightPadding(0);
|
||||
}
|
||||
|
||||
return (setFlags().no_border = ! enable);
|
||||
return ( setFlags().no_border = ! enable );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -189,9 +190,9 @@ void FDialog::hide()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FDialog::exec()
|
||||
FDialog::ResultCode FDialog::exec()
|
||||
{
|
||||
result_code = FDialog::Reject;
|
||||
result_code = ResultCode::Reject;
|
||||
show();
|
||||
return result_code;
|
||||
}
|
||||
@ -358,6 +359,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||
|
||||
const auto d_width = std::size_t(dw);
|
||||
const auto d_height = std::size_t(dh);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Stop);
|
||||
|
||||
// restoring the non-covered terminal areas
|
||||
if ( dw > 0 )
|
||||
@ -376,6 +378,8 @@ void FDialog::setSize (const FSize& size, bool adjust)
|
||||
|
||||
// set the cursor to the focus widget
|
||||
setCursorToFocusWidget();
|
||||
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Start);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -459,9 +463,9 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|
||||
|
||||
cancelMouseResize();
|
||||
|
||||
if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6)
|
||||
|| ev->key() == fc::Fkey_f22 // Shift+F10
|
||||
|| ev->key() == fc::Fkey_smenu ) // Shift+Menu
|
||||
if ( ev->key() == FKey::Ctrl_caret // Ctrl+^ (Ctrl+6)
|
||||
|| ev->key() == FKey::F22 // Shift+F10
|
||||
|| ev->key() == FKey::Shift_menu ) // Shift+Menu
|
||||
{
|
||||
ev->accept();
|
||||
// open the titlebar menu
|
||||
@ -478,13 +482,13 @@ void FDialog::onKeyPress (FKeyEvent* ev)
|
||||
return;
|
||||
|
||||
if ( ! ev->isAccepted()
|
||||
&& ( ev->key() == fc::Fkey_escape
|
||||
|| ev->key() == fc::Fkey_escape_mintty) )
|
||||
&& ( ev->key() == FKey::Escape
|
||||
|| ev->key() == FKey::Escape_mintty) )
|
||||
{
|
||||
ev->accept();
|
||||
|
||||
if ( isModal() )
|
||||
done (FDialog::Reject);
|
||||
done (ResultCode::Reject);
|
||||
else
|
||||
close();
|
||||
}
|
||||
@ -506,7 +510,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
deactivateZoomButton();
|
||||
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
if ( ev->getButton() == MouseButton::Left )
|
||||
{
|
||||
// Click on titlebar or window: raise + activate
|
||||
raiseActivateDialog();
|
||||
@ -527,7 +531,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||
// Click on the lower right resize corner
|
||||
resizeMouseDown(ms);
|
||||
}
|
||||
else // ev->getButton() != fc::LeftButton
|
||||
else // ev->getButton() != MouseButton::Left
|
||||
{
|
||||
// Click on titlebar menu button
|
||||
if ( ms.mouse_x < 4 && ms.mouse_y == 1 && dialog_menu->isShown() )
|
||||
@ -537,14 +541,14 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||
}
|
||||
|
||||
// Click on titlebar: just activate
|
||||
if ( ev->getButton() == fc::RightButton
|
||||
if ( ev->getButton() == MouseButton::Right
|
||||
&& ms.mouse_x >= 4
|
||||
&& ms.mouse_x <= width
|
||||
&& ms.mouse_y == 1 )
|
||||
activateDialog();
|
||||
|
||||
// Click on titlebar: lower + activate
|
||||
if ( ev->getButton() == fc::MiddleButton
|
||||
if ( ev->getButton() == MouseButton::Middle
|
||||
&& ms.mouse_x >= 4 && ms.mouse_x <= width
|
||||
&& ms.mouse_y == 1 )
|
||||
lowerActivateDialog();
|
||||
@ -562,7 +566,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
|
||||
false // mouse_over_menu
|
||||
};
|
||||
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
if ( ev->getButton() == MouseButton::Left )
|
||||
{
|
||||
const int titlebar_x = titlebar_click_pos.getX();
|
||||
const int titlebar_y = titlebar_click_pos.getY();
|
||||
@ -611,7 +615,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
|
||||
isMouseOverMenu(ev->getTermPos())
|
||||
};
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( ! titlebar_click_pos.isOrigin() )
|
||||
@ -623,7 +627,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
|
||||
|
||||
// Mouse event handover to the menu
|
||||
if ( ms.mouse_over_menu )
|
||||
passEventToSubMenu (ms, std::move(*ev));
|
||||
passEventToSubMenu (ms, *ev);
|
||||
|
||||
leaveZoomButton(ms); // Check zoom button pressed
|
||||
resizeMouseUpMove(ms); // Resize the dialog
|
||||
@ -641,7 +645,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||
false // mouse_over_menu
|
||||
};
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
const int x = getTermX();
|
||||
@ -664,7 +668,7 @@ void FDialog::onMouseDoubleClick (FMouseEvent* ev)
|
||||
setClickedWidget(nullptr);
|
||||
|
||||
if ( isModal() )
|
||||
done (FDialog::Reject);
|
||||
done (ResultCode::Reject);
|
||||
else
|
||||
close();
|
||||
}
|
||||
@ -684,6 +688,14 @@ void FDialog::onAccel (FAccelEvent*)
|
||||
{
|
||||
if ( ! (isWindowHidden() || isWindowActive()) )
|
||||
{
|
||||
const auto menu_bar = getMenuBar();
|
||||
|
||||
if ( menu_bar )
|
||||
{
|
||||
menu_bar->resetMenu();
|
||||
menu_bar->redraw();
|
||||
}
|
||||
|
||||
const bool has_raised = raiseWindow();
|
||||
activateDialog();
|
||||
|
||||
@ -754,14 +766,17 @@ void FDialog::onWindowLowered (FEvent*)
|
||||
if ( getWindowList()->empty() )
|
||||
return;
|
||||
|
||||
for (auto&& win : *getWindowList())
|
||||
for (auto&& window : *getWindowList())
|
||||
{
|
||||
const auto win = static_cast<FWidget*>(window);
|
||||
putArea (win->getTermPos(), win->getVWin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// protected methods of FDialog
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::done(int result)
|
||||
void FDialog::done (ResultCode result)
|
||||
{
|
||||
hide();
|
||||
result_code = result;
|
||||
@ -807,7 +822,7 @@ void FDialog::drawDialogShadow()
|
||||
void FDialog::onClose (FCloseEvent* ev)
|
||||
{
|
||||
ev->accept();
|
||||
result_code = FDialog::Reject;
|
||||
result_code = ResultCode::Reject;
|
||||
}
|
||||
|
||||
|
||||
@ -824,6 +839,7 @@ void FDialog::init()
|
||||
// Initialize geometry values
|
||||
setGeometry (FPoint{1, 1}, FSize{10, 10}, false);
|
||||
setMinimumSize (FSize{15, 4});
|
||||
mapKeyFunctions();
|
||||
addDialog(this);
|
||||
setActiveWindow(this);
|
||||
setTransparentShadow();
|
||||
@ -943,6 +959,27 @@ void FDialog::initCloseMenuItem (FMenu* menu)
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FDialog::mapKeyFunctions()
|
||||
{
|
||||
key_map[FKey::Up] = [this] () { moveUp(1); };
|
||||
key_map[FKey::Down] = [this] () { moveDown(1); };
|
||||
key_map[FKey::Left] = [this] () { moveLeft(1); };
|
||||
key_map[FKey::Right] = [this] () { moveRight(1); };
|
||||
key_map[FKey::Meta_up] = [this] () { reduceHeight(1); };
|
||||
key_map[FKey::Shift_up] = [this] () { reduceHeight(1); };
|
||||
key_map[FKey::Meta_down] = [this] () { expandHeight(1); };
|
||||
key_map[FKey::Shift_down] = [this] () { expandHeight(1); };
|
||||
key_map[FKey::Meta_left] = [this] () { reduceWidth(1); };
|
||||
key_map[FKey::Shift_left] = [this] () { reduceWidth(1); };
|
||||
key_map[FKey::Meta_right] = [this] () { expandWidth(1); };
|
||||
key_map[FKey::Shift_right] = [this] () { expandWidth(1); };
|
||||
key_map[FKey::Return] = [this] () { acceptMoveSize(); };
|
||||
key_map[FKey::Enter] = [this] () { acceptMoveSize(); };
|
||||
key_map[FKey::Escape] = [this] () { cancelMoveSize(); };
|
||||
key_map[FKey::Escape_mintty] = [this] () { cancelMoveSize(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FDialog::drawBorder()
|
||||
{
|
||||
@ -965,15 +1002,15 @@ void FDialog::drawBorder()
|
||||
for (auto y = r.getY1() + 1; y < r.getY2(); y++)
|
||||
{
|
||||
print() << FPoint{r.getX1(), y}
|
||||
<< fc::NF_border_line_left // border left ⎸
|
||||
<< UniChar::NF_border_line_left // border left ⎸
|
||||
<< FPoint{r.getX2(), y}
|
||||
<< fc::NF_rev_border_line_right; // border right⎹
|
||||
<< UniChar::NF_rev_border_line_right; // border right⎹
|
||||
}
|
||||
|
||||
print() << r.getLowerLeftPos()
|
||||
<< fc::NF_border_corner_lower_left // ⎣
|
||||
<< FString{r.getWidth() - 2, fc::NF_border_line_bottom} // _
|
||||
<< fc::NF_rev_border_corner_lower_right; // ⎦
|
||||
<< UniChar::NF_border_corner_lower_left // ⎣
|
||||
<< FString{r.getWidth() - 2, UniChar::NF_border_line_bottom} // _
|
||||
<< UniChar::NF_rev_border_corner_lower_right; // ⎦
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1087,13 +1124,13 @@ inline void FDialog::drawRestoreSizeButton()
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
print (fc::BlackDiamondSuit); // ◆
|
||||
print (UniChar::BlackDiamondSuit); // ◆
|
||||
print (']');
|
||||
}
|
||||
else
|
||||
{
|
||||
print (' ');
|
||||
print (fc::BlackDiamondSuit); // ◆
|
||||
print (UniChar::BlackDiamondSuit); // ◆
|
||||
print (' ');
|
||||
}
|
||||
}
|
||||
@ -1111,13 +1148,13 @@ inline void FDialog::drawZoomedButton()
|
||||
if ( FTerm::isMonochron() )
|
||||
{
|
||||
print ('[');
|
||||
print (fc::BlackUpPointingTriangle); // ▲
|
||||
print (UniChar::BlackUpPointingTriangle); // ▲
|
||||
print (']');
|
||||
}
|
||||
else
|
||||
{
|
||||
print (' ');
|
||||
print (fc::BlackUpPointingTriangle); // ▲
|
||||
print (UniChar::BlackUpPointingTriangle); // ▲
|
||||
print (' ');
|
||||
}
|
||||
}
|
||||
@ -1141,10 +1178,11 @@ void FDialog::drawTextBar()
|
||||
|
||||
const auto width = getWidth();
|
||||
const auto zoom_btn = getZoomButtonWidth();
|
||||
const auto tb_width = width - MENU_BTN - zoom_btn;
|
||||
const auto length = getColumnWidth(tb_text);
|
||||
|
||||
if ( width > length + MENU_BTN + zoom_btn )
|
||||
center_offset = (width - length - MENU_BTN - zoom_btn) / 2;
|
||||
center_offset = (tb_width - length) / 2;
|
||||
|
||||
for ( ; x <= center_offset; x++)
|
||||
print (' ');
|
||||
@ -1152,12 +1190,13 @@ void FDialog::drawTextBar()
|
||||
// Print title bar text
|
||||
if ( ! tb_text.isEmpty() )
|
||||
{
|
||||
if ( length <= width - MENU_BTN - zoom_btn )
|
||||
if ( length <= tb_width )
|
||||
print (tb_text);
|
||||
else
|
||||
{
|
||||
// Print ellipsis
|
||||
print (tb_text.left(width - MENU_BTN - zoom_btn - 2));
|
||||
const auto len = getLengthFromColumnWidth (tb_text, tb_width - 2);
|
||||
print (tb_text.left(len));
|
||||
print ("..");
|
||||
}
|
||||
}
|
||||
@ -1180,8 +1219,10 @@ void FDialog::restoreOverlaidWindows()
|
||||
|
||||
bool overlaid{false};
|
||||
|
||||
for (auto&& win : *getWindowList())
|
||||
for (auto&& window : *getWindowList())
|
||||
{
|
||||
const auto win = static_cast<FWidget*>(window);
|
||||
|
||||
if ( overlaid )
|
||||
putArea (win->getTermPos(), win->getVWin());
|
||||
|
||||
@ -1361,7 +1402,7 @@ inline bool FDialog::isMouseOverMenu (const FPoint& termpos) const
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FDialog::passEventToSubMenu ( const MouseStates& ms
|
||||
, const FMouseEvent&& ev )
|
||||
, const FMouseEvent& ev )
|
||||
{
|
||||
// Mouse event handover to the dialog menu
|
||||
if ( ! ms.mouse_over_menu
|
||||
@ -1370,87 +1411,21 @@ inline void FDialog::passEventToSubMenu ( const MouseStates& ms
|
||||
|
||||
const auto& g = ms.termPos;
|
||||
const auto& p = dialog_menu->termToWidgetPos(g);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, g, b);
|
||||
dialog_menu->mouse_down = true;
|
||||
setClickedWidget(dialog_menu);
|
||||
dialog_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
}
|
||||
const auto b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, g, b);
|
||||
dialog_menu->mouse_down = true;
|
||||
setClickedWidget(dialog_menu);
|
||||
dialog_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FDialog::moveSizeKey (FKeyEvent* ev)
|
||||
{
|
||||
switch ( ev->key() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
moveUp(1);
|
||||
ev->accept();
|
||||
break;
|
||||
const auto& entry = key_map[ev->key()];
|
||||
|
||||
case fc::Fkey_down:
|
||||
moveDown(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
moveLeft(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
moveRight(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_up:
|
||||
case fc::Fkey_sr:
|
||||
reduceHeight(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_down:
|
||||
case fc::Fkey_sf:
|
||||
expandHeight(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_left:
|
||||
case fc::Fkey_sleft:
|
||||
reduceWidth(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_right:
|
||||
case fc::Fkey_sright:
|
||||
expandWidth(1);
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
acceptMoveSize();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
cancelMoveSize();
|
||||
ev->accept();
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( entry )
|
||||
entry();
|
||||
|
||||
// Accept for all, so that parent widgets will not receive keystrokes
|
||||
ev->accept();
|
||||
|
@ -46,8 +46,7 @@ FDialogListMenu::FDialogListMenu (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FDialogListMenu::~FDialogListMenu()
|
||||
{ }
|
||||
FDialogListMenu::~FDialogListMenu() noexcept = default; // destructor
|
||||
|
||||
|
||||
// private methods of FMenu
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -30,12 +30,12 @@ namespace finalcut
|
||||
// class FEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FEvent::FEvent (fc::events ev_type) // constructor
|
||||
FEvent::FEvent (Event ev_type) // constructor
|
||||
: t{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fc::events FEvent::getType() const
|
||||
Event FEvent::getType() const
|
||||
{ return t; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -51,15 +51,11 @@ bool FEvent::wasSent() const
|
||||
// class FKeyEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FKeyEvent::FKeyEvent (fc::events ev_type, FKey key_num) // constructor
|
||||
FKeyEvent::FKeyEvent (Event ev_type, FKey key_num) // constructor
|
||||
: FEvent{ev_type}
|
||||
, k{key_num}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKeyEvent::~FKeyEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKey FKeyEvent::key() const
|
||||
{ return k; }
|
||||
@ -81,10 +77,10 @@ void FKeyEvent::ignore()
|
||||
// class FMouseEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
||||
FMouseEvent::FMouseEvent ( Event ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, const FPoint& termPos
|
||||
, int button )
|
||||
, MouseButton button )
|
||||
: FEvent{ev_type}
|
||||
, p{pos}
|
||||
, tp{termPos}
|
||||
@ -92,16 +88,12 @@ FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouseEvent::FMouseEvent ( fc::events ev_type // constructor
|
||||
FMouseEvent::FMouseEvent ( Event ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, int button )
|
||||
, MouseButton button )
|
||||
: FMouseEvent{ev_type, pos, FPoint{}, button}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouseEvent::~FMouseEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FPoint& FMouseEvent::getPos() const
|
||||
{ return p; }
|
||||
@ -127,7 +119,7 @@ int FMouseEvent::getTermY() const
|
||||
{ return tp.getY(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FMouseEvent::getButton() const
|
||||
MouseButton FMouseEvent::getButton() const
|
||||
{ return b; }
|
||||
|
||||
|
||||
@ -135,10 +127,10 @@ int FMouseEvent::getButton() const
|
||||
// class FWheelEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
||||
FWheelEvent::FWheelEvent ( Event ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, const FPoint& termPos
|
||||
, int wheel )
|
||||
, MouseWheel wheel )
|
||||
: FEvent{ev_type}
|
||||
, p{pos}
|
||||
, tp{termPos}
|
||||
@ -146,16 +138,12 @@ FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWheelEvent::FWheelEvent ( fc::events ev_type // constructor
|
||||
FWheelEvent::FWheelEvent ( Event ev_type // constructor
|
||||
, const FPoint& pos
|
||||
, int wheel )
|
||||
, MouseWheel wheel )
|
||||
: FWheelEvent{ev_type, pos, FPoint{}, wheel}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWheelEvent::~FWheelEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FPoint& FWheelEvent::getPos() const
|
||||
{ return p; }
|
||||
@ -181,7 +169,7 @@ int FWheelEvent::getTermY() const
|
||||
{ return tp.getY(); }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FWheelEvent::getWheel() const
|
||||
MouseWheel FWheelEvent::getWheel() const
|
||||
{ return w; }
|
||||
|
||||
|
||||
@ -189,32 +177,28 @@ int FWheelEvent::getWheel() const
|
||||
// class FFocusEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FFocusEvent::FFocusEvent (fc::events ev_type) // constructor
|
||||
FFocusEvent::FFocusEvent (Event ev_type) // constructor
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FFocusEvent::~FFocusEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FFocusEvent::gotFocus() const
|
||||
{
|
||||
return ( getType() == fc::FocusIn_Event );
|
||||
return getType() == Event::FocusIn;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FFocusEvent::lostFocus() const
|
||||
{
|
||||
return ( getType() == fc::FocusOut_Event );
|
||||
return getType() == Event::FocusOut;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fc::FocusTypes FFocusEvent::getFocusType() const
|
||||
FocusTypes FFocusEvent::getFocusType() const
|
||||
{ return focus_type; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FFocusEvent::setFocusType(fc::FocusTypes ft)
|
||||
void FFocusEvent::setFocusType (FocusTypes ft)
|
||||
{ focus_type = ft; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -234,15 +218,11 @@ void FFocusEvent::ignore()
|
||||
// class FAccelEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FAccelEvent::FAccelEvent (fc::events ev_type, FWidget* focused) // constructor
|
||||
FAccelEvent::FAccelEvent (Event ev_type, FWidget* focused) // constructor
|
||||
: FEvent{ev_type}
|
||||
, focus_widget{focused}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FAccelEvent::~FAccelEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FWidget* FAccelEvent::focusedWidget() const
|
||||
{ return focus_widget; }
|
||||
@ -264,14 +244,10 @@ void FAccelEvent::ignore()
|
||||
// class FResizeEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FResizeEvent::FResizeEvent (fc::events ev_type) // constructor
|
||||
FResizeEvent::FResizeEvent (Event ev_type) // constructor
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FResizeEvent::~FResizeEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FResizeEvent::isAccepted() const
|
||||
{ return accpt; }
|
||||
@ -289,40 +265,28 @@ void FResizeEvent::ignore()
|
||||
// class FShowEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FShowEvent::FShowEvent (fc::events ev_type) // constructor
|
||||
FShowEvent::FShowEvent (Event ev_type) // constructor
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FShowEvent::~FShowEvent() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FHideEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FHideEvent::FHideEvent (fc::events ev_type) // constructor
|
||||
FHideEvent::FHideEvent (Event ev_type) // constructor
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FHideEvent::~FHideEvent() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FCloseEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FCloseEvent::FCloseEvent (fc::events ev_type) // constructor
|
||||
FCloseEvent::FCloseEvent (Event ev_type) // constructor
|
||||
: FEvent{ev_type}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FCloseEvent::~FCloseEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FCloseEvent::isAccepted() const
|
||||
{ return accpt; }
|
||||
@ -340,15 +304,11 @@ void FCloseEvent::ignore()
|
||||
// class FTimerEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FTimerEvent::FTimerEvent (fc::events ev_type, int timer_id) // constructor
|
||||
FTimerEvent::FTimerEvent (Event ev_type, int timer_id) // constructor
|
||||
: FEvent{ev_type}
|
||||
, id{timer_id}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTimerEvent::~FTimerEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTimerEvent::getTimerId() const
|
||||
{ return id; }
|
||||
@ -358,15 +318,11 @@ int FTimerEvent::getTimerId() const
|
||||
// class FUserEvent
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor
|
||||
FUserEvent::FUserEvent (Event ev_type, int user_event_id) // constructor
|
||||
: FEvent{ev_type}
|
||||
, uid{user_event_id}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FUserEvent::~FUserEvent() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FUserEvent::getUserId() const
|
||||
{ return uid; }
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -41,7 +41,7 @@ bool sortByName ( const FFileDialog::FDirEntry& lhs
|
||||
, const FFileDialog::FDirEntry& rhs )
|
||||
{
|
||||
// lhs < rhs
|
||||
return bool( strcasecmp(lhs.name.c_str(), rhs.name.c_str()) < 0 );
|
||||
return strcasecmp(lhs.name.c_str(), rhs.name.c_str()) < 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -81,7 +81,7 @@ FString fileChooser ( FWidget* parent
|
||||
, type
|
||||
, parent );
|
||||
|
||||
if ( fileopen.exec() == FDialog::Accept )
|
||||
if ( fileopen.exec() == FDialog::ResultCode::Accept )
|
||||
ret = fileopen.getPath() + fileopen.getSelectedFile();
|
||||
else
|
||||
ret = FString{};
|
||||
@ -89,9 +89,6 @@ FString fileChooser ( FWidget* parent
|
||||
return ret;
|
||||
}
|
||||
|
||||
// static class attributes
|
||||
FSystem* FFileDialog::fsystem{nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FFileDialog
|
||||
@ -105,16 +102,6 @@ FFileDialog::FFileDialog (FWidget* parent)
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FFileDialog::FFileDialog (const FFileDialog& fdlg)
|
||||
: FDialog{fdlg.getParentWidget()}
|
||||
{
|
||||
if ( fdlg.directory )
|
||||
setPath(fdlg.directory);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FFileDialog::FFileDialog ( const FString& dirname
|
||||
, const FString& filter
|
||||
@ -138,42 +125,15 @@ FFileDialog::~FFileDialog() // destructor
|
||||
|
||||
|
||||
// public methods of FFileDialog
|
||||
//----------------------------------------------------------------------
|
||||
FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg)
|
||||
{
|
||||
if ( &fdlg == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
{
|
||||
clear();
|
||||
|
||||
if ( fdlg.getParentWidget() )
|
||||
fdlg.getParentWidget()->addChild (this);
|
||||
|
||||
directory = fdlg.directory;
|
||||
filter_pattern = fdlg.filter_pattern;
|
||||
dlg_type = fdlg.dlg_type;
|
||||
show_hidden = fdlg.show_hidden;
|
||||
|
||||
if ( directory )
|
||||
setPath(directory);
|
||||
|
||||
init();
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString FFileDialog::getSelectedFile() const
|
||||
{
|
||||
const auto n = uLong(filebrowser.currentItem() - 1);
|
||||
|
||||
if ( dir_entries[n].directory )
|
||||
return FString{""};
|
||||
return {""};
|
||||
else
|
||||
return FString{dir_entries[n].name};
|
||||
return {dir_entries[n].name};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -202,7 +162,9 @@ void FFileDialog::setPath (const FString& dir)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
|
||||
r_dir.setString(resolved_path.data());
|
||||
else
|
||||
r_dir.setString(dir);
|
||||
@ -244,16 +206,10 @@ void FFileDialog::onKeyPress (FKeyEvent* ev)
|
||||
|
||||
const FKey key = ev->key();
|
||||
|
||||
switch ( key )
|
||||
if ( key == FKey::Erase || key == FKey::Backspace )
|
||||
{
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
changeDir("..");
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
changeDir("..");
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +218,7 @@ FString FFileDialog::fileOpenChooser ( FWidget* parent
|
||||
, const FString& dirname
|
||||
, const FString& filter )
|
||||
{
|
||||
return fileChooser (parent, dirname, filter, FFileDialog::Open);
|
||||
return fileChooser (parent, dirname, filter, DialogType::Open);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -270,7 +226,7 @@ FString FFileDialog::fileSaveChooser ( FWidget* parent
|
||||
, const FString& dirname
|
||||
, const FString& filter )
|
||||
{
|
||||
return fileChooser (parent, dirname, filter, FFileDialog::Save);
|
||||
return fileChooser (parent, dirname, filter, DialogType::Save);
|
||||
}
|
||||
|
||||
|
||||
@ -324,9 +280,6 @@ void FFileDialog::init()
|
||||
int x{};
|
||||
int y{};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
setGeometry(FPoint{1, 1}, FSize{w, h}, false);
|
||||
const auto& parent_widget = getParentWidget();
|
||||
|
||||
@ -338,7 +291,7 @@ void FFileDialog::init()
|
||||
else
|
||||
x = y = 1;
|
||||
|
||||
if ( dlg_type == FFileDialog::Save )
|
||||
if ( dlg_type == DialogType::Save )
|
||||
FDialog::setText("Save file");
|
||||
else
|
||||
FDialog::setText("Open file");
|
||||
@ -366,7 +319,7 @@ inline void FFileDialog::widgetSettings (const FPoint& pos)
|
||||
cancel_btn.setText ("&Cancel");
|
||||
cancel_btn.setGeometry(FPoint{19, 10}, FSize{9, 1});
|
||||
|
||||
if ( dlg_type == FFileDialog::Save )
|
||||
if ( dlg_type == DialogType::Save )
|
||||
open_btn.setText ("&Save");
|
||||
else
|
||||
open_btn.setText ("&Open");
|
||||
@ -600,9 +553,7 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
|
||||
std::array<char, MAXPATHLEN> symLink{};
|
||||
struct stat sb{};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
std::strncpy (symLink.data(), dir, symLink.size() - 1);
|
||||
symLink[symLink.size() - 1] = '\0';
|
||||
std::strncat ( symLink.data()
|
||||
@ -633,7 +584,7 @@ void FFileDialog::dirEntriesToList()
|
||||
for (auto&& entry : dir_entries)
|
||||
{
|
||||
if ( entry.directory )
|
||||
filebrowser.insert(FString{entry.name}, fc::SquareBrackets);
|
||||
filebrowser.insert(FString{entry.name}, BracketType::Brackets);
|
||||
else
|
||||
filebrowser.insert(FString{entry.name});
|
||||
}
|
||||
@ -666,9 +617,6 @@ int FFileDialog::changeDir (const FString& dirname)
|
||||
FString lastdir{directory};
|
||||
FString newdir{dirname};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( newdir.includes('~') )
|
||||
newdir = newdir.replace('~', getHomeDir());
|
||||
|
||||
@ -743,15 +691,13 @@ FString FFileDialog::getHomeDir()
|
||||
struct passwd* pwd_ptr{};
|
||||
std::array<char, 1024> buf{};
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
const uid_t euid = fsystem->geteuid();
|
||||
|
||||
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )
|
||||
return FString{""};
|
||||
return {""};
|
||||
else
|
||||
return FString{pwd.pw_dir};
|
||||
return {pwd.pw_dir};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -799,7 +745,7 @@ void FFileDialog::cb_processActivate()
|
||||
if ( found )
|
||||
changeDir(input);
|
||||
else
|
||||
done (FDialog::Accept);
|
||||
done (ResultCode::Accept);
|
||||
}
|
||||
}
|
||||
|
||||
@ -829,19 +775,19 @@ void FFileDialog::cb_processClicked()
|
||||
if ( dir_entries[n].directory )
|
||||
changeDir(dir_entries[n].name);
|
||||
else
|
||||
done (FDialog::Accept);
|
||||
done (ResultCode::Accept);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FFileDialog::cb_processCancel()
|
||||
{
|
||||
done (FDialog::Reject);
|
||||
done (ResultCode::Reject);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FFileDialog::cb_processOpen()
|
||||
{
|
||||
done (FDialog::Accept);
|
||||
done (ResultCode::Accept);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
1620
src/fkey_map.cpp
1620
src/fkey_map.cpp
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -23,9 +23,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
#include <sys/filio.h> // need for FIONREAD
|
||||
#elif defined(__CYGWIN__)
|
||||
#if defined(__CYGWIN__)
|
||||
#include <sys/select.h> // need for FD_ZERO, FD_SET, FD_CLR, ...
|
||||
#endif
|
||||
|
||||
@ -55,10 +53,6 @@ uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
|
||||
bool FKeyboard::non_blocking_input_support{true};
|
||||
struct timeval FKeyboard::time_keypressed{};
|
||||
|
||||
#if defined(__linux__)
|
||||
FTermLinux* FKeyboard::linux{nullptr};
|
||||
#endif
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FKeyboard
|
||||
@ -77,13 +71,8 @@ FKeyboard::FKeyboard()
|
||||
|
||||
if ( stdin_status_flags == -1 )
|
||||
std::abort();
|
||||
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FKeyboard::~FKeyboard() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FKeyboard
|
||||
//----------------------------------------------------------------------
|
||||
@ -98,21 +87,21 @@ FString FKeyboard::getKeyName (const FKey keynum) const
|
||||
{
|
||||
const auto& found_key = std::find_if
|
||||
(
|
||||
fc::fkeyname.begin(),
|
||||
fc::fkeyname.end(),
|
||||
fc::fkeyname.cbegin(),
|
||||
fc::fkeyname.cend(),
|
||||
[&keynum] (const fc::FKeyName& kn)
|
||||
{
|
||||
return (kn.num > 0 && kn.num == keynum);
|
||||
return ( kn.num != FKey::None && kn.num == keynum );
|
||||
}
|
||||
);
|
||||
|
||||
if ( found_key != fc::fkeyname.end() )
|
||||
return FString{found_key->string};
|
||||
return {found_key->string};
|
||||
|
||||
if ( keynum > 32 && keynum < 127 )
|
||||
return FString{char(keynum)};
|
||||
return {char(keynum)};
|
||||
|
||||
return FString{""};
|
||||
return {""};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -139,14 +128,6 @@ bool FKeyboard::setNonBlockingInput (bool enable)
|
||||
return non_blocking_stdin;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FKeyboard::init()
|
||||
{
|
||||
#if defined(__linux__)
|
||||
linux = FTerm::getFTermLinux();
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool& FKeyboard::hasUnprocessedInput()
|
||||
{
|
||||
@ -168,13 +149,11 @@ bool FKeyboard::isKeyPressed (uInt64 blocking_time)
|
||||
tv.tv_sec = tv.tv_usec = 0; // Non-blocking input
|
||||
|
||||
if ( blocking_time > 0
|
||||
&& non_blocking_input_support
|
||||
&& select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0
|
||||
&& FD_ISSET(stdin_no, &ifds) )
|
||||
&& non_blocking_input_support
|
||||
&& select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0
|
||||
&& FD_ISSET(stdin_no, &ifds) )
|
||||
{
|
||||
has_pending_input = true;
|
||||
FD_CLR (stdin_no, &ifds);
|
||||
tv.tv_sec = 0;
|
||||
return (has_pending_input = true);
|
||||
}
|
||||
|
||||
if ( isKeypressTimeout() || ! non_blocking_input_support )
|
||||
@ -198,8 +177,8 @@ void FKeyboard::clearKeyBuffer()
|
||||
// Empty the buffer
|
||||
|
||||
fifo_offset = 0;
|
||||
fkey = 0;
|
||||
key = 0;
|
||||
fkey = FKey::None;
|
||||
key = FKey::None;
|
||||
std::fill_n (fifo_buf, FIFO_BUF_SIZE, '\0');
|
||||
fifo_in_use = false;
|
||||
}
|
||||
@ -244,7 +223,7 @@ void FKeyboard::processQueuedInput()
|
||||
key = fkey_queue.front();
|
||||
fkey_queue.pop();
|
||||
|
||||
if ( key > 0 )
|
||||
if ( key > FKey::None )
|
||||
{
|
||||
keyPressed();
|
||||
|
||||
@ -256,7 +235,7 @@ void FKeyboard::processQueuedInput()
|
||||
if ( FApplication::isQuit() )
|
||||
return;
|
||||
|
||||
key = 0;
|
||||
key = FKey::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -274,18 +253,18 @@ inline FKey FKeyboard::getMouseProtocolKey() const
|
||||
|
||||
// x11 mouse tracking
|
||||
if ( buf_len >= 6 && fifo_buf[1] == '[' && fifo_buf[2] == 'M' )
|
||||
return fc::Fkey_mouse;
|
||||
return FKey::X11mouse;
|
||||
|
||||
// SGR mouse tracking
|
||||
if ( fifo_buf[1] == '[' && fifo_buf[2] == '<' && buf_len >= 9
|
||||
&& (fifo_buf[buf_len - 1] == 'M' || fifo_buf[buf_len - 1] == 'm') )
|
||||
return fc::Fkey_extended_mouse;
|
||||
return FKey::Extended_mouse;
|
||||
|
||||
// urxvt mouse tracking
|
||||
if ( fifo_buf[1] == '[' && fifo_buf[2] >= '1' && fifo_buf[2] <= '9'
|
||||
&& fifo_buf[3] >= '0' && fifo_buf[3] <= '9' && buf_len >= 9
|
||||
&& fifo_buf[buf_len - 1] == 'M' )
|
||||
return fc::Fkey_urxvt_mouse;
|
||||
return FKey::Urxvt_mouse;
|
||||
|
||||
return NOT_SET;
|
||||
}
|
||||
@ -302,10 +281,10 @@ inline FKey FKeyboard::getTermcapKey()
|
||||
|
||||
for (auto&& entry : *key_map)
|
||||
{
|
||||
const char* k = entry.string;
|
||||
const std::size_t len = ( k ) ? std::strlen(k) : 0;
|
||||
const char* kstr = entry.string;
|
||||
const std::size_t len = kstr ? std::strlen(kstr) : 0;
|
||||
|
||||
if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found
|
||||
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
std::size_t n{};
|
||||
|
||||
@ -324,18 +303,18 @@ inline FKey FKeyboard::getTermcapKey()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FKey FKeyboard::getMetaKey()
|
||||
inline FKey FKeyboard::getKnownKey()
|
||||
{
|
||||
// Looking for meta key strings in the buffer
|
||||
// Looking for a known key strings in the buffer
|
||||
|
||||
assert ( FIFO_BUF_SIZE > 0 );
|
||||
|
||||
for (auto&& entry : fc::fmetakey)
|
||||
for (auto&& entry : fc::fkey_table)
|
||||
{
|
||||
const char* kmeta = entry.string; // The string is never null
|
||||
const std::size_t len = std::strlen(kmeta);
|
||||
const char* kstr = entry.string; // The string is never null
|
||||
const std::size_t len = std::strlen(kstr);
|
||||
|
||||
if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found
|
||||
if ( std::strncmp(kstr, fifo_buf, len) == 0 ) // found
|
||||
{
|
||||
std::size_t n{};
|
||||
|
||||
@ -345,7 +324,7 @@ inline FKey FKeyboard::getMetaKey()
|
||||
|| fifo_buf[1] == ']' )
|
||||
&& ! isKeypressTimeout() )
|
||||
{
|
||||
return fc::Fkey_incomplete;
|
||||
return FKey::Incomplete;
|
||||
}
|
||||
|
||||
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove founded entry
|
||||
@ -386,7 +365,7 @@ inline FKey FKeyboard::getSingleKey()
|
||||
len = 4;
|
||||
|
||||
if ( buf_len < len && ! isKeypressTimeout() )
|
||||
return fc::Fkey_incomplete;
|
||||
return FKey::Incomplete;
|
||||
|
||||
for (std::size_t i{0}; i < len ; i++)
|
||||
utf8char[i] = char(fifo_buf[i] & 0xff);
|
||||
@ -394,7 +373,7 @@ inline FKey FKeyboard::getSingleKey()
|
||||
keycode = UTF8decode(utf8char.data());
|
||||
}
|
||||
else
|
||||
keycode = uChar(fifo_buf[0] & 0xff);
|
||||
keycode = FKey(fifo_buf[0] & 0xff);
|
||||
|
||||
for (n = len; n < FIFO_BUF_SIZE; n++) // Remove the key from the buffer front
|
||||
fifo_buf[n - len] = fifo_buf[n];
|
||||
@ -404,10 +383,10 @@ inline FKey FKeyboard::getSingleKey()
|
||||
|
||||
unprocessed_buffer_data = bool(fifo_buf[0] != '\0');
|
||||
|
||||
if ( keycode == 0 ) // Ctrl+Space or Ctrl+@
|
||||
keycode = fc::Fckey_space;
|
||||
if ( keycode == FKey(0) ) // Ctrl+Space or Ctrl+@
|
||||
keycode = FKey::Ctrl_space;
|
||||
|
||||
return FKey(keycode == 127 ? fc::Fkey_backspace : keycode);
|
||||
return FKey(keycode == FKey(127) ? FKey::Backspace : keycode);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -419,7 +398,7 @@ inline bool FKeyboard::isKeypressTimeout()
|
||||
//----------------------------------------------------------------------
|
||||
FKey FKeyboard::UTF8decode (const char utf8[]) const
|
||||
{
|
||||
FKey ucs{0}; // Universal coded character
|
||||
FKey ucs{FKey::None}; // Universal coded character
|
||||
constexpr std::size_t max = 4;
|
||||
std::size_t len = std::strlen(utf8);
|
||||
|
||||
@ -433,27 +412,27 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const
|
||||
if ( (ch & 0xc0) == 0x80 )
|
||||
{
|
||||
// byte 2..4 = 10xxxxxx
|
||||
ucs = (ucs << 6) | (ch & 0x3f);
|
||||
ucs = (ucs << 6) | FKey(ch & 0x3f);
|
||||
}
|
||||
else if ( ch < 128 )
|
||||
{
|
||||
// byte 1 = 0xxxxxxx (1 byte mapping)
|
||||
ucs = ch & 0xff;
|
||||
ucs = FKey(ch & 0xff);
|
||||
}
|
||||
else if ( (ch & 0xe0) == 0xc0 )
|
||||
{
|
||||
// byte 1 = 110xxxxx (2 byte mapping)
|
||||
ucs = ch & 0x1f;
|
||||
ucs = FKey(ch & 0x1f);
|
||||
}
|
||||
else if ( (ch & 0xf0) == 0xe0 )
|
||||
{
|
||||
// byte 1 = 1110xxxx (3 byte mapping)
|
||||
ucs = ch & 0x0f;
|
||||
ucs = FKey(ch & 0x0f);
|
||||
}
|
||||
else if ( (ch & 0xf8) == 0xf0 )
|
||||
{
|
||||
// byte 1 = 11110xxx (4 byte mapping)
|
||||
ucs = ch & 0x07;
|
||||
ucs = FKey(ch & 0x07);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -468,13 +447,6 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const
|
||||
//----------------------------------------------------------------------
|
||||
inline ssize_t FKeyboard::readKey()
|
||||
{
|
||||
#if !defined(__CYGWIN__)
|
||||
int len{0};
|
||||
|
||||
if ( ioctl(FTermios::getStdIn(), FIONREAD, &len) < 0 || len == 0 )
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
setNonBlockingInput();
|
||||
const ssize_t bytes = read(FTermios::getStdIn(), &read_character, 1);
|
||||
unsetNonBlockingInput();
|
||||
@ -499,16 +471,14 @@ void FKeyboard::parseKeyBuffer()
|
||||
}
|
||||
|
||||
// Read the rest from the fifo buffer
|
||||
while ( ! isKeypressTimeout()
|
||||
&& fifo_offset > 0
|
||||
&& fkey != fc::Fkey_incomplete )
|
||||
while ( fifo_offset > 0 && fkey != FKey::Incomplete )
|
||||
{
|
||||
fkey = parseKeyString();
|
||||
fkey = keyCorrection(fkey);
|
||||
|
||||
if ( fkey == fc::Fkey_mouse
|
||||
|| fkey == fc::Fkey_extended_mouse
|
||||
|| fkey == fc::Fkey_urxvt_mouse )
|
||||
if ( fkey == FKey::X11mouse
|
||||
|| fkey == FKey::Extended_mouse
|
||||
|| fkey == FKey::Urxvt_mouse )
|
||||
{
|
||||
key = fkey;
|
||||
mouseTracking();
|
||||
@ -516,14 +486,14 @@ void FKeyboard::parseKeyBuffer()
|
||||
break;
|
||||
}
|
||||
|
||||
if ( fkey != fc::Fkey_incomplete )
|
||||
if ( fkey != FKey::Incomplete )
|
||||
{
|
||||
fkey_queue.push(fkey);
|
||||
fifo_offset = int(std::strlen(fifo_buf));
|
||||
}
|
||||
}
|
||||
|
||||
fkey = 0;
|
||||
fkey = FKey::None;
|
||||
|
||||
if ( fkey_queue.size() >= MAX_QUEUE_SIZE )
|
||||
break;
|
||||
@ -547,13 +517,13 @@ FKey FKeyboard::parseKeyString()
|
||||
if ( keycode != NOT_SET )
|
||||
return keycode;
|
||||
|
||||
keycode = getMetaKey();
|
||||
keycode = getKnownKey();
|
||||
|
||||
if ( keycode != NOT_SET )
|
||||
return keycode;
|
||||
|
||||
if ( ! isKeypressTimeout() )
|
||||
return fc::Fkey_incomplete;
|
||||
return FKey::Incomplete;
|
||||
}
|
||||
|
||||
return getSingleKey();
|
||||
@ -565,8 +535,11 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
|
||||
FKey key_correction;
|
||||
|
||||
#if defined(__linux__)
|
||||
if ( linux && FTerm::isLinuxTerm() )
|
||||
key_correction = linux->modifierKeyCorrection(keycode);
|
||||
if ( FTerm::isLinuxTerm() )
|
||||
{
|
||||
auto& linux_console = FTerm::getFTermLinux();
|
||||
key_correction = linux_console.modifierKeyCorrection(keycode);
|
||||
}
|
||||
else
|
||||
key_correction = keycode;
|
||||
#else
|
||||
@ -595,11 +568,11 @@ void FKeyboard::substringKeyHandling()
|
||||
unprocessed_buffer_data = false;
|
||||
|
||||
if ( fifo_buf[1] == 'O' )
|
||||
fkey = fc::Fmkey_O;
|
||||
fkey = FKey::Meta_O;
|
||||
else if ( fifo_buf[1] == '[' )
|
||||
fkey = fc::Fmkey_left_square_bracket;
|
||||
fkey = FKey::Meta_left_square_bracket;
|
||||
else
|
||||
fkey = fc::Fmkey_right_square_bracket;
|
||||
fkey = FKey::Meta_right_square_bracket;
|
||||
|
||||
fkey_queue.push(fkey);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -69,7 +69,7 @@ FLabel& FLabel::operator = (const FString& s)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLabel& FLabel::operator << (fc::SpecialCharacter c)
|
||||
FLabel& FLabel::operator << (UniChar c)
|
||||
{
|
||||
setText(text + static_cast<wchar_t>(c));
|
||||
return *this;
|
||||
@ -105,12 +105,12 @@ void FLabel::setAccelWidget (FWidget* widget)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::setAlignment (fc::text_alignment align)
|
||||
void FLabel::setAlignment (Align align)
|
||||
{
|
||||
if ( align != fc::alignLeft
|
||||
&& align != fc::alignCenter
|
||||
&& align != fc::alignRight )
|
||||
alignment = fc::alignLeft;
|
||||
if ( align != Align::Left
|
||||
&& align != Align::Center
|
||||
&& align != Align::Right )
|
||||
alignment = Align::Left;
|
||||
else
|
||||
alignment = align;
|
||||
}
|
||||
@ -165,7 +165,7 @@ void FLabel::hide()
|
||||
//----------------------------------------------------------------------
|
||||
void FLabel::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( ! (isEnabled() && accel_widget) )
|
||||
@ -173,40 +173,18 @@ void FLabel::onMouseDown (FMouseEvent* ev)
|
||||
// send click to the parent widget
|
||||
if ( auto parent = getParentWidget() )
|
||||
{
|
||||
const int b = ev->getButton();
|
||||
const auto b = ev->getButton();
|
||||
const auto& tp = ev->getTermPos();
|
||||
const auto& p = parent->termToWidgetPos(tp);
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseDown_Event, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
}
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseDown, p, tp, b);
|
||||
FApplication::sendEvent (parent, _ev.get());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! accel_widget->hasFocus() )
|
||||
{
|
||||
// focus the accelerator widget
|
||||
auto focused_widget = getFocusWidget();
|
||||
accel_widget->setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
accel_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
}
|
||||
setWidgetFocus(accel_widget); // focus the accelerator widget
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -217,19 +195,9 @@ void FLabel::onAccel (FAccelEvent* ev)
|
||||
|
||||
if ( ! accel_widget->hasFocus() )
|
||||
{
|
||||
auto focused_widget = ev->focusedWidget();
|
||||
|
||||
if ( focused_widget && focused_widget->isWidget() )
|
||||
{
|
||||
accel_widget->setFocus();
|
||||
focused_widget->redraw();
|
||||
accel_widget->redraw();
|
||||
FFocusEvent in (fc::FocusIn_Event);
|
||||
FApplication::sendEvent(accel_widget, &in);
|
||||
|
||||
if ( getStatusBar() )
|
||||
accel_widget->getStatusBar()->drawMessage();
|
||||
}
|
||||
setWidgetFocus(accel_widget);
|
||||
FFocusEvent in (Event::FocusIn);
|
||||
FApplication::sendEvent(accel_widget, &in);
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
@ -261,26 +229,15 @@ void FLabel::setHotkeyAccelerator()
|
||||
std::size_t FLabel::getAlignOffset (const std::size_t length) const
|
||||
{
|
||||
const std::size_t width(getWidth());
|
||||
assert ( alignment == fc::alignLeft
|
||||
|| alignment == fc::alignCenter
|
||||
|| alignment == fc::alignRight );
|
||||
|
||||
switch ( alignment )
|
||||
if ( alignment == Align::Center )
|
||||
{
|
||||
case fc::alignLeft:
|
||||
return 0;
|
||||
|
||||
case fc::alignCenter:
|
||||
if ( length < width )
|
||||
return (width - length) / 2;
|
||||
else
|
||||
return 0;
|
||||
|
||||
case fc::alignRight:
|
||||
if ( length < width )
|
||||
return width - length;
|
||||
else
|
||||
return 0;
|
||||
if ( length < width )
|
||||
return (width - length) / 2;
|
||||
}
|
||||
else if ( alignment == Align::Right && length < width )
|
||||
{
|
||||
return width - length;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -397,8 +354,8 @@ void FLabel::printLine (FString& line)
|
||||
{
|
||||
if ( ! std::iswprint(std::wint_t(line[z]))
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( line[z] < fc::NF_rev_left_arrow2
|
||||
|| line[z] > fc::NF_check_mark ) )
|
||||
&& ( line[z] < UniChar::NF_rev_left_arrow2
|
||||
|| line[z] > UniChar::NF_check_mark ) )
|
||||
{
|
||||
line[z] = L' ';
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2020 Markus Gans *
|
||||
* Copyright 2012-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -75,7 +75,7 @@ FLineEdit& FLineEdit::operator = (const FString& s)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLineEdit& FLineEdit::operator << (fc::SpecialCharacter c)
|
||||
FLineEdit& FLineEdit::operator << (UniChar c)
|
||||
{
|
||||
setText(text + static_cast<wchar_t>(c));
|
||||
return *this;
|
||||
@ -117,8 +117,8 @@ bool FLineEdit::setFocus (bool enable)
|
||||
bool FLineEdit::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != Encoding::VT100
|
||||
&& FTerm::getEncoding() != Encoding::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
@ -214,7 +214,7 @@ void FLineEdit::setLabelText (const FString& ltxt)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::setLabelOrientation (const label_o o)
|
||||
void FLineEdit::setLabelOrientation (const LabelOrientation o)
|
||||
{
|
||||
label_orientation = o;
|
||||
adjustLabel();
|
||||
@ -296,65 +296,26 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
|
||||
if ( isReadOnly() )
|
||||
return;
|
||||
|
||||
const FKey key = ev->key();
|
||||
const auto key = ev->key();
|
||||
const auto& entry = key_map[key];
|
||||
|
||||
switch ( key )
|
||||
if ( entry )
|
||||
{
|
||||
case fc::Fkey_left:
|
||||
cursorLeft();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
cursorRight();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_home:
|
||||
cursorHome();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
cursorEnd();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_dc: // del key
|
||||
deleteCurrentCharacter();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_erase:
|
||||
case fc::Fkey_backspace:
|
||||
deletePreviousCharacter();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_ic: // insert key
|
||||
switchInsertMode();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
acceptInput();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_tab:
|
||||
ev->ignore();
|
||||
break;
|
||||
|
||||
default:
|
||||
if ( keyInput(key) )
|
||||
ev->accept();
|
||||
entry();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Tab )
|
||||
{
|
||||
ev->ignore();
|
||||
}
|
||||
else if ( keyInput(key) )
|
||||
{
|
||||
ev->accept();
|
||||
}
|
||||
// end of switch
|
||||
|
||||
if ( ev->isAccepted()
|
||||
&& key != fc::Fkey_return
|
||||
&& key != fc::Fkey_enter )
|
||||
&& key != FKey::Return
|
||||
&& key != FKey::Enter )
|
||||
{
|
||||
drawInputField();
|
||||
forceTerminalUpdate();
|
||||
@ -364,23 +325,10 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton || isReadOnly() )
|
||||
if ( ev->getButton() != MouseButton::Left || isReadOnly() )
|
||||
return;
|
||||
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
const int xmin = 2 + int(char_width_offset);
|
||||
@ -404,10 +352,10 @@ void FLineEdit::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onMouseUp (FMouseEvent*)
|
||||
{
|
||||
if ( drag_scroll != FLineEdit::noScroll )
|
||||
if ( drag_scroll != DragScrollMode::None )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
scroll_timer = false;
|
||||
}
|
||||
}
|
||||
@ -415,7 +363,7 @@ void FLineEdit::onMouseUp (FMouseEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton || isReadOnly() )
|
||||
if ( ev->getButton() != MouseButton::Left || isReadOnly() )
|
||||
return;
|
||||
|
||||
const std::size_t len = print_text.getLength();
|
||||
@ -442,13 +390,13 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
drag_scroll = FLineEdit::scrollLeft;
|
||||
drag_scroll = DragScrollMode::Leftward;
|
||||
}
|
||||
|
||||
if ( text_offset == 0 )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
else if ( mouse_x >= int(getWidth()) )
|
||||
@ -458,13 +406,13 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
drag_scroll = FLineEdit::scrollRight;
|
||||
drag_scroll = DragScrollMode::Rightward;
|
||||
}
|
||||
|
||||
if ( cursor_pos == len )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -472,7 +420,7 @@ void FLineEdit::onMouseMove (FMouseEvent* ev)
|
||||
// no dragging
|
||||
delOwnTimers();
|
||||
scroll_timer = false;
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,42 +442,32 @@ void FLineEdit::onTimer (FTimerEvent*)
|
||||
{
|
||||
const auto len = print_text.getLength();
|
||||
|
||||
switch ( int(drag_scroll) )
|
||||
if ( drag_scroll == DragScrollMode::Leftward )
|
||||
{
|
||||
case FLineEdit::noScroll:
|
||||
if ( text_offset == 0 )
|
||||
{
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return;
|
||||
}
|
||||
|
||||
case FLineEdit::scrollLeft:
|
||||
if ( text_offset == 0 )
|
||||
{
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
return;
|
||||
}
|
||||
text_offset--;
|
||||
|
||||
text_offset--;
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
}
|
||||
else if ( drag_scroll == DragScrollMode::Rightward )
|
||||
{
|
||||
if ( text_offset == endPosToOffset(len).first )
|
||||
{
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
if ( text_offset < endPosToOffset(len).first )
|
||||
text_offset++;
|
||||
|
||||
break;
|
||||
|
||||
case FLineEdit::scrollRight:
|
||||
if ( text_offset == endPosToOffset(len).first )
|
||||
{
|
||||
drag_scroll = FLineEdit::noScroll;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( text_offset < endPosToOffset(len).first )
|
||||
text_offset++;
|
||||
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
}
|
||||
|
||||
adjustTextOffset();
|
||||
@ -543,21 +481,7 @@ void FLineEdit::onAccel (FAccelEvent* ev)
|
||||
if ( ! isEnabled() )
|
||||
return;
|
||||
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = ev->focusedWidget();
|
||||
|
||||
if ( focused_widget && focused_widget->isWidget() )
|
||||
{
|
||||
setFocus();
|
||||
focused_widget->redraw();
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
@ -610,15 +534,15 @@ void FLineEdit::adjustLabel()
|
||||
if ( hasHotkey() )
|
||||
label_width--;
|
||||
|
||||
assert ( label_orientation == label_above
|
||||
|| label_orientation == label_left );
|
||||
assert ( label_orientation == LabelOrientation::Above
|
||||
|| label_orientation == LabelOrientation::Left );
|
||||
|
||||
if ( label_orientation == label_above )
|
||||
if ( label_orientation == LabelOrientation::Above )
|
||||
{
|
||||
label->setGeometry ( FPoint{w->getX(), w->getY() - 1}
|
||||
, FSize{label_width, 1} );
|
||||
}
|
||||
else if ( label_orientation == label_left )
|
||||
else if ( label_orientation == LabelOrientation::Left )
|
||||
{
|
||||
label->setGeometry ( FPoint{w->getX() - int(label_width) - 1, w->getY()}
|
||||
, FSize{label_width, 1} );
|
||||
@ -643,6 +567,7 @@ void FLineEdit::init()
|
||||
label->setAccelWidget(this);
|
||||
setShadow();
|
||||
resetColors();
|
||||
mapKeyFunctions();
|
||||
|
||||
if ( isReadOnly() )
|
||||
unsetVisibleCursor();
|
||||
@ -650,6 +575,21 @@ void FLineEdit::init()
|
||||
setVisibleCursor();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::mapKeyFunctions()
|
||||
{
|
||||
key_map[FKey::Left] = [this] { cursorLeft(); };
|
||||
key_map[FKey::Right] = [this] { cursorRight(); };
|
||||
key_map[FKey::Home] = [this] { cursorHome(); };
|
||||
key_map[FKey::End] = [this] { cursorEnd(); };
|
||||
key_map[FKey::Del_char] = [this] { deleteCurrentCharacter(); };
|
||||
key_map[FKey::Erase] = [this] { deletePreviousCharacter(); };
|
||||
key_map[FKey::Backspace] = [this] { deletePreviousCharacter(); };
|
||||
key_map[FKey::Insert] = [this] { switchInsertMode(); };
|
||||
key_map[FKey::Return] = [this] { acceptInput(); };
|
||||
key_map[FKey::Enter] = [this] { acceptInput(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FLineEdit::hasHotkey() const
|
||||
{
|
||||
@ -710,15 +650,15 @@ void FLineEdit::drawInputField()
|
||||
|
||||
const std::size_t text_offset_column = [this] ()
|
||||
{
|
||||
assert ( input_type == FLineEdit::textfield
|
||||
|| input_type == FLineEdit::password );
|
||||
assert ( input_type == InputType::Textfield
|
||||
|| input_type == InputType::Password );
|
||||
|
||||
switch ( input_type )
|
||||
{
|
||||
case FLineEdit::textfield:
|
||||
case InputType::Textfield:
|
||||
return printTextField();
|
||||
|
||||
case FLineEdit::password:
|
||||
case InputType::Password:
|
||||
return printPassword();
|
||||
}
|
||||
|
||||
@ -773,7 +713,7 @@ inline std::size_t FLineEdit::printPassword()
|
||||
const FString show_text{print_text.mid(1 + text_offset, getWidth() - 2)};
|
||||
|
||||
if ( ! show_text.isEmpty() )
|
||||
print() << FString{show_text.getLength(), fc::Bullet}; // •
|
||||
print() << FString{show_text.getLength(), UniChar::Bullet}; // •
|
||||
|
||||
x_pos = show_text.getLength();
|
||||
return text_offset_column;
|
||||
@ -782,11 +722,11 @@ inline std::size_t FLineEdit::printPassword()
|
||||
//----------------------------------------------------------------------
|
||||
inline std::size_t FLineEdit::getCursorColumnPos() const
|
||||
{
|
||||
if ( input_type == FLineEdit::textfield )
|
||||
if ( input_type == InputType::Textfield )
|
||||
{
|
||||
return getColumnWidth (print_text, cursor_pos);
|
||||
}
|
||||
else if ( input_type == FLineEdit::password )
|
||||
else if ( input_type == InputType::Password )
|
||||
{
|
||||
return cursor_pos;
|
||||
}
|
||||
@ -797,13 +737,13 @@ inline std::size_t FLineEdit::getCursorColumnPos() const
|
||||
//----------------------------------------------------------------------
|
||||
inline FString FLineEdit::getPasswordText() const
|
||||
{
|
||||
return FString{text.getLength(), fc::Bullet}; // •
|
||||
return {text.getLength(), UniChar::Bullet}; // •
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FLineEdit::isPasswordField() const
|
||||
{
|
||||
return bool( input_type == FLineEdit::password );
|
||||
return input_type == InputType::Password;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -826,7 +766,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
@ -850,7 +790,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -886,7 +826,7 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
|
||||
@ -920,7 +860,7 @@ void FLineEdit::adjustTextOffset()
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -933,7 +873,7 @@ void FLineEdit::adjustTextOffset()
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -972,21 +912,52 @@ void FLineEdit::adjustTextOffset()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::cursorLeft()
|
||||
{
|
||||
if ( cursor_pos > 0 )
|
||||
cursor_pos--;
|
||||
auto prev_char_len = getPrevCharLength(text, cursor_pos);
|
||||
|
||||
adjustTextOffset();
|
||||
if ( prev_char_len < 0 )
|
||||
{
|
||||
const auto pos = searchLeftCharBegin(text, cursor_pos);
|
||||
|
||||
if ( pos != NOT_FOUND )
|
||||
{
|
||||
cursor_pos = pos;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( cursor_pos >= std::size_t(prev_char_len) )
|
||||
{
|
||||
cursor_pos -= std::size_t(prev_char_len);
|
||||
adjustTextOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FLineEdit::cursorRight()
|
||||
{
|
||||
const auto& len = text.getLength();
|
||||
const auto len = text.getLength();
|
||||
const auto char_len = getCharLength(text, cursor_pos);
|
||||
|
||||
if ( cursor_pos < len )
|
||||
cursor_pos++;
|
||||
if ( char_len < 0 )
|
||||
{
|
||||
const auto pos = searchRightCharBegin(text, cursor_pos);
|
||||
|
||||
adjustTextOffset();
|
||||
if ( pos != NOT_FOUND )
|
||||
{
|
||||
cursor_pos = pos;
|
||||
adjustTextOffset();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( cursor_pos + std::size_t(char_len) <= len )
|
||||
{
|
||||
cursor_pos += std::size_t(char_len);
|
||||
adjustTextOffset();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1015,10 +986,15 @@ inline void FLineEdit::deleteCurrentCharacter()
|
||||
// Delete key functionality
|
||||
|
||||
const auto& len = text.getLength();
|
||||
const auto char_len = getCharLength(text, cursor_pos);
|
||||
|
||||
if ( len > 0 && cursor_pos < len )
|
||||
if ( char_len < 0 )
|
||||
return;
|
||||
|
||||
if ( len >= std::size_t(char_len)
|
||||
&& cursor_pos <= len - std::size_t(char_len) )
|
||||
{
|
||||
text.remove(cursor_pos, 1);
|
||||
text.remove(cursor_pos, std::size_t(char_len));
|
||||
print_text = ( isPasswordField() ) ? getPasswordText() : text;
|
||||
processChanged();
|
||||
}
|
||||
@ -1113,12 +1089,7 @@ inline wchar_t FLineEdit::characterFilter (const wchar_t c) const
|
||||
//----------------------------------------------------------------------
|
||||
void FLineEdit::processActivate()
|
||||
{
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
setFocus();
|
||||
redraw();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
emitCallback("activate");
|
||||
}
|
||||
|
||||
|
332
src/flistbox.cpp
332
src/flistbox.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -39,10 +39,6 @@ namespace finalcut
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListBoxItem::FListBoxItem()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListBoxItem::FListBoxItem (const FListBoxItem& item)
|
||||
: text{item.text}
|
||||
@ -52,8 +48,8 @@ FListBoxItem::FListBoxItem (const FListBoxItem& item)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListBoxItem::~FListBoxItem() // destructor
|
||||
{ }
|
||||
FListBoxItem::~FListBoxItem() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FListBoxItem
|
||||
//----------------------------------------------------------------------
|
||||
@ -128,12 +124,12 @@ void FListBox::setCurrentItem (FListBoxItems::iterator iter)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::showInsideBrackets ( const std::size_t index
|
||||
, fc::brackets_type b )
|
||||
, BracketType b )
|
||||
{
|
||||
auto iter = index2iterator(index - 1);
|
||||
iter->brackets = b;
|
||||
|
||||
if ( b == fc::NoBrackets )
|
||||
if ( b == BracketType::None )
|
||||
return;
|
||||
|
||||
const auto column_width = getColumnWidth(iter->getText()) + 2;
|
||||
@ -189,7 +185,7 @@ void FListBox::hide()
|
||||
void FListBox::insert (const FListBoxItem& listItem)
|
||||
{
|
||||
const std::size_t column_width = getColumnWidth(listItem.text);
|
||||
const bool has_brackets(listItem.brackets);
|
||||
const bool has_brackets(listItem.brackets != BracketType::None);
|
||||
recalculateHorizontalBar (column_width, has_brackets);
|
||||
|
||||
itemlist.push_back (listItem);
|
||||
@ -308,17 +304,16 @@ void FListBox::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Right )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ev->getButton() == fc::RightButton && ! isMultiSelection() )
|
||||
if ( ev->getButton() == MouseButton::Right && ! isMultiSelection() )
|
||||
return;
|
||||
|
||||
getWidgetFocus();
|
||||
|
||||
setWidgetFocus(this);
|
||||
const int yoffset_before = yoffset;
|
||||
const std::size_t current_before = current;
|
||||
const int mouse_x = ev->getX();
|
||||
@ -336,7 +331,7 @@ void FListBox::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
inc_search.clear();
|
||||
|
||||
if ( ev->getButton() == fc::RightButton )
|
||||
if ( ev->getButton() == MouseButton::Right )
|
||||
multiSelection(current);
|
||||
|
||||
if ( current_before != current )
|
||||
@ -361,10 +356,10 @@ void FListBox::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
click_on_list = false;
|
||||
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
if ( drag_scroll != DragScrollMode::None )
|
||||
stopDragScroll();
|
||||
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
if ( ev->getButton() == MouseButton::Left )
|
||||
{
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
@ -381,11 +376,11 @@ void FListBox::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::RightButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Right )
|
||||
return;
|
||||
|
||||
if ( ev->getButton() == fc::RightButton && ! isMultiSelection() )
|
||||
if ( ev->getButton() == MouseButton::Right && ! isMultiSelection() )
|
||||
return;
|
||||
|
||||
const std::size_t current_before = current;
|
||||
@ -408,12 +403,12 @@ void FListBox::onMouseMove (FMouseEvent* ev)
|
||||
if ( current_before != current )
|
||||
{
|
||||
// Handle multiple selections + changes
|
||||
if ( ev->getButton() == fc::RightButton)
|
||||
if ( ev->getButton() == MouseButton::Right )
|
||||
{
|
||||
processChanged();
|
||||
multiSelectionUpTo(current);
|
||||
}
|
||||
else if ( ev->getButton() == fc::LeftButton)
|
||||
else if ( ev->getButton() == MouseButton::Left )
|
||||
processChanged();
|
||||
}
|
||||
|
||||
@ -440,7 +435,7 @@ void FListBox::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::onMouseDoubleClick (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
const int mouse_x = ev->getX();
|
||||
@ -462,25 +457,17 @@ void FListBox::onTimer (FTimerEvent*)
|
||||
const std::size_t current_before = current;
|
||||
const int yoffset_before = yoffset;
|
||||
|
||||
switch ( int(drag_scroll) )
|
||||
if ( ( drag_scroll == DragScrollMode::Upward
|
||||
|| drag_scroll == DragScrollMode::SelectUpward )
|
||||
&& ! dragScrollUp() )
|
||||
{
|
||||
case fc::noScroll:
|
||||
return;
|
||||
|
||||
case fc::scrollUp:
|
||||
case fc::scrollUpSelect:
|
||||
if ( ! dragScrollUp() )
|
||||
return;
|
||||
break;
|
||||
|
||||
case fc::scrollDown:
|
||||
case fc::scrollDownSelect:
|
||||
if ( ! dragScrollDown() )
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
else if ( ( drag_scroll == DragScrollMode::Downward
|
||||
|| drag_scroll == DragScrollMode::SelectDownward )
|
||||
&& ! dragScrollDown() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( current_before != current )
|
||||
@ -489,8 +476,8 @@ void FListBox::onTimer (FTimerEvent*)
|
||||
processChanged();
|
||||
|
||||
// Handle multiple selections
|
||||
if ( drag_scroll == fc::scrollUpSelect
|
||||
|| drag_scroll == fc::scrollDownSelect )
|
||||
if ( drag_scroll == DragScrollMode::SelectUpward
|
||||
|| drag_scroll == DragScrollMode::SelectDownward )
|
||||
multiSelectionUpTo(current);
|
||||
}
|
||||
|
||||
@ -511,24 +498,15 @@ void FListBox::onWheel (FWheelEvent* ev)
|
||||
const std::size_t current_before = current;
|
||||
const int yoffset_before = yoffset;
|
||||
static constexpr int wheel_distance = 4;
|
||||
const int wheel = ev->getWheel();
|
||||
const MouseWheel wheel = ev->getWheel();
|
||||
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
if ( drag_scroll != DragScrollMode::None )
|
||||
stopDragScroll();
|
||||
|
||||
switch ( wheel )
|
||||
{
|
||||
case fc::WheelUp:
|
||||
wheelUp (wheel_distance);
|
||||
break;
|
||||
|
||||
case fc::WheelDown:
|
||||
wheelDown (wheel_distance);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( wheel == MouseWheel::Up )
|
||||
wheelUp (wheel_distance);
|
||||
else if ( wheel == MouseWheel::Down )
|
||||
wheelDown (wheel_distance);
|
||||
|
||||
if ( current_before != current )
|
||||
{
|
||||
@ -620,18 +598,15 @@ void FListBox::adjustSize()
|
||||
hbar->setWidth (width, false);
|
||||
hbar->resize();
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
|
||||
|
||||
@ -645,8 +620,8 @@ inline FString FListBox::getString (FListBoxItems::iterator iter)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::init()
|
||||
{
|
||||
initScrollbar (vbar, fc::vertical, this, &FListBox::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListBox::cb_hbarChange);
|
||||
initScrollbar (vbar, Orientation::Vertical, this, &FListBox::cb_vbarChange);
|
||||
initScrollbar (hbar, Orientation::Horizontal, this, &FListBox::cb_hbarChange);
|
||||
setGeometry (FPoint{1, 1}, FSize{5, 4}, false); // initialize geometry values
|
||||
nf_offset = FTerm::isNewFont() ? 1 : 0;
|
||||
setTopPadding(1);
|
||||
@ -659,50 +634,48 @@ void FListBox::init()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::mapKeyFunctions()
|
||||
{
|
||||
key_map[fc::Fkey_return] = std::bind(&FListBox::acceptSelection, this);
|
||||
key_map[fc::Fkey_enter] = std::bind(&FListBox::acceptSelection, this);
|
||||
key_map[fc::Fkey_up] = std::bind(&FListBox::onePosUp, this);
|
||||
key_map[fc::Fkey_down] = std::bind(&FListBox::onePosDown, this);
|
||||
auto left = static_cast<void(FListBox::*)()>(&FListBox::scrollLeft);
|
||||
key_map[fc::Fkey_left] = std::bind(left, this);
|
||||
auto right = static_cast<void(FListBox::*)()>(&FListBox::scrollRight);
|
||||
key_map[fc::Fkey_right] = std::bind(right, this);
|
||||
key_map[fc::Fkey_ppage] = std::bind(&FListBox::onePageUp, this);
|
||||
key_map[fc::Fkey_npage] = std::bind(&FListBox::onePageDown, this);
|
||||
key_map[fc::Fkey_home] = std::bind(&FListBox::firstPos, this);
|
||||
key_map[fc::Fkey_end] = std::bind(&FListBox::lastPos, this);
|
||||
key_map_result[fc::Fkey_ic] = \
|
||||
std::bind(&FListBox::changeSelectionAndPosition, this);
|
||||
key_map_result[fc::Fkey_space] = \
|
||||
std::bind(&FListBox::spacebarProcessing, this);
|
||||
key_map_result[fc::Fkey_erase] = \
|
||||
std::bind(&FListBox::deletePreviousCharacter, this);
|
||||
key_map_result[fc::Fkey_backspace] = \
|
||||
std::bind(&FListBox::deletePreviousCharacter, this);
|
||||
key_map_result[fc::Fkey_escape] = \
|
||||
std::bind(&FListBox::skipIncrementalSearch, this);
|
||||
key_map_result[fc::Fkey_escape_mintty] = \
|
||||
std::bind(&FListBox::skipIncrementalSearch, this);
|
||||
key_map[FKey::Return] = [this] { acceptSelection(); };
|
||||
key_map[FKey::Enter] = [this] { acceptSelection(); };
|
||||
key_map[FKey::Up] = [this] { onePosUp(); };
|
||||
key_map[FKey::Down] = [this] { onePosDown(); };
|
||||
key_map[FKey::Left] = [this] { scrollLeft(); };
|
||||
key_map[FKey::Right] = [this] { scrollRight(); };
|
||||
key_map[FKey::Page_up] = [this] { onePageUp(); };
|
||||
key_map[FKey::Page_down] = [this] { onePageDown(); };
|
||||
key_map[FKey::Home] = [this] { firstPos(); };
|
||||
key_map[FKey::End] = [this] { lastPos(); };
|
||||
key_map_result[FKey::Insert] = [this] { return changeSelectionAndPosition(); };
|
||||
key_map_result[FKey::Space] = [this] { return spacebarProcessing(); };
|
||||
key_map_result[FKey::Erase] = [this] { return deletePreviousCharacter(); };
|
||||
key_map_result[FKey::Backspace] = [this] { return deletePreviousCharacter(); };
|
||||
key_map_result[FKey::Escape] = [this] { return skipIncrementalSearch(); };
|
||||
key_map_result[FKey::Escape_mintty] = [this] { return skipIncrementalSearch(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::processKeyAction (FKeyEvent* ev)
|
||||
{
|
||||
const auto idx = int(ev->key());
|
||||
const auto idx = ev->key();
|
||||
const auto& entry = key_map[idx];
|
||||
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
if ( entry )
|
||||
{
|
||||
key_map[idx]();
|
||||
entry();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key_map_result.find(idx) != key_map_result.end() )
|
||||
else
|
||||
{
|
||||
if ( key_map_result[idx]() )
|
||||
const auto& entry_result = key_map_result[idx];
|
||||
|
||||
if ( entry_result )
|
||||
{
|
||||
if ( entry_result() )
|
||||
ev->accept();
|
||||
}
|
||||
else if ( keyIncSearchInput(idx) )
|
||||
{
|
||||
ev->accept();
|
||||
}
|
||||
else if ( keyIncSearchInput(ev->key()) )
|
||||
{
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -868,7 +841,7 @@ inline void FListBox::drawListLine ( int y
|
||||
std::size_t column_width = getColumnWidth(element);
|
||||
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
print (UniChar::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
|
||||
@ -887,7 +860,7 @@ inline void FListBox::drawListLine ( int y
|
||||
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
print (UniChar::BlackLeftPointingPointer); // ◄
|
||||
column_width++;
|
||||
}
|
||||
|
||||
@ -896,17 +869,17 @@ inline void FListBox::drawListLine ( int y
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::printLeftBracket (fc::brackets_type bracket_type)
|
||||
inline void FListBox::printLeftBracket (BracketType bracket_type)
|
||||
{
|
||||
if ( bracket_type != fc::NoBrackets )
|
||||
print ("\0[({<"[bracket_type]);
|
||||
if ( bracket_type != BracketType::None )
|
||||
print ("\0[({<"[std::size_t(bracket_type)]);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::printRightBracket (fc::brackets_type bracket_type)
|
||||
inline void FListBox::printRightBracket (BracketType bracket_type)
|
||||
{
|
||||
if ( bracket_type != fc::NoBrackets )
|
||||
print ("\0])}>"[bracket_type]);
|
||||
if ( bracket_type != BracketType::None )
|
||||
print ("\0])}>"[std::size_t(bracket_type)]);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -919,7 +892,7 @@ inline void FListBox::drawListBracketsLine ( int y
|
||||
const bool isCurrentLine( y + yoffset + 1 == int(current) );
|
||||
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
print (fc::BlackRightPointingPointer); // ►
|
||||
print (UniChar::BlackRightPointingPointer); // ►
|
||||
else
|
||||
print (' ');
|
||||
|
||||
@ -963,7 +936,7 @@ inline void FListBox::drawListBracketsLine ( int y
|
||||
|
||||
if ( FTerm::isMonochron() && isCurrentLine && getFlags().focus )
|
||||
{
|
||||
print (fc::BlackLeftPointingPointer); // ◄
|
||||
print (UniChar::BlackLeftPointingPointer); // ◄
|
||||
column_width++;
|
||||
}
|
||||
|
||||
@ -1025,7 +998,7 @@ inline void FListBox::setLineAttributes ( int y
|
||||
{
|
||||
setColor ( wc->current_element_focus_fg
|
||||
, wc->current_element_focus_bg );
|
||||
const int b = ( lineHasBrackets ) ? 1: 0;
|
||||
const int b = lineHasBrackets ? 1 : 0;
|
||||
|
||||
if ( inc_len > 0 ) // incremental search
|
||||
{
|
||||
@ -1130,22 +1103,6 @@ void FListBox::recalculateVerticalBar (std::size_t element_count) const
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListBox::getWidgetFocus()
|
||||
{
|
||||
if ( hasFocus() )
|
||||
return;
|
||||
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::multiSelection (std::size_t pos)
|
||||
{
|
||||
@ -1255,7 +1212,7 @@ bool FListBox::dragScrollUp()
|
||||
{
|
||||
if ( current == 1 )
|
||||
{
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1270,7 +1227,7 @@ bool FListBox::dragScrollDown()
|
||||
|
||||
if ( current == element_count )
|
||||
{
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1279,9 +1236,9 @@ bool FListBox::dragScrollDown()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::dragUp (int mouse_button)
|
||||
void FListBox::dragUp (MouseButton mouse_button)
|
||||
{
|
||||
if ( drag_scroll != fc::noScroll
|
||||
if ( drag_scroll != DragScrollMode::None
|
||||
&& scroll_distance < int(getClientHeight()) )
|
||||
scroll_distance++;
|
||||
|
||||
@ -1290,23 +1247,23 @@ void FListBox::dragUp (int mouse_button)
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
|
||||
if ( mouse_button == fc::RightButton )
|
||||
drag_scroll = fc::scrollUpSelect;
|
||||
if ( mouse_button == MouseButton::Right )
|
||||
drag_scroll = DragScrollMode::SelectUpward;
|
||||
else
|
||||
drag_scroll = fc::scrollUp;
|
||||
drag_scroll = DragScrollMode::Upward;
|
||||
}
|
||||
|
||||
if ( current == 1 )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::dragDown (int mouse_button)
|
||||
void FListBox::dragDown (MouseButton mouse_button)
|
||||
{
|
||||
if ( drag_scroll != fc::noScroll
|
||||
if ( drag_scroll != DragScrollMode::None
|
||||
&& scroll_distance < int(getClientHeight()) )
|
||||
scroll_distance++;
|
||||
|
||||
@ -1315,16 +1272,16 @@ void FListBox::dragDown (int mouse_button)
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
|
||||
if ( mouse_button == fc::RightButton )
|
||||
drag_scroll = fc::scrollDownSelect;
|
||||
if ( mouse_button == MouseButton::Right )
|
||||
drag_scroll = DragScrollMode::SelectDownward;
|
||||
else
|
||||
drag_scroll = fc::scrollDown;
|
||||
drag_scroll = DragScrollMode::Downward;
|
||||
}
|
||||
|
||||
if ( current == getCount() )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1332,7 +1289,7 @@ void FListBox::dragDown (int mouse_button)
|
||||
void FListBox::stopDragScroll()
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
scroll_distance = 1;
|
||||
scroll_timer = false;
|
||||
}
|
||||
@ -1721,7 +1678,7 @@ void FListBox::changeOnResize() const
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
|
||||
{
|
||||
if ( conv_type != lazy_convert || ! iter->getText().isNull() )
|
||||
if ( conv_type != ConvertType::Lazy || ! iter->getText().isNull() )
|
||||
return;
|
||||
|
||||
lazy_inserter (*iter, source_container, y + std::size_t(yoffset));
|
||||
@ -1735,49 +1692,48 @@ void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::cb_vbarChange (const FWidget*)
|
||||
{
|
||||
FScrollbar::sType scrollType;
|
||||
const std::size_t current_before = current;
|
||||
const FScrollbar::ScrollType scrollType = vbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
const std::size_t current_before = current;
|
||||
int distance{1};
|
||||
const int yoffset_before = yoffset;
|
||||
scrollType = vbar->getScrollType();
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getClientHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
prevListItem (distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getClientHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
nextListItem (distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToY (vbar->getValue());
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
wheelUp (wheel_distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
wheelDown (wheel_distance);
|
||||
break;
|
||||
}
|
||||
@ -1791,7 +1747,7 @@ void FListBox::cb_vbarChange (const FWidget*)
|
||||
if ( isShown() )
|
||||
drawList();
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
|
||||
{
|
||||
vbar->setValue (yoffset);
|
||||
|
||||
@ -1805,49 +1761,49 @@ void FListBox::cb_vbarChange (const FWidget*)
|
||||
//----------------------------------------------------------------------
|
||||
void FListBox::cb_hbarChange (const FWidget*)
|
||||
{
|
||||
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
|
||||
const FScrollbar::ScrollType scrollType = hbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
FScrollbar::sType scrollType;
|
||||
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
|
||||
int distance{1};
|
||||
const int xoffset_before = xoffset;
|
||||
scrollType = hbar->getScrollType();
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getClientWidth()) - padding_space;
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
scrollLeft (distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getClientWidth()) - padding_space;
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
scrollRight (distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToX (hbar->getValue());
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
scrollLeft (wheel_distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
scrollRight (wheel_distance);
|
||||
break;
|
||||
}
|
||||
@ -1859,7 +1815,7 @@ void FListBox::cb_hbarChange (const FWidget*)
|
||||
drawList();
|
||||
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
|
||||
{
|
||||
hbar->setValue (xoffset);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -122,7 +122,7 @@ bool sortAscendingByName (const FObject* lhs, const FObject* rhs)
|
||||
const auto& r_string = r_item->getText(column);
|
||||
|
||||
// lhs < rhs
|
||||
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) < 0 );
|
||||
return strcasecmp(l_string.c_str(), r_string.c_str()) < 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -135,7 +135,7 @@ bool sortDescendingByName (const FObject* lhs, const FObject* rhs)
|
||||
const auto& r_string = r_item->getText(column);
|
||||
|
||||
// lhs > rhs
|
||||
return bool( strcasecmp(l_string.c_str(), r_string.c_str()) > 0 );
|
||||
return strcasecmp(l_string.c_str(), r_string.c_str()) > 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -148,7 +148,7 @@ bool sortAscendingByNumber (const FObject* lhs, const FObject* rhs)
|
||||
const auto& r_number = firstNumberFromString(r_item->getText(column));
|
||||
|
||||
// lhs < rhs
|
||||
return bool( l_number < r_number );
|
||||
return l_number < r_number;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -161,7 +161,7 @@ bool sortDescendingByNumber (const FObject* lhs, const FObject* rhs)
|
||||
const auto& r_number = firstNumberFromString(r_item->getText(column));
|
||||
|
||||
// lhs > rhs
|
||||
return bool( l_number > r_number );
|
||||
return l_number > r_number;
|
||||
}
|
||||
|
||||
|
||||
@ -478,51 +478,11 @@ void FListViewItem::resetVisibleLineCounter()
|
||||
|
||||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (iterator iter)
|
||||
FListViewIterator::FListViewIterator (Iterator iter)
|
||||
: node{iter}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::~FListViewIterator() // destructor
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (const FListViewIterator& i)
|
||||
: iter_path{i.iter_path} // copy constructor
|
||||
, node{i.node}
|
||||
, position{i.position}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator::FListViewIterator (FListViewIterator&& i) noexcept
|
||||
: iter_path{std::move(i.iter_path)} // move constructor
|
||||
, node{std::move(i.node)}
|
||||
, position{std::move(i.position)}
|
||||
{ }
|
||||
|
||||
// FListViewIterator operators
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator& FListViewIterator::operator = (const FListViewIterator& i)
|
||||
{
|
||||
iter_path = i.iter_path;
|
||||
node = i.node;
|
||||
position = i.position;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator& FListViewIterator::operator = (FListViewIterator&& i) noexcept
|
||||
{
|
||||
iter_path = std::move(i.iter_path);
|
||||
node = std::move(i.node);
|
||||
position = std::move(i.position);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator& FListViewIterator::operator ++ () // prefix
|
||||
{
|
||||
@ -554,32 +514,26 @@ FListViewIterator FListViewIterator::operator -- (int) // postfix
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator& FListViewIterator::operator += (volatile int n)
|
||||
FListViewIterator& FListViewIterator::operator += (int n)
|
||||
{
|
||||
while ( n > 0 )
|
||||
{
|
||||
for (int i = n; i > 0 ; i--)
|
||||
nextElement(node);
|
||||
n--;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FListViewIterator& FListViewIterator::operator -= (volatile int n)
|
||||
FListViewIterator& FListViewIterator::operator -= (int n)
|
||||
{
|
||||
while ( n > 0 )
|
||||
{
|
||||
for (int i = n; i > 0 ; i--)
|
||||
prevElement(node);
|
||||
n--;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// private methods of FListViewIterator
|
||||
//----------------------------------------------------------------------
|
||||
void FListViewIterator::nextElement (iterator& iter)
|
||||
void FListViewIterator::nextElement (Iterator& iter)
|
||||
{
|
||||
const auto& item = static_cast<FListViewItem*>(*iter);
|
||||
|
||||
@ -616,7 +570,7 @@ void FListViewIterator::nextElement (iterator& iter)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListViewIterator::prevElement (iterator& iter)
|
||||
void FListViewIterator::prevElement (Iterator& iter)
|
||||
{
|
||||
auto start_iter = iter;
|
||||
|
||||
@ -697,12 +651,12 @@ std::size_t FListView::getCount() const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fc::text_alignment FListView::getColumnAlignment (int column) const
|
||||
Align FListView::getColumnAlignment (int column) const
|
||||
{
|
||||
// Get the alignment for a column
|
||||
|
||||
if ( column < 1 || header.empty() || column > int(header.size()) )
|
||||
return fc::alignLeft;
|
||||
return Align::Left;
|
||||
|
||||
// Convert column position to address offset (index)
|
||||
const auto index = std::size_t(column - 1);
|
||||
@ -723,21 +677,21 @@ FString FListView::getColumnText (int column) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
fc::sorting_type FListView::getColumnSortType (int column) const
|
||||
SortType FListView::getColumnSortType (int column) const
|
||||
{
|
||||
fc::sorting_type type;
|
||||
SortType s_type;
|
||||
const auto col = std::size_t(column);
|
||||
|
||||
try
|
||||
{
|
||||
type = sort_type.at(col);
|
||||
s_type = sort_type.at(col);
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
type = fc::unknown;
|
||||
s_type = SortType::Unknown;
|
||||
}
|
||||
|
||||
return type;
|
||||
return s_type;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -756,7 +710,7 @@ void FListView::setGeometry ( const FPoint& pos, const FSize& size
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setColumnAlignment (int column, fc::text_alignment align)
|
||||
void FListView::setColumnAlignment (int column, Align align)
|
||||
{
|
||||
// Set the alignment for a column
|
||||
|
||||
@ -791,7 +745,7 @@ void FListView::setColumnText (int column, const FString& label)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setColumnSortType (int column, fc::sorting_type type)
|
||||
void FListView::setColumnSortType (int column, SortType type)
|
||||
{
|
||||
// Sets the sort type by which the list is to be sorted
|
||||
|
||||
@ -807,7 +761,7 @@ void FListView::setColumnSortType (int column, fc::sorting_type type)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::setColumnSort (int column, fc::sorting_order order)
|
||||
void FListView::setColumnSort (int column, SortOrder order)
|
||||
{
|
||||
// Sets the column to sort by + the sorting order
|
||||
|
||||
@ -975,43 +929,43 @@ void FListView::sort()
|
||||
if ( sort_column < 1 && sort_column > int(header.size()) )
|
||||
return;
|
||||
|
||||
fc::sorting_type column_sort_type = getColumnSortType(sort_column);
|
||||
assert ( column_sort_type == fc::by_name
|
||||
|| column_sort_type == fc::by_number
|
||||
|| column_sort_type == fc::user_defined
|
||||
|| column_sort_type == fc::unknown );
|
||||
SortType column_sort_type = getColumnSortType(sort_column);
|
||||
assert ( column_sort_type == SortType::Name
|
||||
|| column_sort_type == SortType::Number
|
||||
|| column_sort_type == SortType::UserDefined
|
||||
|| column_sort_type == SortType::Unknown );
|
||||
|
||||
switch ( column_sort_type )
|
||||
{
|
||||
case fc::unknown:
|
||||
case fc::by_name:
|
||||
if ( sort_order == fc::ascending )
|
||||
case SortType::Unknown:
|
||||
case SortType::Name:
|
||||
if ( sort_order == SortOrder::Ascending )
|
||||
{
|
||||
sort (sortAscendingByName);
|
||||
}
|
||||
else if ( sort_order == fc::descending )
|
||||
else if ( sort_order == SortOrder::Descending )
|
||||
{
|
||||
sort (sortDescendingByName);
|
||||
}
|
||||
break;
|
||||
|
||||
case fc::by_number:
|
||||
if ( sort_order == fc::ascending )
|
||||
case SortType::Number:
|
||||
if ( sort_order == SortOrder::Ascending )
|
||||
{
|
||||
sort (sortAscendingByNumber);
|
||||
}
|
||||
else if ( sort_order == fc::descending )
|
||||
else if ( sort_order == SortOrder::Descending )
|
||||
{
|
||||
sort (sortDescendingByNumber);
|
||||
}
|
||||
break;
|
||||
|
||||
case fc::user_defined:
|
||||
if ( sort_order == fc::ascending && user_defined_ascending )
|
||||
case SortType::UserDefined:
|
||||
if ( sort_order == SortOrder::Ascending && user_defined_ascending )
|
||||
{
|
||||
sort (user_defined_ascending);
|
||||
}
|
||||
else if ( sort_order == fc::descending && user_defined_descending )
|
||||
else if ( sort_order == SortOrder::Descending && user_defined_descending )
|
||||
{
|
||||
sort (user_defined_descending);
|
||||
}
|
||||
@ -1046,24 +1000,13 @@ void FListView::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
clicked_expander_pos.setPoint(-1, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! hasFocus() )
|
||||
{
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
}
|
||||
|
||||
setWidgetFocus(this);
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
@ -1124,10 +1067,10 @@ void FListView::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
if ( drag_scroll != DragScrollMode::None )
|
||||
stopDragScroll();
|
||||
|
||||
if ( ev->getButton() == fc::LeftButton )
|
||||
if ( ev->getButton() == MouseButton::Left )
|
||||
{
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
@ -1194,7 +1137,7 @@ void FListView::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
clicked_expander_pos.setPoint(-1, -1);
|
||||
return;
|
||||
@ -1235,7 +1178,7 @@ void FListView::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::onMouseDoubleClick (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
const int mouse_x = ev->getX();
|
||||
@ -1277,25 +1220,17 @@ void FListView::onTimer (FTimerEvent*)
|
||||
const int position_before = current_iter.getPosition();
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
switch ( int(drag_scroll) )
|
||||
if ( ( drag_scroll == DragScrollMode::Upward
|
||||
|| drag_scroll == DragScrollMode::SelectUpward )
|
||||
&& ! dragScrollUp(position_before) )
|
||||
{
|
||||
case fc::noScroll:
|
||||
return;
|
||||
|
||||
case fc::scrollUp:
|
||||
case fc::scrollUpSelect:
|
||||
if ( ! dragScrollUp(position_before) )
|
||||
return;
|
||||
break;
|
||||
|
||||
case fc::scrollDown:
|
||||
case fc::scrollDownSelect:
|
||||
if ( ! dragScrollDown(position_before) )
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
return;
|
||||
}
|
||||
else if ( ( drag_scroll == DragScrollMode::Downward
|
||||
|| drag_scroll == DragScrollMode::SelectDownward )
|
||||
&& ! dragScrollDown(position_before) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isShown() )
|
||||
@ -1316,22 +1251,13 @@ void FListView::onWheel (FWheelEvent* ev)
|
||||
static constexpr int wheel_distance = 4;
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
|
||||
if ( drag_scroll != fc::noScroll )
|
||||
if ( drag_scroll != DragScrollMode::None )
|
||||
stopDragScroll();
|
||||
|
||||
switch ( ev->getWheel() )
|
||||
{
|
||||
case fc::WheelUp:
|
||||
wheelUp (wheel_distance);
|
||||
break;
|
||||
|
||||
case fc::WheelDown:
|
||||
wheelDown (wheel_distance);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( ev->getWheel() == MouseWheel::Up )
|
||||
wheelUp (wheel_distance);
|
||||
else if ( ev->getWheel() == MouseWheel::Down )
|
||||
wheelDown (wheel_distance);
|
||||
|
||||
if ( position_before != current_iter.getPosition() )
|
||||
processChanged();
|
||||
@ -1431,18 +1357,15 @@ void FListView::adjustScrollbars (const std::size_t element_count) const
|
||||
hbar->setWidth (width, false);
|
||||
hbar->resize();
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
if ( isHorizontallyScrollable() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
if ( isVerticallyScrollable() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1472,8 +1395,8 @@ void FListView::setNullIterator (const iterator& null_iter)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::init()
|
||||
{
|
||||
initScrollbar (vbar, fc::vertical, this, &FListView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange);
|
||||
initScrollbar (vbar, Orientation::Vertical, this, &FListView::cb_vbarChange);
|
||||
initScrollbar (hbar, Orientation::Horizontal, this, &FListView::cb_hbarChange);
|
||||
selflist.push_back(this);
|
||||
root = selflist.begin();
|
||||
getNullIterator() = selflist.end();
|
||||
@ -1489,39 +1412,45 @@ void FListView::init()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FListView::mapKeyFunctions()
|
||||
{
|
||||
key_map[fc::Fkey_return] = std::bind(&FListView::processClick, this);
|
||||
key_map[fc::Fkey_enter] = std::bind(&FListView::processClick, this);
|
||||
key_map[fc::Fkey_space] = std::bind(&FListView::toggleCheckbox, this);
|
||||
key_map[fc::Fkey_up] = [this] { stepBackward(); };
|
||||
key_map[fc::Fkey_down] = [this] { stepForward(); };
|
||||
key_map[fc::Fkey_left] = std::bind(&FListView::collapseAndScrollLeft, this);
|
||||
key_map[fc::Fkey_right] = std::bind(&FListView::expandAndScrollRight, this);
|
||||
key_map[fc::Fkey_ppage] = [this] { stepBackward(int(getClientHeight()) - 1); };
|
||||
key_map[fc::Fkey_npage] = [this] { stepForward(int(getClientHeight()) - 1); };
|
||||
key_map[fc::Fkey_home] = std::bind(&FListView::firstPos, this);
|
||||
key_map[fc::Fkey_end] = std::bind(&FListView::lastPos, this);
|
||||
key_map_result[FKey('+')] = std::bind(&FListView::expandSubtree, this);
|
||||
key_map_result[FKey('-')] = std::bind(&FListView::collapseSubtree, this);
|
||||
key_map[FKey::Return] = [this] { processClick(); };
|
||||
key_map[FKey::Enter] = [this] { processClick(); };
|
||||
key_map[FKey::Space] = [this] { toggleCheckbox(); };
|
||||
key_map[FKey::Up] = [this] { stepBackward(); };
|
||||
key_map[FKey::Down] = [this] { stepForward(); };
|
||||
key_map[FKey::Left] = [this] { collapseAndScrollLeft(); };
|
||||
key_map[FKey::Right] = [this] { expandAndScrollRight(); };
|
||||
key_map[FKey::Page_up] = [this] { stepBackward(int(getClientHeight()) - 1); };
|
||||
key_map[FKey::Page_down] = [this] { stepForward(int(getClientHeight()) - 1); };
|
||||
key_map[FKey::Home] = [this] { firstPos(); };
|
||||
key_map[FKey::End] = [this] { lastPos(); };
|
||||
key_map_result[FKey('+')] = [this] { return expandSubtree(); };
|
||||
key_map_result[FKey('-')] = [this] { return collapseSubtree(); };
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::processKeyAction (FKeyEvent* ev)
|
||||
{
|
||||
const auto idx = int(ev->key());
|
||||
const auto idx = ev->key();
|
||||
const auto& entry = key_map[idx];
|
||||
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
if ( entry )
|
||||
{
|
||||
key_map[idx]();
|
||||
entry();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key_map_result.find(idx) != key_map_result.end() )
|
||||
{
|
||||
if ( key_map_result[idx]() )
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->ignore();
|
||||
const auto& entry_result = key_map_result[idx];
|
||||
|
||||
if ( entry_result )
|
||||
{
|
||||
if ( entry_result() )
|
||||
ev->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
ev->ignore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,30 +1467,18 @@ void FListView::sort (Compare cmp)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t FListView::getAlignOffset ( const fc::text_alignment align
|
||||
std::size_t FListView::getAlignOffset ( const Align align
|
||||
, const std::size_t column_width
|
||||
, const std::size_t width ) const
|
||||
{
|
||||
assert ( align == fc::alignLeft
|
||||
|| align == fc::alignCenter
|
||||
|| align == fc::alignRight );
|
||||
|
||||
switch ( align )
|
||||
if ( align == Align::Center )
|
||||
{
|
||||
case fc::alignLeft:
|
||||
return 0;
|
||||
|
||||
case fc::alignCenter:
|
||||
if ( column_width < width )
|
||||
return (width - column_width) / 2;
|
||||
else
|
||||
return 0;
|
||||
|
||||
case fc::alignRight:
|
||||
if ( column_width < width )
|
||||
return width - column_width;
|
||||
else
|
||||
return 0;
|
||||
if ( column_width < width )
|
||||
return (width - column_width) / 2;
|
||||
}
|
||||
else if ( align == Align::Right && column_width < width )
|
||||
{
|
||||
return width - column_width;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1666,15 +1583,9 @@ void FListView::drawHeadlines()
|
||||
|
||||
while ( iter != header.end() )
|
||||
{
|
||||
const auto& text = iter->name;
|
||||
if ( ! iter->name.isEmpty() )
|
||||
drawHeadlineLabel(iter); // Draw into FTermBuffer object
|
||||
|
||||
if ( text.isNull() || text.isEmpty() )
|
||||
{
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
|
||||
drawHeadlineLabel(iter); // Draw into FTermBuffer object
|
||||
++iter;
|
||||
}
|
||||
|
||||
@ -1698,8 +1609,8 @@ void FListView::drawList()
|
||||
{
|
||||
const bool is_current_line( iter == current_iter );
|
||||
const auto& item = static_cast<FListViewItem*>(*iter);
|
||||
const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
|
||||
const int checkbox_offset = ( item->isCheckable() ) ? 1 : 0;
|
||||
const int tree_offset = tree_view ? int(item->getDepth() << 1) + 1 : 0;
|
||||
const int checkbox_offset = item->isCheckable() ? 1 : 0;
|
||||
path_end = getListEnd(item);
|
||||
print() << FPoint{2, 2 + int(y)};
|
||||
|
||||
@ -1761,7 +1672,7 @@ void FListView::drawListLine ( const FListViewItem* item
|
||||
// Increment the value of col for the column position
|
||||
// and the next iteration
|
||||
col++;
|
||||
const fc::text_alignment align = getColumnAlignment(int(col));
|
||||
const Align align = getColumnAlignment(int(col));
|
||||
const std::size_t align_offset = getAlignOffset (align, column_width, width);
|
||||
|
||||
if ( tree_view && col == 1 )
|
||||
@ -1784,7 +1695,7 @@ void FListView::drawListLine ( const FListViewItem* item
|
||||
line += FString { leading_space + width
|
||||
- align_offset - column_width, L' '};
|
||||
}
|
||||
else if ( align == fc::alignRight )
|
||||
else if ( align == Align::Right )
|
||||
{
|
||||
// Ellipse right align text
|
||||
const std::size_t first = getColumnWidth(text) + 1 - width;
|
||||
@ -1899,7 +1810,7 @@ inline FString FListView::getCheckBox (const FListViewItem* item) const
|
||||
{
|
||||
try
|
||||
{
|
||||
checkbox[1] = fc::Times; // Times ×
|
||||
checkbox[1] = wchar_t(UniChar::Times); // Times ×
|
||||
}
|
||||
catch (const std::out_of_range&)
|
||||
{
|
||||
@ -1926,12 +1837,12 @@ inline FString FListView::getLinePrefix ( const FListViewItem* item
|
||||
{
|
||||
if ( item->isExpand() )
|
||||
{
|
||||
line += fc::BlackDownPointingTriangle; // ▼
|
||||
line += UniChar::BlackDownPointingTriangle; // ▼
|
||||
line += L' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
line += fc::BlackRightPointingPointer; // ►
|
||||
line += UniChar::BlackRightPointingPointer; // ►
|
||||
line += L' ';
|
||||
}
|
||||
}
|
||||
@ -1957,10 +1868,10 @@ inline void FListView::drawSortIndicator ( std::size_t& length
|
||||
setColor();
|
||||
length++;
|
||||
|
||||
if ( sort_order == fc::ascending )
|
||||
headerline << fc::BlackUpPointingTriangle; // ▲
|
||||
else if ( sort_order == fc::descending )
|
||||
headerline << fc::BlackDownPointingTriangle; // ▼
|
||||
if ( sort_order == SortOrder::Ascending )
|
||||
headerline << UniChar::BlackUpPointingTriangle; // ▲
|
||||
else if ( sort_order == SortOrder::Descending )
|
||||
headerline << UniChar::BlackDownPointingTriangle; // ▼
|
||||
|
||||
if ( length < column_max )
|
||||
{
|
||||
@ -1973,7 +1884,7 @@ inline void FListView::drawSortIndicator ( std::size_t& length
|
||||
inline void FListView::drawHeaderBorder (std::size_t length)
|
||||
{
|
||||
setColor();
|
||||
const FString line {length, fc::BoxDrawingsHorizontal};
|
||||
const FString line {length, UniChar::BoxDrawingsHorizontal};
|
||||
headerline << line; // horizontal line
|
||||
}
|
||||
|
||||
@ -2099,17 +2010,17 @@ void FListView::drawBufferedHeadline()
|
||||
print() << FPoint{2, 1};
|
||||
|
||||
if ( left_truncated_fullwidth )
|
||||
print (fc::SingleLeftAngleQuotationMark); // ‹
|
||||
print (UniChar::SingleLeftAngleQuotationMark); // ‹
|
||||
|
||||
print() << FTermBuffer(first, last);
|
||||
|
||||
if ( right_truncated_fullwidth )
|
||||
print (fc::SingleRightAngleQuotationMark); // ›
|
||||
print (UniChar::SingleRightAngleQuotationMark); // ›
|
||||
|
||||
while ( column_width < getClientWidth() )
|
||||
{
|
||||
setColor();
|
||||
print(fc::BoxDrawingsHorizontal);
|
||||
print(UniChar::BoxDrawingsHorizontal);
|
||||
column_width++;
|
||||
}
|
||||
}
|
||||
@ -2282,10 +2193,10 @@ void FListView::mouseHeaderClicked()
|
||||
if ( header_pos > header_start
|
||||
&& header_pos <= header_start + click_width )
|
||||
{
|
||||
if ( has_sort_indicator && sort_order == fc::ascending )
|
||||
setColumnSort (column, fc::descending);
|
||||
if ( has_sort_indicator && sort_order == SortOrder::Ascending )
|
||||
setColumnSort (column, SortOrder::Descending);
|
||||
else
|
||||
setColumnSort (column, fc::ascending);
|
||||
setColumnSort (column, SortOrder::Ascending);
|
||||
|
||||
sort();
|
||||
|
||||
@ -2358,7 +2269,7 @@ bool FListView::dragScrollUp (int position_before)
|
||||
{
|
||||
if ( position_before == 0 )
|
||||
{
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2373,7 +2284,7 @@ bool FListView::dragScrollDown (int position_before)
|
||||
|
||||
if ( position_before + 1 == element_count )
|
||||
{
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2382,9 +2293,9 @@ bool FListView::dragScrollDown (int position_before)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::dragUp (int mouse_button)
|
||||
void FListView::dragUp (MouseButton mouse_button)
|
||||
{
|
||||
if ( drag_scroll != fc::noScroll
|
||||
if ( drag_scroll != DragScrollMode::None
|
||||
&& scroll_distance < int(getClientHeight()) )
|
||||
scroll_distance++;
|
||||
|
||||
@ -2393,23 +2304,23 @@ void FListView::dragUp (int mouse_button)
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
|
||||
if ( mouse_button == fc::RightButton )
|
||||
drag_scroll = fc::scrollUpSelect;
|
||||
if ( mouse_button == MouseButton::Right )
|
||||
drag_scroll = DragScrollMode::SelectUpward;
|
||||
else
|
||||
drag_scroll = fc::scrollUp;
|
||||
drag_scroll = DragScrollMode::Upward;
|
||||
}
|
||||
|
||||
if ( current_iter.getPosition() == 0 )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::dragDown (int mouse_button)
|
||||
void FListView::dragDown (MouseButton mouse_button)
|
||||
{
|
||||
if ( drag_scroll != fc::noScroll
|
||||
if ( drag_scroll != DragScrollMode::None
|
||||
&& scroll_distance < int(getClientHeight()) )
|
||||
scroll_distance++;
|
||||
|
||||
@ -2418,16 +2329,16 @@ void FListView::dragDown (int mouse_button)
|
||||
scroll_timer = true;
|
||||
addTimer(scroll_repeat);
|
||||
|
||||
if ( mouse_button == fc::RightButton )
|
||||
drag_scroll = fc::scrollDownSelect;
|
||||
if ( mouse_button == MouseButton::Right )
|
||||
drag_scroll = DragScrollMode::SelectDownward;
|
||||
else
|
||||
drag_scroll = fc::scrollDown;
|
||||
drag_scroll = DragScrollMode::Downward;
|
||||
}
|
||||
|
||||
if ( current_iter.getPosition() - 1 == int(getCount()) )
|
||||
{
|
||||
delOwnTimers();
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2437,7 +2348,7 @@ void FListView::stopDragScroll()
|
||||
delOwnTimers();
|
||||
scroll_timer = false;
|
||||
scroll_distance = 1;
|
||||
drag_scroll = fc::noScroll;
|
||||
drag_scroll = DragScrollMode::None;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -2811,47 +2722,47 @@ void FListView::scrollBy (int dx, int dy)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::cb_vbarChange (const FWidget*)
|
||||
{
|
||||
FScrollbar::sType scrollType = vbar->getScrollType();
|
||||
const FScrollbar::ScrollType scrollType = vbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
int distance{1};
|
||||
first_line_position_before = first_visible_line.getPosition();
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getClientHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
stepBackward(distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getClientHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
stepForward(distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToY (vbar->getValue());
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
wheelUp (wheel_distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
wheelDown (wheel_distance);
|
||||
break;
|
||||
}
|
||||
@ -2859,8 +2770,8 @@ void FListView::cb_vbarChange (const FWidget*)
|
||||
if ( isShown() )
|
||||
drawList();
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward
|
||||
&& scrollType <= FScrollbar::scrollPageForward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward
|
||||
&& scrollType <= FScrollbar::ScrollType::PageForward )
|
||||
{
|
||||
vbar->setValue (first_visible_line.getPosition());
|
||||
|
||||
@ -2874,47 +2785,47 @@ void FListView::cb_vbarChange (const FWidget*)
|
||||
//----------------------------------------------------------------------
|
||||
void FListView::cb_hbarChange (const FWidget*)
|
||||
{
|
||||
FScrollbar::sType scrollType = hbar->getScrollType();
|
||||
const FScrollbar::ScrollType scrollType = hbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
int distance{1};
|
||||
const int xoffset_before = xoffset;
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getClientWidth());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
scrollBy (-distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getClientWidth());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
scrollBy (distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToX (hbar->getValue());
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
scrollBy (-wheel_distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
scrollBy (wheel_distance, 0);
|
||||
break;
|
||||
}
|
||||
@ -2925,7 +2836,7 @@ void FListView::cb_hbarChange (const FWidget*)
|
||||
drawList();
|
||||
}
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
|
||||
{
|
||||
hbar->setValue (xoffset);
|
||||
|
||||
|
26
src/flog.cpp
26
src/flog.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -30,10 +30,6 @@ namespace finalcut
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLog::FLog()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLog::~FLog() // destructor
|
||||
{
|
||||
@ -45,26 +41,25 @@ FLog::~FLog() // destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLog& FLog::operator << (LogLevel l)
|
||||
{
|
||||
using std::placeholders::_1;
|
||||
sync();
|
||||
std::lock_guard<std::mutex> lock_guard(mut);
|
||||
std::lock_guard<std::mutex> lock_guard(current_log_mutex);
|
||||
|
||||
switch ( l )
|
||||
{
|
||||
case Info:
|
||||
current_log = std::bind(&FLog::info, this, _1);
|
||||
case LogLevel::Info:
|
||||
current_log = [this] (const std::string& s) { info(s); };
|
||||
break;
|
||||
|
||||
case Warn:
|
||||
current_log = std::bind(&FLog::warn, this, _1);
|
||||
case LogLevel::Warn:
|
||||
current_log = [this] (const std::string& s) { warn(s); };
|
||||
break;
|
||||
|
||||
case Error:
|
||||
current_log = std::bind(&FLog::error, this, _1);
|
||||
case LogLevel::Error:
|
||||
current_log = [this] (const std::string& s) { error(s); };
|
||||
break;
|
||||
|
||||
case Debug:
|
||||
current_log = std::bind(&FLog::debug, this, _1);
|
||||
case LogLevel::Debug:
|
||||
current_log = [this] (const std::string& s) { debug(s); };
|
||||
break;
|
||||
}
|
||||
|
||||
@ -78,7 +73,6 @@ int FLog::sync()
|
||||
{
|
||||
if ( ! str().empty() )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock_guard(mut);
|
||||
current_log (str());
|
||||
str("");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2020 Markus Gans *
|
||||
* Copyright 2020-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -34,12 +34,7 @@ namespace finalcut
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FLogger::FLogger()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FLogger::~FLogger() // destructor
|
||||
{ }
|
||||
FLogger::~FLogger() noexcept = default; // destructor
|
||||
|
||||
|
||||
// private methods of FLogger
|
||||
@ -68,19 +63,17 @@ std::string FLogger::getTimeString() const
|
||||
struct tm time{};
|
||||
localtime_r (&t, &time);
|
||||
std::strftime (str.data(), str.size(), "%a, %d %b %Y %T %z", &time);
|
||||
return std::string(str.data());
|
||||
return {str.data()};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FLogger::getEOL()
|
||||
std::string FLogger::getEOL() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock_guard(getMutex());
|
||||
|
||||
if ( getEnding() == FLog::LF )
|
||||
if ( getEnding() == LineEnding::LF )
|
||||
return "\n";
|
||||
else if ( getEnding() == FLog::CR )
|
||||
else if ( getEnding() == LineEnding::CR )
|
||||
return "\r";
|
||||
else if ( getEnding() == FLog::CRLF )
|
||||
else if ( getEnding() == LineEnding::CRLF )
|
||||
return "\r\n";
|
||||
|
||||
return "";
|
||||
@ -91,20 +84,18 @@ void FLogger::printLogLine (const std::string& msg)
|
||||
{
|
||||
const std::string& log_level = [this] ()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock_guard(getMutex());
|
||||
|
||||
switch ( getLevel() )
|
||||
{
|
||||
case Info:
|
||||
case LogLevel::Info:
|
||||
return "INFO";
|
||||
|
||||
case Warn:
|
||||
case LogLevel::Warn:
|
||||
return "WARNING";
|
||||
|
||||
case Error:
|
||||
case LogLevel::Error:
|
||||
return "ERROR";
|
||||
|
||||
case Debug:
|
||||
case LogLevel::Debug:
|
||||
return "DEBUG";
|
||||
}
|
||||
|
||||
@ -123,6 +114,7 @@ void FLogger::printLogLine (const std::string& msg)
|
||||
const std::string& eol = getEOL();
|
||||
const std::string replace_str = eol + prefix;
|
||||
newlineReplace (message, replace_str);
|
||||
std::lock_guard<std::mutex> lock_guard(output_mutex);
|
||||
output << prefix << message << eol;
|
||||
}
|
||||
|
||||
|
296
src/fmenu.cpp
296
src/fmenu.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -137,50 +137,33 @@ void FMenu::onKeyPress (FKeyEvent* ev)
|
||||
if ( menu_bar && menu_bar->hotkeyMenu(ev) )
|
||||
return;
|
||||
|
||||
switch ( ev->key() )
|
||||
{
|
||||
case fc::Fkey_up:
|
||||
selectPrevItem();
|
||||
break;
|
||||
const auto key = ev->key();
|
||||
// Ignore these keys:
|
||||
// Dialog Switch Accelerator Handling in FApplication
|
||||
std::array<FKey, 9> ignore_list = // Meta-1..9
|
||||
{{
|
||||
FKey::Meta_1, FKey::Meta_2, FKey::Meta_3,
|
||||
FKey::Meta_4, FKey::Meta_5, FKey::Meta_6,
|
||||
FKey::Meta_7, FKey::Meta_8, FKey::Meta_9
|
||||
}};
|
||||
|
||||
case fc::Fkey_down:
|
||||
selectNextItem();
|
||||
break;
|
||||
if ( std::any_of( std::begin(ignore_list)
|
||||
, std::end(ignore_list)
|
||||
, [&key] (FKey k) { return key == k; } ) )
|
||||
return;
|
||||
|
||||
case fc::Fkey_left:
|
||||
selectPrevMenu(ev);
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
selectNextMenu(ev);
|
||||
break;
|
||||
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
acceptSelection();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
closeMenu();
|
||||
break;
|
||||
|
||||
case fc::Fmkey_1:
|
||||
case fc::Fmkey_2:
|
||||
case fc::Fmkey_3:
|
||||
case fc::Fmkey_4:
|
||||
case fc::Fmkey_5:
|
||||
case fc::Fmkey_6:
|
||||
case fc::Fmkey_7:
|
||||
case fc::Fmkey_8:
|
||||
case fc::Fmkey_9:
|
||||
// do nothing:
|
||||
// handle the dialog switch accelerator in FApplication
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( key == FKey::Up )
|
||||
selectPrevItem();
|
||||
else if ( key == FKey::Down )
|
||||
selectNextItem();
|
||||
else if ( key == FKey::Left )
|
||||
selectPrevMenu(ev);
|
||||
else if ( key == FKey::Right )
|
||||
selectNextMenu(ev);
|
||||
else if ( key == FKey::Return || key == FKey::Enter )
|
||||
acceptSelection();
|
||||
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
|
||||
closeMenu();
|
||||
|
||||
// always accept key event -> no forwarding to the parent widget
|
||||
ev->accept();
|
||||
@ -191,7 +174,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
shown_sub_menu = nullptr;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
if ( opened_sub_menu )
|
||||
{
|
||||
@ -231,7 +214,7 @@ void FMenu::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( mouse_down )
|
||||
@ -253,7 +236,7 @@ void FMenu::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( ! isWindowActive() )
|
||||
@ -279,19 +262,19 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||
|
||||
if ( ms.mouse_over_submenu )
|
||||
{
|
||||
passEventToSubMenu(std::move(*ev)); // Event handover to sub-menu
|
||||
passEventToSubMenu(*ev); // Event handover to sub-menu
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! ms.mouse_over_menu && ms.mouse_over_supermenu )
|
||||
{
|
||||
passEventToSuperMenu(std::move(*ev)); // Event handover to super-menu
|
||||
passEventToSuperMenu(*ev); // Event handover to super-menu
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ms.mouse_over_menubar )
|
||||
{
|
||||
passEventToMenuBar(std::move(*ev)); // Event handover to the menu bar
|
||||
passEventToMenuBar(*ev); // Event handover to the menu bar
|
||||
return;
|
||||
}
|
||||
|
||||
@ -390,7 +373,7 @@ bool FMenu::isSubMenu() const
|
||||
bool FMenu::isDialogMenu() const
|
||||
{
|
||||
const auto& super = getSuperMenu();
|
||||
return ( super ) ? super->isDialogWidget() : false;
|
||||
return super ? super->isDialogWidget() : false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -507,7 +490,7 @@ void FMenu::calculateDimensions()
|
||||
{
|
||||
item_width += 3;
|
||||
}
|
||||
else if ( accel_key )
|
||||
else if ( accel_key != FKey::None )
|
||||
{
|
||||
const std::size_t accel_len = FTerm::getKeyName(accel_key).getLength();
|
||||
item_width += accel_len + 2;
|
||||
@ -908,74 +891,50 @@ void FMenu::mouseMoveOverBorder (MouseStates& ms) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::passEventToSubMenu (const FMouseEvent&& ev)
|
||||
void FMenu::passEventToSubMenu (const FMouseEvent& ev)
|
||||
{
|
||||
// Mouse event handover to sub-menu
|
||||
|
||||
const auto& t = ev.getTermPos();
|
||||
const auto& p = opened_sub_menu->termToWidgetPos(t);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
opened_sub_menu->mouse_down = true;
|
||||
setClickedWidget(opened_sub_menu);
|
||||
opened_sub_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const MouseButton b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
opened_sub_menu->mouse_down = true;
|
||||
setClickedWidget(opened_sub_menu);
|
||||
opened_sub_menu->onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::passEventToSuperMenu (const FMouseEvent&& ev)
|
||||
void FMenu::passEventToSuperMenu (const FMouseEvent& ev)
|
||||
{
|
||||
// Mouse event handover to super-menu
|
||||
|
||||
auto smenu = superMenuAt (ev.getTermPos());
|
||||
const auto& t = ev.getTermPos();
|
||||
const auto& p = smenu->termToWidgetPos(t);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
smenu->mouse_down = true;
|
||||
setClickedWidget(smenu);
|
||||
smenu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const MouseButton b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
smenu->mouse_down = true;
|
||||
setClickedWidget(smenu);
|
||||
smenu->onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenu::passEventToMenuBar (const FMouseEvent&& ev) const
|
||||
void FMenu::passEventToMenuBar (const FMouseEvent& ev) const
|
||||
{
|
||||
// Mouse event handover to the menu bar
|
||||
|
||||
auto menu_bar = getMenuBar();
|
||||
const auto& t = ev.getTermPos();
|
||||
const auto& p = menu_bar->termToWidgetPos(t);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
setClickedWidget(menu_bar);
|
||||
menu_bar->mouse_down = true;
|
||||
menu_bar->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const MouseButton b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
setClickedWidget(menu_bar);
|
||||
menu_bar->mouse_down = true;
|
||||
menu_bar->onMouseMove(_ev.get());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1125,57 +1084,62 @@ void FMenu::keypressMenuBar (FKeyEvent* ev) const
|
||||
mbar->onKeyPress(ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline bool FMenu::hotkeyFound (FKey hotkey, const FKeyEvent& ev) const
|
||||
{
|
||||
bool found{false};
|
||||
const FKey key = ev.key();
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
{
|
||||
if ( FKey(std::tolower(int(hotkey))) == key
|
||||
|| FKey(std::toupper(int(hotkey))) == key )
|
||||
found = true;
|
||||
}
|
||||
else if ( hotkey == key )
|
||||
found = true;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenu::hotkeyMenu (FKeyEvent* ev)
|
||||
{
|
||||
auto try_to_open_submenu = [this] (FMenu* sub_menu)
|
||||
{
|
||||
if ( ! sub_menu->isShown() )
|
||||
openSubMenu (sub_menu, SELECT_ITEM);
|
||||
|
||||
sub_menu->redraw();
|
||||
};
|
||||
|
||||
for (auto&& item : getItemList())
|
||||
{
|
||||
if ( item->hasHotkey() )
|
||||
if ( item->hasHotkey() && hotkeyFound(item->getHotkey(), *ev) )
|
||||
{
|
||||
bool found{false};
|
||||
FKey hotkey = item->getHotkey();
|
||||
const FKey key = ev->key();
|
||||
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( std::isalpha(int(hotkey)) || std::isdigit(int(hotkey)) )
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
if ( FKey(std::tolower(int(hotkey))) == key
|
||||
|| FKey(std::toupper(int(hotkey))) == key )
|
||||
found = true;
|
||||
unselectItem();
|
||||
item->setSelected();
|
||||
setSelectedItem (item);
|
||||
redraw();
|
||||
try_to_open_submenu (item->getMenu());
|
||||
}
|
||||
else if ( hotkey == key )
|
||||
found = true;
|
||||
|
||||
if ( found )
|
||||
else
|
||||
{
|
||||
if ( item->hasMenu() )
|
||||
{
|
||||
auto sub_menu = item->getMenu();
|
||||
unselectItem();
|
||||
item->setSelected();
|
||||
setSelectedItem (item);
|
||||
redraw();
|
||||
|
||||
if ( ! sub_menu->isShown() )
|
||||
openSubMenu (sub_menu, SELECT_ITEM);
|
||||
|
||||
sub_menu->redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
unselectItem();
|
||||
hideSubMenus();
|
||||
hide();
|
||||
hideSuperMenus();
|
||||
ev->accept();
|
||||
item->processClicked();
|
||||
}
|
||||
|
||||
unselectItem();
|
||||
hideSubMenus();
|
||||
hide();
|
||||
hideSuperMenus();
|
||||
ev->accept();
|
||||
return true;
|
||||
item->processClicked();
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1229,19 +1193,19 @@ inline void FMenu::drawSeparator (int y)
|
||||
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
print (fc::NF_border_line_vertical_right);
|
||||
print (UniChar::NF_border_line_vertical_right);
|
||||
FString line { std::size_t(getWidth()) - 2
|
||||
, fc::BoxDrawingsHorizontal };
|
||||
, UniChar::BoxDrawingsHorizontal };
|
||||
print (line);
|
||||
print (fc::NF_rev_border_line_vertical_left);
|
||||
print (UniChar::NF_rev_border_line_vertical_left);
|
||||
}
|
||||
else
|
||||
{
|
||||
print (fc::BoxDrawingsVerticalAndRight);
|
||||
print (UniChar::BoxDrawingsVerticalAndRight);
|
||||
FString line { std::size_t(getWidth()) - 2
|
||||
, fc::BoxDrawingsHorizontal};
|
||||
, UniChar::BoxDrawingsHorizontal};
|
||||
print (line);
|
||||
print (fc::BoxDrawingsVerticalAndLeft);
|
||||
print (UniChar::BoxDrawingsVerticalAndLeft);
|
||||
}
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
@ -1284,7 +1248,7 @@ inline void FMenu::drawMenuLine (FMenuItem* m_item, int y)
|
||||
|
||||
if ( m_item->hasMenu() )
|
||||
drawSubMenuIndicator (column_width);
|
||||
else if ( accel_key )
|
||||
else if ( accel_key != FKey::None )
|
||||
drawAcceleratorKey (column_width, accel_key);
|
||||
|
||||
// Draw the trailing spaces of the selected line
|
||||
@ -1305,34 +1269,40 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item)
|
||||
if ( ! has_checkable_items )
|
||||
return;
|
||||
|
||||
auto print_bullet = [this] ()
|
||||
{
|
||||
if ( FTerm::isNewFont() )
|
||||
print (UniChar::NF_Bullet); // NF_Bullet ●
|
||||
else
|
||||
print (UniChar::BlackCircle); // BlackCircle ●
|
||||
};
|
||||
|
||||
auto print_check_mark = [this] ()
|
||||
{
|
||||
if ( FTerm::isNewFont() )
|
||||
print (UniChar::NF_check_mark); // NF_check_mark ✓
|
||||
else
|
||||
print (UniChar::SquareRoot); // SquareRoot √
|
||||
};
|
||||
|
||||
if ( is_checkable )
|
||||
{
|
||||
if ( is_checked )
|
||||
{
|
||||
if ( is_radio_btn )
|
||||
{
|
||||
if ( FTerm::isNewFont() )
|
||||
print (fc::NF_Bullet); // NF_Bullet ●
|
||||
else
|
||||
print (fc::BlackCircle); // BlackCircle ●
|
||||
}
|
||||
print_bullet();
|
||||
else
|
||||
{
|
||||
if ( FTerm::isNewFont() )
|
||||
print (fc::NF_check_mark); // NF_check_mark ✓
|
||||
else
|
||||
print (fc::SquareRoot); // SquareRoot √
|
||||
}
|
||||
print_check_mark();
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& wc = getColorTheme();
|
||||
setColor (wc->menu_inactive_fg, getBackgroundColor());
|
||||
|
||||
if ( FTerm::getEncoding() == fc::ASCII )
|
||||
if ( FTerm::getEncoding() == Encoding::ASCII )
|
||||
print ('-');
|
||||
else
|
||||
print (fc::SmallBullet); // ·
|
||||
print (UniChar::SmallBullet); // ·
|
||||
|
||||
setColor();
|
||||
}
|
||||
@ -1350,8 +1320,8 @@ inline void FMenu::drawMenuText (MenuText& data)
|
||||
{
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z]))
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark )
|
||||
&& ( data.text[z] < UniChar::NF_rev_left_arrow2
|
||||
|| data.text[z] > UniChar::NF_check_mark )
|
||||
&& ! FTerm::charEncodable(wchar_t(data.text[z])) )
|
||||
{
|
||||
data.text[z] = L' ';
|
||||
@ -1380,7 +1350,7 @@ inline void FMenu::drawMenuText (MenuText& data)
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
|
||||
{
|
||||
const std::size_t c = ( has_checkable_items ) ? 1 : 0;
|
||||
const std::size_t c = has_checkable_items ? 1 : 0;
|
||||
const std::size_t len = max_item_width - (startpos + c + 3);
|
||||
|
||||
if ( len > 0 )
|
||||
@ -1388,7 +1358,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
|
||||
// Print filling blank spaces
|
||||
print (FString{len, L' '});
|
||||
// Print BlackRightPointingPointer ►
|
||||
print (fc::BlackRightPointingPointer);
|
||||
print (UniChar::BlackRightPointingPointer);
|
||||
startpos = max_item_width - (c + 2);
|
||||
}
|
||||
}
|
||||
@ -1397,7 +1367,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
|
||||
inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
|
||||
{
|
||||
const FString accel_name {FTerm::getKeyName(accel_key)};
|
||||
const std::size_t c = ( has_checkable_items ) ? 1 : 0;
|
||||
const std::size_t c = has_checkable_items ? 1 : 0;
|
||||
const std::size_t accel_len = accel_name.getLength();
|
||||
const std::size_t plain_text_length = startpos + accel_len + c + 2;
|
||||
|
||||
@ -1414,7 +1384,7 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMenu::drawTrailingSpaces (std::size_t startpos)
|
||||
{
|
||||
const std::size_t c = ( has_checkable_items ) ? 1 : 0;
|
||||
const std::size_t c = has_checkable_items ? 1 : 0;
|
||||
|
||||
// Print trailing blank space
|
||||
for (std::size_t i = startpos + c; i < max_item_width - 1; i++)
|
||||
|
165
src/fmenubar.cpp
165
src/fmenubar.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -92,71 +92,52 @@ void FMenuBar::adjustSize()
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
switch ( ev->key() )
|
||||
const auto key = ev->key();
|
||||
|
||||
if ( key == FKey::Return
|
||||
|| key == FKey::Enter
|
||||
|| key == FKey::Up
|
||||
|| key == FKey::Down )
|
||||
{
|
||||
case fc::Fkey_return:
|
||||
case fc::Fkey_enter:
|
||||
case fc::Fkey_up:
|
||||
case fc::Fkey_down:
|
||||
if ( hasSelectedItem() )
|
||||
if ( hasSelectedItem() )
|
||||
{
|
||||
auto sel_item = getSelectedItem();
|
||||
|
||||
if ( sel_item->hasMenu() )
|
||||
{
|
||||
auto sel_item = getSelectedItem();
|
||||
|
||||
if ( sel_item->hasMenu() )
|
||||
{
|
||||
auto menu = sel_item->getMenu();
|
||||
sel_item->openMenu();
|
||||
menu->selectFirstItem();
|
||||
auto first_item = menu->getSelectedItem();
|
||||
|
||||
if ( first_item )
|
||||
first_item->setFocus();
|
||||
|
||||
menu->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
|
||||
redraw();
|
||||
drop_down = true;
|
||||
}
|
||||
else if ( ev->key() == fc::Fkey_return
|
||||
|| ev->key() == fc::Fkey_enter )
|
||||
{
|
||||
unselectItem();
|
||||
redraw();
|
||||
sel_item->processClicked();
|
||||
}
|
||||
openMenu (sel_item);
|
||||
}
|
||||
else if ( key == FKey::Return || key == FKey::Enter )
|
||||
{
|
||||
unselectItem();
|
||||
redraw();
|
||||
sel_item->processClicked();
|
||||
}
|
||||
}
|
||||
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_left:
|
||||
selectPrevItem();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_right:
|
||||
selectNextItem();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_escape:
|
||||
case fc::Fkey_escape_mintty:
|
||||
leaveMenuBar();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Left )
|
||||
{
|
||||
selectPrevItem();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Right )
|
||||
{
|
||||
selectNextItem();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Escape || key == FKey::Escape_mintty )
|
||||
{
|
||||
leaveMenuBar();
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
@ -186,7 +167,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( mouse_down )
|
||||
@ -201,7 +182,7 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( ! isWindowActive() )
|
||||
@ -209,7 +190,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||
|
||||
// Handle menu entries
|
||||
if ( mouse_down )
|
||||
mouseMoveOverList(std::move(*ev));
|
||||
mouseMoveOverList(*ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -254,9 +235,9 @@ void FMenuBar::init()
|
||||
if ( getRootWidget() )
|
||||
getRootWidget()->setTopPadding(1, true);
|
||||
|
||||
addAccelerator (fc::Fkey_f10);
|
||||
addAccelerator (fc::Fckey_space);
|
||||
addAccelerator (fc::Fkey_menu);
|
||||
addAccelerator (FKey::F10);
|
||||
addAccelerator (FKey::Ctrl_space);
|
||||
addAccelerator (FKey::Menu);
|
||||
resetColors();
|
||||
unsetFocusable();
|
||||
}
|
||||
@ -312,7 +293,7 @@ bool FMenuBar::selectNextItem()
|
||||
if ( next == *iter )
|
||||
return false;
|
||||
|
||||
setTerminalUpdates (FVTerm::stop_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Stop);
|
||||
unselectItem();
|
||||
next->setSelected();
|
||||
setSelectedItem(next);
|
||||
@ -335,7 +316,7 @@ bool FMenuBar::selectNextItem()
|
||||
getStatusBar()->drawMessage();
|
||||
|
||||
redraw();
|
||||
setTerminalUpdates (FVTerm::start_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Start);
|
||||
forceTerminalUpdate();
|
||||
break;
|
||||
}
|
||||
@ -377,7 +358,7 @@ bool FMenuBar::selectPrevItem()
|
||||
if ( prev == *iter )
|
||||
return false;
|
||||
|
||||
setTerminalUpdates (FVTerm::stop_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Stop);
|
||||
unselectItem();
|
||||
prev->setSelected();
|
||||
prev->setFocus();
|
||||
@ -400,7 +381,7 @@ bool FMenuBar::selectPrevItem()
|
||||
|
||||
setSelectedItem(prev);
|
||||
redraw();
|
||||
setTerminalUpdates (FVTerm::start_terminal_updates);
|
||||
setTerminalUpdates (FVTerm::TerminalUpdate::Start);
|
||||
forceTerminalUpdate();
|
||||
break;
|
||||
}
|
||||
@ -423,7 +404,7 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey))) == key )
|
||||
if ( FKey::Meta_offset + FKey(std::tolower(int(hotkey))) == key )
|
||||
{
|
||||
auto sel_item = getSelectedItem();
|
||||
|
||||
@ -607,8 +588,8 @@ inline void FMenuBar::drawMenuText (menuText& data)
|
||||
|
||||
if ( ! std::iswprint(std::wint_t(data.text[z]))
|
||||
&& ! FTerm::isNewFont()
|
||||
&& ( data.text[z] < fc::NF_rev_left_arrow2
|
||||
|| data.text[z] > fc::NF_check_mark ) )
|
||||
&& ( data.text[z] < UniChar::NF_rev_left_arrow2
|
||||
|| data.text[z] > UniChar::NF_check_mark ) )
|
||||
{
|
||||
data.text[z] = L' ';
|
||||
}
|
||||
@ -732,6 +713,26 @@ void FMenuBar::selectMenuItem (FMenuItem* item)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::openMenu (const FMenuItem* sel_item)
|
||||
{
|
||||
auto menu = sel_item->getMenu();
|
||||
sel_item->openMenu();
|
||||
menu->selectFirstItem();
|
||||
auto first_item = menu->getSelectedItem();
|
||||
|
||||
if ( first_item )
|
||||
first_item->setFocus();
|
||||
|
||||
menu->redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
|
||||
redraw();
|
||||
drop_down = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuBar::activateMenu (const FMenuItem* item)
|
||||
{
|
||||
@ -868,7 +869,7 @@ void FMenuBar::mouseUpOverList (const FMouseEvent* ev)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::mouseMoveOverList (const FMouseEvent&& ev)
|
||||
void FMenuBar::mouseMoveOverList (const FMouseEvent& ev)
|
||||
{
|
||||
auto list = getItemList();
|
||||
|
||||
@ -905,7 +906,7 @@ void FMenuBar::mouseMoveOverList (const FMouseEvent&& ev)
|
||||
else
|
||||
{
|
||||
// Event handover to the menu
|
||||
passEventToMenu(std::move(ev));
|
||||
passEventToMenu(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -926,7 +927,7 @@ void FMenuBar::mouseMoveOverList (const FMouseEvent&& ev)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuBar::passEventToMenu (const FMouseEvent&& ev) const
|
||||
void FMenuBar::passEventToMenu (const FMouseEvent& ev) const
|
||||
{
|
||||
if ( ! hasSelectedItem() || ! getSelectedItem()->hasMenu() )
|
||||
return;
|
||||
@ -940,20 +941,12 @@ void FMenuBar::passEventToMenu (const FMouseEvent&& ev) const
|
||||
{
|
||||
const auto& t = ev.getTermPos();
|
||||
const auto& p = menu->termToWidgetPos(t);
|
||||
const int b = ev.getButton();
|
||||
|
||||
try
|
||||
{
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(fc::MouseMove_Event, p, t, b);
|
||||
menu->mouse_down = true;
|
||||
setClickedWidget(menu);
|
||||
menu->onMouseMove(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
}
|
||||
const MouseButton b = ev.getButton();
|
||||
const auto& _ev = \
|
||||
std::make_shared<FMouseEvent>(Event::MouseMove, p, t, b);
|
||||
menu->mouse_down = true;
|
||||
setClickedWidget(menu);
|
||||
menu->onMouseMove(_ev.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -96,7 +96,7 @@ bool FMenuItem::setEnable (bool enable)
|
||||
if ( super && isMenuBar(super) )
|
||||
{
|
||||
// Meta + hotkey
|
||||
super->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
|
||||
super->addAccelerator ( FKey::Meta_offset + FKey(std::tolower(int(hotkey)))
|
||||
, this );
|
||||
}
|
||||
}
|
||||
@ -171,17 +171,7 @@ void FMenuItem::unsetSelected()
|
||||
void FMenuItem::setText (const FString& txt)
|
||||
{
|
||||
text.setString(txt);
|
||||
text_length = text.getLength();
|
||||
text_width = getColumnWidth(txt);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
updateSuperMenuDimensions();
|
||||
calculateTextDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -213,7 +203,7 @@ void FMenuItem::delAccelerator (FWidget* obj)
|
||||
{
|
||||
if ( iter->object == obj )
|
||||
{
|
||||
accel_key = 0;
|
||||
accel_key = FKey::None;
|
||||
iter = list.erase(iter);
|
||||
}
|
||||
else
|
||||
@ -287,19 +277,19 @@ void FMenuItem::onMouseDoubleClick (FMouseEvent* ev)
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
auto smenu = static_cast<FMenu*>(super_menu);
|
||||
passMouseEvent (smenu, ev, fc::MouseDoubleClick_Event);
|
||||
passMouseEvent (smenu, ev, Event::MouseDoubleClick);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
auto mbar = static_cast<FMenuBar*>(super_menu);
|
||||
passMouseEvent (mbar, ev, fc::MouseDoubleClick_Event);
|
||||
passMouseEvent (mbar, ev, Event::MouseDoubleClick);
|
||||
}
|
||||
|
||||
if ( isDialog(super_menu) )
|
||||
{
|
||||
auto dgl = static_cast<FDialog*>(super_menu);
|
||||
passMouseEvent (dgl, ev, fc::MouseDoubleClick_Event);
|
||||
passMouseEvent (dgl, ev, Event::MouseDoubleClick);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,19 +302,19 @@ void FMenuItem::onMouseDown (FMouseEvent* ev)
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
auto smenu = static_cast<FMenu*>(super_menu);
|
||||
passMouseEvent (smenu, ev, fc::MouseDown_Event);
|
||||
passMouseEvent (smenu, ev, Event::MouseDown);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
auto mbar = static_cast<FMenuBar*>(super_menu);
|
||||
passMouseEvent (mbar, ev, fc::MouseDown_Event);
|
||||
passMouseEvent (mbar, ev, Event::MouseDown);
|
||||
}
|
||||
|
||||
if ( isDialog(super_menu) )
|
||||
{
|
||||
auto dgl = static_cast<FDialog*>(super_menu);
|
||||
passMouseEvent (dgl, ev, fc::MouseDown_Event);
|
||||
passMouseEvent (dgl, ev, Event::MouseDown);
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,19 +327,19 @@ void FMenuItem::onMouseUp (FMouseEvent* ev)
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
auto smenu = static_cast<FMenu*>(super_menu);
|
||||
passMouseEvent (smenu, ev, fc::MouseUp_Event);
|
||||
passMouseEvent (smenu, ev, Event::MouseUp);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
auto mbar = static_cast<FMenuBar*>(super_menu);
|
||||
passMouseEvent (mbar, ev, fc::MouseUp_Event);
|
||||
passMouseEvent (mbar, ev, Event::MouseUp);
|
||||
}
|
||||
|
||||
if ( isDialog(super_menu) )
|
||||
{
|
||||
auto dgl = static_cast<FDialog*>(super_menu);
|
||||
passMouseEvent (dgl, ev, fc::MouseUp_Event);
|
||||
passMouseEvent (dgl, ev, Event::MouseUp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,19 +352,19 @@ void FMenuItem::onMouseMove (FMouseEvent* ev)
|
||||
if ( isMenu(super_menu) )
|
||||
{
|
||||
auto smenu = static_cast<FMenu*>(super_menu);
|
||||
passMouseEvent (smenu, ev, fc::MouseMove_Event);
|
||||
passMouseEvent (smenu, ev, Event::MouseMove);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
auto mbar = static_cast<FMenuBar*>(super_menu);
|
||||
passMouseEvent (mbar, ev, fc::MouseMove_Event);
|
||||
passMouseEvent (mbar, ev, Event::MouseMove);
|
||||
}
|
||||
|
||||
if ( isDialog(super_menu) )
|
||||
{
|
||||
auto dgl = static_cast<FDialog*>(super_menu);
|
||||
passMouseEvent (dgl, ev, fc::MouseMove_Event);
|
||||
passMouseEvent (dgl, ev, Event::MouseMove);
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,13 +451,13 @@ void FMenuItem::onFocusOut (FFocusEvent*)
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isDialog (const FWidget* w) const
|
||||
{
|
||||
return ( w ) ? w->isDialogWidget() : false;
|
||||
return w ? w->isDialogWidget() : false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMenuItem::isMenuBar (const FWidget* w) const
|
||||
{
|
||||
return ( w ) ? w->isInstanceOf("FMenuBar") : false;
|
||||
return w ? w->isInstanceOf("FMenuBar") : false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -478,9 +468,14 @@ bool FMenuItem::isMenu (const FWidget* w) const
|
||||
|
||||
const bool m1 = w->isInstanceOf("FMenu");
|
||||
const bool m2 = w->isInstanceOf("FDialogListMenu");
|
||||
return bool( m1 || m2 );
|
||||
return m1 || m2;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::initLayout()
|
||||
{
|
||||
calculateTextDimensions();
|
||||
}
|
||||
|
||||
// private methods of FMenuItem
|
||||
//----------------------------------------------------------------------
|
||||
@ -512,7 +507,7 @@ void FMenuItem::init()
|
||||
if ( hotkey > 0xff00 && hotkey < 0xff5f ) // full-width character
|
||||
hotkey -= 0xfee0;
|
||||
|
||||
if ( hotkey )
|
||||
if ( hotkey != FKey::None )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
@ -526,7 +521,7 @@ void FMenuItem::init()
|
||||
|
||||
setSuperMenu (parent);
|
||||
|
||||
if ( accel_key )
|
||||
if ( accel_key != FKey::None )
|
||||
addAccelerator (accel_key);
|
||||
|
||||
auto menu_list = getFMenuList(*parent);
|
||||
@ -539,8 +534,8 @@ void FMenuItem::init()
|
||||
auto menubar_ptr = static_cast<FMenuBar*>(parent);
|
||||
menubar_ptr->calculateDimensions();
|
||||
|
||||
if ( hotkey ) // Meta + hotkey
|
||||
menubar_ptr->addAccelerator ( fc::Fmkey_meta + FKey(std::tolower(int(hotkey)))
|
||||
if ( hotkey != FKey::None ) // Meta + hotkey
|
||||
menubar_ptr->addAccelerator ( FKey::Meta_offset + FKey(std::tolower(int(hotkey)))
|
||||
, this );
|
||||
|
||||
addCallback // for this element
|
||||
@ -557,6 +552,23 @@ void FMenuItem::init()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::calculateTextDimensions()
|
||||
{
|
||||
text_length = text.getLength();
|
||||
text_width = getColumnWidth(text);
|
||||
hotkey = finalcut::getHotkey(text);
|
||||
|
||||
if ( hotkey != FKey::None )
|
||||
{
|
||||
text_length--;
|
||||
text_width--;
|
||||
}
|
||||
|
||||
updateMenubarDimensions();
|
||||
updateSuperMenuDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::updateSuperMenuDimensions()
|
||||
{
|
||||
@ -567,6 +579,18 @@ void FMenuItem::updateSuperMenuDimensions()
|
||||
menu_ptr->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::updateMenubarDimensions() const
|
||||
{
|
||||
FWidget* parent = getParentWidget();
|
||||
|
||||
if ( ! parent || ! isMenuBar(parent) )
|
||||
return;
|
||||
|
||||
auto menubar_ptr = static_cast<FMenuBar*>(parent);
|
||||
menubar_ptr->calculateDimensions();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMenuItem::processEnable() const
|
||||
{
|
||||
@ -621,7 +645,7 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
|
||||
}
|
||||
|
||||
if ( n < 9 )
|
||||
win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9
|
||||
win_item->addAccelerator (FKey::Meta_1 + n); // Meta + 1..9
|
||||
|
||||
win_item->addCallback
|
||||
(
|
||||
@ -650,46 +674,31 @@ void FMenuItem::createDialogList (FMenu* winmenu) const
|
||||
//----------------------------------------------------------------------
|
||||
template <typename T>
|
||||
void FMenuItem::passMouseEvent ( T widget, const FMouseEvent* ev
|
||||
, fc::events ev_type ) const
|
||||
, Event ev_type ) const
|
||||
{
|
||||
if ( ! widget )
|
||||
return;
|
||||
|
||||
const auto& t = ev->getTermPos();
|
||||
const auto& p2 = widget->termToWidgetPos(t);
|
||||
const int b = ev->getButton();
|
||||
std::shared_ptr<FMouseEvent> _ev;
|
||||
const auto b = ev->getButton();
|
||||
auto _ev = std::make_shared<FMouseEvent>(ev_type, p2, t, b);
|
||||
|
||||
try
|
||||
if ( ev_type == Event::MouseDoubleClick )
|
||||
{
|
||||
_ev = std::make_shared<FMouseEvent>(ev_type, p2, t, b);
|
||||
widget->onMouseDoubleClick(_ev.get());
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
else if ( ev_type == Event::MouseDown )
|
||||
{
|
||||
badAllocOutput ("FMouseEvent");
|
||||
return;
|
||||
widget->onMouseDown(_ev.get());
|
||||
}
|
||||
|
||||
switch ( int(ev_type) )
|
||||
else if ( ev_type == Event::MouseUp )
|
||||
{
|
||||
case fc::MouseDoubleClick_Event:
|
||||
widget->onMouseDoubleClick(_ev.get());
|
||||
break;
|
||||
|
||||
case fc::MouseDown_Event:
|
||||
widget->onMouseDown(_ev.get());
|
||||
break;
|
||||
|
||||
case fc::MouseUp_Event:
|
||||
widget->onMouseUp(_ev.get());
|
||||
break;
|
||||
|
||||
case fc::MouseMove_Event:
|
||||
widget->onMouseMove(_ev.get());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
widget->onMouseUp(_ev.get());
|
||||
}
|
||||
else if ( ev_type == Event::MouseMove )
|
||||
{
|
||||
widget->onMouseMove(_ev.get());
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,7 +709,7 @@ void FMenuItem::cb_switchToDialog (FDialog* win) const
|
||||
return;
|
||||
|
||||
auto focus = getFocusWidget();
|
||||
FAccelEvent a_ev (fc::Accelerator_Event, focus);
|
||||
FAccelEvent a_ev (Event::Accelerator, focus);
|
||||
FApplication::sendEvent (win, &a_ev);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -51,31 +51,12 @@ constexpr std::array<const char* const, 8> button_text =
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::FMessageBox (FWidget* parent)
|
||||
: FDialog{parent}
|
||||
, button_digit{FMessageBox::Ok, FMessageBox::Reject, FMessageBox::Reject}
|
||||
, button_digit{{ButtonType::Ok, ButtonType::Reject, ButtonType::Reject}}
|
||||
{
|
||||
setTitlebarText("Message for you");
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::FMessageBox (const FMessageBox& mbox)
|
||||
: FDialog{mbox.getParentWidget()}
|
||||
, headline_text{mbox.headline_text}
|
||||
, text{mbox.text}
|
||||
, text_components{mbox.text_components}
|
||||
, max_line_width{mbox.max_line_width}
|
||||
, emphasis_color{mbox.emphasis_color}
|
||||
, button_digit{mbox.button_digit[0],
|
||||
mbox.button_digit[1],
|
||||
mbox.button_digit[2]}
|
||||
, num_buttons{mbox.num_buttons}
|
||||
, text_num_lines{mbox.text_num_lines}
|
||||
, center_text{mbox.center_text}
|
||||
{
|
||||
setTitlebarText (mbox.getTitlebarText());
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::FMessageBox ( const FString& caption
|
||||
, const FString& message
|
||||
@ -85,54 +66,17 @@ FMessageBox::FMessageBox ( const FString& caption
|
||||
, FWidget* parent )
|
||||
: FDialog{parent}
|
||||
, text{message}
|
||||
, button_digit{button0, button1, button2}
|
||||
, button_digit{{button0, button1, button2}}
|
||||
{
|
||||
setTitlebarText(caption);
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::~FMessageBox() // destructor
|
||||
{
|
||||
deallocation();
|
||||
}
|
||||
FMessageBox::~FMessageBox() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FMessageBox
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox& FMessageBox::operator = (const FMessageBox& mbox)
|
||||
{
|
||||
if ( &mbox == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
if ( button[n] )
|
||||
delete button[n];
|
||||
|
||||
if ( mbox.getParentWidget() )
|
||||
mbox.getParentWidget()->addChild (this);
|
||||
|
||||
setTitlebarText (mbox.getTitlebarText());
|
||||
headline_text = mbox.headline_text;
|
||||
text = mbox.text;
|
||||
text_components = mbox.text_components;
|
||||
max_line_width = mbox.max_line_width;
|
||||
center_text = mbox.center_text;
|
||||
emphasis_color = mbox.emphasis_color;
|
||||
num_buttons = mbox.num_buttons;
|
||||
text_num_lines = mbox.text_num_lines;
|
||||
button_digit[0] = mbox.button_digit[0];
|
||||
button_digit[1] = mbox.button_digit[1];
|
||||
button_digit[2] = mbox.button_digit[2];
|
||||
init();
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::setHeadline (const FString& headline)
|
||||
{
|
||||
@ -158,17 +102,31 @@ void FMessageBox::setText (const FString& txt)
|
||||
if ( button[0] )
|
||||
button[0]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
if ( button[1] && button_digit[1] != FMessageBox::Reject )
|
||||
if ( button[1] && button_digit[1] != ButtonType::Reject )
|
||||
button[1]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
if ( button[2] && button_digit[2] != FMessageBox::Reject )
|
||||
if ( button[2] && button_digit[2] != ButtonType::Reject )
|
||||
button[2]->setY (int(getHeight()) - 4, false);
|
||||
|
||||
adjustButtons();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMessageBox::ButtonType FMessageBox::exec()
|
||||
{
|
||||
result_code = ButtonType::Reject;
|
||||
show();
|
||||
return result_code;
|
||||
}
|
||||
|
||||
// protected methods of FMessageBox
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::initLayout()
|
||||
{
|
||||
calculateDimensions();
|
||||
adjustButtons();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::adjustSize()
|
||||
{
|
||||
@ -194,10 +152,17 @@ void FMessageBox::adjustSize()
|
||||
FDialog::adjustSize();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::done (ButtonType result)
|
||||
{
|
||||
hide();
|
||||
result_code = result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::cb_processClick (ButtonType reply)
|
||||
{
|
||||
done(int(reply));
|
||||
done(reply);
|
||||
}
|
||||
|
||||
|
||||
@ -207,21 +172,21 @@ void FMessageBox::init()
|
||||
{
|
||||
calculateDimensions();
|
||||
|
||||
if ( (button_digit[2] != Reject && button_digit[1] == Reject)
|
||||
|| (button_digit[1] != Reject && button_digit[0] == Reject) )
|
||||
if ( (button_digit[2] != ButtonType::Reject && button_digit[1] == ButtonType::Reject)
|
||||
|| (button_digit[1] != ButtonType::Reject && button_digit[0] == ButtonType::Reject) )
|
||||
{
|
||||
button_digit[0] = button_digit[1] \
|
||||
= button_digit[2] \
|
||||
= FMessageBox::Reject;
|
||||
= ButtonType::Reject;
|
||||
}
|
||||
|
||||
if ( button_digit[0] == FMessageBox::Reject )
|
||||
button_digit[0] = FMessageBox::Ok;
|
||||
if ( button_digit[0] == ButtonType::Reject )
|
||||
button_digit[0] = ButtonType::Ok;
|
||||
|
||||
if ( button_digit[1] == FMessageBox::Reject
|
||||
&& button_digit[2] == FMessageBox::Reject )
|
||||
if ( button_digit[1] == ButtonType::Reject
|
||||
&& button_digit[2] == ButtonType::Reject )
|
||||
num_buttons = 1;
|
||||
else if ( button_digit[2] == FMessageBox::Reject )
|
||||
else if ( button_digit[2] == ButtonType::Reject )
|
||||
num_buttons = 2;
|
||||
else
|
||||
num_buttons = 3;
|
||||
@ -238,26 +203,26 @@ inline void FMessageBox::allocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
button[0] = new FButton (this);
|
||||
button[0]->setText(button_text[button_digit[0]]);
|
||||
button[0].reset(new FButton (this));
|
||||
button[0]->setText(button_text[std::size_t(button_digit[0])]);
|
||||
button[0]->setPos(FPoint{3, int(getHeight()) - 4}, false);
|
||||
button[0]->setWidth(1, false);
|
||||
button[0]->setHeight(1, false);
|
||||
button[0]->setFocus();
|
||||
|
||||
if ( button_digit[1] > FMessageBox::Reject )
|
||||
if ( button_digit[1] > ButtonType::Reject )
|
||||
{
|
||||
button[1] = new FButton(this);
|
||||
button[1]->setText(button_text[button_digit[1]]);
|
||||
button[1].reset(new FButton(this));
|
||||
button[1]->setText(button_text[std::size_t(button_digit[1])]);
|
||||
button[1]->setPos(FPoint{17, int(getHeight()) - 4}, false);
|
||||
button[1]->setWidth(0, false);
|
||||
button[1]->setHeight(1, false);
|
||||
}
|
||||
|
||||
if ( button_digit[2] > FMessageBox::Reject )
|
||||
if ( button_digit[2] > ButtonType::Reject )
|
||||
{
|
||||
button[2] = new FButton(this);
|
||||
button[2]->setText(button_text[button_digit[2]]);
|
||||
button[2].reset(new FButton(this));
|
||||
button[2]->setText(button_text[std::size_t(button_digit[2])]);
|
||||
button[2]->setPos(FPoint{32, int(getHeight()) - 4}, false);
|
||||
button[2]->setWidth(0, false);
|
||||
button[2]->setHeight(1, false);
|
||||
@ -270,18 +235,10 @@ inline void FMessageBox::allocation()
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMessageBox::deallocation()
|
||||
{
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
if ( button[n] )
|
||||
delete button[n];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FMessageBox::initCallbacks()
|
||||
{
|
||||
if ( button[0] && button_digit[0] != FMessageBox::Reject )
|
||||
if ( button[0] && button_digit[0] != ButtonType::Reject )
|
||||
{
|
||||
button[0]->addCallback
|
||||
(
|
||||
@ -291,7 +248,7 @@ inline void FMessageBox::initCallbacks()
|
||||
);
|
||||
}
|
||||
|
||||
if ( button[1] && button_digit[1] != FMessageBox::Reject )
|
||||
if ( button[1] && button_digit[1] != ButtonType::Reject )
|
||||
{
|
||||
button[1]->addCallback
|
||||
(
|
||||
@ -301,7 +258,7 @@ inline void FMessageBox::initCallbacks()
|
||||
);
|
||||
}
|
||||
|
||||
if ( button[2] && button_digit[2] != FMessageBox::Reject )
|
||||
if ( button[2] && button_digit[2] != ButtonType::Reject )
|
||||
{
|
||||
button[2]->addCallback
|
||||
(
|
||||
@ -391,7 +348,7 @@ void FMessageBox::draw()
|
||||
//----------------------------------------------------------------------
|
||||
void FMessageBox::resizeButtons() const
|
||||
{
|
||||
std::array<std::size_t, 3> len{};
|
||||
std::array<std::size_t, MAX_BUTTONS> len{};
|
||||
std::size_t max_size{};
|
||||
|
||||
for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++)
|
||||
@ -446,7 +403,7 @@ void FMessageBox::adjustButtons()
|
||||
std::size_t max_width;
|
||||
const auto& root_widget = getRootWidget();
|
||||
setWidth(btn_width + 5);
|
||||
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80;
|
||||
max_width = root_widget ? root_widget->getClientWidth() : 80;
|
||||
setX (int((max_width - getWidth()) / 2));
|
||||
}
|
||||
|
||||
|
326
src/fmouse.cpp
326
src/fmouse.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -34,6 +34,7 @@
|
||||
#include "final/fmouse.h"
|
||||
#include "final/fobject.h"
|
||||
#include "final/fterm.h"
|
||||
#include "final/ftermlinux.h"
|
||||
#include "final/ftermxterminal.h"
|
||||
#include "final/ftypes.h"
|
||||
|
||||
@ -44,14 +45,10 @@ namespace finalcut
|
||||
// class FMouseData
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FMouseData::FMouseData()
|
||||
{ }
|
||||
FMouseData::~FMouseData() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouseData::~FMouseData()
|
||||
{ }
|
||||
|
||||
// public methods of FMouseData
|
||||
//----------------------------------------------------------------------
|
||||
@ -65,88 +62,96 @@ const FPoint& FMouseData::getPos() const
|
||||
{
|
||||
return mouse;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isLeftButtonPressed() const
|
||||
{
|
||||
return bool(getButtonState().left_button == Pressed);
|
||||
return getButtonState().left_button == State::Pressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isLeftButtonReleased() const
|
||||
{
|
||||
return bool(getButtonState().left_button == Released);
|
||||
return getButtonState().left_button == State::Released;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isLeftButtonDoubleClick() const
|
||||
{
|
||||
return bool(getButtonState().left_button == DoubleClick);
|
||||
return getButtonState().left_button == State::DoubleClick;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isRightButtonPressed() const
|
||||
{
|
||||
return bool(getButtonState().right_button == Pressed);
|
||||
return getButtonState().right_button == State::Pressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isRightButtonReleased() const
|
||||
{
|
||||
return bool(getButtonState().right_button == Released);
|
||||
return getButtonState().right_button == State::Released;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isMiddleButtonPressed() const
|
||||
{
|
||||
return bool(getButtonState().middle_button == Pressed);
|
||||
return getButtonState().middle_button == State::Pressed;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isMiddleButtonReleased() const
|
||||
{
|
||||
return bool(getButtonState().middle_button == Released);
|
||||
return getButtonState().middle_button == State::Released;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isShiftKeyPressed() const
|
||||
{
|
||||
return bool(getButtonState().shift_button);
|
||||
return getButtonState().shift_button;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isControlKeyPressed() const
|
||||
{
|
||||
return bool(getButtonState().control_button);
|
||||
return getButtonState().control_button;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isMetaKeyPressed() const
|
||||
{
|
||||
return bool(getButtonState().meta_button);
|
||||
return getButtonState().meta_button;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isWheelUp() const
|
||||
{
|
||||
return bool(getButtonState().wheel_up);
|
||||
return getButtonState().wheel_up;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isWheelDown() const
|
||||
{
|
||||
return bool(getButtonState().wheel_down);
|
||||
return getButtonState().wheel_down;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseData::isMoved() const
|
||||
{
|
||||
return bool(getButtonState().mouse_moved);
|
||||
return getButtonState().mouse_moved;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseData::clearButtonState()
|
||||
{
|
||||
// Fill bit field with 0
|
||||
std::memset(&b_state, 0x00, sizeof(b_state));
|
||||
b_state.left_button = State::Undefined;
|
||||
b_state.right_button = State::Undefined;
|
||||
b_state.middle_button = State::Undefined;
|
||||
b_state.shift_button = false;
|
||||
b_state.control_button = false;
|
||||
b_state.meta_button = false;
|
||||
b_state.wheel_up = false;
|
||||
b_state.wheel_down = false;
|
||||
b_state.mouse_moved = false;
|
||||
}
|
||||
|
||||
|
||||
@ -182,10 +187,6 @@ FMouse::FMouse()
|
||||
clearButtonState();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouse::~FMouse() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FMouse
|
||||
//----------------------------------------------------------------------
|
||||
@ -313,10 +314,6 @@ FMouseGPM::FMouseGPM()
|
||||
gpm_ev.x = -1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouseGPM::~FMouseGPM() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FMouseX11
|
||||
//----------------------------------------------------------------------
|
||||
@ -385,7 +382,7 @@ void FMouseGPM::processEvent (struct timeval*)
|
||||
setPos (FPoint{ std::max(gpm_ev.x, sInt16(1))
|
||||
, std::max(gpm_ev.y, sInt16(1)) });
|
||||
|
||||
if ( gpmEvent(false) == mouse_event )
|
||||
if ( gpmEvent(false) == gpmEventType::Mouse )
|
||||
setPending(true);
|
||||
else
|
||||
setPending(false);
|
||||
@ -445,16 +442,16 @@ void FMouseGPM::interpretKeyDown()
|
||||
if ( gpm_ev.buttons & GPM_B_LEFT )
|
||||
{
|
||||
if ( gpm_ev.type & GPM_DOUBLE )
|
||||
getButtonState().left_button = DoubleClick;
|
||||
getButtonState().left_button = State::DoubleClick;
|
||||
else
|
||||
getButtonState().left_button = Pressed;
|
||||
getButtonState().left_button = State::Pressed;
|
||||
}
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_MIDDLE )
|
||||
getButtonState().middle_button = Pressed;
|
||||
getButtonState().middle_button = State::Pressed;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_RIGHT )
|
||||
getButtonState().right_button = Pressed;
|
||||
getButtonState().right_button = State::Pressed;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_UP )
|
||||
getButtonState().wheel_up = true;
|
||||
@ -477,13 +474,13 @@ void FMouseGPM::interpretKeyDown()
|
||||
void FMouseGPM::interpretKeyUp()
|
||||
{
|
||||
if ( gpm_ev.buttons & GPM_B_LEFT )
|
||||
getButtonState().left_button = Released;
|
||||
getButtonState().left_button = State::Released;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_MIDDLE )
|
||||
getButtonState().middle_button = Released;
|
||||
getButtonState().middle_button = State::Released;
|
||||
|
||||
if ( gpm_ev.buttons & GPM_B_RIGHT )
|
||||
getButtonState().right_button = Released;
|
||||
getButtonState().right_button = State::Released;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -491,33 +488,25 @@ bool FMouseGPM::getGpmKeyPressed (bool is_pending)
|
||||
{
|
||||
setPending(is_pending);
|
||||
has_gpm_mouse_data = false;
|
||||
const int type = gpmEvent();
|
||||
const auto type = gpmEvent();
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case mouse_event:
|
||||
has_gpm_mouse_data = true;
|
||||
break;
|
||||
|
||||
case keyboard_event:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if ( type == gpmEventType::Mouse )
|
||||
has_gpm_mouse_data = true;
|
||||
else if ( type == gpmEventType::Keyboard )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseGPM::drawGpmPointer() const
|
||||
void FMouseGPM::drawPointer() const
|
||||
{
|
||||
if ( isGpmMouseEnabled() && gpm_ev.x != -1 )
|
||||
GPM_DRAWPOINTER(&gpm_ev);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FMouseGPM::gpmEvent (bool clear) const
|
||||
FMouseGPM::gpmEventType FMouseGPM::gpmEvent (bool clear) const
|
||||
{
|
||||
const int max = ( gpm_fd > stdin_no ) ? gpm_fd : stdin_no;
|
||||
fd_set ifds{};
|
||||
@ -535,16 +524,16 @@ int FMouseGPM::gpmEvent (bool clear) const
|
||||
if ( clear )
|
||||
FD_CLR (stdin_no, &ifds);
|
||||
|
||||
return keyboard_event;
|
||||
return gpmEventType::Keyboard;
|
||||
}
|
||||
|
||||
if ( clear && result > 0 && FD_ISSET(gpm_fd, &ifds) )
|
||||
FD_CLR (gpm_fd, &ifds);
|
||||
|
||||
if ( result > 0 )
|
||||
return mouse_event;
|
||||
return gpmEventType::Mouse;
|
||||
else
|
||||
return no_event;
|
||||
return gpmEventType::None;
|
||||
}
|
||||
#endif // F_HAVE_LIBGPM
|
||||
|
||||
@ -563,7 +552,7 @@ FString FMouseX11::getClassName() const
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseX11::hasData()
|
||||
{
|
||||
return bool(x11_mouse[0]);
|
||||
return ( x11_mouse[0] );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -631,13 +620,13 @@ void FMouseX11::processEvent (struct timeval* time)
|
||||
void FMouseX11::setKeyState (int btn)
|
||||
{
|
||||
if ( (btn & key_shift) == key_shift )
|
||||
getButtonState().shift_button = Pressed;
|
||||
getButtonState().shift_button = true;
|
||||
|
||||
if ( (btn & key_meta) == key_meta )
|
||||
getButtonState().meta_button = Pressed;
|
||||
getButtonState().meta_button = true;
|
||||
|
||||
if ( (btn & key_ctrl) == key_ctrl )
|
||||
getButtonState().control_button = Pressed;
|
||||
getButtonState().control_button = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -667,25 +656,25 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
getButtonState().left_button = State::DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
getButtonState().left_button = State::Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
getButtonState().middle_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
getButtonState().right_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case all_buttons_released:
|
||||
@ -693,17 +682,17 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
getButtonState().left_button = Released;
|
||||
getButtonState().left_button = State::Released;
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
getButtonState().middle_button = Released;
|
||||
getButtonState().middle_button = State::Released;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
getButtonState().right_button = Released;
|
||||
getButtonState().right_button = State::Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -713,12 +702,12 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
|
||||
|
||||
case button_up:
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_up = Pressed;
|
||||
getButtonState().wheel_up = true;
|
||||
break;
|
||||
|
||||
case button_down:
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_down = Pressed;
|
||||
getButtonState().wheel_down = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -741,7 +730,7 @@ FString FMouseSGR::getClassName() const
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseSGR::hasData()
|
||||
{
|
||||
return bool(sgr_mouse[0]);
|
||||
return ( sgr_mouse[0] );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -893,25 +882,25 @@ void FMouseSGR::setPressedButtonState ( const int btn
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
getButtonState().left_button = State::DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
getButtonState().left_button = State::Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2:
|
||||
case button2_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
getButtonState().middle_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case button3:
|
||||
case button3_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
getButtonState().right_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case button_up:
|
||||
@ -938,17 +927,17 @@ void FMouseSGR::setReleasedButtonState (const int btn)
|
||||
{
|
||||
case button1:
|
||||
case button1_move:
|
||||
getButtonState().left_button = Released;
|
||||
getButtonState().left_button = State::Released;
|
||||
break;
|
||||
|
||||
case button2:
|
||||
case button2_move:
|
||||
getButtonState().middle_button = Released;
|
||||
getButtonState().middle_button = State::Released;
|
||||
break;
|
||||
|
||||
case button3:
|
||||
case button3_move:
|
||||
getButtonState().right_button = Released;
|
||||
getButtonState().right_button = State::Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -971,7 +960,7 @@ FString FMouseUrxvt::getClassName() const
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseUrxvt::hasData()
|
||||
{
|
||||
return bool(urxvt_mouse[0]);
|
||||
return ( urxvt_mouse[0] );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1112,13 +1101,13 @@ void FMouseUrxvt::processEvent (struct timeval* time)
|
||||
void FMouseUrxvt::setKeyState (int btn)
|
||||
{
|
||||
if ( (btn & key_shift) == key_shift )
|
||||
getButtonState().shift_button = Pressed;
|
||||
getButtonState().shift_button = true;
|
||||
|
||||
if ( (btn & key_meta) == key_meta )
|
||||
getButtonState().meta_button = Pressed;
|
||||
getButtonState().meta_button = true;
|
||||
|
||||
if ( (btn & key_ctrl) == key_ctrl )
|
||||
getButtonState().control_button = Pressed;
|
||||
getButtonState().control_button = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1148,25 +1137,25 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
&& ! isDblclickTimeout(getMousePressedTime()) )
|
||||
{
|
||||
resetMousePressedTime();
|
||||
getButtonState().left_button = DoubleClick;
|
||||
getButtonState().left_button = State::DoubleClick;
|
||||
}
|
||||
else
|
||||
{
|
||||
setMousePressedTime (time); // save click time
|
||||
getButtonState().left_button = Pressed;
|
||||
getButtonState().left_button = State::Pressed;
|
||||
}
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().middle_button = Pressed;
|
||||
getButtonState().middle_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
resetMousePressedTime();
|
||||
getButtonState().right_button = Pressed;
|
||||
getButtonState().right_button = State::Pressed;
|
||||
break;
|
||||
|
||||
case all_buttons_released:
|
||||
@ -1174,17 +1163,17 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
{
|
||||
case button1_pressed:
|
||||
case button1_pressed_move:
|
||||
getButtonState().left_button = Released;
|
||||
getButtonState().left_button = State::Released;
|
||||
break;
|
||||
|
||||
case button2_pressed:
|
||||
case button2_pressed_move:
|
||||
getButtonState().middle_button = Released;
|
||||
getButtonState().middle_button = State::Released;
|
||||
break;
|
||||
|
||||
case button3_pressed:
|
||||
case button3_pressed_move:
|
||||
getButtonState().right_button = Released;
|
||||
getButtonState().right_button = State::Released;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1194,12 +1183,12 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
|
||||
case button_up:
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_up = Pressed;
|
||||
getButtonState().wheel_up = true;
|
||||
break;
|
||||
|
||||
case button_down:
|
||||
resetMousePressedTime();
|
||||
getButtonState().wheel_down = Pressed;
|
||||
getButtonState().wheel_down = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1217,27 +1206,25 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
|
||||
FMouseControl::FMouseControl()
|
||||
{
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
mouse_protocol[FMouse::gpm] = FMouse::createMouseObject<FMouseGPM>();
|
||||
if ( FTermLinux::isLinuxConsole() )
|
||||
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
|
||||
#endif
|
||||
|
||||
mouse_protocol[FMouse::x11] = FMouse::createMouseObject<FMouseX11>();
|
||||
mouse_protocol[FMouse::sgr] = FMouse::createMouseObject<FMouseSGR>();
|
||||
mouse_protocol[FMouse::urxvt] = FMouse::createMouseObject<FMouseUrxvt>();
|
||||
mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>());
|
||||
mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
|
||||
mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouseControl::~FMouseControl() // destructor
|
||||
{
|
||||
for (auto&& m : mouse_protocol)
|
||||
delete m.second;
|
||||
}
|
||||
FMouseControl::~FMouseControl() = default; // destructor
|
||||
|
||||
|
||||
// public methods of FMouseControl
|
||||
//----------------------------------------------------------------------
|
||||
const FPoint& FMouseControl::getPos()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
const auto& mouse_object = mouse_protocol[mtype].get();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->getPos();
|
||||
@ -1248,17 +1235,23 @@ const FPoint& FMouseControl::getPos()
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::clearEvent()
|
||||
{
|
||||
FMouse* mouse_object;
|
||||
FMouse::MouseType mtype;
|
||||
|
||||
while ( (mouse_object = getMouseWithEvent()) != nullptr )
|
||||
mouse_object->clearEvent();
|
||||
do
|
||||
{
|
||||
mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_protocol[mtype] )
|
||||
mouse_protocol[mtype]->clearEvent();
|
||||
}
|
||||
while ( mtype != FMouse::MouseType::None );
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
void FMouseControl::setStdinNo (int file_descriptor)
|
||||
{
|
||||
auto mouse = mouse_protocol[FMouse::gpm];
|
||||
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
@ -1272,17 +1265,17 @@ void FMouseControl::setStdinNo (int)
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::setMaxWidth (uInt16 x_max)
|
||||
{
|
||||
mouse_protocol[FMouse::urxvt]->setMaxWidth(x_max);
|
||||
mouse_protocol[FMouse::MouseType::Urxvt]->setMaxWidth(x_max);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::setMaxHeight (uInt16 y_max)
|
||||
{
|
||||
mouse_protocol[FMouse::urxvt]->setMaxHeight(y_max);
|
||||
mouse_protocol[FMouse::MouseType::Urxvt]->setMaxHeight(y_max);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::setDblclickInterval (const uInt64 timeout)
|
||||
void FMouseControl::setDblclickInterval (const uInt64 timeout) const
|
||||
{
|
||||
for (auto&& m : mouse_protocol)
|
||||
if ( m.second )
|
||||
@ -1304,7 +1297,8 @@ void FMouseControl::useXtermMouse (bool enable)
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::hasData()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithData();
|
||||
auto mtype = getMouseWithData();
|
||||
const auto& mouse_object = mouse_protocol[mtype].get();
|
||||
|
||||
if ( mouse_object ) // with data
|
||||
return true;
|
||||
@ -1315,9 +1309,9 @@ bool FMouseControl::hasData()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::hasEvent()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object ) // with event
|
||||
if ( mouse_protocol[mtype] ) // with event
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -1326,10 +1320,10 @@ bool FMouseControl::hasEvent()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isLeftButtonPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isLeftButtonPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isLeftButtonPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1337,10 +1331,10 @@ bool FMouseControl::isLeftButtonPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isLeftButtonReleased()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isLeftButtonReleased();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isLeftButtonReleased();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1348,10 +1342,10 @@ bool FMouseControl::isLeftButtonReleased()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isLeftButtonDoubleClick()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isLeftButtonDoubleClick();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isLeftButtonDoubleClick();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1359,10 +1353,10 @@ bool FMouseControl::isLeftButtonDoubleClick()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isRightButtonPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isRightButtonPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isRightButtonPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1370,10 +1364,10 @@ bool FMouseControl::isRightButtonPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isRightButtonReleased()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isRightButtonReleased();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isRightButtonReleased();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1381,10 +1375,10 @@ bool FMouseControl::isRightButtonReleased()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isMiddleButtonPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isMiddleButtonPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isMiddleButtonPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1392,10 +1386,10 @@ bool FMouseControl::isMiddleButtonPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isMiddleButtonReleased()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isMiddleButtonReleased();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isMiddleButtonReleased();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1403,10 +1397,10 @@ bool FMouseControl::isMiddleButtonReleased()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isShiftKeyPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isShiftKeyPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isShiftKeyPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1414,10 +1408,10 @@ bool FMouseControl::isShiftKeyPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isControlKeyPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isControlKeyPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isControlKeyPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1425,10 +1419,10 @@ bool FMouseControl::isControlKeyPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isMetaKeyPressed()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isMetaKeyPressed();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isMetaKeyPressed();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1436,10 +1430,10 @@ bool FMouseControl::isMetaKeyPressed()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isWheelUp()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isWheelUp();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isWheelUp();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1447,10 +1441,10 @@ bool FMouseControl::isWheelUp()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isWheelDown()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isWheelDown();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isWheelDown();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1458,10 +1452,10 @@ bool FMouseControl::isWheelDown()
|
||||
//----------------------------------------------------------------------
|
||||
bool FMouseControl::isMoved()
|
||||
{
|
||||
const auto& mouse_object = getMouseWithEvent();
|
||||
auto mtype = getMouseWithEvent();
|
||||
|
||||
if ( mouse_object )
|
||||
return mouse_object->isMoved();
|
||||
if ( mouse_protocol[mtype] )
|
||||
return mouse_protocol[mtype]->isMoved();
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1486,7 +1480,7 @@ bool FMouseControl::isGpmMouseEnabled()
|
||||
if ( mouse_protocol.empty() )
|
||||
return false;
|
||||
|
||||
const auto& mouse = mouse_protocol[FMouse::gpm];
|
||||
const auto& mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
const auto& gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
@ -1507,7 +1501,7 @@ void FMouseControl::enable()
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
if ( use_gpm_mouse )
|
||||
{
|
||||
auto mouse = mouse_protocol[FMouse::gpm];
|
||||
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
@ -1525,7 +1519,7 @@ void FMouseControl::disable()
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
if ( use_gpm_mouse )
|
||||
{
|
||||
auto mouse = mouse_protocol[FMouse::gpm];
|
||||
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
@ -1538,10 +1532,10 @@ void FMouseControl::disable()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::setRawData ( FMouse::mouse_type mt
|
||||
void FMouseControl::setRawData ( FMouse::MouseType mt
|
||||
, FKeyboard::keybuffer& fifo_buf)
|
||||
{
|
||||
auto mouse = mouse_protocol[mt];
|
||||
auto mouse = mouse_protocol[mt].get();
|
||||
|
||||
if ( mouse )
|
||||
mouse->setRawData (fifo_buf);
|
||||
@ -1569,7 +1563,9 @@ void FMouseControl::processQueuedInput()
|
||||
//----------------------------------------------------------------------
|
||||
void FMouseControl::processEvent (struct timeval* time)
|
||||
{
|
||||
auto mouse_object = getMouseWithData();
|
||||
auto mtype = getMouseWithData();
|
||||
auto mouse_object = mouse_protocol[mtype].get();
|
||||
|
||||
// Clear all old mouse events
|
||||
clearEvent();
|
||||
|
||||
@ -1577,7 +1573,7 @@ void FMouseControl::processEvent (struct timeval* time)
|
||||
{
|
||||
mouse_object->processEvent(time);
|
||||
auto& md = static_cast<FMouseData&>(*mouse_object);
|
||||
fmousedata_queue.emplace(new FMouseData(std::move(md)));
|
||||
fmousedata_queue.emplace(make_unique<FMouseData>(std::move(md)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1588,7 +1584,7 @@ bool FMouseControl::getGpmKeyPressed (bool pending)
|
||||
if ( mouse_protocol.empty() )
|
||||
return false;
|
||||
|
||||
auto mouse = mouse_protocol[FMouse::gpm];
|
||||
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
@ -1605,26 +1601,26 @@ bool FMouseControl::getGpmKeyPressed (bool)
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
void FMouseControl::drawGpmPointer()
|
||||
void FMouseControl::drawPointer()
|
||||
{
|
||||
if ( mouse_protocol.empty() )
|
||||
return;
|
||||
|
||||
auto mouse = mouse_protocol[FMouse::gpm];
|
||||
auto mouse = mouse_protocol[FMouse::MouseType::Gpm].get();
|
||||
auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
|
||||
|
||||
if ( gpm_mouse )
|
||||
gpm_mouse->drawGpmPointer();
|
||||
gpm_mouse->drawPointer();
|
||||
}
|
||||
#else // F_HAVE_LIBGPM
|
||||
void FMouseControl::drawGpmPointer()
|
||||
void FMouseControl::drawPointer()
|
||||
{ }
|
||||
#endif // F_HAVE_LIBGPM
|
||||
|
||||
|
||||
// private methods of FMouseControl
|
||||
//----------------------------------------------------------------------
|
||||
FMouse* FMouseControl::getMouseWithData()
|
||||
FMouse::MouseType FMouseControl::getMouseWithData()
|
||||
{
|
||||
const auto& iter = \
|
||||
std::find_if ( std::begin(mouse_protocol)
|
||||
@ -1636,11 +1632,11 @@ FMouse* FMouseControl::getMouseWithData()
|
||||
}
|
||||
);
|
||||
|
||||
return ( iter != mouse_protocol.end() ) ? iter->second : nullptr;
|
||||
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::None;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FMouse* FMouseControl::getMouseWithEvent()
|
||||
FMouse::MouseType FMouseControl::getMouseWithEvent()
|
||||
{
|
||||
const auto& iter = \
|
||||
std::find_if ( std::begin(mouse_protocol)
|
||||
@ -1652,7 +1648,7 @@ FMouse* FMouseControl::getMouseWithEvent()
|
||||
}
|
||||
);
|
||||
|
||||
return ( iter != mouse_protocol.end() ) ? iter->second : nullptr;
|
||||
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::None;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "final/emptyfstring.h"
|
||||
#include "final/fevent.h"
|
||||
#include "final/fc.h"
|
||||
#include "final/fobject.h"
|
||||
@ -32,8 +31,6 @@ namespace finalcut
|
||||
|
||||
// static class attributes
|
||||
bool FObject::timer_modify_lock;
|
||||
FObject::FTimerList* FObject::timer_list{nullptr};
|
||||
const FString* fc::emptyFString::empty_string{nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -45,27 +42,10 @@ const FString* fc::emptyFString::empty_string{nullptr};
|
||||
FObject::FObject (FObject* parent)
|
||||
: parent_obj{parent}
|
||||
{
|
||||
if ( parent ) // add object to parent
|
||||
{
|
||||
if ( parent ) // add object to parent
|
||||
parent->addChild(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
timer_modify_lock = false;
|
||||
|
||||
if ( ! timer_list )
|
||||
{
|
||||
try
|
||||
{
|
||||
timer_list = new FTimerList;
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FTimerList");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -73,15 +53,6 @@ FObject::~FObject() // destructor
|
||||
{
|
||||
delOwnTimers(); // Delete all timers of this object
|
||||
|
||||
if ( ! has_parent && timer_list )
|
||||
{
|
||||
delete timer_list;
|
||||
timer_list = nullptr;
|
||||
}
|
||||
|
||||
if ( ! has_parent && ! fc::emptyFString::isNull() )
|
||||
fc::emptyFString::clear();
|
||||
|
||||
// Delete children objects
|
||||
if ( hasChildren() )
|
||||
{
|
||||
@ -193,11 +164,11 @@ bool FObject::event (FEvent* ev)
|
||||
{
|
||||
// Receives events on this object
|
||||
|
||||
if ( ev->getType() == fc::Timer_Event )
|
||||
if ( ev->getType() == Event::Timer )
|
||||
{
|
||||
onTimer ( static_cast<FTimerEvent*>(ev) );
|
||||
}
|
||||
else if ( ev->getType() == fc::User_Event )
|
||||
else if ( ev->getType() == Event::User )
|
||||
{
|
||||
onUserEvent ( static_cast<FUserEvent*>(ev) );
|
||||
}
|
||||
@ -268,6 +239,7 @@ int FObject::addTimer (int interval)
|
||||
timeval currentTime{};
|
||||
int id{1};
|
||||
timer_modify_lock = true;
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
// find an unused timer id
|
||||
if ( ! timer_list->empty() )
|
||||
@ -317,6 +289,7 @@ bool FObject::delTimer (int id) const
|
||||
return false;
|
||||
|
||||
timer_modify_lock = true;
|
||||
auto& timer_list = globalTimerList();
|
||||
auto iter = timer_list->begin();
|
||||
const auto& last = timer_list->end();
|
||||
|
||||
@ -339,6 +312,8 @@ bool FObject::delOwnTimers() const
|
||||
{
|
||||
// Deletes all timers of this object
|
||||
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
return false;
|
||||
|
||||
@ -365,6 +340,8 @@ bool FObject::delAllTimers() const
|
||||
{
|
||||
// Deletes all timers of all objects
|
||||
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
return false;
|
||||
|
||||
@ -405,6 +382,8 @@ uInt FObject::processTimerEvent()
|
||||
if ( isTimerInUpdating() )
|
||||
return 0;
|
||||
|
||||
auto& timer_list = globalTimerList();
|
||||
|
||||
if ( ! timer_list )
|
||||
return 0;
|
||||
|
||||
@ -426,7 +405,7 @@ uInt FObject::processTimerEvent()
|
||||
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 )
|
||||
activated++;
|
||||
|
||||
FTimerEvent t_ev(fc::Timer_Event, timer.id);
|
||||
FTimerEvent t_ev(Event::Timer, timer.id);
|
||||
performTimerAction (timer.object, &t_ev);
|
||||
}
|
||||
|
||||
@ -440,4 +419,11 @@ void FObject::performTimerAction (FObject*, FEvent*)
|
||||
// to process the passed object and timer event
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
auto FObject::globalTimerList() -> const FTimerListUniquePtr&
|
||||
{
|
||||
static const auto& timer_list = make_unique<FTimerList>();
|
||||
return timer_list;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2016-2020 Markus Gans *
|
||||
* Copyright 2016-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -47,10 +47,6 @@ FOptiAttr::FOptiAttr()
|
||||
reset_byte_mask.attr.bit.printed = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FOptiAttr::~FOptiAttr() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FOptiAttr
|
||||
//----------------------------------------------------------------------
|
||||
@ -528,17 +524,19 @@ FColor FOptiAttr::vga2ansi (FColor color)
|
||||
// 1 1 1 0 | 1 0 1 1
|
||||
// 1 1 1 1 | 1 1 1 1
|
||||
|
||||
if ( color == fc::Default )
|
||||
color = 0;
|
||||
if ( color == FColor::Default )
|
||||
color = FColor::Black;
|
||||
else if ( color < 16 )
|
||||
{
|
||||
constexpr std::array<FColor, 16> lookup_table =
|
||||
{{
|
||||
0, 4, 2, 6, 1, 5, 3, 7,
|
||||
8, 12, 10, 14, 9, 13, 11, 15
|
||||
FColor(0), FColor(4), FColor(2), FColor(6),
|
||||
FColor(1), FColor(5), FColor(3), FColor(7),
|
||||
FColor(8), FColor(12), FColor(10), FColor(14),
|
||||
FColor(9), FColor(13), FColor(11), FColor(15)
|
||||
}};
|
||||
|
||||
color = lookup_table[color];
|
||||
color = lookup_table[uInt16(color)];
|
||||
}
|
||||
|
||||
return color;
|
||||
@ -888,17 +886,17 @@ bool FOptiAttr::setTermAttributes ( FChar& term
|
||||
{
|
||||
if ( F_set_attributes.cap )
|
||||
{
|
||||
const char* sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
||||
, p1 && ! fake_reverse
|
||||
, p2
|
||||
, p3 && ! fake_reverse
|
||||
, p4
|
||||
, p5
|
||||
, p6
|
||||
, p7
|
||||
, p8
|
||||
, p9 );
|
||||
append_sequence (sgr);
|
||||
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
|
||||
, p1 && ! fake_reverse
|
||||
, p2
|
||||
, p3 && ! fake_reverse
|
||||
, p4
|
||||
, p5
|
||||
, p6
|
||||
, p7
|
||||
, p8
|
||||
, p9 );
|
||||
append_sequence (sgr.data());
|
||||
resetColor(term);
|
||||
term.attr.bit.standout = p1;
|
||||
term.attr.bit.underline = p2;
|
||||
@ -990,8 +988,8 @@ inline bool FOptiAttr::unsetTermPCcharset (FChar& term)
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::setTermDefaultColor (FChar& term)
|
||||
{
|
||||
term.fg_color = fc::Default;
|
||||
term.bg_color = fc::Default;
|
||||
term.fg_color = FColor::Default;
|
||||
term.bg_color = FColor::Default;
|
||||
|
||||
if ( append_sequence(F_orig_pair.cap) )
|
||||
return true;
|
||||
@ -1096,8 +1094,8 @@ void FOptiAttr::setAttributesOff (FChar& term)
|
||||
//----------------------------------------------------------------------
|
||||
bool FOptiAttr::hasColor (const FChar& attr)
|
||||
{
|
||||
if ( attr.fg_color == fc::Default
|
||||
&& attr.bg_color == fc::Default )
|
||||
if ( attr.fg_color == FColor::Default
|
||||
&& attr.bg_color == FColor::Default )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -1131,20 +1129,20 @@ bool FOptiAttr::hasNoAttribute (const FChar& attr)
|
||||
inline bool FOptiAttr::hasColorChanged ( const FChar& term
|
||||
, const FChar& next ) const
|
||||
{
|
||||
bool frev ( ( on.attr.bit.reverse
|
||||
bool frev { ( on.attr.bit.reverse
|
||||
|| on.attr.bit.standout
|
||||
|| off.attr.bit.reverse
|
||||
|| off.attr.bit.standout ) && fake_reverse );
|
||||
return bool ( frev
|
||||
|| term.fg_color != next.fg_color
|
||||
|| term.bg_color != next.bg_color );
|
||||
|| off.attr.bit.standout ) && fake_reverse };
|
||||
return frev
|
||||
|| term.fg_color != next.fg_color
|
||||
|| term.bg_color != next.bg_color;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FOptiAttr::resetColor (FChar& attr) const
|
||||
{
|
||||
attr.fg_color = fc::Default;
|
||||
attr.bg_color = fc::Default;
|
||||
attr.fg_color = FColor::Default;
|
||||
attr.bg_color = FColor::Default;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1292,24 +1290,24 @@ void FOptiAttr::change_color (FChar& term, FChar& next)
|
||||
{
|
||||
if ( monochron )
|
||||
{
|
||||
next.fg_color = fc::Default;
|
||||
next.bg_color = fc::Default;
|
||||
next.fg_color = FColor::Default;
|
||||
next.bg_color = FColor::Default;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( next.fg_color != fc::Default )
|
||||
next.fg_color %= max_color;
|
||||
if ( next.fg_color != FColor::Default )
|
||||
next.fg_color %= uInt16(max_color);
|
||||
|
||||
if ( next.bg_color != fc::Default )
|
||||
next.bg_color %= max_color;
|
||||
if ( next.bg_color != FColor::Default )
|
||||
next.bg_color %= uInt16(max_color);
|
||||
|
||||
FColor fg = next.fg_color;
|
||||
FColor bg = next.bg_color;
|
||||
|
||||
if ( fg == fc::Default || bg == fc::Default )
|
||||
if ( fg == FColor::Default || bg == FColor::Default )
|
||||
change_to_default_color (term, next, fg, bg);
|
||||
|
||||
if ( fake_reverse && fg == fc::Default && bg == fc::Default )
|
||||
if ( fake_reverse && fg == FColor::Default && bg == FColor::Default )
|
||||
return;
|
||||
|
||||
if ( fake_reverse
|
||||
@ -1317,7 +1315,7 @@ void FOptiAttr::change_color (FChar& term, FChar& next)
|
||||
{
|
||||
std::swap (fg, bg);
|
||||
|
||||
if ( fg == fc::Default || bg == fc::Default )
|
||||
if ( fg == FColor::Default || bg == FColor::Default )
|
||||
setTermDefaultColor(term);
|
||||
}
|
||||
|
||||
@ -1333,18 +1331,18 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
|
||||
{
|
||||
if ( ansi_default_color )
|
||||
{
|
||||
if ( fg == fc::Default && term.fg_color != fc::Default
|
||||
&& bg == fc::Default && term.bg_color != fc::Default )
|
||||
if ( fg == FColor::Default && term.fg_color != FColor::Default
|
||||
&& bg == FColor::Default && term.bg_color != FColor::Default )
|
||||
{
|
||||
setTermDefaultColor(term);
|
||||
}
|
||||
else if ( fg == fc::Default && term.fg_color != fc::Default )
|
||||
else if ( fg == FColor::Default && term.fg_color != FColor::Default )
|
||||
{
|
||||
std::string sgr_39{CSI "39m"};
|
||||
append_sequence (sgr_39.c_str());
|
||||
term.fg_color = fc::Default;
|
||||
term.fg_color = FColor::Default;
|
||||
}
|
||||
else if ( bg == fc::Default && term.bg_color != fc::Default )
|
||||
else if ( bg == FColor::Default && term.bg_color != FColor::Default )
|
||||
{
|
||||
const char* sgr_49;
|
||||
const auto& op = F_orig_pair.cap;
|
||||
@ -1355,14 +1353,14 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
|
||||
sgr_49 = CSI "49m";
|
||||
|
||||
append_sequence (sgr_49);
|
||||
term.bg_color = fc::Default;
|
||||
term.bg_color = FColor::Default;
|
||||
}
|
||||
}
|
||||
else if ( ! setTermDefaultColor(term) )
|
||||
{
|
||||
// Fallback to gray on black
|
||||
fg = next.fg_color = fc::LightGray;
|
||||
bg = next.bg_color = fc::Black;
|
||||
fg = next.fg_color = FColor::LightGray;
|
||||
bg = next.bg_color = FColor::Black;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1370,7 +1368,6 @@ inline void FOptiAttr::change_to_default_color ( FChar& term, FChar& next
|
||||
inline void FOptiAttr::change_current_color ( const FChar& term
|
||||
, FColor fg, FColor bg )
|
||||
{
|
||||
const char* color_str{};
|
||||
const auto& AF = F_set_a_foreground.cap;
|
||||
const auto& AB = F_set_a_background.cap;
|
||||
const auto& Sf = F_set_foreground.cap;
|
||||
@ -1388,36 +1385,36 @@ inline void FOptiAttr::change_current_color ( const FChar& term
|
||||
|
||||
if ( term.fg_color != fg || frev )
|
||||
{
|
||||
color_str = FTermcap::encodeParameter(AF, ansi_fg, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
append_sequence (color_str);
|
||||
const auto& color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg));
|
||||
append_sequence (color_str.data());
|
||||
}
|
||||
|
||||
if ( term.bg_color != bg || frev )
|
||||
{
|
||||
color_str = FTermcap::encodeParameter(AB, ansi_bg, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
append_sequence (color_str);
|
||||
const auto& color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg));
|
||||
append_sequence (color_str.data());
|
||||
}
|
||||
}
|
||||
else if ( Sf && Sb )
|
||||
{
|
||||
if ( term.fg_color != fg || frev )
|
||||
{
|
||||
color_str = FTermcap::encodeParameter(Sf, fg, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
append_sequence (color_str);
|
||||
const auto& color_str = FTermcap::encodeParameter(Sf, uInt16(fg));
|
||||
append_sequence (color_str.data());
|
||||
}
|
||||
|
||||
if ( term.bg_color != bg || frev )
|
||||
{
|
||||
color_str = FTermcap::encodeParameter(Sb, bg, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
append_sequence (color_str);
|
||||
const auto& color_str = FTermcap::encodeParameter(Sb, uInt16(bg));
|
||||
append_sequence (color_str.data());
|
||||
}
|
||||
}
|
||||
else if ( sp )
|
||||
{
|
||||
fg = vga2ansi(fg);
|
||||
bg = vga2ansi(bg);
|
||||
color_str = FTermcap::encodeParameter(sp, fg, bg, 0, 0, 0, 0, 0, 0, 0);
|
||||
append_sequence (color_str);
|
||||
const auto& color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg));
|
||||
append_sequence (color_str.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -52,10 +52,6 @@ FOptiMove::FOptiMove (int baud)
|
||||
set_cursor_down ("\n");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FOptiMove::~FOptiMove() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FOptiMove
|
||||
//----------------------------------------------------------------------
|
||||
@ -270,9 +266,9 @@ void FOptiMove::set_cursor_address (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23);
|
||||
const auto& temp = FTermcap::encodeMotionParameter(cap, 23, 23);
|
||||
F_cursor_address.cap = cap;
|
||||
F_cursor_address.duration = capDuration (temp, 1);
|
||||
F_cursor_address.duration = capDuration (temp.data(), 1);
|
||||
F_cursor_address.length = capDurationToLength (F_cursor_address.duration);
|
||||
}
|
||||
else
|
||||
@ -288,9 +284,9 @@ void FOptiMove::set_column_address (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_column_address.cap = cap;
|
||||
F_column_address.duration = capDuration (temp, 1);
|
||||
F_column_address.duration = capDuration (temp.data(), 1);
|
||||
F_column_address.length = capDurationToLength (F_column_address.duration);
|
||||
}
|
||||
else
|
||||
@ -306,9 +302,9 @@ void FOptiMove::set_row_address (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_row_address.cap = cap;
|
||||
F_row_address.duration = capDuration (temp, 1);
|
||||
F_row_address.duration = capDuration (temp.data(), 1);
|
||||
F_row_address.length = capDurationToLength (F_row_address.duration);
|
||||
}
|
||||
else
|
||||
@ -324,9 +320,9 @@ void FOptiMove::set_parm_up_cursor (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_parm_up_cursor.cap = cap;
|
||||
F_parm_up_cursor.duration = capDuration (temp, 1);
|
||||
F_parm_up_cursor.duration = capDuration (temp.data(), 1);
|
||||
F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration);
|
||||
}
|
||||
else
|
||||
@ -342,9 +338,9 @@ void FOptiMove::set_parm_down_cursor (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_parm_down_cursor.cap = cap;
|
||||
F_parm_down_cursor.duration = capDuration (temp, 1);
|
||||
F_parm_down_cursor.duration = capDuration (temp.data(), 1);
|
||||
F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration);
|
||||
}
|
||||
else
|
||||
@ -360,9 +356,9 @@ void FOptiMove::set_parm_left_cursor (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_parm_left_cursor.cap = cap;
|
||||
F_parm_left_cursor.duration = capDuration (temp, 1);
|
||||
F_parm_left_cursor.duration = capDuration (temp.data(), 1);
|
||||
F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration);
|
||||
}
|
||||
else
|
||||
@ -378,9 +374,9 @@ void FOptiMove::set_parm_right_cursor (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_parm_right_cursor.cap = cap;
|
||||
F_parm_right_cursor.duration = capDuration (temp, 1);
|
||||
F_parm_right_cursor.duration = capDuration (temp.data(), 1);
|
||||
F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration);
|
||||
}
|
||||
else
|
||||
@ -396,9 +392,9 @@ void FOptiMove::set_erase_chars (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, 23);
|
||||
F_erase_chars.cap = cap;
|
||||
F_erase_chars.duration = capDuration (temp, 1);
|
||||
F_erase_chars.duration = capDuration (temp.data(), 1);
|
||||
F_erase_chars.length = capDurationToLength (F_erase_chars.duration);
|
||||
}
|
||||
else
|
||||
@ -414,9 +410,9 @@ void FOptiMove::set_repeat_char (const char cap[])
|
||||
{
|
||||
if ( cap && FTermcap::isInitialized() )
|
||||
{
|
||||
const char* temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0);
|
||||
const auto& temp = FTermcap::encodeParameter(cap, ' ');
|
||||
F_repeat_char.cap = cap;
|
||||
F_repeat_char.duration = capDuration (temp, 1);
|
||||
F_repeat_char.duration = capDuration (temp.data(), 1);
|
||||
F_repeat_char.length = capDurationToLength (F_repeat_char.duration);
|
||||
}
|
||||
else
|
||||
@ -608,7 +604,7 @@ int FOptiMove::capDurationToLength (int duration) const
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FOptiMove::repeatedAppend ( const Capability& o
|
||||
, volatile int count
|
||||
, int count
|
||||
, char* dst ) const
|
||||
{
|
||||
const std::size_t src_len = std::strlen(o.cap);
|
||||
@ -623,8 +619,9 @@ int FOptiMove::repeatedAppend ( const Capability& o
|
||||
{
|
||||
dst += dst_len;
|
||||
std::size_t free = BUF_SIZE - dst_len - 2;
|
||||
int cnt = count;
|
||||
|
||||
while ( count-- > 0 )
|
||||
while ( cnt-- > 0 )
|
||||
{
|
||||
std::strncpy (dst, o.cap, free);
|
||||
dst += src_len;
|
||||
@ -689,7 +686,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_row_address.cap, to_y).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
@ -716,7 +713,7 @@ inline void FOptiMove::downMove ( char move[], int& vtime
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
@ -744,7 +741,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
|
||||
if ( move )
|
||||
{
|
||||
std::strncpy ( move
|
||||
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num).data()
|
||||
, BUF_SIZE );
|
||||
move[BUF_SIZE - 1] = '\0';
|
||||
}
|
||||
@ -770,7 +767,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
|
||||
{
|
||||
// Move to fixed column position1
|
||||
std::strncat ( hmove
|
||||
, FTermcap::encodeParameter(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_column_address.cap, to_x).data()
|
||||
, BUF_SIZE - std::strlen(hmove) - 1 );
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_column_address.duration;
|
||||
@ -793,7 +790,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
|
||||
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_parm_right_cursor.duration;
|
||||
@ -848,7 +845,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
|
||||
{
|
||||
std::strncpy ( hmove
|
||||
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num).data()
|
||||
, BUF_SIZE - 1);
|
||||
hmove[BUF_SIZE - 1] = '\0';
|
||||
htime = F_parm_left_cursor.duration;
|
||||
@ -898,10 +895,9 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
|
||||
inline bool FOptiMove::isWideMove ( int xold, int yold
|
||||
, int xnew, int ynew ) const
|
||||
{
|
||||
return bool ( xnew > MOVE_LIMIT
|
||||
&& xnew < int(screen_width) - 1 - MOVE_LIMIT
|
||||
&& std::abs(xnew - xold) + std::abs(ynew - yold)
|
||||
> MOVE_LIMIT );
|
||||
return xnew > MOVE_LIMIT
|
||||
&& xnew < int(screen_width) - 1 - MOVE_LIMIT
|
||||
&& std::abs(xnew - xold) + std::abs(ynew - yold) > MOVE_LIMIT;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -909,13 +905,17 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
|
||||
, int xnew, int ynew )
|
||||
{
|
||||
// Test method 0: direct cursor addressing
|
||||
const char* move_xy = \
|
||||
|
||||
if ( ! F_cursor_address.cap )
|
||||
return false;
|
||||
|
||||
const auto move_xy = \
|
||||
FTermcap::encodeMotionParameter(F_cursor_address.cap, xnew, ynew);
|
||||
|
||||
if ( move_xy )
|
||||
if ( ! move_xy.empty() )
|
||||
{
|
||||
std::strncpy ( reinterpret_cast<char*>(move_buf)
|
||||
, move_xy, BUF_SIZE - 1 );
|
||||
std::strncpy ( static_cast<char*>(move_buf)
|
||||
, move_xy.data(), BUF_SIZE - 1 );
|
||||
move_buf[BUF_SIZE - 1] = '\0';
|
||||
move_time = F_cursor_address.duration;
|
||||
return true;
|
||||
|
@ -31,26 +31,7 @@ namespace finalcut
|
||||
// class FPoint
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
FPoint::~FPoint() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FPoint
|
||||
//----------------------------------------------------------------------
|
||||
FPoint& FPoint::operator = (const FPoint& p)
|
||||
{
|
||||
xpos = p.xpos;
|
||||
ypos = p.ypos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint& FPoint::operator = (FPoint&& p) noexcept
|
||||
{
|
||||
xpos = std::move(p.xpos);
|
||||
ypos = std::move(p.ypos);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FPoint& FPoint::operator += (const FPoint& p)
|
||||
{
|
||||
|
@ -42,8 +42,7 @@ FProgressbar::FProgressbar(FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FProgressbar::~FProgressbar() // destructor
|
||||
{ }
|
||||
FProgressbar::~FProgressbar() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FProgressbar
|
||||
@ -89,8 +88,8 @@ void FProgressbar::setGeometry ( const FPoint& pos, const FSize& size
|
||||
bool FProgressbar::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != Encoding::VT100
|
||||
&& FTerm::getEncoding() != Encoding::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
@ -192,7 +191,7 @@ std::size_t FProgressbar::drawProgressIndicator()
|
||||
const double length = double(bar_length * percentage) / 100;
|
||||
auto len = std::size_t(trunc(length));
|
||||
print() << FColorPair {wc->progressbar_fg, wc->progressbar_fg}
|
||||
<< FString {len, fc::FullBlock}; // █
|
||||
<< FString {len, UniChar::FullBlock}; // █
|
||||
|
||||
if ( len >= bar_length )
|
||||
return len;
|
||||
@ -210,7 +209,7 @@ std::size_t FProgressbar::drawProgressIndicator()
|
||||
else
|
||||
{
|
||||
print() << FColorPair{wc->progressbar_fg, wc->progressbar_bg}
|
||||
<< fc::LeftHalfBlock; // ▌
|
||||
<< UniChar::LeftHalfBlock; // ▌
|
||||
}
|
||||
|
||||
len++;
|
||||
@ -227,7 +226,7 @@ void FProgressbar::drawProgressBackground (std::size_t len)
|
||||
setColor (wc->progressbar_fg, wc->progressbar_bg);
|
||||
|
||||
if ( FTerm::getMaxColor() < 16 )
|
||||
print() << FString {bg_len, fc::MediumShade}; // ▒
|
||||
print() << FString {bg_len, UniChar::MediumShade}; // ▒
|
||||
else
|
||||
print() << FString {bg_len, L' '};
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ FRadioButton::FRadioButton (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRadioButton::~FRadioButton() // destructor
|
||||
{ }
|
||||
FRadioButton::~FRadioButton() noexcept = default; // destructor
|
||||
|
||||
|
||||
// private methods of FRadioButton
|
||||
@ -101,7 +100,7 @@ inline void FRadioButton::drawChecked()
|
||||
else
|
||||
{
|
||||
print ('(');
|
||||
print (fc::Bullet); // Bullet ●
|
||||
print (UniChar::Bullet); // Bullet ●
|
||||
print (')');
|
||||
}
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRadioMenuItem::~FRadioMenuItem() // destructor
|
||||
{ }
|
||||
FRadioMenuItem::~FRadioMenuItem() noexcept = default; // destructor
|
||||
|
||||
|
||||
// private methods of FRadioMenuItem
|
||||
|
@ -36,7 +36,7 @@ namespace finalcut
|
||||
|
||||
// constructor and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FRect::FRect (const FPoint& p, const FSize& s)
|
||||
FRect::FRect (const FPoint& p, const FSize& s) noexcept
|
||||
: X1{p.getX()}
|
||||
, Y1{p.getY()}
|
||||
, X2{p.getX() + int(s.getWidth()) - 1}
|
||||
@ -44,39 +44,15 @@ FRect::FRect (const FPoint& p, const FSize& s)
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRect::FRect (const FPoint& p1, const FPoint& p2)
|
||||
FRect::FRect (const FPoint& p1, const FPoint& p2) noexcept
|
||||
: X1{p1.getX()}
|
||||
, Y1{p1.getY()}
|
||||
, X2{p2.getX()}
|
||||
, Y2{p2.getY()}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRect::~FRect() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FRect
|
||||
//----------------------------------------------------------------------
|
||||
FRect& FRect::operator = (const FRect& r)
|
||||
{
|
||||
X1 = r.X1;
|
||||
Y1 = r.Y1;
|
||||
X2 = r.X2;
|
||||
Y2 = r.Y2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FRect& FRect::operator = (FRect&& r) noexcept
|
||||
{
|
||||
X1 = std::move(r.X1);
|
||||
Y1 = std::move(r.Y1);
|
||||
X2 = std::move(r.X2);
|
||||
Y2 = std::move(r.Y2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
bool FRect::isEmpty() const
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "final/fevent.h"
|
||||
#include "final/fscrollbar.h"
|
||||
#include "final/fsize.h"
|
||||
#include "final/fstatusbar.h"
|
||||
#include "final/fwidgetcolors.h"
|
||||
|
||||
namespace finalcut
|
||||
@ -45,7 +46,7 @@ FScrollbar::FScrollbar(FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::FScrollbar(fc::orientation o, FWidget* parent)
|
||||
FScrollbar::FScrollbar(Orientation o, FWidget* parent)
|
||||
: FWidget{parent}
|
||||
{
|
||||
setOrientation (o);
|
||||
@ -127,16 +128,16 @@ void FScrollbar::setPageSize (int document_size, int page_size)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::setOrientation (fc::orientation o)
|
||||
void FScrollbar::setOrientation (Orientation o)
|
||||
{
|
||||
length = ( o == fc::vertical ) ? getHeight() : getWidth();
|
||||
length = ( o == Orientation::Vertical ) ? getHeight() : getWidth();
|
||||
|
||||
if ( o == fc::vertical && bar_orientation == fc::horizontal )
|
||||
if ( o == Orientation::Vertical && bar_orientation == Orientation::Horizontal )
|
||||
{
|
||||
setWidth(1);
|
||||
setHeight(length);
|
||||
}
|
||||
else if ( o == fc::horizontal && bar_orientation == fc::vertical )
|
||||
else if ( o == Orientation::Horizontal && bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
setWidth(length);
|
||||
setHeight(1);
|
||||
@ -184,7 +185,7 @@ void FScrollbar::redraw()
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::calculateSliderValues()
|
||||
{
|
||||
if ( FTerm::isNewFont() && bar_orientation == fc::horizontal )
|
||||
if ( FTerm::isNewFont() && bar_orientation == Orientation::Horizontal )
|
||||
bar_length = ( length > 2 ) ? length - 4 : 1;
|
||||
else
|
||||
bar_length = ( length > 2 ) ? length - 2 : 1;
|
||||
@ -231,7 +232,7 @@ void FScrollbar::drawBar()
|
||||
if ( slider_pos == current_slider_pos || length < 3 )
|
||||
return;
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
drawVerticalBar();
|
||||
else // horizontal
|
||||
drawHorizontalBar();
|
||||
@ -242,17 +243,19 @@ void FScrollbar::drawBar()
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Middle )
|
||||
return;
|
||||
|
||||
setWidgetFocus(getParentWidget());
|
||||
|
||||
if ( min == max )
|
||||
return;
|
||||
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
if ( ev->getButton() == MouseButton::Middle )
|
||||
{
|
||||
jumpToClickPos (mouse_x, mouse_y);
|
||||
return;
|
||||
@ -261,18 +264,18 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
// Process left mouse button
|
||||
scroll_type = getClickedScrollType(mouse_x, mouse_y);
|
||||
|
||||
if ( scroll_type == FScrollbar::noScroll )
|
||||
if ( scroll_type == ScrollType::None )
|
||||
{
|
||||
slider_click_pos = getSliderClickPos (mouse_x, mouse_y);
|
||||
|
||||
if ( slider_click_pos > 0 )
|
||||
scroll_type = FScrollbar::scrollJump;
|
||||
scroll_type = ScrollType::Jump;
|
||||
}
|
||||
|
||||
if ( scroll_type == FScrollbar::scrollPageBackward
|
||||
|| scroll_type == FScrollbar::scrollPageForward )
|
||||
if ( scroll_type == ScrollType::PageBackward
|
||||
|| scroll_type == ScrollType::PageForward )
|
||||
{
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
slider_click_stop_pos = mouse_y - 2;
|
||||
else
|
||||
{
|
||||
@ -285,8 +288,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
else
|
||||
slider_click_stop_pos = -1;
|
||||
|
||||
if ( scroll_type >= FScrollbar::scrollStepBackward
|
||||
&& scroll_type <= FScrollbar::scrollPageForward )
|
||||
if ( scroll_type >= ScrollType::StepBackward
|
||||
&& scroll_type <= ScrollType::PageForward )
|
||||
{
|
||||
processScroll();
|
||||
threshold_reached = false;
|
||||
@ -297,43 +300,43 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Middle )
|
||||
return;
|
||||
|
||||
slider_click_pos = -1;
|
||||
|
||||
if ( scroll_type != FScrollbar::noScroll )
|
||||
if ( scroll_type != ScrollType::None )
|
||||
{
|
||||
delOwnTimers();
|
||||
scroll_type = FScrollbar::noScroll;
|
||||
scroll_type = ScrollType::None;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Middle )
|
||||
return;
|
||||
|
||||
const int mouse_x = ev->getX();
|
||||
const int mouse_y = ev->getY();
|
||||
|
||||
if ( ev->getButton() == fc::MiddleButton )
|
||||
if ( ev->getButton() == MouseButton::Middle )
|
||||
{
|
||||
jumpToClickPos (mouse_x, mouse_y);
|
||||
return;
|
||||
}
|
||||
|
||||
// Process left mouse button
|
||||
const int new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
|
||||
const auto new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
|
||||
|
||||
if ( scroll_type == FScrollbar::scrollJump )
|
||||
if ( scroll_type == ScrollType::Jump )
|
||||
{
|
||||
int new_val{};
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
const int dy = mouse_y - slider_click_pos;
|
||||
slider_click_pos = mouse_y;
|
||||
@ -362,7 +365,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
|
||||
{
|
||||
delOwnTimers();
|
||||
}
|
||||
else if ( scroll_type != FScrollbar::scrollJump )
|
||||
else if ( scroll_type != ScrollType::Jump )
|
||||
{
|
||||
addTimer(repeat_time);
|
||||
}
|
||||
@ -376,18 +379,18 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
const int wheel = ev->getWheel();
|
||||
const MouseWheel wheel = ev->getWheel();
|
||||
|
||||
if ( scroll_type != FScrollbar::noScroll )
|
||||
if ( scroll_type != ScrollType::None )
|
||||
{
|
||||
delOwnTimers();
|
||||
scroll_type = FScrollbar::noScroll;
|
||||
scroll_type = ScrollType::None;
|
||||
}
|
||||
|
||||
if ( wheel == fc::WheelUp )
|
||||
scroll_type = FScrollbar::scrollWheelUp;
|
||||
else if ( wheel == fc::WheelDown )
|
||||
scroll_type = FScrollbar::scrollWheelDown;
|
||||
if ( wheel == MouseWheel::Up )
|
||||
scroll_type = ScrollType::WheelUp;
|
||||
else if ( wheel == MouseWheel::Down )
|
||||
scroll_type = ScrollType::WheelDown;
|
||||
|
||||
processScroll();
|
||||
}
|
||||
@ -395,7 +398,7 @@ void FScrollbar::onWheel (FWheelEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::onTimer (FTimerEvent*)
|
||||
{
|
||||
if ( scroll_type == FScrollbar::noScroll )
|
||||
if ( scroll_type == ScrollType::None )
|
||||
return;
|
||||
|
||||
if ( ! threshold_reached )
|
||||
@ -406,20 +409,20 @@ void FScrollbar::onTimer (FTimerEvent*)
|
||||
}
|
||||
|
||||
// Timer stop condition
|
||||
if ( ( scroll_type == FScrollbar::scrollPageBackward
|
||||
if ( ( scroll_type == ScrollType::PageBackward
|
||||
&& slider_pos == slider_click_stop_pos )
|
||||
|| ( scroll_type == FScrollbar::scrollPageForward
|
||||
|| ( scroll_type == ScrollType::PageForward
|
||||
&& slider_pos == slider_click_stop_pos ) )
|
||||
{
|
||||
const auto max_slider_pos = int(bar_length - slider_length);
|
||||
|
||||
if ( scroll_type == FScrollbar::scrollPageBackward
|
||||
if ( scroll_type == ScrollType::PageBackward
|
||||
&& slider_pos == 0 )
|
||||
{
|
||||
jumpToClickPos(0); // Scroll to the start
|
||||
processScroll();
|
||||
}
|
||||
else if ( scroll_type == FScrollbar::scrollPageForward
|
||||
else if ( scroll_type == ScrollType::PageForward
|
||||
&& slider_pos == max_slider_pos )
|
||||
{
|
||||
jumpToClickPos (max_slider_pos); // Scroll to the end
|
||||
@ -505,15 +508,15 @@ inline void FScrollbar::drawVerticalBackgroundLine()
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
print (UniChar::MediumShade); // ▒
|
||||
else
|
||||
print (fc::NF_border_line_left); // ⎸
|
||||
print (UniChar::NF_border_line_left); // ⎸
|
||||
}
|
||||
|
||||
if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
print (UniChar::MediumShade); // ▒
|
||||
else if ( FTerm::isNewFont() )
|
||||
print (fc::NF_rev_border_line_right); //⎹
|
||||
print (UniChar::NF_rev_border_line_right); //⎹
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
@ -557,9 +560,9 @@ void FScrollbar::drawHorizontalBar()
|
||||
inline void FScrollbar::drawHorizontalBackgroundColumn()
|
||||
{
|
||||
if ( FTerm::isNewFont() && max_color > 8 )
|
||||
print (fc::NF_border_line_up_and_down); // ニ
|
||||
print (UniChar::NF_border_line_up_and_down); // ニ
|
||||
else if ( FTerm::isMonochron() || max_color < 16 )
|
||||
print (fc::MediumShade); // ▒
|
||||
print (UniChar::MediumShade); // ▒
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
@ -574,7 +577,7 @@ void FScrollbar::drawButtons()
|
||||
{
|
||||
print() << FPoint{1, 1};
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
print() << NF_button_arrow_up
|
||||
<< FPoint{1, int(length)}
|
||||
@ -594,17 +597,17 @@ void FScrollbar::drawButtons()
|
||||
if ( FTerm::isMonochron() )
|
||||
setReverse(true);
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
print() << fc::BlackUpPointingTriangle // ▲
|
||||
print() << UniChar::BlackUpPointingTriangle // ▲
|
||||
<< FPoint{1, int(length)}
|
||||
<< fc::BlackDownPointingTriangle; // ▼
|
||||
<< UniChar::BlackDownPointingTriangle; // ▼
|
||||
}
|
||||
else // horizontal
|
||||
{
|
||||
print() << fc::BlackLeftPointingPointer // ◄
|
||||
print() << UniChar::BlackLeftPointingPointer // ◄
|
||||
<< FPoint{int(length), 1}
|
||||
<< fc::BlackRightPointingPointer; // ►
|
||||
<< UniChar::BlackRightPointingPointer; // ►
|
||||
}
|
||||
|
||||
if ( FTerm::isMonochron() )
|
||||
@ -613,9 +616,9 @@ void FScrollbar::drawButtons()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) const
|
||||
FScrollbar::ScrollType FScrollbar::getClickedScrollType (int x, int y) const
|
||||
{
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
return getVerticalClickedScrollType(y);
|
||||
}
|
||||
@ -626,72 +629,72 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y) const
|
||||
FScrollbar::ScrollType FScrollbar::getVerticalClickedScrollType (int y) const
|
||||
{
|
||||
if ( y == 1 )
|
||||
{
|
||||
return FScrollbar::scrollStepBackward; // decrement button
|
||||
return ScrollType::StepBackward; // decrement button
|
||||
}
|
||||
else if ( y > 1 && y <= slider_pos + 1 )
|
||||
{
|
||||
return FScrollbar::scrollPageBackward; // before slider
|
||||
return ScrollType::PageBackward; // before slider
|
||||
}
|
||||
else if ( y > slider_pos + int(slider_length) + 1 && y < int(getHeight()) )
|
||||
{
|
||||
return FScrollbar::scrollPageForward; // after slider
|
||||
return ScrollType::PageForward; // after slider
|
||||
}
|
||||
else if ( y == int(getHeight()) )
|
||||
{
|
||||
return FScrollbar::scrollStepForward; // increment button
|
||||
return ScrollType::StepForward; // increment button
|
||||
}
|
||||
|
||||
return FScrollbar::noScroll;
|
||||
return ScrollType::None;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x) const
|
||||
FScrollbar::ScrollType FScrollbar::getHorizontalClickedScrollType (int x) const
|
||||
{
|
||||
if ( FTerm::isNewFont() )
|
||||
{
|
||||
if ( x == 1 || x == 2 )
|
||||
{
|
||||
return FScrollbar::scrollStepBackward; // decrement button
|
||||
return ScrollType::StepBackward; // decrement button
|
||||
}
|
||||
else if ( x > 2 && x <= slider_pos + 2 )
|
||||
{
|
||||
return FScrollbar::scrollPageBackward; // before slider
|
||||
return ScrollType::PageBackward; // before slider
|
||||
}
|
||||
else if ( x > slider_pos + int(slider_length) + 2 && x < int(getWidth()) - 1 )
|
||||
{
|
||||
return FScrollbar::scrollPageForward; // after slider
|
||||
return ScrollType::PageForward; // after slider
|
||||
}
|
||||
else if ( x == int(getWidth()) - 1 || x == int(getWidth()) )
|
||||
{
|
||||
return FScrollbar::scrollStepForward; // increment button
|
||||
return ScrollType::StepForward; // increment button
|
||||
}
|
||||
|
||||
return FScrollbar::noScroll;
|
||||
return ScrollType::None;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( x == 1 )
|
||||
{
|
||||
return FScrollbar::scrollStepBackward; // decrement button
|
||||
return ScrollType::StepBackward; // decrement button
|
||||
}
|
||||
else if ( x > 1 && x <= slider_pos + 1 )
|
||||
{
|
||||
return FScrollbar::scrollPageBackward; // before slider
|
||||
return ScrollType::PageBackward; // before slider
|
||||
}
|
||||
else if ( x > slider_pos + int(slider_length) + 1 && x < int(getWidth()) )
|
||||
{
|
||||
return FScrollbar::scrollPageForward; // after slider
|
||||
return ScrollType::PageForward; // after slider
|
||||
}
|
||||
else if ( x == int(getWidth()) )
|
||||
{
|
||||
return FScrollbar::scrollStepForward; // increment button
|
||||
return ScrollType::StepForward; // increment button
|
||||
}
|
||||
|
||||
return FScrollbar::noScroll;
|
||||
return ScrollType::None;
|
||||
}
|
||||
}
|
||||
|
||||
@ -700,7 +703,7 @@ int FScrollbar::getSliderClickPos (int mouse_x, int mouse_y) const
|
||||
{
|
||||
// Get the clicked position on the slider
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
if ( mouse_y > slider_pos + 1
|
||||
&& mouse_y <= slider_pos + int(slider_length) + 1 )
|
||||
@ -730,7 +733,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
|
||||
{
|
||||
int new_val{};
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
if ( y > 1 && y < int(getHeight()) )
|
||||
{
|
||||
@ -758,7 +761,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
|
||||
setValue(new_val);
|
||||
drawBar();
|
||||
forceTerminalUpdate();
|
||||
scroll_type = FScrollbar::scrollJump;
|
||||
scroll_type = ScrollType::Jump;
|
||||
processScroll();
|
||||
}
|
||||
}
|
||||
@ -766,7 +769,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollbar::jumpToClickPos (int pos)
|
||||
{
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
jumpToClickPos (0, pos + 2);
|
||||
else
|
||||
{
|
||||
@ -781,9 +784,9 @@ void FScrollbar::jumpToClickPos (int pos)
|
||||
void FScrollbar::avoidScrollOvershoot()
|
||||
{
|
||||
// Avoid overshoot
|
||||
if ( ( scroll_type == FScrollbar::scrollPageBackward
|
||||
if ( ( scroll_type == ScrollType::PageBackward
|
||||
&& slider_pos < slider_click_stop_pos )
|
||||
|| ( scroll_type == FScrollbar::scrollPageForward
|
||||
|| ( scroll_type == ScrollType::PageForward
|
||||
&& slider_pos > slider_click_stop_pos ) )
|
||||
{
|
||||
jumpToClickPos (slider_click_stop_pos);
|
||||
@ -804,9 +807,9 @@ void FScrollbar::changeOnResize()
|
||||
const FSize& size = getSize();
|
||||
const std::size_t w = size.getWidth();
|
||||
const std::size_t h = size.getHeight();
|
||||
length = ( bar_orientation == fc::vertical ) ? h : w;
|
||||
length = ( bar_orientation == Orientation::Vertical ) ? h : w;
|
||||
|
||||
if ( bar_orientation == fc::vertical )
|
||||
if ( bar_orientation == Orientation::Vertical )
|
||||
{
|
||||
setWidth(FTerm::isNewFont() ? 2 : 1);
|
||||
setHeight(length);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -212,6 +212,9 @@ void FScrollView::setPos (const FPoint& p, bool adjust)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setWidth (std::size_t w, bool adjust)
|
||||
{
|
||||
if ( w <= vertical_border_spacing + nf_offset )
|
||||
return;
|
||||
|
||||
FWidget::setWidth (w, adjust);
|
||||
viewport_geometry.setWidth(w - vertical_border_spacing - nf_offset);
|
||||
calculateScrollbarPos();
|
||||
@ -223,6 +226,9 @@ void FScrollView::setWidth (std::size_t w, bool adjust)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setHeight (std::size_t h, bool adjust)
|
||||
{
|
||||
if ( h <= horizontal_border_spacing )
|
||||
return;
|
||||
|
||||
FWidget::setHeight (h, adjust);
|
||||
viewport_geometry.setHeight(h - horizontal_border_spacing);
|
||||
calculateScrollbarPos();
|
||||
@ -236,6 +242,11 @@ void FScrollView::setSize (const FSize& size, bool adjust)
|
||||
{
|
||||
const std::size_t w = size.getWidth();
|
||||
const std::size_t h = size.getHeight();
|
||||
|
||||
if ( w <= vertical_border_spacing + nf_offset
|
||||
|| h <= horizontal_border_spacing )
|
||||
return;
|
||||
|
||||
FWidget::setSize (size, adjust);
|
||||
viewport_geometry.setSize ( w - vertical_border_spacing - nf_offset
|
||||
, h - horizontal_border_spacing );
|
||||
@ -309,7 +320,7 @@ bool FScrollView::setBorder (bool enable)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
|
||||
void FScrollView::setHorizontalScrollBarMode (ScrollBarMode mode)
|
||||
{
|
||||
h_mode = mode;
|
||||
|
||||
@ -318,7 +329,7 @@ void FScrollView::setHorizontalScrollBarMode (fc::scrollBarMode mode)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
|
||||
void FScrollView::setVerticalScrollBarMode (ScrollBarMode mode)
|
||||
{
|
||||
v_mode = mode;
|
||||
|
||||
@ -327,7 +338,7 @@ void FScrollView::setVerticalScrollBarMode (fc::scrollBarMode mode)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::clearArea (int fillchar)
|
||||
void FScrollView::clearArea (wchar_t fillchar)
|
||||
{
|
||||
if ( viewport )
|
||||
clearArea (viewport, fillchar);
|
||||
@ -462,11 +473,11 @@ void FScrollView::drawBorder()
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
const auto idx = int(ev->key());
|
||||
const auto& entry = key_map[ev->key()];
|
||||
|
||||
if ( key_map.find(idx) != key_map.end() )
|
||||
if ( entry )
|
||||
{
|
||||
key_map[idx]();
|
||||
entry();
|
||||
ev->accept();
|
||||
}
|
||||
}
|
||||
@ -476,18 +487,13 @@ void FScrollView::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
static constexpr int distance = 4;
|
||||
|
||||
switch ( ev->getWheel() )
|
||||
if ( ev->getWheel() == MouseWheel::Up )
|
||||
{
|
||||
case fc::WheelUp:
|
||||
scrollBy (0, -distance);
|
||||
break;
|
||||
|
||||
case fc::WheelDown:
|
||||
scrollBy (0, distance);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
scrollBy (0, -distance);
|
||||
}
|
||||
else if ( ev->getWheel() == MouseWheel::Down )
|
||||
{
|
||||
scrollBy (0, distance);
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,9 +506,9 @@ void FScrollView::onFocusIn (FFocusEvent* in_ev)
|
||||
{
|
||||
auto prev_element = getFocusWidget();
|
||||
|
||||
if ( in_ev->getFocusType() == fc::FocusNextWidget )
|
||||
if ( in_ev->getFocusType() == FocusTypes::NextWidget )
|
||||
focusFirstChild();
|
||||
else if ( in_ev->getFocusType() == fc::FocusPreviousWidget )
|
||||
else if ( in_ev->getFocusType() == FocusTypes::PreviousWidget )
|
||||
focusLastChild();
|
||||
|
||||
if ( prev_element )
|
||||
@ -511,7 +517,7 @@ void FScrollView::onFocusIn (FFocusEvent* in_ev)
|
||||
if ( getFocusWidget() )
|
||||
getFocusWidget()->redraw();
|
||||
|
||||
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
||||
FFocusEvent cfi (Event::ChildFocusIn);
|
||||
onChildFocusIn(&cfi);
|
||||
}
|
||||
}
|
||||
@ -560,7 +566,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
|
||||
|
||||
const auto& focus = FWidget::getFocusWidget();
|
||||
|
||||
if ( out_ev->getFocusType() == fc::FocusNextWidget )
|
||||
if ( out_ev->getFocusType() == FocusTypes::NextWidget )
|
||||
{
|
||||
const auto& last_widget = getLastFocusableWidget(getChildren());
|
||||
|
||||
@ -570,7 +576,7 @@ void FScrollView::onChildFocusOut (FFocusEvent* out_ev)
|
||||
focusNextChild();
|
||||
}
|
||||
}
|
||||
else if ( out_ev->getFocusType() == fc::FocusPreviousWidget )
|
||||
else if ( out_ev->getFocusType() == FocusTypes::PreviousWidget )
|
||||
{
|
||||
const auto& first_widget = getFirstFocusableWidget(getChildren());
|
||||
|
||||
@ -632,11 +638,8 @@ void FScrollView::adjustSize()
|
||||
vbar->setValue (yoffset);
|
||||
vbar->resize();
|
||||
|
||||
if ( isShown() )
|
||||
{
|
||||
setHorizontalScrollBarVisibility();
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
setHorizontalScrollBarVisibility();
|
||||
setVerticalScrollBarVisibility();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -717,8 +720,8 @@ void FScrollView::init()
|
||||
assert ( parent != nullptr );
|
||||
assert ( ! parent->isInstanceOf("FScrollView") );
|
||||
|
||||
initScrollbar (vbar, fc::vertical, &FScrollView::cb_vbarChange);
|
||||
initScrollbar (hbar, fc::horizontal, &FScrollView::cb_hbarChange);
|
||||
initScrollbar (vbar, Orientation::Vertical, &FScrollView::cb_vbarChange);
|
||||
initScrollbar (hbar, Orientation::Horizontal, &FScrollView::cb_hbarChange);
|
||||
mapKeyFunctions();
|
||||
resetColors();
|
||||
setGeometry (FPoint{1, 1}, FSize{4, 4});
|
||||
@ -754,14 +757,14 @@ void FScrollView::init()
|
||||
//----------------------------------------------------------------------
|
||||
inline void FScrollView::mapKeyFunctions()
|
||||
{
|
||||
key_map[fc::Fkey_up] = [this] { scrollBy (0, -1); };
|
||||
key_map[fc::Fkey_down] = [this] { scrollBy (0, 1); };
|
||||
key_map[fc::Fkey_left] = [this] { scrollBy (-1, 0); };
|
||||
key_map[fc::Fkey_right] = [this] { scrollBy (1, 0); };
|
||||
key_map[fc::Fkey_ppage] = [this] { scrollBy (0, -int(getViewportHeight())); };
|
||||
key_map[fc::Fkey_npage] = [this] { scrollBy (0, int(getViewportHeight())); };
|
||||
key_map[fc::Fkey_home] = [this] { scrollToY (1); };
|
||||
key_map[fc::Fkey_end] = \
|
||||
key_map[FKey::Up] = [this] { scrollBy (0, -1); };
|
||||
key_map[FKey::Down] = [this] { scrollBy (0, 1); };
|
||||
key_map[FKey::Left] = [this] { scrollBy (-1, 0); };
|
||||
key_map[FKey::Right] = [this] { scrollBy (1, 0); };
|
||||
key_map[FKey::Page_up] = [this] { scrollBy (0, -int(getViewportHeight())); };
|
||||
key_map[FKey::Page_down] = [this] { scrollBy (0, int(getViewportHeight())); };
|
||||
key_map[FKey::Home] = [this] { scrollToY (1); };
|
||||
key_map[FKey::End] = \
|
||||
[this] ()
|
||||
{
|
||||
auto yoffset_end = int(getScrollHeight() - getViewportHeight());
|
||||
@ -793,52 +796,40 @@ void FScrollView::calculateScrollbarPos() const
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setHorizontalScrollBarVisibility() const
|
||||
{
|
||||
assert ( v_mode == fc::Auto
|
||||
|| v_mode == fc::Hidden
|
||||
|| v_mode == fc::Scroll );
|
||||
|
||||
switch ( h_mode )
|
||||
if ( h_mode == ScrollBarMode::Auto )
|
||||
{
|
||||
case fc::Auto:
|
||||
if ( getScrollWidth() > getViewportWidth() )
|
||||
hbar->show();
|
||||
else
|
||||
hbar->hide();
|
||||
break;
|
||||
|
||||
case fc::Hidden:
|
||||
hbar->hide();
|
||||
break;
|
||||
|
||||
case fc::Scroll:
|
||||
if ( getScrollWidth() > getViewportWidth() )
|
||||
hbar->show();
|
||||
break;
|
||||
else
|
||||
hbar->hide();
|
||||
}
|
||||
else if ( h_mode == ScrollBarMode::Hidden )
|
||||
{
|
||||
hbar->hide();
|
||||
}
|
||||
else if ( h_mode == ScrollBarMode::Scroll )
|
||||
{
|
||||
hbar->show();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::setVerticalScrollBarVisibility() const
|
||||
{
|
||||
assert ( v_mode == fc::Auto
|
||||
|| v_mode == fc::Hidden
|
||||
|| v_mode == fc::Scroll );
|
||||
|
||||
switch ( v_mode )
|
||||
if ( v_mode == ScrollBarMode::Auto )
|
||||
{
|
||||
case fc::Auto:
|
||||
if ( getScrollHeight() > getViewportHeight() )
|
||||
vbar->show();
|
||||
else
|
||||
vbar->hide();
|
||||
break;
|
||||
|
||||
case fc::Hidden:
|
||||
vbar->hide();
|
||||
break;
|
||||
|
||||
case fc::Scroll:
|
||||
if ( getScrollHeight() > getViewportHeight() )
|
||||
vbar->show();
|
||||
break;
|
||||
else
|
||||
vbar->hide();
|
||||
}
|
||||
else if ( v_mode == ScrollBarMode::Hidden )
|
||||
{
|
||||
vbar->hide();
|
||||
}
|
||||
else if ( v_mode == ScrollBarMode::Scroll )
|
||||
{
|
||||
vbar->show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,19 +856,19 @@ void FScrollView::setViewportCursor()
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::cb_vbarChange (const FWidget*)
|
||||
{
|
||||
FScrollbar::sType scrollType = vbar->getScrollType();
|
||||
FScrollbar::ScrollType scrollType = vbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
int distance{1};
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
|
||||
{
|
||||
update_scrollbar = true;
|
||||
}
|
||||
@ -888,32 +879,32 @@ void FScrollView::cb_vbarChange (const FWidget*)
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getViewportHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
scrollBy (0, -distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getViewportHeight());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
scrollBy (0, distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToY (1 + int(vbar->getValue()));
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
scrollBy (0, -wheel_distance);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
scrollBy (0, wheel_distance);
|
||||
break;
|
||||
}
|
||||
@ -924,19 +915,19 @@ void FScrollView::cb_vbarChange (const FWidget*)
|
||||
//----------------------------------------------------------------------
|
||||
void FScrollView::cb_hbarChange (const FWidget*)
|
||||
{
|
||||
FScrollbar::sType scrollType = hbar->getScrollType();
|
||||
FScrollbar::ScrollType scrollType = hbar->getScrollType();
|
||||
static constexpr int wheel_distance = 4;
|
||||
int distance{1};
|
||||
assert ( scrollType == FScrollbar::noScroll
|
||||
|| scrollType == FScrollbar::scrollJump
|
||||
|| scrollType == FScrollbar::scrollStepBackward
|
||||
|| scrollType == FScrollbar::scrollStepForward
|
||||
|| scrollType == FScrollbar::scrollPageBackward
|
||||
|| scrollType == FScrollbar::scrollPageForward
|
||||
|| scrollType == FScrollbar::scrollWheelUp
|
||||
|| scrollType == FScrollbar::scrollWheelDown );
|
||||
assert ( scrollType == FScrollbar::ScrollType::None
|
||||
|| scrollType == FScrollbar::ScrollType::Jump
|
||||
|| scrollType == FScrollbar::ScrollType::StepBackward
|
||||
|| scrollType == FScrollbar::ScrollType::StepForward
|
||||
|| scrollType == FScrollbar::ScrollType::PageBackward
|
||||
|| scrollType == FScrollbar::ScrollType::PageForward
|
||||
|| scrollType == FScrollbar::ScrollType::WheelUp
|
||||
|| scrollType == FScrollbar::ScrollType::WheelDown );
|
||||
|
||||
if ( scrollType >= FScrollbar::scrollStepBackward )
|
||||
if ( scrollType >= FScrollbar::ScrollType::StepBackward )
|
||||
{
|
||||
update_scrollbar = true;
|
||||
}
|
||||
@ -947,32 +938,32 @@ void FScrollView::cb_hbarChange (const FWidget*)
|
||||
|
||||
switch ( scrollType )
|
||||
{
|
||||
case FScrollbar::noScroll:
|
||||
case FScrollbar::ScrollType::None:
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageBackward:
|
||||
case FScrollbar::ScrollType::PageBackward:
|
||||
distance = int(getViewportWidth());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepBackward:
|
||||
case FScrollbar::ScrollType::StepBackward:
|
||||
scrollBy (-distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollPageForward:
|
||||
case FScrollbar::ScrollType::PageForward:
|
||||
distance = int(getViewportWidth());
|
||||
// fall through
|
||||
case FScrollbar::scrollStepForward:
|
||||
case FScrollbar::ScrollType::StepForward:
|
||||
scrollBy (distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollJump:
|
||||
case FScrollbar::ScrollType::Jump:
|
||||
scrollToX (1 + int(hbar->getValue()));
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelUp:
|
||||
case FScrollbar::ScrollType::WheelUp:
|
||||
scrollBy (-wheel_distance, 0);
|
||||
break;
|
||||
|
||||
case FScrollbar::scrollWheelDown:
|
||||
case FScrollbar::ScrollType::WheelDown:
|
||||
scrollBy (wheel_distance, 0);
|
||||
break;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -33,26 +33,7 @@ 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 = (FSize&& s) noexcept
|
||||
{
|
||||
width = std::move(s.width);
|
||||
height = std::move(s.height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSize& FSize::operator += (const FSize& s)
|
||||
{
|
||||
|
135
src/fspinbox.cpp
135
src/fspinbox.cpp
@ -48,8 +48,7 @@ FSpinBox::FSpinBox (FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSpinBox::~FSpinBox() // destructor
|
||||
{ }
|
||||
FSpinBox::~FSpinBox() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FSpinBox
|
||||
@ -92,8 +91,8 @@ bool FSpinBox::setFocus (bool enable)
|
||||
bool FSpinBox::setShadow (bool enable)
|
||||
{
|
||||
if ( enable
|
||||
&& FTerm::getEncoding() != fc::VT100
|
||||
&& FTerm::getEncoding() != fc::ASCII )
|
||||
&& FTerm::getEncoding() != Encoding::VT100
|
||||
&& FTerm::getEncoding() != Encoding::ASCII )
|
||||
{
|
||||
setFlags().shadow = true;
|
||||
setShadowSize(FSize{1, 1});
|
||||
@ -175,28 +174,33 @@ void FSpinBox::onKeyPress (FKeyEvent* ev)
|
||||
|
||||
const FKey key = ev->key();
|
||||
|
||||
switch ( key )
|
||||
if ( key == FKey::Tab )
|
||||
{
|
||||
case fc::Fkey_tab:
|
||||
focusNextChild();
|
||||
break;
|
||||
|
||||
case fc::Fkey_btab:
|
||||
focusPrevChild();
|
||||
break;
|
||||
|
||||
case fc::Fkey_up:
|
||||
increaseValue();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_down:
|
||||
decreaseValue();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
focusNextChild();
|
||||
}
|
||||
else if ( key == FKey::Back_tab )
|
||||
{
|
||||
focusPrevChild();
|
||||
}
|
||||
else if ( key == FKey::Up )
|
||||
{
|
||||
increaseValue();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Down )
|
||||
{
|
||||
decreaseValue();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Page_up )
|
||||
{
|
||||
increaseValue(10);
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::Page_down )
|
||||
{
|
||||
decreaseValue(10);
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
if ( ev->isAccepted() )
|
||||
@ -206,8 +210,8 @@ void FSpinBox::onKeyPress (FKeyEvent* ev)
|
||||
//----------------------------------------------------------------------
|
||||
void FSpinBox::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
if ( ev->getButton() != fc::LeftButton
|
||||
&& ev->getButton() != fc::MiddleButton )
|
||||
if ( ev->getButton() != MouseButton::Left
|
||||
&& ev->getButton() != MouseButton::Middle )
|
||||
return;
|
||||
|
||||
forceFocus();
|
||||
@ -220,7 +224,7 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
|
||||
|
||||
if ( mouse_x == int(getWidth()) - 1 && mouse_y == 1 )
|
||||
{
|
||||
spining_state = FSpinBox::spinDown;
|
||||
spining_state = SpiningState::Down;
|
||||
decreaseValue();
|
||||
updateInputField();
|
||||
threshold_reached = false;
|
||||
@ -228,7 +232,7 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
|
||||
}
|
||||
else if ( mouse_x == int(getWidth()) && mouse_y == 1 )
|
||||
{
|
||||
spining_state = FSpinBox::spinUp;
|
||||
spining_state = SpiningState::Up;
|
||||
increaseValue();
|
||||
updateInputField();
|
||||
threshold_reached = false;
|
||||
@ -242,32 +246,27 @@ void FSpinBox::onMouseDown (FMouseEvent* ev)
|
||||
void FSpinBox::onMouseUp (FMouseEvent*)
|
||||
{
|
||||
delOwnTimers();
|
||||
spining_state = FSpinBox::noSpin;
|
||||
spining_state = SpiningState::None;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FSpinBox::onWheel (FWheelEvent* ev)
|
||||
{
|
||||
const int wheel = ev->getWheel();
|
||||
const MouseWheel wheel = ev->getWheel();
|
||||
|
||||
delOwnTimers();
|
||||
forceFocus();
|
||||
spining_state = FSpinBox::noSpin;
|
||||
spining_state = SpiningState::None;
|
||||
|
||||
switch ( wheel )
|
||||
if ( wheel == MouseWheel::Up )
|
||||
{
|
||||
case fc::WheelUp:
|
||||
increaseValue();
|
||||
updateInputField();
|
||||
break;
|
||||
|
||||
case fc::WheelDown:
|
||||
decreaseValue();
|
||||
updateInputField();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
increaseValue();
|
||||
updateInputField();
|
||||
}
|
||||
else if ( wheel == MouseWheel::Down )
|
||||
{
|
||||
decreaseValue();
|
||||
updateInputField();
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,21 +280,21 @@ void FSpinBox::onTimer (FTimerEvent*)
|
||||
addTimer(repeat_time);
|
||||
}
|
||||
|
||||
assert ( spining_state == FSpinBox::noSpin
|
||||
|| spining_state == FSpinBox::spinUp
|
||||
|| spining_state == FSpinBox::spinDown );
|
||||
assert ( spining_state == SpiningState::None
|
||||
|| spining_state == SpiningState::Up
|
||||
|| spining_state == SpiningState::Down );
|
||||
|
||||
switch ( spining_state )
|
||||
{
|
||||
case FSpinBox::noSpin:
|
||||
case SpiningState::None:
|
||||
break;
|
||||
|
||||
case FSpinBox::spinUp:
|
||||
case SpiningState::Up:
|
||||
increaseValue();
|
||||
updateInputField();
|
||||
break;
|
||||
|
||||
case FSpinBox::spinDown:
|
||||
case SpiningState::Down:
|
||||
decreaseValue();
|
||||
updateInputField();
|
||||
break;
|
||||
@ -356,9 +355,9 @@ void FSpinBox::draw()
|
||||
|
||||
print() << FPoint{int(getWidth()) - 1, 1}
|
||||
<< dec_button_color
|
||||
<< fc::BlackDownPointingTriangle // ▼
|
||||
<< UniChar::BlackDownPointingTriangle // ▼
|
||||
<< inc_button_color
|
||||
<< fc::BlackUpPointingTriangle; // ▲
|
||||
<< UniChar::BlackUpPointingTriangle; // ▲
|
||||
|
||||
if ( getFlags().shadow )
|
||||
drawShadow(this);
|
||||
@ -374,11 +373,15 @@ inline void FSpinBox::updateInputField()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FSpinBox::increaseValue()
|
||||
inline void FSpinBox::increaseValue (sInt64 n)
|
||||
{
|
||||
if ( value < max )
|
||||
{
|
||||
value++;
|
||||
if ( value < max - n )
|
||||
value += n;
|
||||
else
|
||||
value = max;
|
||||
|
||||
processChanged();
|
||||
}
|
||||
else
|
||||
@ -386,11 +389,15 @@ inline void FSpinBox::increaseValue()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FSpinBox::decreaseValue()
|
||||
inline void FSpinBox::decreaseValue (sInt64 n)
|
||||
{
|
||||
if ( value > min )
|
||||
{
|
||||
value--;
|
||||
if ( value > min + n )
|
||||
value -= n;
|
||||
else
|
||||
value = min;
|
||||
|
||||
processChanged();
|
||||
}
|
||||
else
|
||||
@ -412,19 +419,7 @@ void FSpinBox::processChanged() const
|
||||
//----------------------------------------------------------------------
|
||||
void FSpinBox::forceFocus()
|
||||
{
|
||||
if ( hasFocus() )
|
||||
return;
|
||||
|
||||
auto focused_widget = getFocusWidget();
|
||||
setFocus();
|
||||
|
||||
if ( focused_widget )
|
||||
focused_widget->redraw();
|
||||
|
||||
redraw();
|
||||
|
||||
if ( getStatusBar() )
|
||||
getStatusBar()->drawMessage();
|
||||
setWidgetFocus(this);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -27,9 +27,6 @@
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attribute
|
||||
FStartOptions* FStartOptions::start_options{};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
@ -54,37 +51,15 @@ FStartOptions::FStartOptions()
|
||||
, dark_theme{false}
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions::~FStartOptions() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FStartOptions
|
||||
//----------------------------------------------------------------------
|
||||
FStartOptions& FStartOptions::getFStartOptions()
|
||||
{
|
||||
if ( start_options == nullptr )
|
||||
{
|
||||
try
|
||||
{
|
||||
start_options = new FStartOptions;
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
badAllocOutput ("FStartOptions");
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
static const auto& start_options = make_unique<FStartOptions>();
|
||||
return *start_options;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStartOptions::destroyObject()
|
||||
{
|
||||
if ( start_options )
|
||||
delete start_options;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FStartOptions::setDefault()
|
||||
{
|
||||
@ -94,7 +69,7 @@ void FStartOptions::setDefault()
|
||||
color_change = true;
|
||||
vgafont = false;
|
||||
newfont = false;
|
||||
encoding = fc::UNKNOWN;
|
||||
encoding = Encoding::Unknown;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
meta_sends_escape = true;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2014-2020 Markus Gans *
|
||||
* Copyright 2014-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -143,12 +143,12 @@ FStatusBar::~FStatusBar() // destructor
|
||||
while ( iter != key_list.end() )
|
||||
{
|
||||
(*iter)->setConnectedStatusbar(nullptr);
|
||||
delAccelerator (*iter);
|
||||
FWidget::delAccelerator (*iter);
|
||||
iter = key_list.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
setStatusBar(nullptr);
|
||||
FWidget::setStatusBar(nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ void FStatusBar::drawMessage()
|
||||
if ( hasKeys )
|
||||
{
|
||||
x += 2;
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
print (UniChar::BoxDrawingsVertical); // │
|
||||
print (' ');
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ void FStatusBar::onMouseDown (FMouseEvent* ev)
|
||||
if ( hasActivatedKey() )
|
||||
return;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
{
|
||||
mouse_down = false;
|
||||
|
||||
@ -392,7 +392,7 @@ void FStatusBar::onMouseUp (FMouseEvent* ev)
|
||||
if ( hasActivatedKey() )
|
||||
return;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( mouse_down )
|
||||
@ -439,7 +439,7 @@ void FStatusBar::onMouseMove (FMouseEvent* ev)
|
||||
if ( hasActivatedKey() )
|
||||
return;
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
if ( mouse_down && ! key_list.empty() )
|
||||
@ -639,7 +639,7 @@ void FStatusBar::drawKey (FKeyList::const_iterator iter)
|
||||
if ( FTerm::hasHalfBlockCharacter() )
|
||||
{
|
||||
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
|
||||
print (fc::LeftHalfBlock); // ▐
|
||||
print (UniChar::LeftHalfBlock); // ▐
|
||||
}
|
||||
else
|
||||
print (' ');
|
||||
@ -654,7 +654,7 @@ void FStatusBar::drawKey (FKeyList::const_iterator iter)
|
||||
// Not the last element
|
||||
setColor (wc->statusbar_separator_fg, wc->statusbar_bg);
|
||||
x++;
|
||||
print (fc::BoxDrawingsVertical); // │
|
||||
print (UniChar::BoxDrawingsVertical); // │
|
||||
}
|
||||
}
|
||||
|
||||
@ -685,8 +685,14 @@ void FStatusBar::drawActiveKey (FKeyList::const_iterator iter)
|
||||
{
|
||||
print (item->getText());
|
||||
x++;
|
||||
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
|
||||
print (fc::RightHalfBlock); // ▌
|
||||
|
||||
if ( FTerm::hasHalfBlockCharacter() )
|
||||
{
|
||||
setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg);
|
||||
print (UniChar::RightHalfBlock); // ▌
|
||||
}
|
||||
else
|
||||
print (' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2012-2020 Markus Gans *
|
||||
* Copyright 2012-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -67,6 +67,11 @@ FString::FString (std::size_t len, wchar_t c)
|
||||
*--pe = c;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (std::size_t len, const UniChar& c)
|
||||
: FString(len, wchar_t(c))
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (const FString& s) // copy constructor
|
||||
{
|
||||
@ -76,10 +81,10 @@ FString::FString (const FString& s) // copy constructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (FString&& s) noexcept // move constructor
|
||||
: string{std::move(s.string)}
|
||||
: string{s.string}
|
||||
, length{s.length}
|
||||
, bufsize{s.bufsize}
|
||||
, c_string{std::move(s.c_string)}
|
||||
, c_string{s.c_string}
|
||||
{
|
||||
s.string = nullptr;
|
||||
s.length = 0;
|
||||
@ -124,13 +129,10 @@ FString::FString (const char s[])
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString::FString (fc::SpecialCharacter c)
|
||||
FString::FString (const UniChar& c)
|
||||
{
|
||||
if ( c )
|
||||
{
|
||||
std::array<wchar_t, 2> s{{ static_cast<wchar_t>(c), L'\0' }};
|
||||
_assign (s.data());
|
||||
}
|
||||
std::array<wchar_t, 2> s{{ static_cast<wchar_t>(c), L'\0' }};
|
||||
_assign (s.data());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -157,10 +159,10 @@ FString::FString (const char c)
|
||||
FString::~FString() // destructor
|
||||
{
|
||||
if ( string )
|
||||
delete[](string);
|
||||
delete[] string;
|
||||
|
||||
if ( c_string )
|
||||
delete[](c_string);
|
||||
delete[] c_string;
|
||||
}
|
||||
|
||||
|
||||
@ -180,15 +182,15 @@ FString& FString::operator = (FString&& s) noexcept
|
||||
if ( &s != this )
|
||||
{
|
||||
if ( string )
|
||||
delete[](string);
|
||||
delete[] string;
|
||||
|
||||
if ( c_string )
|
||||
delete[](c_string);
|
||||
delete[] c_string;
|
||||
|
||||
string = std::move(s.string);
|
||||
string = s.string;
|
||||
length = s.length;
|
||||
bufsize = s.bufsize;
|
||||
c_string = std::move(s.c_string);
|
||||
c_string = s.c_string;
|
||||
|
||||
s.string = nullptr;
|
||||
s.length = 0;
|
||||
@ -214,7 +216,7 @@ FString& FString::operator << (const FString& s)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FString& FString::operator << (fc::SpecialCharacter c)
|
||||
FString& FString::operator << (const UniChar& c)
|
||||
{
|
||||
FString s{static_cast<wchar_t>(c)};
|
||||
_insert (length, s.length, s.string);
|
||||
@ -331,7 +333,7 @@ const FString& FString::operator >> (float& num) const
|
||||
//----------------------------------------------------------------------
|
||||
FString::operator bool () const
|
||||
{
|
||||
return bool(string);
|
||||
return string;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -346,7 +348,7 @@ const FString& FString::operator () () const
|
||||
FString FString::clear()
|
||||
{
|
||||
if ( string )
|
||||
delete[](string);
|
||||
delete[] string;
|
||||
|
||||
length = 0;
|
||||
bufsize = 0;
|
||||
@ -402,7 +404,7 @@ char* FString::c_str()
|
||||
//----------------------------------------------------------------------
|
||||
std::string FString::toString() const
|
||||
{
|
||||
return std::string(c_str(), length);
|
||||
return {c_str(), length};
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -440,7 +442,7 @@ sInt16 FString::toShort() const
|
||||
if ( num < SHRT_MIN )
|
||||
throw std::underflow_error ("underflow");
|
||||
|
||||
return sInt16(num);
|
||||
return static_cast<sInt16>(num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -451,7 +453,7 @@ uInt16 FString::toUShort() const
|
||||
if ( num > USHRT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
|
||||
return uInt16(num);
|
||||
return static_cast<uInt16>(num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -465,7 +467,7 @@ int FString::toInt() const
|
||||
if ( num < INT_MIN )
|
||||
throw std::underflow_error ("underflow");
|
||||
|
||||
return int(num);
|
||||
return static_cast<int>(num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -476,7 +478,7 @@ uInt FString::toUInt() const
|
||||
if ( num > UINT_MAX )
|
||||
throw std::overflow_error ("overflow");
|
||||
|
||||
return uInt(num);
|
||||
return static_cast<uInt>(num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -588,7 +590,7 @@ float FString::toFloat() const
|
||||
if ( std::fabs(num) < double(FLT_EPSILON) ) // num == 0.0f
|
||||
throw std::underflow_error ("underflow");
|
||||
|
||||
return float(num);
|
||||
return static_cast<float>(num);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -720,7 +722,7 @@ FString FString::mid (std::size_t pos, std::size_t len) const
|
||||
len = length - pos + 1;
|
||||
|
||||
if ( pos > length || pos + len - 1 > length || len == 0 )
|
||||
return FString{L""};
|
||||
return {L""};
|
||||
|
||||
wchar_t* p = s.string;
|
||||
wchar_t* first = p + pos - 1;
|
||||
@ -743,7 +745,7 @@ FStringList FString::split (const FString& delimiter) const
|
||||
|
||||
while ( token )
|
||||
{
|
||||
string_list.push_back (FString{token});
|
||||
string_list.emplace_back(token);
|
||||
token = _extractToken (&rest, nullptr, delimiter.wc_str());
|
||||
}
|
||||
|
||||
@ -905,7 +907,7 @@ bool FString::operator < (const FString& s) const
|
||||
if ( ! (string || s.string) )
|
||||
return false;
|
||||
|
||||
return ( std::wcscmp(string, s.string) < 0 );
|
||||
return std::wcscmp(string, s.string) < 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -920,7 +922,7 @@ bool FString::operator <= (const FString& s) const
|
||||
if ( ! string && s.string )
|
||||
return true;
|
||||
|
||||
return ( std::wcscmp(string, s.string) <= 0 );
|
||||
return std::wcscmp(string, s.string) <= 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -932,7 +934,7 @@ bool FString::operator == (const FString& s) const
|
||||
if ( bool(string) != bool(s.string) || length != s.length )
|
||||
return false;
|
||||
|
||||
return ( std::wcscmp(string, s.string) == 0 );
|
||||
return std::wcscmp(string, s.string) == 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -953,7 +955,7 @@ bool FString::operator >= (const FString& s) const
|
||||
if ( ! (string || s.string) )
|
||||
return true;
|
||||
|
||||
return ( std::wcscmp(string, s.string) >= 0 );
|
||||
return std::wcscmp(string, s.string) >= 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -968,7 +970,7 @@ bool FString::operator > (const FString& s) const
|
||||
if ( ! string && s.string )
|
||||
return false;
|
||||
|
||||
return ( std::wcscmp(string, s.string) > 0 );
|
||||
return std::wcscmp(string, s.string) > 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -1187,7 +1189,7 @@ bool FString::includes (const FString& s) const
|
||||
if ( ! (string && s.string) )
|
||||
return false;
|
||||
|
||||
return ( std::wcsstr(string, s.string) != nullptr );
|
||||
return std::wcsstr(string, s.string) != nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -1229,7 +1231,7 @@ void FString::_assign (const wchar_t s[])
|
||||
if ( ! string || new_length > capacity() )
|
||||
{
|
||||
if ( string )
|
||||
delete[](string);
|
||||
delete[] string;
|
||||
|
||||
bufsize = FWDBUFFER + new_length + 1;
|
||||
|
||||
@ -1256,7 +1258,7 @@ void FString::_insert (std::size_t len, const wchar_t s[])
|
||||
return;
|
||||
|
||||
if ( string )
|
||||
delete[](string);
|
||||
delete[] string;
|
||||
|
||||
length = len;
|
||||
bufsize = FWDBUFFER + length + 1;
|
||||
@ -1310,7 +1312,7 @@ void FString::_insert ( std::size_t pos
|
||||
|
||||
try
|
||||
{
|
||||
sptr = new wchar_t[bufsize]; // generate new string
|
||||
sptr = new wchar_t[bufsize]; // generate new string
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
@ -1330,7 +1332,7 @@ void FString::_insert ( std::size_t pos
|
||||
sptr[y++] = string[x];
|
||||
|
||||
length += len;
|
||||
delete[](string); // delete old string
|
||||
delete[] string; // delete old string
|
||||
string = sptr;
|
||||
}
|
||||
}
|
||||
@ -1354,7 +1356,7 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
||||
|
||||
try
|
||||
{
|
||||
sptr = new wchar_t[bufsize]; // generate new string
|
||||
sptr = new wchar_t[bufsize]; // generate new string
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
@ -1365,13 +1367,13 @@ void FString::_remove (std::size_t pos, std::size_t len)
|
||||
std::size_t x{};
|
||||
std::size_t y{};
|
||||
|
||||
for (x = 0; x < pos; x++) // left side
|
||||
for (x = 0; x < pos; x++) // left side
|
||||
sptr[y++] = string[x];
|
||||
|
||||
for (x = pos + len; x < length + 1; x++) // right side + '\0'
|
||||
sptr[y++] = string[x];
|
||||
|
||||
delete[](string); // delete old string
|
||||
delete[] string; // delete old string
|
||||
string = sptr;
|
||||
length -= len;
|
||||
}
|
||||
@ -1400,7 +1402,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const
|
||||
}
|
||||
|
||||
if ( c_string )
|
||||
delete[](c_string);
|
||||
delete[] c_string;
|
||||
|
||||
const wchar_t* src = s;
|
||||
auto state = std::mbstate_t();
|
||||
@ -1423,7 +1425,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const
|
||||
|
||||
if ( mblength == static_cast<std::size_t>(-1) && errno != EILSEQ )
|
||||
{
|
||||
delete[](c_string);
|
||||
delete[] c_string;
|
||||
c_string = nullptr;
|
||||
return "";
|
||||
}
|
||||
@ -1456,6 +1458,9 @@ inline const wchar_t* FString::_to_wcstring (const char s[]) const
|
||||
auto state = std::mbstate_t();
|
||||
auto size = std::mbsrtowcs(nullptr, &src, 0, &state) + 1;
|
||||
|
||||
if ( size == 0 ) // ...malformed UTF-8 string
|
||||
return nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
dest = new wchar_t[size];
|
||||
@ -1498,7 +1503,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[]
|
||||
, const wchar_t s[]
|
||||
, const wchar_t delim[] ) const
|
||||
{
|
||||
wchar_t* token = ( s ) ? const_cast<wchar_t*>(s) : *rest;
|
||||
wchar_t* token = s ? const_cast<wchar_t*>(s) : *rest;
|
||||
|
||||
if ( ! token )
|
||||
return nullptr;
|
||||
|
@ -54,8 +54,8 @@ FStringStream::FStringStream (FStringStream&& sstream) noexcept
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FStringStream::~FStringStream() // destructor
|
||||
{ }
|
||||
FStringStream::~FStringStream() noexcept = default;
|
||||
|
||||
|
||||
// public methods of FStringStream
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -49,8 +49,7 @@ FSwitch::FSwitch (const FString& txt, FWidget* parent)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSwitch::~FSwitch() // destructor
|
||||
{ }
|
||||
FSwitch::~FSwitch() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FSwitch
|
||||
@ -64,22 +63,17 @@ void FSwitch::setText (const FString& txt)
|
||||
//----------------------------------------------------------------------
|
||||
void FSwitch::onKeyPress (FKeyEvent* ev)
|
||||
{
|
||||
switch ( ev->key() )
|
||||
const auto key = ev->key();
|
||||
|
||||
if ( key == FKey::Home || key == FKey::Left )
|
||||
{
|
||||
case fc::Fkey_home:
|
||||
case fc::Fkey_left:
|
||||
setChecked();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
case fc::Fkey_end:
|
||||
case fc::Fkey_right:
|
||||
unsetChecked();
|
||||
ev->accept();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
setChecked();
|
||||
ev->accept();
|
||||
}
|
||||
else if ( key == FKey::End || key == FKey::Right )
|
||||
{
|
||||
unsetChecked();
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
if ( ev->isAccepted() )
|
||||
@ -93,7 +87,7 @@ void FSwitch::onMouseDown (FMouseEvent* ev)
|
||||
{
|
||||
FToggleButton::onMouseDown(ev);
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
button_pressed = true;
|
||||
@ -105,7 +99,7 @@ void FSwitch::onMouseUp (FMouseEvent* ev)
|
||||
{
|
||||
FToggleButton::onMouseUp(ev);
|
||||
|
||||
if ( ev->getButton() != fc::LeftButton )
|
||||
if ( ev->getButton() != MouseButton::Left )
|
||||
return;
|
||||
|
||||
button_pressed = false;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019 Markus Gans *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -31,12 +31,7 @@ namespace finalcut
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSystem::FSystem()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSystem::~FSystem() // destructor
|
||||
{ }
|
||||
FSystem::~FSystem() noexcept = default; // destructor
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
|
@ -35,12 +35,8 @@ namespace finalcut
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FSystemImpl::FSystemImpl()
|
||||
{ }
|
||||
FSystemImpl::~FSystemImpl() noexcept = default; // destructor
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FSystemImpl::~FSystemImpl() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FSystemImpl
|
||||
//----------------------------------------------------------------------
|
||||
|
1314
src/fterm.cpp
1314
src/fterm.cpp
File diff suppressed because it is too large
Load Diff
@ -43,15 +43,18 @@ namespace finalcut
|
||||
{
|
||||
|
||||
// Enumeration
|
||||
enum fullWidthSupport
|
||||
enum class FullWidthSupport
|
||||
{
|
||||
unknown_fullwidth_support = -1,
|
||||
supports_fullwidth = 0,
|
||||
no_fullwidth_support = 1
|
||||
Unknown = -1,
|
||||
No = 0,
|
||||
Yes = 1
|
||||
};
|
||||
|
||||
// Constant
|
||||
constexpr std::size_t NOT_FOUND = static_cast<std::size_t>(-1);
|
||||
|
||||
// global state
|
||||
static fullWidthSupport has_fullwidth_support = unknown_fullwidth_support;
|
||||
static FullWidthSupport has_fullwidth_support = FullWidthSupport::Unknown;
|
||||
|
||||
// Function prototypes
|
||||
bool hasAmbiguousWidth (wchar_t);
|
||||
@ -169,29 +172,29 @@ const wchar_t ambiguous_width_list[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
const wchar_t reverse_newfont_list[] =
|
||||
{
|
||||
fc::NF_rev_left_arrow2,
|
||||
fc::NF_rev_right_arrow2,
|
||||
fc::NF_rev_border_corner_upper_right,
|
||||
fc::NF_rev_border_line_right,
|
||||
fc::NF_rev_border_line_vertical_left,
|
||||
fc::NF_rev_border_corner_lower_right,
|
||||
fc::NF_rev_up_arrow2,
|
||||
fc::NF_rev_down_arrow2,
|
||||
fc::NF_rev_up_arrow1,
|
||||
fc::NF_rev_down_arrow1,
|
||||
fc::NF_rev_left_arrow1,
|
||||
fc::NF_rev_right_arrow1,
|
||||
fc::NF_rev_menu_button1,
|
||||
fc::NF_rev_menu_button2,
|
||||
fc::NF_rev_up_pointing_triangle1,
|
||||
fc::NF_rev_down_pointing_triangle1,
|
||||
fc::NF_rev_up_pointing_triangle2,
|
||||
fc::NF_rev_down_pointing_triangle2,
|
||||
fc::NF_rev_menu_button3,
|
||||
fc::NF_rev_border_line_right_and_left
|
||||
};
|
||||
constexpr std::array<UniChar, 20> reverse_newfont_list =
|
||||
{{
|
||||
UniChar::NF_rev_left_arrow2,
|
||||
UniChar::NF_rev_right_arrow2,
|
||||
UniChar::NF_rev_border_corner_upper_right,
|
||||
UniChar::NF_rev_border_line_right,
|
||||
UniChar::NF_rev_border_line_vertical_left,
|
||||
UniChar::NF_rev_border_corner_lower_right,
|
||||
UniChar::NF_rev_up_arrow2,
|
||||
UniChar::NF_rev_down_arrow2,
|
||||
UniChar::NF_rev_up_arrow1,
|
||||
UniChar::NF_rev_down_arrow1,
|
||||
UniChar::NF_rev_left_arrow1,
|
||||
UniChar::NF_rev_right_arrow1,
|
||||
UniChar::NF_rev_menu_button1,
|
||||
UniChar::NF_rev_menu_button2,
|
||||
UniChar::NF_rev_up_pointing_triangle1,
|
||||
UniChar::NF_rev_down_pointing_triangle1,
|
||||
UniChar::NF_rev_up_pointing_triangle2,
|
||||
UniChar::NF_rev_down_pointing_triangle2,
|
||||
UniChar::NF_rev_menu_button3,
|
||||
UniChar::NF_rev_border_line_right_and_left
|
||||
}};
|
||||
|
||||
|
||||
// FTerm non-member functions
|
||||
@ -227,8 +230,11 @@ inline bool hasAmbiguousWidth (wchar_t wchar)
|
||||
const auto& begin = std::begin(ambiguous_width_list);
|
||||
const auto& end = std::end(ambiguous_width_list);
|
||||
|
||||
if ( std::find(begin, end, wchar) != end ) // found
|
||||
if ( std::any_of(begin, end, [&wchar] (const wchar_t c)
|
||||
{ return c == wchar; }) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -239,8 +245,11 @@ bool isReverseNewFontchar (wchar_t wchar)
|
||||
const auto& begin = std::begin(reverse_newfont_list);
|
||||
const auto& end = std::end(reverse_newfont_list);
|
||||
|
||||
if ( std::find(begin, end, wchar) != end ) // found
|
||||
if ( std::any_of(begin, end, [&wchar] (const UniChar& c)
|
||||
{ return wchar_t(c) == wchar; }) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -250,7 +259,7 @@ bool hasFullWidthSupports()
|
||||
{
|
||||
// Checks if the terminal has full-width character support
|
||||
|
||||
if ( has_fullwidth_support == unknown_fullwidth_support )
|
||||
if ( has_fullwidth_support == FullWidthSupport::Unknown )
|
||||
{
|
||||
if ( ! FTerm::isInitialized() )
|
||||
return true; // Assume that it is a modern terminal with full-width support
|
||||
@ -262,12 +271,12 @@ bool hasFullWidthSupports()
|
||||
|| FTerm::isOpenBSDTerm()
|
||||
|| FTerm::isSunTerminal()
|
||||
|| FTerm::isAnsiTerminal() )
|
||||
has_fullwidth_support = no_fullwidth_support;
|
||||
has_fullwidth_support = FullWidthSupport::No;
|
||||
else
|
||||
has_fullwidth_support = supports_fullwidth;
|
||||
has_fullwidth_support = FullWidthSupport::Yes;
|
||||
}
|
||||
|
||||
return ( has_fullwidth_support == supports_fullwidth) ? true : false;
|
||||
return ( has_fullwidth_support == FullWidthSupport::Yes ) ? true : false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -276,15 +285,15 @@ wchar_t cp437_to_unicode (uChar c)
|
||||
constexpr std::size_t CP437 = 0;
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
wchar_t ucs = c;
|
||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[CP437] == c;
|
||||
} );
|
||||
|
||||
for (auto&& entry : fc::cp437_ucs)
|
||||
{
|
||||
if ( entry[CP437] == c ) // found
|
||||
{
|
||||
ucs = entry[UNICODE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
ucs = (*found)[UNICODE];
|
||||
|
||||
return ucs;
|
||||
}
|
||||
@ -296,14 +305,15 @@ uChar unicode_to_cp437 (wchar_t ucs)
|
||||
constexpr std::size_t UNICODE = 1;
|
||||
uChar c{'?'};
|
||||
|
||||
for (auto&& entry : fc::cp437_ucs)
|
||||
{
|
||||
if ( entry[UNICODE] == ucs ) // found
|
||||
{
|
||||
c = uChar(entry[CP437]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto found = std::find_if ( fc::cp437_ucs.begin()
|
||||
, fc::cp437_ucs.end()
|
||||
, [&ucs] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[UNICODE] == ucs;
|
||||
} );
|
||||
|
||||
if ( found != fc::cp437_ucs.end() )
|
||||
c = static_cast<uChar>((*found)[CP437]);
|
||||
|
||||
return c;
|
||||
}
|
||||
@ -314,23 +324,27 @@ FString getFullWidth (const FString& str)
|
||||
// Converts half-width to full-width characters
|
||||
|
||||
FString s{str};
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto table_search = [] (wchar_t& c)
|
||||
{
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[HALF] == c;
|
||||
} );
|
||||
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
c = (*found)[FULL];
|
||||
};
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\x20' && c < L'\x7f' ) // half-width ASCII
|
||||
{
|
||||
c += 0xfee0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto&& entry : fc::halfwidth_fullwidth)
|
||||
{
|
||||
if ( entry[HALF] == c ) // found
|
||||
c = entry[FULL];
|
||||
}
|
||||
}
|
||||
table_search(c);
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -342,23 +356,27 @@ FString getHalfWidth (const FString& str)
|
||||
// Converts full-width to half-width characters
|
||||
|
||||
FString s{str};
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto table_search = [] (wchar_t& c)
|
||||
{
|
||||
constexpr std::size_t HALF = 0;
|
||||
constexpr std::size_t FULL = 1;
|
||||
auto found = std::find_if ( fc::halfwidth_fullwidth.begin()
|
||||
, fc::halfwidth_fullwidth.end()
|
||||
, [&c] (const std::array<wchar_t, 2>& entry)
|
||||
{
|
||||
return entry[FULL] == c;
|
||||
} );
|
||||
|
||||
if ( found != fc::halfwidth_fullwidth.end() )
|
||||
c = (*found)[HALF];
|
||||
};
|
||||
|
||||
for (auto&& c : s)
|
||||
{
|
||||
if ( c > L'\xff00' && c < L'\xff5f' ) // full-width ASCII
|
||||
{
|
||||
c -= 0xfee0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto&& entry : fc::halfwidth_fullwidth)
|
||||
{
|
||||
if ( entry[FULL] == c ) // found
|
||||
c = entry[HALF];
|
||||
}
|
||||
}
|
||||
table_search(c);
|
||||
}
|
||||
|
||||
return s;
|
||||
@ -376,7 +394,7 @@ FString getColumnSubString ( const FString& str
|
||||
std::size_t num{0};
|
||||
|
||||
if ( col_len == 0 || s.isEmpty() )
|
||||
return FString{L""};
|
||||
return {L""};
|
||||
|
||||
if ( col_pos == 0 )
|
||||
col_pos = 1;
|
||||
@ -394,29 +412,35 @@ FString getColumnSubString ( const FString& str
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = fc::SingleLeftAngleQuotationMark; // ‹
|
||||
ch = wchar_t(UniChar::SingleLeftAngleQuotationMark); // ‹
|
||||
num = col_num = 1;
|
||||
col_pos = col_first;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( col_num + width <= col_len )
|
||||
if ( col_first == col_pos && width == 0 && num == 0 )
|
||||
{
|
||||
first++;
|
||||
}
|
||||
else if ( col_num + width <= col_len )
|
||||
{
|
||||
col_num += width;
|
||||
num++;
|
||||
}
|
||||
else if ( col_num < col_len )
|
||||
{
|
||||
ch = fc::SingleRightAngleQuotationMark; // ›
|
||||
ch = wchar_t(UniChar::SingleRightAngleQuotationMark); // ›
|
||||
num++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( col_first < col_pos ) // String length < col_pos
|
||||
return FString{L""};
|
||||
return {L""};
|
||||
|
||||
return s.mid(first, num);
|
||||
}
|
||||
@ -441,7 +465,7 @@ std::size_t getLengthFromColumnWidth ( const FString& str
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||
std::size_t getColumnWidth (const FString& s, std::size_t end_pos)
|
||||
{
|
||||
if ( s.isEmpty() )
|
||||
return 0;
|
||||
@ -449,10 +473,10 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||
std::size_t column_width{0};
|
||||
const auto length = s.getLength();
|
||||
|
||||
if ( pos > length )
|
||||
pos = length;
|
||||
if ( end_pos > length )
|
||||
end_pos = length;
|
||||
|
||||
for (std::size_t i{0}; i < pos; i++)
|
||||
for (std::size_t i{0}; i < end_pos; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -460,7 +484,7 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
|
||||
}
|
||||
catch (const std::out_of_range& ex)
|
||||
{
|
||||
std::clog << FLog::Error
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Out of Range error: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -495,42 +519,165 @@ std::size_t getColumnWidth (const wchar_t wchar)
|
||||
else
|
||||
#endif
|
||||
|
||||
if ( (wchar >= fc::NF_rev_left_arrow2 && wchar <= fc::NF_check_mark)
|
||||
|| ! hasFullWidthSupports() )
|
||||
column_width = wcwidth(wchar);
|
||||
|
||||
if ( (wchar >= UniChar::NF_rev_left_arrow2 && wchar <= UniChar::NF_check_mark)
|
||||
|| FTerm::getEncoding() != Encoding::UTF8 )
|
||||
{
|
||||
column_width = 1;
|
||||
else
|
||||
column_width = wcwidth(wchar);
|
||||
}
|
||||
else if ( ! hasFullWidthSupports() )
|
||||
{
|
||||
column_width = std::min(column_width, 1);
|
||||
}
|
||||
|
||||
return ( column_width == -1 ) ? 0 : std::size_t(column_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (FChar& term_char)
|
||||
std::size_t getColumnWidth (const FChar& term_char)
|
||||
{
|
||||
return std::size_t(term_char.attr.bit.char_width);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FTermBuffer& tbuf)
|
||||
{
|
||||
return ( tbuf.isEmpty() )
|
||||
? 0
|
||||
: std::accumulate ( std::next(tbuf.begin())
|
||||
, tbuf.end()
|
||||
, tbuf.front().attr.bit.char_width
|
||||
, [] (std::size_t s, const FChar& c)
|
||||
{
|
||||
return s + c.attr.bit.char_width;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void addColumnWidth (FChar& term_char)
|
||||
{
|
||||
const std::size_t char_width = getColumnWidth(term_char.ch[0]);
|
||||
|
||||
if ( char_width == 2 && FTerm::getEncoding() != fc::UTF8 )
|
||||
if ( char_width == 2 && FTerm::getEncoding() != Encoding::UTF8 )
|
||||
{
|
||||
term_char.ch[0] = '.';
|
||||
term_char.attr.bit.char_width = 1;
|
||||
}
|
||||
else
|
||||
term_char.attr.bit.char_width = char_width & 0x03;
|
||||
|
||||
return char_width;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t getColumnWidth (const FTermBuffer& tb)
|
||||
inline int isWhitespace (const wchar_t ch) noexcept
|
||||
{
|
||||
return std::accumulate ( std::next(tb.begin())
|
||||
, tb.end()
|
||||
, tb.front().attr.bit.char_width
|
||||
, [] (std::size_t s, const FChar& c)
|
||||
{
|
||||
return std::move(s) + c.attr.bit.char_width;
|
||||
}
|
||||
);
|
||||
return std::iswspace(static_cast<wint_t>(ch));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int getCharLength (const FString& string, std::size_t pos)
|
||||
{
|
||||
// Gets the number of characters of the combined character
|
||||
// at string position pos
|
||||
|
||||
const std::size_t len = string.getLength();
|
||||
std::size_t n = pos;
|
||||
const auto& ch = string[n];
|
||||
std::size_t char_width = getColumnWidth(ch);
|
||||
|
||||
if ( isWhitespace(ch) )
|
||||
return 1;
|
||||
|
||||
if ( char_width == 0 || n >= len )
|
||||
return -1;
|
||||
|
||||
do
|
||||
{
|
||||
n++;
|
||||
char_width = getColumnWidth(string[n]);
|
||||
}
|
||||
while ( n < len && char_width == 0 && ! isWhitespace(string[n]) );
|
||||
|
||||
return static_cast<int>(n - pos);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int getPrevCharLength (const FString& string, std::size_t pos)
|
||||
{
|
||||
// Gets the number of characters of the previous combined character
|
||||
// at string position pos
|
||||
|
||||
const std::size_t len = string.getLength();
|
||||
std::size_t n = pos;
|
||||
const auto& ch = string[n];
|
||||
std::size_t char_width = getColumnWidth(ch);
|
||||
|
||||
if ( (char_width == 0 || n == 0 || n >= len) && ! isWhitespace(ch) )
|
||||
return -1;
|
||||
|
||||
do
|
||||
{
|
||||
n--;
|
||||
char_width = getColumnWidth(string[n]);
|
||||
}
|
||||
while ( n > 0 && char_width == 0 && ! isWhitespace(string[n]) );
|
||||
|
||||
if ( char_width == 0 )
|
||||
return -1;
|
||||
|
||||
return int(pos - n);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t searchLeftCharBegin (const FString& string, std::size_t pos)
|
||||
{
|
||||
// Search for the next character position to the left of string position pos
|
||||
|
||||
std::size_t n = pos;
|
||||
|
||||
if ( n == 0 )
|
||||
return NOT_FOUND;
|
||||
|
||||
std::size_t char_width{0};
|
||||
|
||||
do
|
||||
{
|
||||
n--;
|
||||
char_width = getColumnWidth(string[n]);
|
||||
}
|
||||
while ( n > 0 && char_width == 0 && ! isWhitespace(string[n]) );
|
||||
|
||||
if ( n == 0 && char_width == 0 )
|
||||
return NOT_FOUND;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::size_t searchRightCharBegin (const FString& string, std::size_t pos)
|
||||
{
|
||||
// Search for the next character position to the right of string position pos
|
||||
|
||||
const std::size_t len = string.getLength();
|
||||
std::size_t n = pos;
|
||||
|
||||
if ( n >= len )
|
||||
return NOT_FOUND;
|
||||
|
||||
std::size_t char_width{0};
|
||||
|
||||
do
|
||||
{
|
||||
n++;
|
||||
char_width = getColumnWidth(string[n]);
|
||||
}
|
||||
while ( n < len && char_width == 0 && ! isWhitespace(string[n]) );
|
||||
|
||||
if ( n == len && char_width == 0 )
|
||||
return NOT_FOUND;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -546,7 +693,7 @@ FPoint readCursorPos()
|
||||
|
||||
// Report Cursor Position (DECXCPR)
|
||||
if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 )
|
||||
return FPoint{x, y};
|
||||
return {x, y};
|
||||
|
||||
std::fflush(stdout);
|
||||
FD_ZERO(&ifds);
|
||||
@ -558,7 +705,7 @@ FPoint readCursorPos()
|
||||
|
||||
// Read the answer
|
||||
if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) != 1 )
|
||||
return FPoint{x, y};
|
||||
return {x, y};
|
||||
|
||||
do
|
||||
{
|
||||
@ -575,10 +722,10 @@ FPoint readCursorPos()
|
||||
if ( pos > 4 )
|
||||
{
|
||||
constexpr auto parse = "\033[%4d;%4dR";
|
||||
std::sscanf(temp.data(), parse, &x, &y);
|
||||
std::sscanf(temp.data(), parse, &y, &x );
|
||||
}
|
||||
|
||||
return FPoint{x, y};
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2017-2020 Markus Gans *
|
||||
* Copyright 2017-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -38,8 +38,8 @@ namespace finalcut
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
FTermBuffer::~FTermBuffer() // destructor
|
||||
{ }
|
||||
FTermBuffer::~FTermBuffer() noexcept = default; // destructor
|
||||
|
||||
|
||||
// public methods of FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
@ -47,14 +47,19 @@ FString FTermBuffer::toString() const
|
||||
{
|
||||
std::wstring wide_string{};
|
||||
wide_string.reserve(data.size());
|
||||
std::transform ( data.begin()
|
||||
, data.end()
|
||||
, std::back_inserter(wide_string)
|
||||
, [] (const FChar& fchar)
|
||||
{
|
||||
return fchar.ch[0];
|
||||
}
|
||||
);
|
||||
std::for_each ( data.begin()
|
||||
, data.end()
|
||||
, [&wide_string] (const FChar& fchar)
|
||||
{
|
||||
for (auto&& ch : fchar.ch)
|
||||
{
|
||||
if ( ch == L'\0' )
|
||||
return;
|
||||
else
|
||||
wide_string.push_back(ch);
|
||||
}
|
||||
}
|
||||
);
|
||||
return wide_string;
|
||||
}
|
||||
|
||||
@ -62,70 +67,79 @@ FString FTermBuffer::toString() const
|
||||
int FTermBuffer::write (const FString& string)
|
||||
{
|
||||
assert ( ! string.isNull() );
|
||||
const auto len = int(string.getLength());
|
||||
data.reserve(data.size() + string.getLength());
|
||||
const auto last = string.end();
|
||||
auto begin = string.begin();
|
||||
auto iter = begin;
|
||||
int char_width{0};
|
||||
|
||||
for (auto&& c : string)
|
||||
for (auto&& ch : string)
|
||||
{
|
||||
FChar nc; // next character
|
||||
nc = FVTerm::getAttribute();
|
||||
nc.ch[0] = c;
|
||||
nc.attr.byte[2] = 0;
|
||||
nc.attr.byte[3] = 0;
|
||||
getColumnWidth(nc); // add column width
|
||||
data.push_back(std::move(nc));
|
||||
auto width = getColumnWidth(ch);
|
||||
auto wspace = std::iswspace(wint_t(ch));
|
||||
|
||||
if ( width == 0 && ! wspace ) // zero-width character
|
||||
{
|
||||
if ( iter == begin)
|
||||
++begin;
|
||||
|
||||
++iter;
|
||||
}
|
||||
else if ( iter != begin )
|
||||
add(begin, iter, char_width);
|
||||
|
||||
if ( iter == begin && (width > 0 || is7bit(ch)) ) // 1st char
|
||||
++iter;
|
||||
|
||||
if ( width > 0 )
|
||||
char_width += width;
|
||||
|
||||
if ( wspace )
|
||||
add(begin, iter, char_width);
|
||||
}
|
||||
|
||||
return len;
|
||||
if ( iter == last )
|
||||
add(begin, iter, char_width);
|
||||
|
||||
return int(string.getLength());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermBuffer::write (wchar_t ch)
|
||||
{
|
||||
FChar nc = FVTerm::getAttribute(); // next character
|
||||
FChar nc{FVTerm::getAttribute()}; // next character
|
||||
nc.ch[0] = ch;
|
||||
getColumnWidth(nc); // add column width
|
||||
addColumnWidth(nc); // add column width
|
||||
nc.attr.bit.no_changes = false;
|
||||
nc.attr.bit.printed = false;
|
||||
|
||||
data.push_back(nc);
|
||||
data.emplace_back(nc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBuffer::write (const FStyle& style) const
|
||||
{
|
||||
FAttribute attr = style.getStyle();
|
||||
Style attr = style.getStyle();
|
||||
|
||||
if ( attr == 0 )
|
||||
if ( attr == Style::None )
|
||||
FVTerm::setNormal();
|
||||
else if ( (attr & fc::Bold) != 0 )
|
||||
FVTerm::setBold();
|
||||
else if ( (attr & fc::Dim) != 0 )
|
||||
FVTerm::setDim();
|
||||
else if ( (attr & fc::Italic) != 0 )
|
||||
FVTerm::setItalic();
|
||||
else if ( (attr & fc::Underline) != 0 )
|
||||
FVTerm::setUnderline();
|
||||
else if ( (attr & fc::Blink) != 0 )
|
||||
FVTerm::setBlink();
|
||||
else if ( (attr & fc::Reverse) != 0 )
|
||||
FVTerm::setReverse();
|
||||
else if ( (attr & fc::Standout) != 0 )
|
||||
FVTerm::setStandout();
|
||||
else if ( (attr & fc::Invisible) != 0 )
|
||||
FVTerm::setInvisible();
|
||||
else if ( (attr & fc::Protected) != 0 )
|
||||
FVTerm::setProtected();
|
||||
else if ( (attr & fc::CrossedOut) != 0 )
|
||||
FVTerm::setCrossedOut();
|
||||
else if ( (attr & fc::DoubleUnderline) != 0 )
|
||||
FVTerm::setDoubleUnderline();
|
||||
else if ( (attr & fc::Transparent) != 0 )
|
||||
FVTerm::setTransparent();
|
||||
else if ( (attr & fc::ColorOverlay) != 0 )
|
||||
FVTerm::setColorOverlay();
|
||||
else if ( (attr & fc::InheritBackground) != 0 )
|
||||
FVTerm::setInheritBackground();
|
||||
else
|
||||
{
|
||||
if ( (attr & Style::Bold) != Style::None ) FVTerm::setBold();
|
||||
if ( (attr & Style::Dim) != Style::None ) FVTerm::setDim();
|
||||
if ( (attr & Style::Italic) != Style::None ) FVTerm::setItalic();
|
||||
if ( (attr & Style::Underline) != Style::None ) FVTerm::setUnderline();
|
||||
if ( (attr & Style::Blink) != Style::None ) FVTerm::setBlink();
|
||||
if ( (attr & Style::Reverse) != Style::None ) FVTerm::setReverse();
|
||||
if ( (attr & Style::Standout) != Style::None ) FVTerm::setStandout();
|
||||
if ( (attr & Style::Invisible) != Style::None ) FVTerm::setInvisible();
|
||||
if ( (attr & Style::Protected) != Style::None ) FVTerm::setProtected();
|
||||
if ( (attr & Style::CrossedOut) != Style::None ) FVTerm::setCrossedOut();
|
||||
if ( (attr & Style::DoubleUnderline) != Style::None ) FVTerm::setDoubleUnderline();
|
||||
if ( (attr & Style::Transparent) != Style::None ) FVTerm::setTransparent();
|
||||
if ( (attr & Style::ColorOverlay) != Style::None ) FVTerm::setColorOverlay();
|
||||
if ( (attr & Style::InheritBackground) != Style::None ) FVTerm::setInheritBackground();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -135,15 +149,43 @@ void FTermBuffer::write (const FColorPair& pair) const
|
||||
}
|
||||
|
||||
|
||||
// private methods of FTermBuffer
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBuffer::add ( FString::const_iterator& begin
|
||||
, FString::const_iterator& end
|
||||
, int& char_width )
|
||||
{
|
||||
if ( begin == end )
|
||||
return;
|
||||
|
||||
FChar nc{FVTerm::getAttribute()}; // next character
|
||||
nc.attr.byte[2] = 0;
|
||||
nc.attr.byte[3] = 0;
|
||||
|
||||
if ( char_width == 2 && FTerm::getEncoding() != Encoding::UTF8 )
|
||||
{
|
||||
nc.ch[0] = '.';
|
||||
nc.attr.bit.char_width = 1;
|
||||
}
|
||||
else
|
||||
nc.attr.bit.char_width = char_width & 0x03;
|
||||
|
||||
std::copy(begin, std::min(end, begin + UNICODE_MAX), nc.ch.begin());
|
||||
data.emplace_back(nc);
|
||||
begin = end;
|
||||
char_width = 0;
|
||||
}
|
||||
|
||||
|
||||
// FTermBuffer non-member operators
|
||||
//----------------------------------------------------------------------
|
||||
FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& termString
|
||||
FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& term_string
|
||||
, const FTermBuffer& buf )
|
||||
{
|
||||
if ( ! buf.data.empty() )
|
||||
termString.assign(buf.data.begin(), buf.data.end());
|
||||
term_string.assign(buf.data.begin(), buf.data.end());
|
||||
|
||||
return termString;
|
||||
return term_string;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
263
src/ftermcap.cpp
263
src/ftermcap.cpp
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2015-2020 Markus Gans *
|
||||
* Copyright 2015-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -20,6 +20,26 @@
|
||||
* <http://www.gnu.org/licenses/>. *
|
||||
***********************************************************************/
|
||||
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
#include <termio.h>
|
||||
typedef struct termio SGTTY;
|
||||
typedef struct termios SGTTYS;
|
||||
|
||||
#ifdef _LP64
|
||||
typedef unsigned int chtype;
|
||||
#else
|
||||
typedef unsigned long chtype;
|
||||
#endif // _LP64
|
||||
|
||||
#include <term.h> // termcap
|
||||
#else
|
||||
#include <term.h> // termcap
|
||||
#endif // defined(__sun) && defined(__SVR4)
|
||||
|
||||
#ifdef F_HAVE_LIBGPM
|
||||
#undef buttons // from term.h
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -38,6 +58,7 @@ namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
bool FTermcap::initialized {false};
|
||||
bool FTermcap::background_color_erase {false};
|
||||
bool FTermcap::can_change_color_palette {false};
|
||||
bool FTermcap::automatic_left_margin {false};
|
||||
@ -47,12 +68,14 @@ bool FTermcap::has_ansi_escape_sequences{false};
|
||||
bool FTermcap::ansi_default_color {false};
|
||||
bool FTermcap::osc_support {false};
|
||||
bool FTermcap::no_utf8_acs_chars {false};
|
||||
bool FTermcap::no_padding_char {false};
|
||||
bool FTermcap::xon_xoff_flow_control {false};
|
||||
int FTermcap::max_color {1};
|
||||
int FTermcap::tabstop {8};
|
||||
int FTermcap::padding_baudrate {0};
|
||||
int FTermcap::attr_without_color {0};
|
||||
FSystem* FTermcap::fsystem {nullptr};
|
||||
FTermData* FTermcap::fterm_data {nullptr};
|
||||
FTermDetection* FTermcap::term_detection {nullptr};
|
||||
int FTermcap::baudrate {9600};
|
||||
char FTermcap::PC {'\0'};
|
||||
char FTermcap::string_buf[2048] {};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -69,12 +92,153 @@ char FTermcap::string_buf[2048] {};
|
||||
*/
|
||||
|
||||
// public methods of FTermcap
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermcap::getFlag (const std::string& cap)
|
||||
{
|
||||
return ::tgetflag(C_STR(cap.data())) == 1;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermcap::getNumber (const std::string& cap)
|
||||
{
|
||||
auto num = ::tgetnum(C_STR(cap.data()));
|
||||
return num > 0 ? num : 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
char* FTermcap::getString (const std::string& cap)
|
||||
{
|
||||
auto string = ::tgetstr(C_STR(cap.data()), reinterpret_cast<char**>(&string_buf));
|
||||
return ( string && string[0] != '\0' ) ? string : nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
std::string FTermcap::encodeMotionParameter (const std::string& cap, int col, int row)
|
||||
{
|
||||
auto str = ::tgoto(C_STR(cap.data()), col, row);
|
||||
return str ? str : std::string();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermcap::Status FTermcap::paddingPrint ( const std::string& string
|
||||
, int affcnt
|
||||
, const defaultPutChar& outc )
|
||||
{
|
||||
if ( string.empty() )
|
||||
return Status::Error;
|
||||
|
||||
bool has_delay = (TCAP(t_bell) && string == std::string(TCAP(t_bell)))
|
||||
|| (TCAP(t_flash_screen) && string == std::string(TCAP(t_flash_screen)))
|
||||
|| ( ! xon_xoff_flow_control && padding_baudrate
|
||||
&& (baudrate >= padding_baudrate) );
|
||||
auto iter = string.begin();
|
||||
using iter_type = decltype(iter);
|
||||
|
||||
auto read_digits = [] (iter_type& it, int& number)
|
||||
{
|
||||
while ( std::isdigit(int(*it)) && number < 1000 )
|
||||
{
|
||||
number = number * 10 + (*it - '0');
|
||||
++it;
|
||||
}
|
||||
|
||||
number *= 10;
|
||||
};
|
||||
|
||||
auto decimal_point = [] (iter_type& it, int& number)
|
||||
{
|
||||
if ( *it == '.' )
|
||||
{
|
||||
++it;
|
||||
|
||||
if ( std::isdigit(int(*it)) )
|
||||
{
|
||||
number += (*it - '0'); // Position after decimal point
|
||||
++it;
|
||||
}
|
||||
|
||||
while ( std::isdigit(int(*it)) )
|
||||
++it;
|
||||
}
|
||||
};
|
||||
|
||||
auto asterisk_slash = [&affcnt, &has_delay] (iter_type& it, int& number)
|
||||
{
|
||||
while ( *it == '*' || *it == '/' )
|
||||
{
|
||||
if ( *it == '*' )
|
||||
{
|
||||
// Padding is proportional to the number of affected lines (suffix '*')
|
||||
number *= affcnt;
|
||||
++it;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Padding is mandatory (suffix '/')
|
||||
has_delay = true;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
while ( iter != string.end() )
|
||||
{
|
||||
if ( *iter != '$' )
|
||||
outc(int(*iter));
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
|
||||
if ( *iter != '<' )
|
||||
{
|
||||
outc(int('$'));
|
||||
|
||||
if ( iter != string.end() )
|
||||
outc(int(*iter));
|
||||
}
|
||||
else
|
||||
{
|
||||
++iter;
|
||||
const auto first_digit = iter;
|
||||
|
||||
if ( ! std::isdigit(int(*iter)) && *iter != '.' )
|
||||
{
|
||||
outc(int('$'));
|
||||
outc(int('<'));
|
||||
continue;
|
||||
}
|
||||
|
||||
int number = 0;
|
||||
read_digits (iter, number);
|
||||
decimal_point (iter, number);
|
||||
asterisk_slash (iter, number);
|
||||
|
||||
if ( *iter != '>' )
|
||||
{
|
||||
outc(int('$'));
|
||||
outc(int('<'));
|
||||
iter = first_digit;
|
||||
continue;
|
||||
}
|
||||
else if ( has_delay && number > 0 )
|
||||
{
|
||||
delay_output(number / 10, outc);
|
||||
}
|
||||
} // end of else (*iter == '<')
|
||||
} // end of else (*iter == '$')
|
||||
|
||||
if ( iter == string.end() )
|
||||
break;
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
return Status::OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::init()
|
||||
{
|
||||
fsystem = FTerm::getFSystem();
|
||||
fterm_data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
termcap();
|
||||
}
|
||||
|
||||
@ -82,37 +246,43 @@ void FTermcap::init()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcap::termcap()
|
||||
{
|
||||
std::vector<std::string> terminals{};
|
||||
static constexpr int success = 1;
|
||||
static constexpr int uninitialized = -2;
|
||||
static char term_buffer[BUF_SIZE]{};
|
||||
std::vector<std::string> terminals{};
|
||||
int status = uninitialized;
|
||||
const bool color256 = term_detection->canDisplay256Colors();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
const bool color256 = term_detection.canDisplay256Colors();
|
||||
baudrate = int(fterm_data.getBaudrate());
|
||||
|
||||
// Open termcap file
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
char* termtype = const_cast<char*>(fterm_data->getTermType());
|
||||
#else
|
||||
const char* termtype = fterm_data->getTermType();
|
||||
#endif
|
||||
terminals.push_back(termtype); // available terminal type
|
||||
const auto& termtype = fterm_data.getTermType();
|
||||
terminals.emplace_back(termtype); // available terminal type
|
||||
|
||||
if ( color256 ) // 1st fallback if not found
|
||||
terminals.push_back("xterm-256color");
|
||||
terminals.emplace_back("xterm-256color");
|
||||
|
||||
terminals.push_back("xterm"); // 2nd fallback if not found
|
||||
terminals.push_back("ansi"); // 3rd fallback if not found
|
||||
terminals.push_back("vt100"); // 4th fallback if not found
|
||||
terminals.emplace_back("xterm"); // 2nd fallback if not found
|
||||
terminals.emplace_back("ansi"); // 3rd fallback if not found
|
||||
terminals.emplace_back("vt100"); // 4th fallback if not found
|
||||
auto iter = terminals.begin();
|
||||
|
||||
while ( iter != terminals.end() )
|
||||
{
|
||||
fterm_data->setTermType(iter->c_str());
|
||||
fterm_data.setTermType(*iter);
|
||||
|
||||
// Open the termcap file + load entry for termtype
|
||||
status = tgetent(term_buffer, termtype);
|
||||
#if defined(__sun) && defined(__SVR4)
|
||||
status = tgetent(term_buffer, const_cast<char*>(termtype.data()));
|
||||
#else
|
||||
status = tgetent(term_buffer, termtype.data());
|
||||
#endif
|
||||
|
||||
if ( status == success || ! term_detection->hasTerminalDetection() )
|
||||
if ( status == success )
|
||||
initialized = true;
|
||||
|
||||
if ( status == success || ! term_detection.hasTerminalDetection() )
|
||||
break;
|
||||
|
||||
++iter;
|
||||
@ -131,9 +301,9 @@ void FTermcap::termcapError (int status)
|
||||
|
||||
if ( status == no_entry || status == uninitialized )
|
||||
{
|
||||
const char* termtype = fterm_data->getTermType();
|
||||
std::clog << FLog::Error
|
||||
<< "Unknown terminal: \"" << termtype << "\". "
|
||||
const auto& termtype = FTerm::getFTermData().getTermType();
|
||||
std::clog << FLog::LogLevel::Error
|
||||
<< "Unknown terminal: \"" << termtype << "\". "
|
||||
<< "Check the TERM environment variable. "
|
||||
<< "Also make sure that the terminal "
|
||||
<< "is defined in the termcap/terminfo database."
|
||||
@ -193,6 +363,12 @@ void FTermcap::termcapBoleans()
|
||||
|
||||
// U8 is nonzero for terminals with no VT100 line-drawing in UTF-8 mode
|
||||
no_utf8_acs_chars = bool(getNumber("U8") != 0);
|
||||
|
||||
// No padding character available
|
||||
no_padding_char = getFlag("NP");
|
||||
|
||||
// Terminal uses software flow control (XON/XOFF) with (Ctrl-Q/Ctrl-S)
|
||||
xon_xoff_flow_control = getFlag("xo");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -200,6 +376,8 @@ void FTermcap::termcapNumerics()
|
||||
{
|
||||
// Get termcap numerics
|
||||
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
|
||||
// Maximum number of colors on screen
|
||||
max_color = std::max(max_color, getNumber("Co"));
|
||||
|
||||
@ -207,13 +385,16 @@ void FTermcap::termcapNumerics()
|
||||
max_color = 1;
|
||||
|
||||
if ( max_color < 8 )
|
||||
fterm_data->setMonochron(true);
|
||||
fterm_data.setMonochron(true);
|
||||
else
|
||||
fterm_data->setMonochron(false);
|
||||
fterm_data.setMonochron(false);
|
||||
|
||||
// Get initial spacing for hardware tab stop
|
||||
tabstop = getNumber("it");
|
||||
|
||||
// Get the smallest baud rate where padding is required
|
||||
padding_baudrate = getNumber("pb");
|
||||
|
||||
// Get video attributes that cannot be used with colors
|
||||
attr_without_color = getNumber("NC");
|
||||
}
|
||||
@ -228,10 +409,15 @@ void FTermcap::termcapStrings()
|
||||
for (auto&& entry : strings)
|
||||
entry.string = getString(entry.tname);
|
||||
|
||||
const auto& ho = TCAP(fc::t_cursor_home);
|
||||
const auto& ho = TCAP(t_cursor_home);
|
||||
|
||||
if ( std::strncmp(ho, "\033[H", 3) == 0 )
|
||||
if ( ho && std::strncmp(ho, "\033[H", 3) == 0 )
|
||||
has_ansi_escape_sequences = true;
|
||||
|
||||
const auto& pc = TCAP(t_pad_char);
|
||||
|
||||
if ( pc )
|
||||
PC = pc[0];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -240,9 +426,9 @@ void FTermcap::termcapKeys()
|
||||
// Get termcap keys
|
||||
|
||||
// Read termcap key sequences up to the self-defined values
|
||||
for (auto&& entry : fc::fkey)
|
||||
for (auto&& entry : fc::fkey_cap_table)
|
||||
{
|
||||
if ( entry.string != nullptr )
|
||||
if ( entry.string != nullptr ) // String is already set
|
||||
break;
|
||||
|
||||
entry.string = getString(entry.tname);
|
||||
@ -250,12 +436,15 @@ void FTermcap::termcapKeys()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
int FTermcap::_tputs (const char* str, int affcnt, fn_putc putc)
|
||||
std::string FTermcap::encodeParams ( const std::string& cap
|
||||
, const std::vector<int>& param_vec )
|
||||
{
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
return fsystem->tputs (str, affcnt, putc);
|
||||
std::array<int, 9> params{{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }};
|
||||
std::copy (param_vec.begin(), param_vec.end(), params.begin());
|
||||
auto str = ::tparm ( C_STR(cap.data()), params[0], params[1]
|
||||
, params[2], params[3], params[4], params[5]
|
||||
, params[6], params[7], params[8] );
|
||||
return str ? str : std::string();
|
||||
}
|
||||
|
||||
|
||||
@ -268,6 +457,7 @@ FTermcap::TCapMapType FTermcap::strings =
|
||||
// | | // variable name -> description
|
||||
//------------------------------------------------------------------------------
|
||||
{ nullptr, "bl" }, // bell -> audible signal (bell) (P)
|
||||
{ nullptr, "vb" }, // flash_screen -> visible bell (may not move cursor)
|
||||
{ nullptr, "ec" }, // erase_chars -> erase #1 characters (P)
|
||||
{ nullptr, "cl" }, // clear_screen -> clear screen and home cursor (P*)
|
||||
{ nullptr, "cd" }, // clr_eos -> clear to end of screen (P*)
|
||||
@ -278,6 +468,7 @@ FTermcap::TCapMapType FTermcap::strings =
|
||||
{ nullptr, "cr" }, // carriage_return -> carriage return (P*)
|
||||
{ nullptr, "ta" }, // tab -> tab to next 8-space hardware tab stop
|
||||
{ nullptr, "bt" }, // back_tab -> back tab (P)
|
||||
{ nullptr, "pc" }, // pad_char -> padding char (instead of null)
|
||||
{ nullptr, "ip" }, // insert_padding -> insert padding after inserted character
|
||||
{ nullptr, "ic" }, // insert_character -> insert character (P)
|
||||
{ nullptr, "IC" }, // parm_ich -> insert #1 characters (P*)
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -34,74 +34,61 @@
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
FTermData* FTermcapQuirks::fterm_data {nullptr};
|
||||
FTermDetection* FTermcapQuirks::term_detection {nullptr};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermcapQuirks
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// constructors and destructor
|
||||
//----------------------------------------------------------------------
|
||||
FTermcapQuirks::FTermcapQuirks()
|
||||
{ }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermcapQuirks::~FTermcapQuirks() // destructor
|
||||
{ }
|
||||
|
||||
|
||||
// public methods of FTermcapQuirks
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::terminalFixup()
|
||||
{
|
||||
fterm_data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
const auto& td = term_detection;
|
||||
const auto& td = FTerm::getFTermDetection();
|
||||
|
||||
if ( td->isCygwinTerminal() )
|
||||
if ( td.isCygwinTerminal() )
|
||||
{
|
||||
cygwin();
|
||||
}
|
||||
else if ( td->isLinuxTerm() )
|
||||
else if ( td.isLinuxTerm() )
|
||||
{
|
||||
linux();
|
||||
}
|
||||
else if ( td->isRxvtTerminal() )
|
||||
else if ( td.isRxvtTerminal() )
|
||||
{
|
||||
rxvt();
|
||||
}
|
||||
else if ( td->isGnomeTerminal() )
|
||||
else if ( td.isGnomeTerminal() )
|
||||
{
|
||||
vte();
|
||||
}
|
||||
else if ( td->isTeraTerm() )
|
||||
else if ( td.isKittyTerminal() )
|
||||
{
|
||||
kitty();
|
||||
}
|
||||
else if ( td.isTeraTerm() )
|
||||
{
|
||||
teraterm();
|
||||
}
|
||||
else if ( td->isSunTerminal() )
|
||||
else if ( td.isSunTerminal() )
|
||||
{
|
||||
sunConsole();
|
||||
}
|
||||
else if ( td->isPuttyTerminal() )
|
||||
else if ( td.isPuttyTerminal() )
|
||||
{
|
||||
putty();
|
||||
}
|
||||
else if ( td->isScreenTerm() )
|
||||
else if ( td.isScreenTerm() )
|
||||
{
|
||||
screen();
|
||||
}
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
else if ( td->isFreeBSDTerm() )
|
||||
else if ( td.isFreeBSDTerm() )
|
||||
{
|
||||
freebsd();
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
||||
// xterm and compatible terminals
|
||||
if ( td->isXTerminal() && ! td->isPuttyTerminal() )
|
||||
if ( td.isXTerminal() && ! td.isPuttyTerminal() )
|
||||
xterm();
|
||||
|
||||
// Fixes general quirks
|
||||
@ -118,7 +105,7 @@ void FTermcapQuirks::freebsd()
|
||||
{
|
||||
// FreeBSD console fixes
|
||||
|
||||
TCAP(fc::t_acs_chars) = \
|
||||
TCAP(t_acs_chars) = \
|
||||
"-\036.\0370\333"
|
||||
"a\260f\370g\361"
|
||||
"h\261j\331k\277"
|
||||
@ -127,7 +114,7 @@ void FTermcapQuirks::freebsd()
|
||||
"v\301w\302x\263"
|
||||
"y\363z\362~\371";
|
||||
|
||||
TCAP(fc::t_set_attributes) = \
|
||||
TCAP(t_set_attributes) = \
|
||||
CSI "0"
|
||||
"%?%p1%p6%|%t;1%;"
|
||||
"%?%p2%t;4%;"
|
||||
@ -143,20 +130,20 @@ void FTermcapQuirks::freebsd()
|
||||
void FTermcapQuirks::cygwin()
|
||||
{
|
||||
// Set invisible cursor for cygwin terminal
|
||||
if ( ! TCAP(fc::t_cursor_invisible) )
|
||||
TCAP(fc::t_cursor_invisible) = CSI "?25l";
|
||||
if ( ! TCAP(t_cursor_invisible) )
|
||||
TCAP(t_cursor_invisible) = CSI "?25l";
|
||||
|
||||
// Set visible cursor for cygwin terminal
|
||||
if ( ! TCAP(fc::t_cursor_visible) )
|
||||
TCAP(fc::t_cursor_visible) = CSI "?25h";
|
||||
if ( ! TCAP(t_cursor_visible) )
|
||||
TCAP(t_cursor_visible) = CSI "?25h";
|
||||
|
||||
// Set ansi blink for cygwin terminal
|
||||
if ( ! TCAP(fc::t_enter_blink_mode) )
|
||||
TCAP(fc::t_enter_blink_mode) = CSI "5m";
|
||||
if ( ! TCAP(t_enter_blink_mode) )
|
||||
TCAP(t_enter_blink_mode) = CSI "5m";
|
||||
|
||||
// Set enable alternate character set for cygwin terminal
|
||||
if ( ! TCAP(fc::t_enable_acs) )
|
||||
TCAP(fc::t_enable_acs) = ESC "(B" ESC ")0";
|
||||
if ( ! TCAP(t_enable_acs) )
|
||||
TCAP(t_enable_acs) = ESC "(B" ESC ")0";
|
||||
|
||||
// Set background color erase for cygwin terminal
|
||||
FTermcap::background_color_erase = true;
|
||||
@ -173,55 +160,55 @@ void FTermcapQuirks::linux()
|
||||
// Set ansi foreground and background color
|
||||
if ( FTerm::getMaxColor() > 8 )
|
||||
{
|
||||
TCAP(fc::t_set_a_foreground) = \
|
||||
TCAP(t_set_a_foreground) = \
|
||||
CSI "3%p1%{8}%m%d%?%p1%{7}%>%t;1%e;22%;m";
|
||||
TCAP(fc::t_set_a_background) = \
|
||||
TCAP(t_set_a_background) = \
|
||||
CSI "4%p1%{8}%m%d%?%p1%{7}%>%t;5%e;25%;m";
|
||||
// Avoid underline, blink, dim mode and reverse
|
||||
FTermcap::attr_without_color = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
TCAP(fc::t_set_a_foreground) = CSI "3%p1%dm";
|
||||
TCAP(fc::t_set_a_background) = CSI "4%p1%dm";
|
||||
TCAP(t_set_a_foreground) = CSI "3%p1%dm";
|
||||
TCAP(t_set_a_background) = CSI "4%p1%dm";
|
||||
// Avoid underline and dim mode
|
||||
FTermcap::attr_without_color = 18;
|
||||
}
|
||||
|
||||
// Set select graphic rendition attributes
|
||||
TCAP(fc::t_set_attributes) = \
|
||||
TCAP(t_set_attributes) = \
|
||||
CSI "0"
|
||||
"%?%p6%t;1%;"
|
||||
"%?%p1%p3%|%t;7%;"
|
||||
"%?%p4%t;5%;m"
|
||||
"%?%p9%t\016%e\017%;";
|
||||
|
||||
TCAP(fc::t_enter_alt_charset_mode) = SO;
|
||||
TCAP(fc::t_exit_alt_charset_mode) = SI;
|
||||
TCAP(fc::t_exit_attribute_mode) = CSI "0m" SI;
|
||||
TCAP(fc::t_exit_bold_mode) = CSI "22m";
|
||||
TCAP(fc::t_exit_blink_mode) = CSI "25m";
|
||||
TCAP(fc::t_exit_reverse_mode) = CSI "27m";
|
||||
TCAP(fc::t_exit_secure_mode) = nullptr;
|
||||
TCAP(fc::t_exit_protected_mode) = nullptr;
|
||||
TCAP(fc::t_exit_crossed_out_mode) = nullptr;
|
||||
TCAP(fc::t_orig_pair) = CSI "39;49;25m";
|
||||
TCAP(t_enter_alt_charset_mode) = SO;
|
||||
TCAP(t_exit_alt_charset_mode) = SI;
|
||||
TCAP(t_exit_attribute_mode) = CSI "0m" SI;
|
||||
TCAP(t_exit_bold_mode) = CSI "22m";
|
||||
TCAP(t_exit_blink_mode) = CSI "25m";
|
||||
TCAP(t_exit_reverse_mode) = CSI "27m";
|
||||
TCAP(t_exit_secure_mode) = nullptr;
|
||||
TCAP(t_exit_protected_mode) = nullptr;
|
||||
TCAP(t_exit_crossed_out_mode) = nullptr;
|
||||
TCAP(t_orig_pair) = CSI "39;49;25m";
|
||||
|
||||
// Avoid underline and dim mode
|
||||
TCAP(fc::t_enter_dim_mode) = nullptr;
|
||||
TCAP(fc::t_exit_dim_mode) = nullptr;
|
||||
TCAP(fc::t_enter_underline_mode) = nullptr;
|
||||
TCAP(fc::t_exit_underline_mode) = nullptr;
|
||||
TCAP(t_enter_dim_mode) = nullptr;
|
||||
TCAP(t_exit_dim_mode) = nullptr;
|
||||
TCAP(t_enter_underline_mode) = nullptr;
|
||||
TCAP(t_exit_underline_mode) = nullptr;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::xterm()
|
||||
{
|
||||
// Fallback if "Ic" is not found
|
||||
if ( ! TCAP(fc::t_initialize_color) )
|
||||
if ( ! TCAP(t_initialize_color) )
|
||||
{
|
||||
FTermcap::can_change_color_palette = true;
|
||||
TCAP(fc::t_initialize_color) = \
|
||||
TCAP(t_initialize_color) = \
|
||||
OSC "4;%p1%d;rgb:"
|
||||
"%p2%{255}%*%{1000}%/%2.2X/"
|
||||
"%p3%{255}%*%{1000}%/%2.2X/"
|
||||
@ -229,32 +216,32 @@ void FTermcapQuirks::xterm()
|
||||
}
|
||||
|
||||
// Fallback if "vi" is not found
|
||||
if ( ! TCAP(fc::t_cursor_invisible) )
|
||||
TCAP(fc::t_cursor_invisible) = CSI "?25l";
|
||||
if ( ! TCAP(t_cursor_invisible) )
|
||||
TCAP(t_cursor_invisible) = CSI "?25l";
|
||||
|
||||
// Fallback if "ve" is not found
|
||||
if ( ! TCAP(fc::t_cursor_normal) )
|
||||
TCAP(fc::t_cursor_normal) = CSI "?12l" CSI "?25h";
|
||||
if ( ! TCAP(t_cursor_normal) )
|
||||
TCAP(t_cursor_normal) = CSI "?12l" CSI "?25h";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::rxvt()
|
||||
{
|
||||
// Set enter/exit alternative charset mode for rxvt terminal
|
||||
const char* termtype = fterm_data->getTermType();
|
||||
const auto& termtype = FTerm::getFTermData().getTermType();
|
||||
|
||||
if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
|
||||
if ( termtype.substr(0,12) == "rxvt-16color" )
|
||||
{
|
||||
TCAP(fc::t_enter_alt_charset_mode) = ESC "(0";
|
||||
TCAP(fc::t_exit_alt_charset_mode) = ESC "(B";
|
||||
TCAP(t_enter_alt_charset_mode) = ESC "(0";
|
||||
TCAP(t_exit_alt_charset_mode) = ESC "(B";
|
||||
}
|
||||
|
||||
// Set ansi foreground and background color
|
||||
if ( ! term_detection->isUrxvtTerminal() )
|
||||
if ( ! FTerm::getFTermDetection().isUrxvtTerminal() )
|
||||
{
|
||||
TCAP(fc::t_set_a_foreground) = \
|
||||
TCAP(t_set_a_foreground) = \
|
||||
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
|
||||
TCAP(fc::t_set_a_background) = \
|
||||
TCAP(t_set_a_background) = \
|
||||
CSI "%?%p1%{8}%<%t%p1%'('%+%e%p1%{92}%+%;%dm";
|
||||
}
|
||||
}
|
||||
@ -262,33 +249,22 @@ void FTermcapQuirks::rxvt()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::vte()
|
||||
{
|
||||
const auto& term_detection = FTerm::getFTermDetection();
|
||||
|
||||
// gnome-terminal has NC=16 however, it can use the dim attribute
|
||||
FTermcap::attr_without_color = 0;
|
||||
|
||||
// set exit underline for gnome terminal
|
||||
TCAP(fc::t_exit_underline_mode) = \
|
||||
CSI "24m";
|
||||
TCAP(t_exit_underline_mode) = CSI "24m";
|
||||
|
||||
if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
|
||||
{
|
||||
if ( TCAP(fc::t_enter_ca_mode)
|
||||
&& ! std::strstr(TCAP(fc::t_enter_ca_mode), "\033[22;0;0t") )
|
||||
{
|
||||
// Save the cursor position, enter alternate screen buffer
|
||||
// and save xterm icon and window title on stack
|
||||
TCAP(fc::t_enter_ca_mode) = \
|
||||
CSI "?1049h" CSI "22;0;0t";
|
||||
}
|
||||
if ( term_detection.getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
|
||||
caModeExtension();
|
||||
}
|
||||
|
||||
if ( TCAP(fc::t_exit_ca_mode)
|
||||
&& ! std::strstr(TCAP(fc::t_exit_ca_mode), "\033[23;0;0t") )
|
||||
{
|
||||
// Use normal screen buffer, restore the cursor position
|
||||
// and restore xterm icon and window title from stack
|
||||
TCAP(fc::t_exit_ca_mode) = \
|
||||
CSI "?1049l" CSI "23;0;0t";
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
void FTermcapQuirks::kitty()
|
||||
{
|
||||
caModeExtension();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -302,21 +278,21 @@ void FTermcapQuirks::putty()
|
||||
FTermcap::attr_without_color = 0;
|
||||
|
||||
// Set ansi foreground and background color
|
||||
TCAP(fc::t_set_a_foreground) = \
|
||||
TCAP(t_set_a_foreground) = \
|
||||
CSI "%?%p1%{8}%<"
|
||||
"%t3%p1%d"
|
||||
"%e%p1%{16}%<"
|
||||
"%t9%p1%{8}%-%d"
|
||||
"%e38;5;%p1%d%;m";
|
||||
|
||||
TCAP(fc::t_set_a_background) = \
|
||||
TCAP(t_set_a_background) = \
|
||||
CSI "%?%p1%{8}%<"
|
||||
"%t4%p1%d"
|
||||
"%e%p1%{16}%<"
|
||||
"%t10%p1%{8}%-%d"
|
||||
"%e48;5;%p1%d%;m";
|
||||
|
||||
TCAP(fc::t_set_attributes) = \
|
||||
TCAP(t_set_attributes) = \
|
||||
CSI "0"
|
||||
"%?%p1%p6%|%t;1%;"
|
||||
"%?%p5%t;2%;" // since putty 0.71
|
||||
@ -325,49 +301,49 @@ void FTermcapQuirks::putty()
|
||||
"%?%p4%t;5%;m"
|
||||
"%?%p9%t\016%e\017%;";
|
||||
// PuTTY 0.71 or higher
|
||||
TCAP(fc::t_enter_dim_mode) = CSI "2m";
|
||||
TCAP(t_enter_dim_mode) = CSI "2m";
|
||||
|
||||
// PuTTY 0.71 or higher
|
||||
TCAP(fc::t_exit_dim_mode) = CSI "22m";
|
||||
TCAP(t_exit_dim_mode) = CSI "22m";
|
||||
|
||||
if ( ! TCAP(fc::t_clr_bol) )
|
||||
TCAP(fc::t_clr_bol) = CSI "1K";
|
||||
if ( ! TCAP(t_clr_bol) )
|
||||
TCAP(t_clr_bol) = CSI "1K";
|
||||
|
||||
if ( ! TCAP(fc::t_orig_pair) )
|
||||
TCAP(fc::t_orig_pair) = CSI "39;49m";
|
||||
if ( ! TCAP(t_orig_pair) )
|
||||
TCAP(t_orig_pair) = CSI "39;49m";
|
||||
|
||||
if ( ! TCAP(fc::t_orig_colors) )
|
||||
TCAP(fc::t_orig_colors) = OSC "R";
|
||||
if ( ! TCAP(t_orig_colors) )
|
||||
TCAP(t_orig_colors) = OSC "R";
|
||||
|
||||
if ( ! TCAP(fc::t_column_address) )
|
||||
TCAP(fc::t_column_address) = CSI "%i%p1%dG";
|
||||
if ( ! TCAP(t_column_address) )
|
||||
TCAP(t_column_address) = CSI "%i%p1%dG";
|
||||
|
||||
if ( ! TCAP(fc::t_row_address) )
|
||||
TCAP(fc::t_row_address) = CSI "%i%p1%dd";
|
||||
if ( ! TCAP(t_row_address) )
|
||||
TCAP(t_row_address) = CSI "%i%p1%dd";
|
||||
|
||||
if ( ! TCAP(fc::t_enable_acs) )
|
||||
TCAP(fc::t_enable_acs) = ESC "(B" ESC ")0";
|
||||
if ( ! TCAP(t_enable_acs) )
|
||||
TCAP(t_enable_acs) = ESC "(B" ESC ")0";
|
||||
|
||||
if ( ! TCAP(fc::t_enter_am_mode) )
|
||||
TCAP(fc::t_enter_am_mode) = CSI "?7h";
|
||||
if ( ! TCAP(t_enter_am_mode) )
|
||||
TCAP(t_enter_am_mode) = CSI "?7h";
|
||||
|
||||
if ( ! TCAP(fc::t_exit_am_mode) )
|
||||
TCAP(fc::t_exit_am_mode) = CSI "?7l";
|
||||
if ( ! TCAP(t_exit_am_mode) )
|
||||
TCAP(t_exit_am_mode) = CSI "?7l";
|
||||
|
||||
if ( ! TCAP(fc::t_enter_pc_charset_mode) )
|
||||
TCAP(fc::t_enter_pc_charset_mode) = CSI "11m";
|
||||
if ( ! TCAP(t_enter_pc_charset_mode) )
|
||||
TCAP(t_enter_pc_charset_mode) = CSI "11m";
|
||||
|
||||
if ( ! TCAP(fc::t_exit_pc_charset_mode) )
|
||||
TCAP(fc::t_exit_pc_charset_mode) = CSI "10m";
|
||||
if ( ! TCAP(t_exit_pc_charset_mode) )
|
||||
TCAP(t_exit_pc_charset_mode) = CSI "10m";
|
||||
|
||||
if ( ! TCAP(fc::t_keypad_xmit) )
|
||||
TCAP(fc::t_keypad_xmit) = CSI "?1h" ESC "=";
|
||||
if ( ! TCAP(t_keypad_xmit) )
|
||||
TCAP(t_keypad_xmit) = CSI "?1h" ESC "=";
|
||||
|
||||
if ( ! TCAP(fc::t_keypad_local) )
|
||||
TCAP(fc::t_keypad_local) = CSI "?1l" ESC ">";
|
||||
if ( ! TCAP(t_keypad_local) )
|
||||
TCAP(t_keypad_local) = CSI "?1l" ESC ">";
|
||||
|
||||
if ( ! TCAP(fc::t_key_mouse) )
|
||||
TCAP(fc::t_key_mouse) = CSI "M";
|
||||
if ( ! TCAP(t_key_mouse) )
|
||||
TCAP(t_key_mouse) = CSI "M";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -377,10 +353,10 @@ void FTermcapQuirks::teraterm()
|
||||
FTermcap::eat_nl_glitch = true;
|
||||
|
||||
// Tera Term color settings
|
||||
TCAP(fc::t_set_a_foreground) = CSI "38;5;%p1%dm";
|
||||
TCAP(fc::t_set_a_background) = CSI "48;5;%p1%dm";
|
||||
TCAP(fc::t_exit_attribute_mode) = CSI "0m" SI;
|
||||
TCAP(fc::t_orig_pair) = CSI "39;49m";
|
||||
TCAP(t_set_a_foreground) = CSI "38;5;%p1%dm";
|
||||
TCAP(t_set_a_background) = CSI "48;5;%p1%dm";
|
||||
TCAP(t_exit_attribute_mode) = CSI "0m" SI;
|
||||
TCAP(t_orig_pair) = CSI "39;49m";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -390,77 +366,77 @@ void FTermcapQuirks::sunConsole()
|
||||
FTermcap::eat_nl_glitch = true;
|
||||
|
||||
// Sun Microsystems workstation console parameter cursor control
|
||||
TCAP(fc::t_parm_up_cursor) = CSI "%p1%dA";
|
||||
TCAP(fc::t_parm_down_cursor) = CSI "%p1%dB";
|
||||
TCAP(fc::t_parm_right_cursor) = CSI "%p1%dC";
|
||||
TCAP(fc::t_parm_left_cursor) = CSI "%p1%dD";
|
||||
TCAP(t_parm_up_cursor) = CSI "%p1%dA";
|
||||
TCAP(t_parm_down_cursor) = CSI "%p1%dB";
|
||||
TCAP(t_parm_right_cursor) = CSI "%p1%dC";
|
||||
TCAP(t_parm_left_cursor) = CSI "%p1%dD";
|
||||
|
||||
// Sun Microsystems workstation console keys
|
||||
for (std::size_t i{0}; fc::fkey[i].tname[0] != 0; i++)
|
||||
for (std::size_t i{0}; fc::fkey_cap_table[i].tname[0] != 0; i++)
|
||||
{
|
||||
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "218z"; // center of keypad
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kb", 2) == 0 )
|
||||
fc::fkey[i].string = "\b"; // backspace key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kb", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = "\b"; // backspace key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kD", 2) == 0
|
||||
&& std::strlen(fc::fkey[i].tname) == 2 )
|
||||
fc::fkey[i].string = "\177"; // delete-character key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kD", 2) == 0
|
||||
&& std::strlen(fc::fkey_cap_table[i].tname) == 2 )
|
||||
fc::fkey_cap_table[i].string = "\177"; // delete-character key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@7", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "220z"; // end key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "220z"; // end key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "k;", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "233z"; // F10 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "k;", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "233z"; // F10 function key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "F1", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "234z"; // F11 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F1", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "234z"; // F11 function key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "F2", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "235z"; // F12 function key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "F2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "235z"; // F12 function key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kh", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "214z"; // home key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kh", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "214z"; // home key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kI", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "247z"; // insert-character key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kI", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "247z"; // insert-character key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kN", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "222z"; // next-page key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kN", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "222z"; // next-page key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "%7", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "194z"; // options key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "%7", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "194z"; // options key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kP", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "216z"; // prev-page key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kP", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "216z"; // prev-page key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "&5", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "193z"; // resume key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&5", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "193z"; // resume key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "&8", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "195z"; // undo key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "&8", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "195z"; // undo key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey[i].string = CSI "218z"; // center of keypad
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "K2", 2) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "218z"; // center of keypad
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "kDx", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "249z"; // keypad delete
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "kDx", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "249z"; // keypad delete
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "@8x", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "250z"; // enter/send key
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "@8x", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "250z"; // enter/send key
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP1", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "212z"; // keypad slash
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP1", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "212z"; // keypad slash
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP2", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "213z"; // keypad asterisk
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP2", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "213z"; // keypad asterisk
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP3", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "254z"; // keypad minus sign
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP3", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "254z"; // keypad minus sign
|
||||
|
||||
if ( std::strncmp(fc::fkey[i].tname, "KP4", 3) == 0 )
|
||||
fc::fkey[i].string = CSI "253z"; // keypad plus sign
|
||||
if ( std::strncmp(fc::fkey_cap_table[i].tname, "KP4", 3) == 0 )
|
||||
fc::fkey_cap_table[i].string = CSI "253z"; // keypad plus sign
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,13 +444,13 @@ void FTermcapQuirks::sunConsole()
|
||||
void FTermcapQuirks::screen()
|
||||
{
|
||||
// Fallback if "Ic" is not found
|
||||
if ( ! TCAP(fc::t_initialize_color) )
|
||||
if ( ! TCAP(t_initialize_color) )
|
||||
{
|
||||
FTermcap::can_change_color_palette = true;
|
||||
|
||||
if ( term_detection->isTmuxTerm() )
|
||||
if ( FTerm::getFTermDetection().isTmuxTerm() )
|
||||
{
|
||||
TCAP(fc::t_initialize_color) = \
|
||||
TCAP(t_initialize_color) = \
|
||||
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"
|
||||
"%p2%{255}%*%{1000}%/%2.2X/"
|
||||
"%p3%{255}%*%{1000}%/%2.2X/"
|
||||
@ -482,7 +458,7 @@ void FTermcapQuirks::screen()
|
||||
}
|
||||
else
|
||||
{
|
||||
TCAP(fc::t_initialize_color) = \
|
||||
TCAP(t_initialize_color) = \
|
||||
ESC "P" OSC "4;%p1%d;rgb:"
|
||||
"%p2%{255}%*%{1000}%/%2.2X/"
|
||||
"%p3%{255}%*%{1000}%/%2.2X/"
|
||||
@ -503,18 +479,18 @@ void FTermcapQuirks::general()
|
||||
FTermcap::attr_without_color = 0;
|
||||
|
||||
// Fallback if "AF" is not found
|
||||
if ( ! TCAP(fc::t_set_a_foreground) )
|
||||
TCAP(fc::t_set_a_foreground) = CSI "3%p1%dm";
|
||||
if ( ! TCAP(t_set_a_foreground) )
|
||||
TCAP(t_set_a_foreground) = CSI "3%p1%dm";
|
||||
|
||||
// Fallback if "AB" is not found
|
||||
if ( ! TCAP(fc::t_set_a_background) )
|
||||
TCAP(fc::t_set_a_background) = CSI "4%p1%dm";
|
||||
if ( ! TCAP(t_set_a_background) )
|
||||
TCAP(t_set_a_background) = CSI "4%p1%dm";
|
||||
|
||||
// Fallback if "Ic" is not found
|
||||
if ( ! TCAP(fc::t_initialize_color) )
|
||||
if ( ! TCAP(t_initialize_color) )
|
||||
{
|
||||
FTermcap::can_change_color_palette = true;
|
||||
TCAP(fc::t_initialize_color) = \
|
||||
TCAP(t_initialize_color) = \
|
||||
OSC "P%p1%x"
|
||||
"%p2%{255}%*%{1000}%/%02x"
|
||||
"%p3%{255}%*%{1000}%/%02x"
|
||||
@ -522,37 +498,57 @@ void FTermcapQuirks::general()
|
||||
}
|
||||
|
||||
// Fallback if "ti" is not found
|
||||
if ( ! TCAP(fc::t_enter_ca_mode) )
|
||||
TCAP(fc::t_enter_ca_mode) = ESC "7" CSI "?47h";
|
||||
if ( ! TCAP(t_enter_ca_mode) )
|
||||
TCAP(t_enter_ca_mode) = ESC "7" CSI "?47h";
|
||||
|
||||
// Fallback if "te" is not found
|
||||
if ( ! TCAP(fc::t_exit_ca_mode) )
|
||||
TCAP(fc::t_exit_ca_mode) = CSI "?47l" ESC "8" CSI "m";
|
||||
if ( ! TCAP(t_exit_ca_mode) )
|
||||
TCAP(t_exit_ca_mode) = CSI "?47l" ESC "8" CSI "m";
|
||||
|
||||
// Set ansi move if "cm" is not found
|
||||
if ( ! TCAP(fc::t_cursor_address) )
|
||||
TCAP(fc::t_cursor_address) = CSI "%i%p1%d;%p2%dH";
|
||||
if ( ! TCAP(t_cursor_address) )
|
||||
TCAP(t_cursor_address) = CSI "%i%p1%d;%p2%dH";
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline void FTermcapQuirks::caModeExtension()
|
||||
{
|
||||
if ( TCAP(t_enter_ca_mode)
|
||||
&& ! std::strstr(TCAP(t_enter_ca_mode), "\033[22;0;0t") )
|
||||
{
|
||||
// Save the cursor position, enter alternate screen buffer
|
||||
// and save xterm icon and window title on stack
|
||||
TCAP(t_enter_ca_mode) = CSI "?1049h" CSI "22;0;0t";
|
||||
}
|
||||
|
||||
if ( TCAP(t_exit_ca_mode)
|
||||
&& ! std::strstr(TCAP(t_exit_ca_mode), "\033[23;0;0t") )
|
||||
{
|
||||
// Use normal screen buffer, restore the cursor position
|
||||
// and restore xterm icon and window title from stack
|
||||
TCAP(t_exit_ca_mode) = CSI "?1049l" CSI "23;0;0t";
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
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 )
|
||||
if ( ! TCAP(t_exit_underline_mode)
|
||||
|| std::strncmp(TCAP(t_exit_underline_mode), CSI "24m", 5) != 0 )
|
||||
return;
|
||||
|
||||
// Seems to be a ECMA-48 (ANSI X3.64) compatible terminal
|
||||
TCAP(fc::t_enter_dbl_underline_mode) = CSI "21m"; // Leaves single underlined too
|
||||
TCAP(fc::t_exit_dbl_underline_mode) = CSI "24m";
|
||||
TCAP(fc::t_exit_bold_mode) = CSI "22m"; // Exit dim, too
|
||||
TCAP(fc::t_exit_dim_mode) = CSI "22m";
|
||||
TCAP(fc::t_exit_underline_mode) = CSI "24m";
|
||||
TCAP(fc::t_exit_blink_mode) = CSI "25m";
|
||||
TCAP(fc::t_exit_reverse_mode) = CSI "27m";
|
||||
TCAP(fc::t_exit_secure_mode) = CSI "28m";
|
||||
TCAP(fc::t_enter_crossed_out_mode) = CSI "9m";
|
||||
TCAP(fc::t_exit_crossed_out_mode) = CSI "29m";
|
||||
TCAP(t_enter_dbl_underline_mode) = CSI "21m"; // Leaves single underlined too
|
||||
TCAP(t_exit_dbl_underline_mode) = CSI "24m";
|
||||
TCAP(t_exit_bold_mode) = CSI "22m"; // Exit dim, too
|
||||
TCAP(t_exit_dim_mode) = CSI "22m";
|
||||
TCAP(t_exit_underline_mode) = CSI "24m";
|
||||
TCAP(t_exit_blink_mode) = CSI "25m";
|
||||
TCAP(t_exit_reverse_mode) = CSI "27m";
|
||||
TCAP(t_exit_secure_mode) = CSI "28m";
|
||||
TCAP(t_enter_crossed_out_mode) = CSI "9m";
|
||||
TCAP(t_exit_crossed_out_mode) = CSI "29m";
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2019-2020 Markus Gans *
|
||||
* Copyright 2019-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -26,65 +26,60 @@
|
||||
#include "final/ftermdetection.h"
|
||||
#include "final/ftermdebugdata.h"
|
||||
|
||||
#if DEBUG
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
#if DEBUG
|
||||
// static class attributes
|
||||
FTermData* FTermDebugData::data {nullptr};
|
||||
FTermDetection* FTermDebugData::term_detection {nullptr};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// class FTermDebugData
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// public methods of FTermDebugData
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDebugData::init()
|
||||
{
|
||||
data = FTerm::getFTermData();
|
||||
term_detection = FTerm::getFTermDetection();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getAnswerbackString()
|
||||
{
|
||||
return term_detection->getAnswerbackString();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getAnswerbackString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const FString& FTermDebugData::getSecDAString()
|
||||
{
|
||||
return term_detection->getSecDAString();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getSecDAString();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_256color()
|
||||
{
|
||||
return term_detection->getTermType_256color();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_256color();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_Answerback()
|
||||
{
|
||||
return term_detection->getTermType_Answerback();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_Answerback();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
const char* FTermDebugData::getTermType_SecDA()
|
||||
{
|
||||
return term_detection->getTermType_SecDA();
|
||||
auto& term_detection = FTerm::getFTermDetection();
|
||||
return term_detection.getTermType_SecDA();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__linux__)
|
||||
int FTermDebugData::getFramebufferBpp()
|
||||
{
|
||||
return data->getFramebufferBpp();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
return fterm_data.getFramebufferBpp();
|
||||
}
|
||||
#endif // defined(__linux__)
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // DEBUG
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -53,14 +53,11 @@ namespace finalcut
|
||||
// static class attributes
|
||||
FTermDetection::FTerminalType FTermDetection::terminal_type{};
|
||||
FTermDetection::colorEnv FTermDetection::color_env{};
|
||||
FTermDetection::kittyVersion FTermDetection::kitty_version{};
|
||||
FTermDetection::secondaryDA FTermDetection::secondary_da{};
|
||||
FTermData* FTermDetection::fterm_data{nullptr};
|
||||
FSystem* FTermDetection::fsystem{nullptr};
|
||||
FKeyboard* FTermDetection::keyboard{nullptr};
|
||||
char FTermDetection::termtype[256]{};
|
||||
char FTermDetection::ttytypename[256]{};
|
||||
bool FTermDetection::decscusr_support{};
|
||||
|
||||
bool FTermDetection::terminal_detection{};
|
||||
bool FTermDetection::color256{};
|
||||
const FString* FTermDetection::answer_back{nullptr};
|
||||
@ -133,9 +130,6 @@ void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
|
||||
//----------------------------------------------------------------------
|
||||
void FTermDetection::detect()
|
||||
{
|
||||
fterm_data = FTerm::getFTermData();
|
||||
fsystem = FTerm::getFSystem();
|
||||
keyboard = FTerm::getFKeyboard();
|
||||
deallocation();
|
||||
|
||||
// Set the variable 'termtype' to the predefined type of the terminal
|
||||
@ -165,7 +159,7 @@ void FTermDetection::getSystemTermType()
|
||||
{
|
||||
// Import the untrusted environment variable TERM
|
||||
const auto& term_env = std::getenv("TERM");
|
||||
const auto& termfilename = fterm_data->getTermFileName();
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
|
||||
if ( term_env )
|
||||
{
|
||||
@ -174,7 +168,7 @@ void FTermDetection::getSystemTermType()
|
||||
termtype[sizeof(termtype) - 1] = '\0';
|
||||
return;
|
||||
}
|
||||
else if ( *termfilename ) // 1st fallback: use the teminal file name
|
||||
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
|
||||
{
|
||||
if ( getTTYtype() ) // Look into /etc/ttytype
|
||||
return;
|
||||
@ -203,19 +197,17 @@ bool FTermDetection::getTTYtype()
|
||||
// vt100 ttys0
|
||||
|
||||
// Get term basename
|
||||
const char* termfilename = fterm_data->getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename, '/');
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
term_basename = termfilename;
|
||||
term_basename = termfilename.data();
|
||||
else
|
||||
term_basename++;
|
||||
|
||||
std::FILE* fp{};
|
||||
std::array<char, BUFSIZ> str{};
|
||||
|
||||
if ( ! fsystem )
|
||||
return false;
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
|
||||
return false;
|
||||
@ -260,11 +252,11 @@ bool FTermDetection::getTTYSFileEntry()
|
||||
// Analyse /etc/ttys and get the term name
|
||||
|
||||
// get term basename
|
||||
const char* termfilename = fterm_data->getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename, '/');
|
||||
const auto& termfilename = FTerm::getFTermData().getTermFileName();
|
||||
const char* term_basename = std::strrchr(termfilename.data(), '/');
|
||||
|
||||
if ( term_basename == nullptr )
|
||||
term_basename = termfilename;
|
||||
term_basename = termfilename.data();
|
||||
else
|
||||
term_basename++;
|
||||
|
||||
@ -352,6 +344,10 @@ void FTermDetection::termtypeAnalysis()
|
||||
// NetBSD workstation console
|
||||
if ( std::strncmp(termtype, "wsvt25", 6) == 0 )
|
||||
terminal_type.netbsd_con = true;
|
||||
|
||||
// kitty
|
||||
if ( std::strncmp(termtype, "xterm-kitty", 11) == 0 )
|
||||
terminal_type.kitty = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -364,7 +360,8 @@ void FTermDetection::detectTerminal()
|
||||
if ( terminal_detection )
|
||||
{
|
||||
FTermios::setCaptureSendCharacters();
|
||||
keyboard->setNonBlockingInput();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
// Initialize 256 colors terminals
|
||||
new_termtype = init_256colorTerminal();
|
||||
@ -378,7 +375,7 @@ void FTermDetection::detectTerminal()
|
||||
// Determines the maximum number of colors
|
||||
new_termtype = determineMaxColor(new_termtype);
|
||||
|
||||
keyboard->unsetNonBlockingInput();
|
||||
keyboard.unsetNonBlockingInput();
|
||||
FTermios::unsetCaptureSendCharacters();
|
||||
}
|
||||
|
||||
@ -408,10 +405,11 @@ void FTermDetection::detectTerminal()
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
const auto& termfilename = fterm_data->getTermFileName();
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
const auto& termfilename = fterm_data.getTermFileName();
|
||||
|
||||
// Fixes problem with mouse input
|
||||
if ( std::strncmp(termfilename, "/dev/cons", 9) == 0 )
|
||||
if ( termfilename.substr(0, 9) == "/dev/cons" )
|
||||
FKeyboard::setNonBlockingInputSupport(false);
|
||||
#endif
|
||||
}
|
||||
@ -454,26 +452,16 @@ bool FTermDetection::get256colorEnvString()
|
||||
color_env.string5 = std::getenv("KONSOLE_DBUS_SESSION");
|
||||
color_env.string6 = std::getenv("KONSOLE_DCOP");
|
||||
color_env.string7 = std::getenv("COLORFGBG");
|
||||
color_env.string7 = std::getenv("KITTY_WINDOW_ID");
|
||||
|
||||
if ( color_env.string1 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string2 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string3 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string4 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string5 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string6 != nullptr )
|
||||
return true;
|
||||
|
||||
if ( color_env.string7 != nullptr )
|
||||
if ( color_env.string1 != nullptr
|
||||
|| color_env.string2 != nullptr
|
||||
|| color_env.string3 != nullptr
|
||||
|| color_env.string4 != nullptr
|
||||
|| color_env.string5 != nullptr
|
||||
|| color_env.string6 != nullptr
|
||||
|| color_env.string7 != nullptr
|
||||
|| color_env.string8 != nullptr )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -541,16 +529,17 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||
// Determine xterm maximum number of colors via OSC 4
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
keyboard->setNonBlockingInput();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
|
||||
if ( ! color256
|
||||
&& ! isCygwinTerminal()
|
||||
&& ! isTeraTerm()
|
||||
&& ! isLinuxTerm()
|
||||
&& ! isNetBSDTerm()
|
||||
&& ! getXTermColorName(0).isEmpty() )
|
||||
&& ! getXTermColorName(FColor(0)).isEmpty() )
|
||||
{
|
||||
if ( ! getXTermColorName(255).isEmpty() )
|
||||
if ( ! getXTermColorName(FColor(255)).isEmpty() )
|
||||
{
|
||||
color256 = true;
|
||||
|
||||
@ -559,17 +548,17 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
|
||||
else
|
||||
new_termtype = "xterm-256color";
|
||||
}
|
||||
else if ( ! getXTermColorName(87).isEmpty() )
|
||||
else if ( ! getXTermColorName(FColor(87)).isEmpty() )
|
||||
{
|
||||
new_termtype = "xterm-88color";
|
||||
}
|
||||
else if ( ! getXTermColorName(15).isEmpty() )
|
||||
else if ( ! getXTermColorName(FColor(15)).isEmpty() )
|
||||
{
|
||||
new_termtype = "xterm-16color";
|
||||
}
|
||||
}
|
||||
|
||||
keyboard->unsetNonBlockingInput();
|
||||
keyboard.unsetNonBlockingInput();
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
@ -583,7 +572,8 @@ FString FTermDetection::getXTermColorName (FColor color)
|
||||
const int stdin_no = FTermios::getStdIn();
|
||||
|
||||
// get color
|
||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, color);
|
||||
auto index = uInt16(color);
|
||||
std::fprintf (stdout, OSC "4;%hu;?" BEL, index);
|
||||
std::fflush (stdout);
|
||||
FD_ZERO(&ifds);
|
||||
FD_SET(stdin_no, &ifds);
|
||||
@ -610,7 +600,7 @@ FString FTermDetection::getXTermColorName (FColor color)
|
||||
}
|
||||
while ( pos < temp.size() );
|
||||
|
||||
if ( pos > 4 && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 )
|
||||
if ( pos > 4 && std::sscanf(temp.data(), parse, &index, buf.data()) == 2 )
|
||||
{
|
||||
std::size_t n = std::strlen(buf.data());
|
||||
|
||||
@ -632,10 +622,11 @@ FString FTermDetection::getXTermColorName (FColor color)
|
||||
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
|
||||
{
|
||||
const char* new_termtype = current_termtype;
|
||||
keyboard->setNonBlockingInput();
|
||||
auto& keyboard = FTerm::getFKeyboard();
|
||||
keyboard.setNonBlockingInput();
|
||||
// send ENQ and read the answerback message
|
||||
const auto& ans = getAnswerbackMsg();
|
||||
keyboard->unsetNonBlockingInput();
|
||||
keyboard.unsetNonBlockingInput();
|
||||
|
||||
try
|
||||
{
|
||||
@ -965,7 +956,12 @@ inline const char* FTermDetection::secDA_Analysis_1 (const char current_termtype
|
||||
// Terminal ID 1 - DEC VT220
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
new_termtype = secDA_Analysis_vte(new_termtype);
|
||||
|
||||
if ( isKittyTerminal() )
|
||||
new_termtype = secDA_Analysis_kitty(new_termtype);
|
||||
else
|
||||
new_termtype = secDA_Analysis_vte(new_termtype);
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
@ -1120,4 +1116,23 @@ inline const char* FTermDetection::secDA_Analysis_vte (const char current_termty
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline const char* FTermDetection::secDA_Analysis_kitty (const char current_termtype[])
|
||||
{
|
||||
// kitty
|
||||
|
||||
const char* new_termtype = current_termtype;
|
||||
|
||||
if ( secondary_da.terminal_id_version > 3999 )
|
||||
{
|
||||
// All kitty terminals can use 256 colors
|
||||
color256 = true;
|
||||
new_termtype = "xterm-kitty";
|
||||
kitty_version.primary = secondary_da.terminal_id_version - 4000;
|
||||
kitty_version.secondary = secondary_da.terminal_id_hardware;
|
||||
}
|
||||
|
||||
return new_termtype;
|
||||
}
|
||||
|
||||
} // namespace finalcut
|
||||
|
@ -3,7 +3,7 @@
|
||||
* *
|
||||
* This file is part of the FINAL CUT widget toolkit *
|
||||
* *
|
||||
* Copyright 2018-2020 Markus Gans *
|
||||
* Copyright 2018-2021 Markus Gans *
|
||||
* *
|
||||
* FINAL CUT is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
@ -30,28 +30,15 @@
|
||||
#include "final/ftypes.h"
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
#define initCheck(ret_value) \
|
||||
if ( ! isInitialized() ) \
|
||||
{ \
|
||||
if ( ! FApplication::isQuit() ) \
|
||||
warnNotInitialized(); \
|
||||
\
|
||||
return ret_value; \
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace finalcut
|
||||
{
|
||||
|
||||
// static class attributes
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
uInt FTermFreeBSD::bsd_alt_keymap{0};
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor};
|
||||
bool FTermFreeBSD::change_cursorstyle{true};
|
||||
bool FTermFreeBSD::meta_sends_escape{true};
|
||||
FSystem* FTermFreeBSD::fsystem{nullptr};
|
||||
FTermData* FTermFreeBSD::fterm_data{nullptr};
|
||||
#endif
|
||||
uInt FTermFreeBSD::bsd_alt_keymap{0};
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{FreeBSDConsoleCursorStyle::Normal};
|
||||
bool FTermFreeBSD::change_cursorstyle{true};
|
||||
bool FTermFreeBSD::meta_sends_escape{true};
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -60,7 +47,6 @@ namespace finalcut
|
||||
|
||||
// public methods of FTermFreeBSD
|
||||
//----------------------------------------------------------------------
|
||||
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
|
||||
{
|
||||
return cursor_style;
|
||||
@ -71,17 +57,13 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
|
||||
{
|
||||
// Set cursor style in a BSD console
|
||||
|
||||
if ( ! fterm_data )
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
initCheck(false);
|
||||
|
||||
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
|
||||
if ( ! isFreeBSDConsole() || ! change_cursorstyle )
|
||||
return false;
|
||||
|
||||
cursor_style = style;
|
||||
auto& fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( fterm_data->isCursorHidden() )
|
||||
if ( fterm_data.isCursorHidden() )
|
||||
return false;
|
||||
|
||||
return setFreeBSDCursorStyle(style);
|
||||
@ -93,11 +75,9 @@ bool FTermFreeBSD::isFreeBSDConsole()
|
||||
// Check if it's a FreeBSD console
|
||||
|
||||
keymap_t keymap{};
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( ! fsystem )
|
||||
fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@ -141,9 +121,6 @@ void FTermFreeBSD::init()
|
||||
{
|
||||
// Initialize BSD console
|
||||
|
||||
fsystem = FTerm::getFSystem();
|
||||
fterm_data = FTerm::getFTermData();
|
||||
|
||||
if ( ! isFreeBSDConsole() )
|
||||
return;
|
||||
|
||||
@ -159,7 +136,7 @@ void FTermFreeBSD::init()
|
||||
if ( change_cursorstyle )
|
||||
{
|
||||
// Initialize FreeBSD console cursor
|
||||
setCursorStyle (fc::destructive_cursor);
|
||||
setCursorStyle (FreeBSDConsoleCursorStyle::Destructive);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,8 +149,8 @@ void FTermFreeBSD::initCharMap()
|
||||
return;
|
||||
|
||||
for (auto&& entry : fc::character)
|
||||
if ( entry[fc::PC] < 0x1c )
|
||||
entry[fc::PC] = entry[fc::ASCII];
|
||||
if ( entry.pc < 0x1c )
|
||||
entry.pc = entry.ascii;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -187,7 +164,7 @@ void FTermFreeBSD::finish()
|
||||
if ( meta_sends_escape )
|
||||
resetFreeBSDAlt2Meta();
|
||||
|
||||
setFreeBSDCursorStyle (fc::normal_cursor);
|
||||
setFreeBSDCursorStyle (FreeBSDConsoleCursorStyle::Normal);
|
||||
}
|
||||
|
||||
|
||||
@ -195,7 +172,7 @@ void FTermFreeBSD::finish()
|
||||
//----------------------------------------------------------------------
|
||||
void FTermFreeBSD::warnNotInitialized()
|
||||
{
|
||||
std::clog << FLog::Warn
|
||||
std::clog << FLog::LogLevel::Warn
|
||||
<< "The FTermFreeBSD object has "
|
||||
<< "not yet been initialized! "
|
||||
<< "Please call the init() method first."
|
||||
@ -210,7 +187,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
|
||||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
initCheck(false);
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
@ -229,7 +206,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
||||
static constexpr int left_alt = 0x38;
|
||||
int ret{-1};
|
||||
keymap_t keymap{};
|
||||
initCheck(false);
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
|
||||
|
||||
if ( ret < 0 )
|
||||
@ -239,7 +216,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
|
||||
keymap.key[left_alt].map[0] = int(key);
|
||||
|
||||
if ( (keymap.n_keys > 0)
|
||||
&& fsystem && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
&& (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@ -264,13 +241,14 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
|
||||
//----------------------------------------------------------------------
|
||||
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
|
||||
{
|
||||
initCheck(false);
|
||||
const auto& fsystem = FTerm::getFSystem();
|
||||
|
||||
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
||||
} // namespace finalcut
|
||||
|
||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||
|
@ -52,10 +52,6 @@ FTermios::FTermios()
|
||||
init();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
FTermios::~FTermios() // destructor
|
||||
{ }
|
||||
|
||||
// public methods of FTermios
|
||||
//----------------------------------------------------------------------
|
||||
void FTermios::init()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user